@@ -264,6 +264,15 @@ TEST(Value, BasicSemantics) {
264264 v.resize (10 );
265265 TestBasicSemantics (v);
266266
267+ for (auto x : {Uuid ()}) {
268+ SCOPED_TRACE (" Testing: google::cloud::spanner::Uuid " + std::string{x});
269+ TestBasicSemantics (x);
270+ TestBasicSemantics (std::vector<Uuid>(5 , x));
271+ std::vector<absl::optional<Uuid>> v (5 , x);
272+ v.resize (10 );
273+ TestBasicSemantics (v);
274+ }
275+
267276 for (auto x : {testing::Genre::POP, testing::Genre::JAZZ,
268277 testing::Genre::FOLK, testing::Genre::ROCK}) {
269278 SCOPED_TRACE (" Testing: ProtoEnum<testing::Genre> " +
@@ -922,6 +931,20 @@ TEST(Value, ProtoConversionDate) {
922931 }
923932}
924933
934+ TEST (Value, ProtoConversionUuid) {
935+ for (auto const & x : std::vector<Uuid>{
936+ Uuid (),
937+ Uuid (0x7bf8a7b819171919 , 0x2625f208c5824254 ),
938+ MakeUuid (" {0b6ed04ca16dfc4652817f9978c13738}" ).value (),
939+ }) {
940+ Value const v (x);
941+ auto const p = spanner_internal::ToProto (v);
942+ EXPECT_EQ (v, spanner_internal::FromProto (p.first , p.second ));
943+ EXPECT_EQ (google::spanner::v1::TypeCode::UUID, p.first .code ());
944+ EXPECT_EQ (std::string{x}, p.second .string_value ());
945+ }
946+ }
947+
925948TEST (Value, ProtoConversionProtoEnum) {
926949 for (auto e : {testing::Genre::POP, testing::Genre::JAZZ,
927950 testing::Genre::FOLK, testing::Genre::ROCK}) {
@@ -1251,6 +1274,24 @@ TEST(Value, GetBadDate) {
12511274 EXPECT_THAT (v.get <absl::CivilDay>(), Not (IsOk ()));
12521275}
12531276
1277+ TEST (Value, GetBadUuid) {
1278+ Value v (Uuid{});
1279+ ClearProtoKind (v);
1280+ EXPECT_THAT (v.get <Uuid>(), Not (IsOk ()));
1281+
1282+ SetProtoKind (v, google::protobuf::NULL_VALUE);
1283+ EXPECT_THAT (v.get <Uuid>(), Not (IsOk ()));
1284+
1285+ SetProtoKind (v, true );
1286+ EXPECT_THAT (v.get <Uuid>(), Not (IsOk ()));
1287+
1288+ SetProtoKind (v, 0.0 );
1289+ EXPECT_THAT (v.get <Uuid>(), Not (IsOk ()));
1290+
1291+ SetProtoKind (v, " blah" );
1292+ EXPECT_THAT (v.get <Uuid>(), Not (IsOk ()));
1293+ }
1294+
12541295TEST (Value, GetBadProtoEnum) {
12551296 Value v (ProtoEnum<testing::Genre>{});
12561297 ClearProtoKind (v);
@@ -1429,6 +1470,7 @@ TEST(Value, OutputStream) {
14291470 {Value (PgOid (1234567890 )), " 1234567890" , normal},
14301471 {Value (absl::CivilDay ()), " 1970-01-01" , normal},
14311472 {Value (Timestamp ()), " 1970-01-01T00:00:00Z" , normal},
1473+ {Value (Uuid ()), " 00000000-0000-0000-0000-000000000000" , normal},
14321474 {Value (ProtoEnum<testing::Genre>(testing::Genre::POP)),
14331475 " google.cloud.spanner.testing.POP" , normal},
14341476 {Value (ProtoMessage<testing::SingerInfo>(singer)),
@@ -1462,6 +1504,7 @@ TEST(Value, OutputStream) {
14621504 {MakeNullValue<PgOid>(), " NULL" , normal},
14631505 {MakeNullValue<absl::CivilDay>(), " NULL" , normal},
14641506 {MakeNullValue<Timestamp>(), " NULL" , normal},
1507+ {MakeNullValue<Uuid>(), " NULL" , normal},
14651508 {MakeNullValue<ProtoEnum<testing::Genre>>(), " NULL" , normal},
14661509 {MakeNullValue<ProtoMessage<testing::SingerInfo>>(), " NULL" , normal},
14671510
@@ -1482,6 +1525,8 @@ TEST(Value, OutputStream) {
14821525 {Value (std::vector<absl::CivilDay>{2 }), " [1970-01-01, 1970-01-01]" ,
14831526 normal},
14841527 {Value (std::vector<Timestamp>{1 }), " [1970-01-01T00:00:00Z]" , normal},
1528+ {Value (std::vector<Uuid>{1 }), " [00000000-0000-0000-0000-000000000000]" ,
1529+ normal},
14851530 {Value (std::vector<ProtoEnum<testing::Genre>>{testing::JAZZ,
14861531 testing::FOLK}),
14871532 " [google.cloud.spanner.testing.JAZZ, google.cloud.spanner.testing.FOLK]" ,
@@ -1507,6 +1552,7 @@ TEST(Value, OutputStream) {
15071552 {MakeNullValue<std::vector<Numeric>>(), " NULL" , normal},
15081553 {MakeNullValue<std::vector<absl::CivilDay>>(), " NULL" , normal},
15091554 {MakeNullValue<std::vector<Timestamp>>(), " NULL" , normal},
1555+ {MakeNullValue<std::vector<Uuid>>(), " NULL" , normal},
15101556 {MakeNullValue<std::vector<ProtoEnum<testing::Genre>>>(), " NULL" , normal},
15111557 {MakeNullValue<std::vector<ProtoMessage<testing::SingerInfo>>>(), " NULL" ,
15121558 normal},
@@ -1657,6 +1703,11 @@ TEST(Value, OutputStreamMatchesT) {
16571703 StreamMatchesValueStream (Timestamp ());
16581704 StreamMatchesValueStream (MakeTimestamp (MakeTime (1 , 1 )).value ());
16591705
1706+ // Uuid
1707+ StreamMatchesValueStream (Uuid ());
1708+ StreamMatchesValueStream (
1709+ MakeUuid (" {0b6ed04ca16dfc4652817f9978c13738}" ).value ());
1710+
16601711 // ProtoEnum
16611712 StreamMatchesValueStream (ProtoEnum<testing::Genre>());
16621713 StreamMatchesValueStream (ProtoEnum<testing::Genre>(testing::ROCK));
0 commit comments