Also rerun clang-format.
spvtest::TextToBinaryTestBase<::testing::TestWithParam<IdCheckCase>>;
TEST_P(IdValidityTest, IdTypes) {
- std::string input = GetParam().id + " = OpTypeVoid";
+ const std::string input = GetParam().id + " = OpTypeVoid";
SetText(input);
if (GetParam().valid) {
CompileSuccessfully(input);
std::string enum_name;
};
-using OpDecorateEnumTest = spvtest::TextToBinaryTestBase<
- ::testing::TestWithParam<DecorateEnumCase>>;
+using OpDecorateEnumTest =
+ spvtest::TextToBinaryTestBase<::testing::TestWithParam<DecorateEnumCase>>;
TEST_P(OpDecorateEnumTest, AnyEnumDecoration) {
// This string should assemble, but should not validate.
- std::string input = "OpDecorate %1 " + GetParam().enum_name + " " + GetParam().name;
+ const std::string input =
+ "OpDecorate %1 " + GetParam().enum_name + " " + GetParam().name;
EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(spv::OpDecorate, {1, GetParam().enum_value, GetParam().value})));
+ Eq(MakeInstruction(spv::OpDecorate, {1, GetParam().enum_value,
+ GetParam().value})));
}
// Test OpDecorate BuiltIn.
TEST_F(TextToBinaryTest, CombinedFPFastMathMask) {
// Sample a single combination. This ensures we've integrated
// the instruction parsing logic with spvTextParseMask.
- const std::string input = "OpDecorate %1 FPFastMathMode NotNaN|NotInf|NSZ";
+ const std::string input =
+ "OpDecorate %1 FPFastMathMode NotNaN|NotInf|NSZ";
const uint32_t expected_enum = spv::DecorationFPFastMathMode;
const uint32_t expected_mask = spv::FPFastMathModeNotNaNMask |
spv::FPFastMathModeNotInfMask |
TEST_P(OpDecorateLinkageTest, AnyLinkageDecoration) {
// This string should assemble, but should not validate.
- std::string input = "OpDecorate %1 LinkageAttributes \"" + GetParam().external_name +
- "\" " + GetParam().linkage_type_name;
+ const std::string input = "OpDecorate %1 LinkageAttributes \"" +
+ GetParam().external_name + "\" " +
+ GetParam().linkage_type_name;
std::vector<uint32_t> expected_operands{1, spv::DecorationLinkageAttributes};
std::vector<uint32_t> encoded_external_name =
MakeVector(GetParam().external_name);
#undef CASE
// clang-format on
-
// Test OpGroupMemberDecorate
TEST_F(TextToBinaryTest, GroupMemberDecorateGoodOneTarget) {
EXPECT_THAT(CompiledInstructions("OpGroupMemberDecorate %group %id0 42"),
- Eq(MakeInstruction(spv::OpGroupMemberDecorate,
- {1, 2, 42})));
+ Eq(MakeInstruction(spv::OpGroupMemberDecorate, {1, 2, 42})));
}
TEST_F(TextToBinaryTest, GroupMemberDecorateGoodTwoTargets) {
- EXPECT_THAT(CompiledInstructions("OpGroupMemberDecorate %group %id0 96 %id1 42"),
- Eq(MakeInstruction(spv::OpGroupMemberDecorate,
- {1, 2, 96, 3, 42})));
+ EXPECT_THAT(
+ CompiledInstructions("OpGroupMemberDecorate %group %id0 96 %id1 42"),
+ Eq(MakeInstruction(spv::OpGroupMemberDecorate, {1, 2, 96, 3, 42})));
}
TEST_F(TextToBinaryTest, GroupMemberDecorateMissingGroupId) {
using OpMemoryBarrier = spvtest::TextToBinaryTest;
TEST_F(OpMemoryBarrier, Good) {
- std::string input = "OpMemoryBarrier %1 %2\n";
+ const std::string input = "OpMemoryBarrier %1 %2\n";
EXPECT_THAT(CompiledInstructions(input),
Eq(MakeInstruction(spv::OpMemoryBarrier, {1, 2})));
EXPECT_THAT(EncodeAndDecodeSuccessfully(input), Eq(input));
}
TEST_F(OpMemoryBarrier, BadMissingScopeId) {
- std::string input = "OpMemoryBarrier\n";
+ const std::string input = "OpMemoryBarrier\n";
EXPECT_THAT(CompileFailure(input),
Eq("Expected operand, found end of stream."));
}
TEST_F(OpMemoryBarrier, BadInvalidScopeId) {
- std::string input = "OpMemoryBarrier 99\n";
+ const std::string input = "OpMemoryBarrier 99\n";
EXPECT_THAT(CompileFailure(input),
Eq("Expected id to start with %."));
}
TEST_F(OpMemoryBarrier, BadMissingMemorySemanticsId) {
- std::string input = "OpMemoryBarrier %scope\n";
+ const std::string input = "OpMemoryBarrier %scope\n";
EXPECT_THAT(CompileFailure(input),
Eq("Expected operand, found end of stream."));
}
TEST_F(OpMemoryBarrier, BadInvalidMemorySemanticsId) {
- std::string input = "OpMemoryBarrier %scope 14\n";
+ const std::string input = "OpMemoryBarrier %scope 14\n";
EXPECT_THAT(CompileFailure(input),
Eq("Expected id to start with %."));
}
::testing::TestWithParam<EnumCase<spv::SamplerAddressingMode>>>;
TEST_P(SamplerAddressingModeTest, AnySamplerAddressingMode) {
- std::string input =
+ const std::string input =
"%result = OpConstantSampler %type " + GetParam().name() + " 0 Nearest";
EXPECT_THAT(CompiledInstructions(input),
Eq(MakeInstruction(spv::OpConstantSampler,
::testing::TestWithParam<EnumCase<spv::SamplerFilterMode>>>;
TEST_P(SamplerFilterModeTest, AnySamplerFilterMode) {
- std::string input =
+ const std::string input =
"%result = OpConstantSampler %type Clamp 0 " + GetParam().name();
EXPECT_THAT(CompiledInstructions(input),
Eq(MakeInstruction(spv::OpConstantSampler,
spvtest::TextToBinaryTestBase<::testing::TestWithParam<ConstantTestCase>>;
TEST_P(OpConstantValidTest, ValidTypes) {
- std::string input = "%1 = " + GetParam().constant_type +
- "\n"
- "%2 = OpConstant %1 " +
- GetParam().constant_value + "\n";
+ const std::string input = "%1 = " + GetParam().constant_type +
+ "\n"
+ "%2 = OpConstant %1 " +
+ GetParam().constant_value + "\n";
std::vector<uint32_t> instructions;
EXPECT_THAT(CompiledInstructions(input),
Eq(GetParam().expected_instructions));
spvtest::TextToBinaryTestBase<::testing::TestWithParam<std::string>>;
TEST_P(OpConstantInvalidTypeTest, InvalidTypes) {
- std::string input = "%1 = " + GetParam() +
- "\n"
- "%2 = OpConstant %1 0\n";
+ const std::string input = "%1 = " + GetParam() +
+ "\n"
+ "%2 = OpConstant %1 0\n";
EXPECT_THAT(
CompileFailure(input),
Eq("Type for Constant must be a scalar floating point or integer type"));
::testing::TestWithParam<EnumCase<spv::SelectionControlMask>>>;
TEST_P(OpSelectionMergeTest, AnySingleSelectionControlMask) {
- std::string input = "OpSelectionMerge %1 " + GetParam().name();
+ const std::string input = "OpSelectionMerge %1 " + GetParam().name();
EXPECT_THAT(
CompiledInstructions(input),
Eq(MakeInstruction(spv::OpSelectionMerge, {1, GetParam().value()})));
::testing::TestWithParam<EnumCase<spv::LoopControlMask>>>;
TEST_P(OpLoopMergeTest, AnySingleLoopControlMask) {
- std::string input = "OpLoopMerge %merge %continue " + GetParam().name();
+ const std::string input = "OpLoopMerge %merge %continue " + GetParam().name();
EXPECT_THAT(
CompiledInstructions(input),
Eq(MakeInstruction(spv::OpLoopMerge, {1, 2, GetParam().value()})));
EXPECT_THAT(CompiledInstructions("%1 = OpTypeInt 32 0\n"
"%2 = OpConstant %1 52\n"
"OpSwitch %2 %default 12 %target0"),
- Eq(Concatenate({
- MakeInstruction(spv::OpTypeInt, {1, 32, 0}),
- MakeInstruction(spv::OpConstant, {1, 2, 52}),
- MakeInstruction(spv::OpSwitch, {2, 3, 12, 4})})));
+ Eq(Concatenate({MakeInstruction(spv::OpTypeInt, {1, 32, 0}),
+ MakeInstruction(spv::OpConstant, {1, 2, 52}),
+ MakeInstruction(spv::OpSwitch, {2, 3, 12, 4})})));
}
TEST_F(TextToBinaryTest, SwitchGoodTwoTargets) {
Eq("Expected operand, found end of stream."));
}
-struct SwitchTestCase{
+struct SwitchTestCase {
std::string constant_type_args;
std::vector<uint32_t> expected_instructions;
};
-using OpSwitchValidTest = spvtest::TextToBinaryTestBase<
- ::testing::TestWithParam<SwitchTestCase>>;
+using OpSwitchValidTest =
+ spvtest::TextToBinaryTestBase<::testing::TestWithParam<SwitchTestCase>>;
-TEST_P(OpSwitchValidTest, ValidTypes)
-{
- std::string input =
- "%1 = OpTypeInt " + GetParam().constant_type_args + "\n"
- "%2 = OpConstant %1 0\n"
- "OpSwitch %2 %default 32 %4\n";
+TEST_P(OpSwitchValidTest, ValidTypes) {
+ const std::string input = "%1 = OpTypeInt " + GetParam().constant_type_args +
+ "\n"
+ "%2 = OpConstant %1 0\n"
+ "OpSwitch %2 %default 32 %4\n";
std::vector<uint32_t> instructions;
EXPECT_THAT(CompiledInstructions(input),
Eq(GetParam().expected_instructions));
#undef CASE
// clang-format on
-using OpSwitchInvalidTypeTestCase = spvtest::TextToBinaryTestBase<
- ::testing::TestWithParam<std::string>>;
+using OpSwitchInvalidTypeTestCase =
+ spvtest::TextToBinaryTestBase<::testing::TestWithParam<std::string>>;
-TEST_P(OpSwitchInvalidTypeTestCase, InvalidTypes)
-{
- std::string input =
- "%1 = " + GetParam() + "\n"
- "%3 = OpCopyObject %1 %2\n" // We only care the type of the expression
+TEST_P(OpSwitchInvalidTypeTestCase, InvalidTypes) {
+ const std::string input =
+ "%1 = " + GetParam() +
+ "\n"
+ "%3 = OpCopyObject %1 %2\n" // We only care the type of the expression
"%4 = OpSwitch %3 %default 32 %c\n";
EXPECT_THAT(CompileFailure(input),
Eq(std::string(
}));
// clang-format on
-//TODO(awoloszyn): Add tests for switch with different operand widths
+// TODO(awoloszyn): Add tests for switch with different operand widths
// once non-32-bit support is in.
// TODO(dneto): OpPhi
// TODO(dneto): OpLoopMerge
spvtest::TextToBinaryTestBase<::testing::TestWithParam<LanguageCase>>;
TEST_P(OpSourceTest, AnyLanguage) {
- std::string input = std::string("OpSource ") + GetParam().language_name +
- " " + std::to_string(GetParam().version);
+ const std::string input = std::string("OpSource ") +
+ GetParam().language_name + " " +
+ std::to_string(GetParam().version);
EXPECT_THAT(
CompiledInstructions(input),
Eq(MakeInstruction(spv::OpSource, {GetParam().get_language_value(),
TEST_F(TextToBinaryTest, OpSourceAcceptsOptionalFileId) {
// In the grammar, the file id is an OperandOptionalId.
- std::string input = "OpSource GLSL 450 %file_id";
+ const std::string input = "OpSource GLSL 450 %file_id";
EXPECT_THAT(
CompiledInstructions(input),
Eq(MakeInstruction(spv::OpSource, {spv::SourceLanguageGLSL, 450, 1})));
TEST_F(TextToBinaryTest, OpSourceAcceptsOptionalSourceText) {
std::string fake_source = "To be or not to be";
- std::string input = "OpSource GLSL 450 %file_id \"" + fake_source + "\"";
+ const std::string input =
+ "OpSource GLSL 450 %file_id \"" + fake_source + "\"";
EXPECT_THAT(
CompiledInstructions(input),
Eq(MakeInstruction(spv::OpSource, {spv::SourceLanguageGLSL, 450, 1},
TEST_P(OpSourceContinuedTest, AnyExtension) {
// TODO(dneto): utf-8, quoting, escaping
- std::string input = std::string("OpSourceContinued \"") + GetParam() + "\"";
+ const std::string input =
+ std::string("OpSourceContinued \"") + GetParam() + "\"";
EXPECT_THAT(
CompiledInstructions(input),
Eq(MakeInstruction(spv::OpSourceContinued, MakeVector(GetParam()))));
TEST_P(OpSourceExtensionTest, AnyExtension) {
// TODO(dneto): utf-8, quoting, escaping
- std::string input = std::string("OpSourceExtension \"") + GetParam() + "\"";
+ const std::string input =
+ std::string("OpSourceExtension \"") + GetParam() + "\"";
EXPECT_THAT(
CompiledInstructions(input),
Eq(MakeInstruction(spv::OpSourceExtension, MakeVector(GetParam()))));
TEST_P(OpStringTest, AnyString) {
// TODO(dneto): utf-8, quoting, escaping
- std::string input = std::string("%result = OpString \"") + GetParam() + "\"";
+ const std::string input =
+ std::string("%result = OpString \"") + GetParam() + "\"";
EXPECT_THAT(CompiledInstructions(input),
Eq(MakeInstruction(spv::OpString, {1}, MakeVector(GetParam()))));
}
TEST_P(OpNameTest, AnyString) {
// TODO(dneto): utf-8, quoting, escaping
- std::string input = std::string("OpName %target \"") + GetParam() + "\"";
+ const std::string input =
+ std::string("OpName %target \"") + GetParam() + "\"";
EXPECT_THAT(CompiledInstructions(input),
Eq(MakeInstruction(spv::OpName, {1}, MakeVector(GetParam()))));
}
TEST_P(OpMemberNameTest, AnyString) {
// TODO(dneto): utf-8, quoting, escaping
- std::string input =
+ const std::string input =
std::string("OpMemberName %type 42 \"") + GetParam() + "\"";
EXPECT_THAT(
CompiledInstructions(input),
spvtest::TextToBinaryTestBase<::testing::TestWithParam<KernelEnqueueCase>>;
TEST_P(OpEnqueueKernelGood, Sample) {
- std::string input =
+ const std::string input =
"%result = OpEnqueueKernel %type %queue %flags %NDRange %num_events"
" %wait_events %ret_event %invoke %param %param_size %param_align " +
GetParam().local_size_source;
::testing::TestWithParam<EnumCase<spv::FunctionControlMask>>>;
TEST_P(OpFunctionControlTest, AnySingleFunctionControlMask) {
- std::string input = "%result_id = OpFunction %result_type " +
- GetParam().name() + " %function_type ";
+ const std::string input = "%result_id = OpFunction %result_type " +
+ GetParam().name() + " %function_type ";
EXPECT_THAT(
CompiledInstructions(input),
Eq(MakeInstruction(spv::OpFunction, {1, 2, GetParam().value(), 3})));
::testing::TestWithParam<EnumCase<spv::GroupOperation>>>;
TEST_P(GroupOperationTest, AnyGroupOperation) {
- std::string input =
+ const std::string input =
"%result = OpGroupIAdd %type %scope " + GetParam().name() + " %x";
- EXPECT_THAT(CompiledInstructions(input),
- Eq(MakeInstruction(spv::OpGroupIAdd,
- {1, 2, 3, GetParam().value(), 4})));
+ EXPECT_THAT(
+ CompiledInstructions(input),
+ Eq(MakeInstruction(spv::OpGroupIAdd, {1, 2, 3, GetParam().value(), 4})));
}
// clang-format off
// Test all kinds of image operands.
-using ImageOperandsTest = spvtest::TextToBinaryTestBase<
- ::testing::TestWithParam<ImageOperandsCase>>;
+using ImageOperandsTest =
+ spvtest::TextToBinaryTestBase<::testing::TestWithParam<ImageOperandsCase>>;
TEST_P(ImageOperandsTest, Sample) {
- std::string input =
+ const std::string input =
"%result = OpImageFetch %type %image %coord " + GetParam().image_operands;
EXPECT_THAT(CompiledInstructions(input),
Eq(MakeInstruction(spv::OpImageFetch, {1, 2, 3, 4},
::testing::TestWithParam<EnumCase<spv::StorageClass>>>;
TEST_P(StorageClassTest, AnyStorageClass) {
- std::string input = "%1 = OpVariable %2 " + GetParam().name();
+ const std::string input = "%1 = OpVariable %2 " + GetParam().name();
EXPECT_THAT(CompiledInstructions(input),
Eq(MakeInstruction(spv::OpVariable, {1, 2, GetParam().value()})));
}
spvtest::TextToBinaryTestBase<::testing::TestWithParam<MemoryModelCase>>;
TEST_P(OpMemoryModelTest, AnyMemoryModelCase) {
- std::string input = "OpMemoryModel " + GetParam().addressing_name + " " +
- GetParam().memory_name;
+ const std::string input = "OpMemoryModel " + GetParam().addressing_name +
+ " " + GetParam().memory_name;
EXPECT_THAT(
CompiledInstructions(input),
Eq(MakeInstruction(spv::OpMemoryModel, {GetParam().get_addressing_value(),
TEST_P(OpEntryPointTest, AnyEntryPointCase) {
// TODO(dneto): utf-8, escaping, quoting cases for entry point name.
- std::string input = "OpEntryPoint " + GetParam().execution_name + " %1 \"" +
- GetParam().entry_point_name + "\"";
+ const std::string input = "OpEntryPoint " + GetParam().execution_name +
+ " %1 \"" + GetParam().entry_point_name + "\"";
EXPECT_THAT(CompiledInstructions(input),
Eq(MakeInstruction(spv::OpEntryPoint,
{GetParam().get_execution_value(), 1},
::testing::TestWithParam<EnumCase<spv::Capability>>>;
TEST_P(OpCapabilityTest, AnyCapability) {
- std::string input = "OpCapability " + GetParam().name();
+ const std::string input = "OpCapability " + GetParam().name();
EXPECT_THAT(CompiledInstructions(input),
Eq(MakeInstruction(spv::OpCapability, {GetParam().value()})));
}
spvtest::TextToBinaryTestBase<::testing::TestWithParam<EnumCase<spv::Dim>>>;
TEST_P(DimTest, AnyDim) {
- std::string input = "%imageType = OpTypeImage %sampledType " +
- GetParam().name() + " 2 3 0 4 Rgba8";
+ const std::string input = "%imageType = OpTypeImage %sampledType " +
+ GetParam().name() + " 2 3 0 4 Rgba8";
EXPECT_THAT(
CompiledInstructions(input),
Eq(MakeInstruction(spv::OpTypeImage, {1, 2, GetParam().value(), 2, 3, 0,
::testing::TestWithParam<EnumCase<spv::ImageFormat>>>;
TEST_P(ImageFormatTest, AnyImageFormat) {
- std::string input =
+ const std::string input =
"%imageType = OpTypeImage %sampledType 1D 2 3 0 4 " + GetParam().name();
EXPECT_THAT(CompiledInstructions(input),
Eq(MakeInstruction(spv::OpTypeImage, {1, 2, spv::Dim1D, 2, 3, 0,
::testing::TestWithParam<EnumCase<spv::AccessQualifier>>>;
TEST_P(OpTypePipeTest, AnyAccessQualifier) {
- std::string input = "%1 = OpTypePipe " + GetParam().name();
+ const std::string input = "%1 = OpTypePipe " + GetParam().name();
EXPECT_THAT(CompiledInstructions(input),
Eq(MakeInstruction(spv::OpTypePipe, {1, GetParam().value()})));
}