/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #include #include #include #include #include #include "Data/Containers/BinSearchArrayMap.hpp" #include "Data/Containers/StableVector.hpp" using namespace OpenVulkano; TEST_CASE("BinSearchArrayMap With Default") { SECTION("Insert") { BinSearchArrayMap 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 map; 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.Size() == 47); } SECTION("Emplace") { BinSearchArrayMap map; for (int i = 0; i < 50; i++) { map.Emplace(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("FindPair") { BinSearchArrayMap map; for (int i = 0; i < 50; i++) { map.Insert(i, std::to_string(i)); } auto pair = map.FindPair(16); REQUIRE(pair.first == 16); REQUIRE(pair.second == "16"); } } TEST_CASE("BinSearchArrayMap With StableVector") { //SECTION("Insert") //{ // BinSearchArrayMap 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 map; for (int i = 0; i < 50; i++) { map.Insert(i, std::to_string(i)); } map.Remove(16); map.Remove(23); map.Remove(48); for (int i = 0; i < map.Size(); i++) { if (i == 16 || i == 23 || i == 48) { continue; } printf("i: %d, value: %s\n", i, map[i].c_str()); } }*/ }