Brian Silverman | eb16fa4 | 2016-02-20 15:29:56 -0500 | [diff] [blame] | 1 | #include "gtest/gtest.h" |
| 2 | |
| 3 | #include "build_tests/proto.pb.h" |
| 4 | |
| 5 | TEST(ProtoBuildTest, Serialize) { |
| 6 | ::frc971::TestProto test_proto1, test_proto2; |
| 7 | test_proto1.set_s("Hi!"); |
| 8 | test_proto1.set_i(971); |
Parker Schuh | 971588a | 2017-03-01 22:15:04 -0800 | [diff] [blame] | 9 | test_proto1.mutable_base_proto()->set_a("silly"); |
Brian Silverman | eb16fa4 | 2016-02-20 15:29:56 -0500 | [diff] [blame] | 10 | |
| 11 | ::std::string serialized; |
| 12 | ASSERT_TRUE(test_proto1.SerializeToString(&serialized)); |
| 13 | ASSERT_TRUE(test_proto2.ParseFromString(serialized)); |
| 14 | |
| 15 | EXPECT_EQ("Hi!", test_proto2.s()); |
| 16 | EXPECT_EQ(971, test_proto2.i()); |
| 17 | } |