From 5a43652ebe5da3c0be6dc3bf6c2928ccef95f6ca Mon Sep 17 00:00:00 2001 From: Emmanuel Nyarko Date: Sat, 1 Jun 2024 09:52:04 +0000 Subject: [PATCH] test for swap --- source/stdcpp/test/map.d | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/stdcpp/test/map.d b/source/stdcpp/test/map.d index a6add12..ad78403 100644 --- a/source/stdcpp/test/map.d +++ b/source/stdcpp/test/map.d @@ -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! }