Skip to content

Commit

Permalink
Tests should only be in CppRuntime_Gcc now as that's the only runtime…
Browse files Browse the repository at this point in the history
… implemented for
  • Loading branch information
Emmanuel Nyarko authored and Emmanuel Nyarko committed Feb 22, 2024
1 parent 0c6042b commit 4420dd3
Showing 1 changed file with 35 additions and 32 deletions.
67 changes: 35 additions & 32 deletions source/stdcpp/test/set.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,41 @@ module stdcpp.test.set;
import stdcpp.set;
import stdcpp.test.base;

unittest
version (CppRuntime_Gcc)
{
assert(cppSizeOf!(vector!int) == vector!int.sizeof);
}
unittest
{
assert(cppSizeOf!(set!int) == set!int.sizeof);
}

unittest
{
import stdcpp.allocator;
allocator!int alloc_instance = allocator!(int).init;
less!int a;
auto p = set!int(a);
p.insert(5);
assert(p.size == 1);
assert(p.empty == 0);
p.erase(5);
p.insert(6);
p.clear;
assert(p.size == 0);
assert(p.empty == 1);
set!int q = a;
q.swap(p);
q.insert(4);
q.insert(4);
q.insert(4);
assert(q.size == 1);
assert(q.count(4) == 1);//count for set only results in 0 for not present or 1 for present
assert(q.count(5) == 0);
assert(q.contains(4) == 1); // q contains 4 evaluates to true
auto iter = q.find(4);
set!int w = q; //copy constructor
assert(w.size() == 1);
auto alloc = set!int(alloc_instance);
alloc.insert(5);
assert(alloc.size() == 1);
unittest
{
import stdcpp.allocator;
allocator!int alloc_instance = allocator!(int).init;
less!int a;
auto p = set!int(a);
p.insert(5);
assert(p.size == 1);
assert(p.empty == 0);
p.erase(5);
p.insert(6);
p.clear;
assert(p.size == 0);
assert(p.empty == 1);
set!int q = a;
q.swap(p);
q.insert(4);
q.insert(4);
q.insert(4);
assert(q.size == 1);
assert(q.count(4) == 1);//count for set only results in 0 for not present or 1 for present
assert(q.count(5) == 0);
assert(q.contains(4) == 1); // q contains 4 evaluates to true
auto iter = q.find(4);
set!int w = q; //copy constructor
assert(w.size() == 1);
auto alloc = set!int(alloc_instance);
alloc.insert(5);
assert(alloc.size() == 1);
}
}

0 comments on commit 4420dd3

Please sign in to comment.