123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #include <catch2/catch_test_macros.hpp>
- #include "swap.hpp"
- TEST_CASE("Swap value with references", "[swap]") {
- int a=5, b=3;
- mcl::swap(a, b);
- REQUIRE( a == 3 );
- REQUIRE( b == 5 );
- }
- TEST_CASE("Swap value with points", "[swap]") {
- int a=5;
- int b=3;
- int* x=&a;
- int* y=&b;
- mcl::swap(x, y);
- REQUIRE( a == 3 );
- REQUIRE( b == 5 );
- REQUIRE( *x == 3 );
- REQUIRE( *y == 5 );
- }
- TEST_CASE("Swap points with points", "[swap]") {
- int a=5, b=3;
- int* x=&a;
- int* y=&b;
- mcl::swap(&x, &y);
- REQUIRE( a == 5 );
- REQUIRE( b == 3 );
- REQUIRE( *x == 3 );
- REQUIRE( *y == 5 );
- }
|