Add initializer list support for Dictionary.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -10,6 +10,14 @@ TEST_CASE("Create Dictionary, insert values", "[Utilities]") {
|
||||
dic.Insert(9, 2000);
|
||||
}
|
||||
|
||||
TEST_CASE("Create Dictionary with initializer list", "[Utilities]") {
|
||||
auto dic = Dictionary<int, int>({{5, 100}, {10, 200}, {50, 2}});
|
||||
|
||||
CHECK(dic.Get(5) == 100);
|
||||
CHECK(dic.Get(10) == 200);
|
||||
CHECK(dic.Get(50) == 2);
|
||||
}
|
||||
|
||||
TEST_CASE("Create Dictionary, insert values, get values", "[Utilities]") {
|
||||
auto dic = Dictionary<int, int>(5);
|
||||
dic.Insert(10, 5);
|
||||
@@ -80,7 +88,7 @@ TEST_CASE("Create Dictionary, insert values, iterate over keys", "[Utilities]")
|
||||
dic.Insert(9, 2000);
|
||||
|
||||
size_t i = 0;
|
||||
for (auto val: dic){
|
||||
for (auto val : dic) {
|
||||
CHECK(dic.Has(val.first));
|
||||
i++;
|
||||
}
|
||||
@@ -94,12 +102,11 @@ TEST_CASE("Create Dictionary with different types, insert values, iterate over k
|
||||
dic.Insert(9, 105);
|
||||
|
||||
size_t i = 0;
|
||||
for (auto val: dic){
|
||||
for (auto val : dic) {
|
||||
CHECK(dic.Has(val.first));
|
||||
i++;
|
||||
}
|
||||
CHECK(i == 3);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user