Added more tests
-added Vector test -added HashMap test -added EntityMeta test -added default hashing function to hashmap
This commit is contained in:
parent
2f827a94db
commit
f964d7bf85
6 changed files with 133 additions and 7 deletions
53
tests/map.d
Normal file
53
tests/map.d
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
module tests.map;
|
||||
|
||||
import bubel.ecs.hash_map;
|
||||
|
||||
version(GNU)
|
||||
{
|
||||
pragma(inline, true) T[n] staticArray(T, size_t n)(auto ref T[n] a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
}
|
||||
else import std.array : staticArray;
|
||||
|
||||
@("HashMap")
|
||||
unittest
|
||||
{
|
||||
HashMap!(string, int) map;
|
||||
|
||||
assert(map.length == 0);
|
||||
map.add("asd",1);
|
||||
assert(map.length == 1);
|
||||
map.clear();
|
||||
assert(map.length == 0);
|
||||
map.add("asd",1);
|
||||
assert(map.length == 1);
|
||||
map.reset();
|
||||
assert(map.length == 0);
|
||||
|
||||
map.add("asd",1);
|
||||
string asd = "asd";
|
||||
assert(map.isIn("asd"));
|
||||
assert(map.isIn(asd));
|
||||
assert(!map.isIn("asdf"));
|
||||
map.tryRemove("asdf");
|
||||
map.tryRemove("asd");
|
||||
assert(map.length == 0);
|
||||
map.add("asdf",1);
|
||||
map.add("asd",2);
|
||||
assert(map["asd"] == 2);
|
||||
assert(map["asdf"] == 1);
|
||||
assert(map.length == 2);
|
||||
map.tryRemove("asdf");
|
||||
assert(map.length == 1);
|
||||
map.remove("asd");
|
||||
assert(map.length == 0);
|
||||
|
||||
map.add("asd",1);
|
||||
map.add("asdwwghe",6);
|
||||
foreach(k,v;&map.byKeyValue)
|
||||
{
|
||||
assert(map[k] == v);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue