MCPcopy Create free account
hub / github.com/apache/tvm-ffi / ExampleVariant

Function ExampleVariant

tests/cpp/test_example.cc:223–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221TEST(Example, Optional) { ExampleOptional(); }
222
223void ExampleVariant() {
224 namespace ffi = tvm::ffi;
225 ffi::Variant<int, ffi::String> var0 = 100;
226 EXPECT_EQ(var0.get<int>(), 100);
227
228 var0 = ffi::String("hello");
229 std::optional<ffi::String> maybe_str = var0.as<ffi::String>();
230 EXPECT_EQ(maybe_str.value(), "hello"); // NOLINT(bugprone-unchecked-optional-access)
231
232 std::optional<int> maybe_int2 = var0.as<int>();
233 EXPECT_EQ(maybe_int2.has_value(), false);
234}
235
236TEST(Example, Variant) { ExampleVariant(); }
237

Callers 1

TESTFunction · 0.85

Calls 3

StringClass · 0.50
valueMethod · 0.45
has_valueMethod · 0.45

Tested by

no test coverage detected