MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / TEST

Function TEST

test/cpp_interface_test.cpp:43–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41const uint32_t kExpectedSpvVersion = 0x10100;
42
43TEST(CppInterface, SuccessfulRoundTrip) {
44 const std::string input_text = "%2 = OpSizeOf %1 %3\n";
45 SpirvTools t(SPV_ENV_UNIVERSAL_1_1);
46
47 std::vector<uint32_t> binary;
48 EXPECT_TRUE(t.Assemble(input_text, &binary));
49 EXPECT_TRUE(binary.size() > 5u);
50 EXPECT_EQ(spv::MagicNumber, binary[0]);
51 EXPECT_EQ(kExpectedSpvVersion, binary[1]);
52
53 // This cannot pass validation since %1 is not defined.
54 t.SetMessageConsumer([](spv_message_level_t level, const char* source,
55 const spv_position_t& position, const char* message) {
56 EXPECT_EQ(SPV_MSG_ERROR, level);
57 EXPECT_STREQ("input", source);
58 EXPECT_EQ(0u, position.line);
59 EXPECT_EQ(0u, position.column);
60 EXPECT_EQ(1u, position.index);
61 EXPECT_STREQ("ID '1[%1]' has not been defined\n %2 = OpSizeOf %1 %3\n",
62 message);
63 });
64 EXPECT_FALSE(t.Validate(binary));
65
66 std::string output_text;
67 EXPECT_TRUE(t.Disassemble(binary, &output_text));
68 EXPECT_EQ(input_text, output_text);
69}
70
71TEST(CppInterface, AssembleEmptyModule) {
72 std::vector<uint32_t> binary(10, 42);

Callers

nothing calls this directly

Calls 15

MakeModuleHavingStructFunction · 0.85
CreateStripDebugInfoPassFunction · 0.85
CheckOptimizationFunction · 0.85
CreateUnifyConstantPassFunction · 0.85
CreateNullPassFunction · 0.85
OptimizerFunction · 0.85
HeaderFunction · 0.70
AssembleMethod · 0.45
sizeMethod · 0.45
SetMessageConsumerMethod · 0.45
ValidateMethod · 0.45

Tested by

no test coverage detected