-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Martinho Fernandes
committed
Jul 24, 2013
1 parent
69c6647
commit 139264a
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
|
||
|