initial version.

This commit is contained in:
Metehan Tuncbilek
2024-09-20 18:03:13 +03:00
parent f6c48edac6
commit fdd072770c
2 changed files with 148 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
/*
* 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 <catch2/catch_all.hpp>
#include <vector>
#include <map>
#include <utility>
#include <type_traits>
#include "Data/Containers/BinSearchArrayMap.hpp"
using namespace OpenVulkano;
TEST_CASE("BinSearchArrayMap")
{
std::vector<std::pair<int, std::string>> data;
data.push_back(std::make_pair(1, "One"));
data.push_back(std::make_pair(2, "Two"));
data.push_back(std::make_pair(6, "Three"));
data.push_back(std::make_pair(8, "Four"));
data.push_back(std::make_pair(10, "Five"));
auto wtf =
std::lower_bound(data.begin(), data.end(), 10, [](const auto& pair, const int& key) { return pair.first < key; });
auto test = *wtf;
REQUIRE(test.first == 10);
REQUIRE(test.second == "Five");
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");
REQUIRE(map[6] == "Three");
}