| 18 | |
| 19 | struct NonSerializable {}; |
| 20 | TEST_F(UniquePtrTest, serializable_same_as_instance) { |
| 21 | ASSERT_FALSE( |
| 22 | SerializeTraits<::std::unique_ptr<NonSerializable>>::SERIALIZABLE); |
| 23 | { |
| 24 | using T = int; |
| 25 | using S = ::std::unique_ptr<T>; |
| 26 | ASSERT_TRUE(SerializeTraits<S>::SERIALIZABLE); |
| 27 | S s {new T(gen())}; |
| 28 | ASSERT_TRUE(Serialization::serialize_to_string(s, string)); |
| 29 | S ss; |
| 30 | ASSERT_TRUE(Serialization::parse_from_string(string, ss)); |
| 31 | ASSERT_TRUE(ss); |
| 32 | ASSERT_EQ(*s, *ss); |
| 33 | } |
| 34 | { |
| 35 | using T = ::std::string; |
| 36 | using S = ::std::unique_ptr<T>; |
| 37 | ASSERT_TRUE(SerializeTraits<S>::SERIALIZABLE); |
| 38 | S s {new T(::std::to_string(gen()))}; |
| 39 | ASSERT_TRUE(Serialization::serialize_to_string(s, string)); |
| 40 | S ss; |
| 41 | ASSERT_TRUE(Serialization::parse_from_string(string, ss)); |
| 42 | ASSERT_TRUE(ss); |
| 43 | ASSERT_EQ(*s, *ss); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | TEST_F(UniquePtrTest, support_const_type) { |
| 48 | { |