Skip to content

Commit

Permalink
test for swap
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Nyarko authored and Emmanuel Nyarko committed Jun 1, 2024
1 parent 9be6481 commit 5a43652
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions source/stdcpp/test/map.d
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,14 @@ unittest
assert(mymap.size == 0);
assert(mymap.empty == 1);
assert(mymap.count(1) == 0); // container cleared
/* utilities to use to test after a swap */
mymap.opIndex(2) = 'b';
mymap.opIndex(3) = 'c';


auto mymap2 = Map!(int, char).make();
mymap2.swap(mymap);
assert(mymap2.size == 2);
assert(mymap2.at(2) == 'b');
assert(mymap2.at(3) == 'c'); // swap works!
}

0 comments on commit 5a43652

Please sign in to comment.