mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
d988e0e19b
fixes: https://github.com/microsoft/GSL/issues/1129 * create gsl::swap<T>(T&, T&) which wraps std::swap * specialize gsl::swap<T>(gsl::not_null<T>&, gsl::not_null<T>&) * add tests
22 lines
394 B
C++
22 lines
394 B
C++
#include <gtest/gtest.h>
|
|
|
|
#include <gsl/pointers>
|
|
|
|
#include <memory>
|
|
|
|
TEST(pointers_test, swap)
|
|
{
|
|
// taken from gh-1129:
|
|
gsl::not_null<std::unique_ptr<int>> a(std::make_unique<int>(0));
|
|
gsl::not_null<std::unique_ptr<int>> b(std::make_unique<int>(1));
|
|
|
|
EXPECT_TRUE(*a == 0);
|
|
EXPECT_TRUE(*b == 1);
|
|
|
|
gsl::swap(a, b);
|
|
|
|
EXPECT_TRUE(*a == 1);
|
|
EXPECT_TRUE(*b == 0);
|
|
}
|
|
|