Skip to content

Commit

Permalink
Add ADL swap test
Browse files Browse the repository at this point in the history
  • Loading branch information
Martinho Fernandes committed Jul 24, 2013
1 parent 69c6647 commit 139264a
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/adl/swap.c++
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Wheels - various C++ utilities
//
// Written in 2013 by Martinho Fernandes <[email protected]>
//
// To the extent possible under law, the author(s) have dedicated all copyright and related
// and neighboring rights to this software to the public domain worldwide. This software is
// distributed without any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>

// ADL swap tests

#include <wheels/adl/swap.h++>

#include <catch.h++>

namespace test {
struct foo { int x; };

void swap(foo& a, foo& b) { a.x += 1; b.x += 2; }
} // namespace test

TEST_CASE("adl/swap", "adl::swap tests") {
SECTION("custom", "") {
test::foo a = { 16 };
test::foo b = { 21 };
wheels::adl::swap(a, b);
CHECK(a.x == 17);
CHECK(b.x == 23);
}
SECTION("default", "") {
int a = 17;
int b = 23;
wheels::adl::swap(a, b);
CHECK(a == 23);
CHECK(b == 17);
}
}


0 comments on commit 139264a

Please sign in to comment.