New StableVector but Iterator is missing.

This commit is contained in:
Metehan Tuncbilek
2024-10-03 18:15:48 +03:00
parent 6661e9e9af
commit eb2ca2ff5a
4 changed files with 716 additions and 571 deletions

View File

@@ -16,24 +16,98 @@
using namespace OpenVulkano;
TEST_CASE("BinSearchArrayMap")
TEST_CASE("BinSearchArrayMap With Default")
{
BinSearchArrayMap<int, std::string, std::pair<int, std::string>, StableVector<std::pair<int, std::string>>> map;
SECTION("Insert")
{
BinSearchArrayMap<int, std::string> map;
map.Insert(1, "One");
map.Insert(2, "Two");
map.Insert(6, "Three");
map.Insert(8, "Four");
map.Insert(10, "Five");
for (int i = 0; i < 50; i++)
{
map.Insert(i, std::to_string(i));
}
REQUIRE(map.Get(1) == "One");
REQUIRE(map.Get(2) == "Two");
REQUIRE(map.Get(6) == "Three");
REQUIRE(map.Get(8) == "Four");
REQUIRE(map.Get(10) == "Five");
REQUIRE(map.Size() == 50);
REQUIRE(map.Get(16) == "16");
REQUIRE(map.Get(23) == "23");
REQUIRE(map.Get(48) == "48");
}
REQUIRE(map.Size() == 5);
SECTION("Remove")
{
BinSearchArrayMap<int, std::string> map;
map.Remove(6);
REQUIRE(map.Size() == 4);
for (int i = 0; i < 50; i++)
{
map.Insert(i, std::to_string(i));
}
map.Remove(16);
map.Remove(23);
map.Remove(48);
REQUIRE(map[49] == "49");
printf("ARRAY WITH DEFAULT\n");
for (int i = 0; i < 50; i++)
{
if (map.Contains(i))
{
printf("index: %d, value: %s\n", i, map[i].c_str());
}
else
{
printf("index: %d, value: %s\n", i, "EMPTY");
}
}
}
}
//TEST_CASE("BinSearchArrayMap With StableVector")
//{
// SECTION("Insert")
// {
// BinSearchArrayMap<int, std::string, std::pair, StableVector> map;
//
// for (int i = 0; i < 50; i++)
// {
// map.Insert(i, std::to_string(i));
// }
//
// REQUIRE(map.Size() == 50);
// REQUIRE(map.Get(16) == "16");
// REQUIRE(map.Get(23) == "23");
// REQUIRE(map.Get(48) == "48");
// }
//
// SECTION("Remove")
// {
// BinSearchArrayMap<int, std::string, std::pair, StableVector> map;
//
// for (int i = 0; i < 50; i++)
// {
// map.Insert(i, std::to_string(i));
// }
//
// map.Remove(16);
// map.Remove(23);
//
// if (map.Contains(49))
// {
// printf("index: %d, value: %s\n", 49, map[49].c_str());
// }
//
// printf("ARRAY WITH STABLE VECTOR\n");
// for (int i = 0; i < 50; i++)
// {
// if (map.Contains(i))
// {
// printf("index: %d, value: %s\n", i, map[i].c_str());
// }
// else
// {
// printf("index: %d, value: %s\n", i, "EMPTY");
// }
// }
// }
//}