@@ -273,6 +273,15 @@ TEST(Value, BasicSemantics) {
273273 TestBasicSemantics (v);
274274 }
275275
276+ for (auto x : {Uuid ()}) {
277+ SCOPED_TRACE (" Testing: google::cloud::spanner::Uuid " + std::string{x});
278+ TestBasicSemantics (x);
279+ TestBasicSemantics (std::vector<Uuid>(5 , x));
280+ std::vector<absl::optional<Uuid>> v (5 , x);
281+ v.resize (10 );
282+ TestBasicSemantics (v);
283+ }
284+
276285 for (auto x : {testing::Genre::POP, testing::Genre::JAZZ,
277286 testing::Genre::FOLK, testing::Genre::ROCK}) {
278287 SCOPED_TRACE (" Testing: ProtoEnum<testing::Genre> " +
@@ -949,6 +958,20 @@ TEST(Value, ProtoConversionInterval) {
949958 }
950959}
951960
961+ TEST (Value, ProtoConversionUuid) {
962+ for (auto const & x : std::vector<Uuid>{
963+ Uuid (),
964+ Uuid (0x7bf8a7b819171919 , 0x2625f208c5824254 ),
965+ MakeUuid (" {0b6ed04ca16dfc4652817f9978c13738}" ).value (),
966+ }) {
967+ Value const v (x);
968+ auto const p = spanner_internal::ToProto (v);
969+ EXPECT_EQ (v, spanner_internal::FromProto (p.first , p.second ));
970+ EXPECT_EQ (google::spanner::v1::TypeCode::UUID, p.first .code ());
971+ EXPECT_EQ (std::string{x}, p.second .string_value ());
972+ }
973+ }
974+
952975TEST (Value, ProtoConversionProtoEnum) {
953976 for (auto e : {testing::Genre::POP, testing::Genre::JAZZ,
954977 testing::Genre::FOLK, testing::Genre::ROCK}) {
@@ -1296,6 +1319,24 @@ TEST(Value, GetBadInterval) {
12961319 EXPECT_THAT (v.get <Interval>(), Not (IsOk ()));
12971320}
12981321
1322+ TEST (Value, GetBadUuid) {
1323+ Value v (Uuid{});
1324+ ClearProtoKind (v);
1325+ EXPECT_THAT (v.get <Uuid>(), Not (IsOk ()));
1326+
1327+ SetProtoKind (v, google::protobuf::NULL_VALUE);
1328+ EXPECT_THAT (v.get <Uuid>(), Not (IsOk ()));
1329+
1330+ SetProtoKind (v, true );
1331+ EXPECT_THAT (v.get <Uuid>(), Not (IsOk ()));
1332+
1333+ SetProtoKind (v, 0.0 );
1334+ EXPECT_THAT (v.get <Uuid>(), Not (IsOk ()));
1335+
1336+ SetProtoKind (v, " blah" );
1337+ EXPECT_THAT (v.get <Uuid>(), Not (IsOk ()));
1338+ }
1339+
12991340TEST (Value, GetBadProtoEnum) {
13001341 Value v (ProtoEnum<testing::Genre>{});
13011342 ClearProtoKind (v);
@@ -1475,6 +1516,7 @@ TEST(Value, OutputStream) {
14751516 {Value (absl::CivilDay ()), " 1970-01-01" , normal},
14761517 {Value (Timestamp ()), " 1970-01-01T00:00:00Z" , normal},
14771518 {Value (Interval ()), " P0D" , normal},
1519+ {Value (Uuid ()), " 00000000-0000-0000-0000-000000000000" , normal},
14781520 {Value (ProtoEnum<testing::Genre>(testing::Genre::POP)),
14791521 " google.cloud.spanner.testing.POP" , normal},
14801522 {Value (ProtoMessage<testing::SingerInfo>(singer)),
@@ -1509,6 +1551,7 @@ TEST(Value, OutputStream) {
15091551 {MakeNullValue<absl::CivilDay>(), " NULL" , normal},
15101552 {MakeNullValue<Timestamp>(), " NULL" , normal},
15111553 {MakeNullValue<Interval>(), " NULL" , normal},
1554+ {MakeNullValue<Uuid>(), " NULL" , normal},
15121555 {MakeNullValue<ProtoEnum<testing::Genre>>(), " NULL" , normal},
15131556 {MakeNullValue<ProtoMessage<testing::SingerInfo>>(), " NULL" , normal},
15141557
@@ -1530,6 +1573,8 @@ TEST(Value, OutputStream) {
15301573 normal},
15311574 {Value (std::vector<Timestamp>{1 }), " [1970-01-01T00:00:00Z]" , normal},
15321575 {Value (std::vector<Interval>{1 }), " [P0D]" , normal},
1576+ {Value (std::vector<Uuid>{1 }), " [00000000-0000-0000-0000-000000000000]" ,
1577+ normal},
15331578 {Value (std::vector<ProtoEnum<testing::Genre>>{testing::JAZZ,
15341579 testing::FOLK}),
15351580 " [google.cloud.spanner.testing.JAZZ, google.cloud.spanner.testing.FOLK]" ,
@@ -1556,6 +1601,7 @@ TEST(Value, OutputStream) {
15561601 {MakeNullValue<std::vector<absl::CivilDay>>(), " NULL" , normal},
15571602 {MakeNullValue<std::vector<Timestamp>>(), " NULL" , normal},
15581603 {MakeNullValue<std::vector<Interval>>(), " NULL" , normal},
1604+ {MakeNullValue<std::vector<Uuid>>(), " NULL" , normal},
15591605 {MakeNullValue<std::vector<ProtoEnum<testing::Genre>>>(), " NULL" , normal},
15601606 {MakeNullValue<std::vector<ProtoMessage<testing::SingerInfo>>>(), " NULL" ,
15611607 normal},
@@ -1710,6 +1756,11 @@ TEST(Value, OutputStreamMatchesT) {
17101756 StreamMatchesValueStream (Interval ());
17111757 StreamMatchesValueStream (MakeInterval (" P1Y2M3DT4H5M6.789S" ).value ());
17121758
1759+ // Uuid
1760+ StreamMatchesValueStream (Uuid ());
1761+ StreamMatchesValueStream (
1762+ MakeUuid (" {0b6ed04ca16dfc4652817f9978c13738}" ).value ());
1763+
17131764 // ProtoEnum
17141765 StreamMatchesValueStream (ProtoEnum<testing::Genre>());
17151766 StreamMatchesValueStream (ProtoEnum<testing::Genre>(testing::ROCK));
0 commit comments