| 105 | } // namespace |
| 106 | |
| 107 | TEST(VariantOpDecodeRegistryTest, TestBasic) { |
| 108 | EXPECT_EQ(UnaryVariantOpRegistry::Global()->GetDecodeFn("YOU SHALL NOT PASS"), |
| 109 | nullptr); |
| 110 | |
| 111 | auto* decode_fn = |
| 112 | UnaryVariantOpRegistry::Global()->GetDecodeFn("TEST VariantValue"); |
| 113 | EXPECT_NE(decode_fn, nullptr); |
| 114 | |
| 115 | VariantValue vv{true /* early_exit */}; |
| 116 | Variant v = vv; |
| 117 | VariantTensorData data; |
| 118 | v.Encode(&data); |
| 119 | VariantTensorDataProto proto; |
| 120 | data.ToProto(&proto); |
| 121 | Variant encoded = std::move(proto); |
| 122 | EXPECT_TRUE((*decode_fn)(&encoded)); |
| 123 | VariantValue* decoded = encoded.get<VariantValue>(); |
| 124 | EXPECT_NE(decoded, nullptr); |
| 125 | EXPECT_EQ(decoded->early_exit, true); |
| 126 | } |
| 127 | |
| 128 | TEST(VariantOpDecodeRegistryTest, TestEmpty) { |
| 129 | VariantTensorDataProto empty_proto; |
nothing calls this directly
no test coverage detected