mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
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);
|
||
|
}
|
||
|
|