#include "test/unit_spirv.h"
#include "gmock/gmock.h"
#include "test/test_fixture.h"
namespace spvtools {
namespace {
using SpirvVector = spvtest::TextToBinaryTest::SpirvVector;
using spvtest::MakeInstruction;
using ::testing::Eq;
using TextToBinaryMisc = spvtest::TextToBinaryTest;
TEST_F(TextToBinaryMisc, OpNop) {
EXPECT_THAT(CompiledInstructions("OpNop"),
Eq(MakeInstruction(spv::Op::OpNop, {})));
}
TEST_F(TextToBinaryMisc, OpUndef) {
const SpirvVector code = CompiledInstructions(R"(%f32 = OpTypeFloat 32
%u = OpUndef %f32)");
const uint32_t typeID = 1;
EXPECT_THAT(code[1], Eq(typeID));
EXPECT_THAT(Subvector(code, 3),
Eq(MakeInstruction(spv::Op::OpUndef, {typeID, 2})));
}
TEST_F(TextToBinaryMisc, OpWrong) {
EXPECT_THAT(CompileFailure(" OpWrong %1 %2"),
Eq("Invalid Opcode name 'OpWrong'"));
}
TEST_F(TextToBinaryMisc, OpWrongAfterRight) {
const auto assembly = R"(
OpCapability Shader
OpMemoryModel Logical GLSL450
OpXYZ
)";
EXPECT_THAT(CompileFailure(assembly), Eq("Invalid Opcode name 'OpXYZ'"));
}
}
}