std::stringstream input;
input << "OpDecorate %1 " << GetParam().name();
for (auto operand : GetParam().operands()) input << " " << operand;
- std::vector<uint32_t> expected_operands{1, uint32_t(GetParam().value())};
- expected_operands.insert(expected_operands.end(),
- GetParam().operands().begin(),
- GetParam().operands().end());
- EXPECT_THAT(CompiledInstructions(input.str()),
- Eq(MakeInstruction(spv::OpDecorate, expected_operands)));
+ EXPECT_THAT(
+ CompiledInstructions(input.str()),
+ Eq(MakeInstruction(spv::OpDecorate, {1, uint32_t(GetParam().value())},
+ GetParam().operands())));
}
#define CASE(NAME) spv::Decoration##NAME, #NAME
TEST_F(TextToBinaryTest, OpSourceAcceptsOptionalSourceText) {
std::string fake_source = "To be or not to be";
std::string input = "OpSource GLSL 450 %file_id \"" + fake_source + "\"";
- std::vector<uint32_t> expected_operands = {spv::SourceLanguageGLSL, 450, 1};
- std::vector<uint32_t> encoded_source = MakeVector(fake_source);
- expected_operands.insert(expected_operands.end(), encoded_source.begin(),
- encoded_source.end());
- EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(spv::OpSource, expected_operands)));
+ EXPECT_THAT(
+ CompiledInstructions(input),
+ Eq(MakeInstruction(spv::OpSource, {spv::SourceLanguageGLSL, 450, 1},
+ MakeVector(fake_source))));
};
// Test OpSourceContinued
TEST_P(OpStringTest, AnyString) {
// TODO(dneto): utf-8, quoting, escaping
std::string input = std::string("%result = OpString \"") + GetParam() + "\"";
- std::vector<uint32_t> expected_operands = MakeVector(GetParam());
- expected_operands.insert(expected_operands.begin(), 1); // The ID of the result.
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(spv::OpString, expected_operands)));
+ Eq(MakeInstruction(spv::OpString, {1}, MakeVector(GetParam()))));
}
// TODO(dneto): utf-8, quoting, escaping
TEST_P(OpNameTest, AnyString) {
// TODO(dneto): utf-8, quoting, escaping
std::string input = std::string("OpName %target \"") + GetParam() + "\"";
- std::vector<uint32_t> expected_operands = MakeVector(GetParam());
- expected_operands.insert(expected_operands.begin(), 1); // The ID of the target.
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(spv::OpName, expected_operands)));
+ Eq(MakeInstruction(spv::OpName, {1}, MakeVector(GetParam()))));
}
// TODO(dneto): utf-8, quoting, escaping
// TODO(dneto): utf-8, quoting, escaping
std::string input =
std::string("OpMemberName %type 42 \"") + GetParam() + "\"";
- std::vector<uint32_t> expected_operands = {1, 42};
- std::vector<uint32_t> encoded_string = MakeVector(GetParam());
- expected_operands.insert(expected_operands.end(), encoded_string.begin(),
- encoded_string.end());
- EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(spv::OpMemberName, expected_operands)));
+ EXPECT_THAT(
+ CompiledInstructions(input),
+ Eq(MakeInstruction(spv::OpMemberName, {1, 42}, MakeVector(GetParam()))));
}
// TODO(dneto): utf-8, quoting, escaping
TEST_P(ImageOperandsTest, Sample) {
std::string input =
"%result = OpImageFetch %type %image %coord " + GetParam().image_operands;
- std::vector<uint32_t> expected_operands{1, 2, 3, 4};
- expected_operands.insert(expected_operands.end(),
- GetParam().expected_mask_and_operands.begin(),
- GetParam().expected_mask_and_operands.end());
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(spv::OpImageFetch, expected_operands)));
+ Eq(MakeInstruction(spv::OpImageFetch, {1, 2, 3, 4},
+ GetParam().expected_mask_and_operands)));
}
#define MASK(NAME) spv::ImageOperands##NAME##Mask
std::stringstream input;
input << "OpStore %ptr %value " << GetParam().name();
for (auto operand : GetParam().operands()) input << " " << operand;
- std::vector<uint32_t> expected_operands{1, 2, GetParam().value()};
- expected_operands.insert(expected_operands.end(), GetParam().operands().begin(),
- GetParam().operands().end());
EXPECT_THAT(CompiledInstructions(input.str()),
- Eq(MakeInstruction(spv::OpStore, expected_operands)));
+ Eq(MakeInstruction(spv::OpStore, {1, 2, GetParam().value()},
+ GetParam().operands())));
}
INSTANTIATE_TEST_CASE_P(
// TODO(dneto): utf-8, escaping, quoting cases for entry point name.
std::string input = "OpEntryPoint " + GetParam().execution_name + " %1 \"" +
GetParam().entry_point_name + "\"";
- std::vector<uint32_t> expected_operands{GetParam().get_execution_value(), 1};
- std::vector<uint32_t> encoded_entry_point_name =
- MakeVector(GetParam().entry_point_name);
- expected_operands.insert(expected_operands.end(),
- encoded_entry_point_name.begin(),
- encoded_entry_point_name.end());
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(spv::OpEntryPoint, expected_operands)));
+ Eq(MakeInstruction(spv::OpEntryPoint,
+ {GetParam().get_execution_value(), 1},
+ MakeVector(GetParam().entry_point_name))));
}
// clang-format off
std::stringstream input;
input << "OpExecutionMode %1 " << GetParam().name();
for (auto operand : GetParam().operands()) input << " " << operand;
- std::vector<uint32_t> expected_operands{1, GetParam().value()};
- expected_operands.insert(expected_operands.end(), GetParam().operands().begin(),
- GetParam().operands().end());
EXPECT_THAT(CompiledInstructions(input.str()),
- Eq(MakeInstruction(spv::OpExecutionMode, expected_operands)));
+ Eq(MakeInstruction(spv::OpExecutionMode, {1, GetParam().value()},
+ GetParam().operands())));
}
#define CASE(NAME) spv::ExecutionMode##NAME, #NAME