A bunch of small fixes to build in MSVC2013.
authorAndrew Woloszyn <awoloszyn@google.com>
Fri, 18 Sep 2015 15:50:54 +0000 (11:50 -0400)
committerDavid Neto <dneto@google.com>
Mon, 26 Oct 2015 16:55:33 +0000 (12:55 -0400)
Fixed an issue where some of the tests were testing
the wrong word with the wrong operation. (| != ||).

Coalesced the many versions of EnumCase into one.
Added a get_value() to EnumCase to convert to a uint32_t.

Replaces ASSERT_TRUE(pointer), with ASSERT_NE(nullptr, pointer),
so that we do not do implicit pointer->bool conversion.

Removed const from some test structs since gtest needs to be
able to swap them.

15 files changed:
test/AssemblyFormat.cpp [changed mode: 0644->0755]
test/OperandPattern.cpp [changed mode: 0644->0755]
test/TextLiteral.cpp [changed mode: 0644->0755]
test/TextStartsNewInst.cpp [changed mode: 0644->0755]
test/TextToBinary.Annotation.cpp [changed mode: 0644->0755]
test/TextToBinary.Constant.cpp [changed mode: 0644->0755]
test/TextToBinary.ControlFlow.cpp [changed mode: 0644->0755]
test/TextToBinary.Debug.cpp [changed mode: 0644->0755]
test/TextToBinary.Function.cpp [changed mode: 0644->0755]
test/TextToBinary.Group.cpp [changed mode: 0644->0755]
test/TextToBinary.Memory.cpp [changed mode: 0644->0755]
test/TextToBinary.ModeSetting.cpp [changed mode: 0644->0755]
test/TextToBinary.TypeDeclaration.cpp [changed mode: 0644->0755]
test/TextToBinary.cpp [changed mode: 0644->0755]
test/UnitSPIRV.h [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 99d10d4..d9b646d
@@ -47,7 +47,7 @@ TEST_F(TextToBinaryTest, EncodeAAFTextAsCAF) {
             spvTextWithFormatToBinary(
                 text.str, text.length, SPV_ASSEMBLY_SYNTAX_FORMAT_CANONICAL,
                 opcodeTable, operandTable, extInstTable, &binary, &diagnostic));
-  ASSERT_TRUE(diagnostic);
+  ASSERT_NE(nullptr, diagnostic);
   EXPECT_STREQ(
       "Expected <opcode> at the beginning of an instruction, found '%2'.",
       diagnostic->error);
@@ -71,7 +71,7 @@ TEST_F(TextToBinaryTest, EncodeCAFTextAsAAF) {
             spvTextWithFormatToBinary(
                 text.str, text.length, SPV_ASSEMBLY_SYNTAX_FORMAT_ASSIGNMENT,
                 opcodeTable, operandTable, extInstTable, &binary, &diagnostic));
-  ASSERT_TRUE(diagnostic);
+  ASSERT_NE(nullptr, diagnostic);
   EXPECT_STREQ(
       "Expected <result-id> at the beginning of an instruction, found "
       "'OpConstant'.",
@@ -85,7 +85,7 @@ TEST_F(TextToBinaryTest, EncodeMixedTextAsAAF) {
             spvTextWithFormatToBinary(
                 text.str, text.length, SPV_ASSEMBLY_SYNTAX_FORMAT_ASSIGNMENT,
                 opcodeTable, operandTable, extInstTable, &binary, &diagnostic));
-  ASSERT_TRUE(diagnostic);
+  ASSERT_NE(nullptr, diagnostic);
   EXPECT_STREQ(
       "Expected <result-id> at the beginning of an instruction, found "
       "'OpConstant'.",
@@ -99,7 +99,7 @@ TEST_F(TextToBinaryTest, EncodeMixedTextAsCAF) {
             spvTextWithFormatToBinary(
                 text.str, text.length, SPV_ASSEMBLY_SYNTAX_FORMAT_CANONICAL,
                 opcodeTable, operandTable, extInstTable, &binary, &diagnostic));
-  ASSERT_TRUE(diagnostic);
+  ASSERT_NE(nullptr, diagnostic);
   EXPECT_STREQ(
       "Expected <opcode> at the beginning of an instruction, found '%3'.",
       diagnostic->error);
old mode 100644 (file)
new mode 100755 (executable)
index 1cf4eaa..6fc9df3
@@ -70,10 +70,10 @@ TEST(OperandPattern, PopFrontsAreOnTheLeft) {
 
 // A test case for typed mask expansion
 struct MaskExpansionCase {
-  const spv_operand_type_t type;
-  const uint32_t mask;
-  const spv_operand_pattern_t initial;
-  const spv_operand_pattern_t expected;
+  spv_operand_type_t type;
+  uint32_t mask;
+  spv_operand_pattern_t initial;
+  spv_operand_pattern_t expected;
 };
 
 using MaskExpansionTest = ::testing::TestWithParam<MaskExpansionCase>;
old mode 100644 (file)
new mode 100755 (executable)
index 088ffb0..4114c37
@@ -39,7 +39,7 @@ TEST(TextLiteral, GoodI32) {
 
   ASSERT_EQ(SPV_SUCCESS, spvTextToLiteral("-2147483648", &l));
   EXPECT_EQ(SPV_LITERAL_TYPE_INT_32, l.type);
-  EXPECT_EQ(-2147483648, l.value.i32);
+  EXPECT_EQ((-2147483647L - 1), l.value.i32);
 }
 
 TEST(TextLiteral, GoodU32) {
@@ -59,7 +59,7 @@ TEST(TextLiteral, GoodI64) {
 
   ASSERT_EQ(SPV_SUCCESS, spvTextToLiteral("-2147483649", &l));
   EXPECT_EQ(SPV_LITERAL_TYPE_INT_64, l.type);
-  EXPECT_EQ(-2147483649, l.value.i64);
+  EXPECT_EQ(-2147483649LL, l.value.i64);
 }
 
 TEST(TextLiteral, GoodU64) {
old mode 100644 (file)
new mode 100755 (executable)
index 4e3de7c..8590451
@@ -60,14 +60,14 @@ TEST(TextStartsWithOp, NoRegular) {
 TEST(TextStartsWithOp, YesForValueGenerationForm) {
   spv_position_t startPosition = {};
   EXPECT_TRUE(
-      spvTextIsStartOfNewInst(AutoText("\%foo = OpAdd"), &startPosition));
+      spvTextIsStartOfNewInst(AutoText("%foo = OpAdd"), &startPosition));
   EXPECT_TRUE(
-      spvTextIsStartOfNewInst(AutoText("\%foo  =  OpAdd"), &startPosition));
+      spvTextIsStartOfNewInst(AutoText("%foo  =  OpAdd"), &startPosition));
 }
 
 TEST(TextStartsWithOp, NoForNearlyValueGeneration) {
   spv_position_t startPosition = {};
-  EXPECT_FALSE(spvTextIsStartOfNewInst(AutoText("\%foo = "), &startPosition));
-  EXPECT_FALSE(spvTextIsStartOfNewInst(AutoText("\%foo "), &startPosition));
-  EXPECT_FALSE(spvTextIsStartOfNewInst(AutoText("\%foo"), &startPosition));
+  EXPECT_FALSE(spvTextIsStartOfNewInst(AutoText("%foo = "), &startPosition));
+  EXPECT_FALSE(spvTextIsStartOfNewInst(AutoText("%foo "), &startPosition));
+  EXPECT_FALSE(spvTextIsStartOfNewInst(AutoText("%foo"), &startPosition));
 }
old mode 100644 (file)
new mode 100755 (executable)
index 554dcb8..0ab5c1b
@@ -49,9 +49,9 @@ using test_fixture::TextToBinaryTest;
 struct DecorateSimpleCase {
   // Place the enum value first, so it's easier to read the binary dumps when
   // the test fails.
-  const spv::Decoration decoration;
-  const std::string name;
-  const std::vector<uint32_t> operands;
+  spv::Decoration decoration;
+  std::string name;
+  std::vector<uint32_t> operands;
 };
 
 using OpDecorateSimpleTest =
@@ -118,10 +118,10 @@ INSTANTIATE_TEST_CASE_P(TextToBinaryDecorateSimple, OpDecorateSimpleTest,
 struct DecorateEnumCase {
   // Place the enum value first, so it's easier to read the binary dumps when
   // the test fails.
-  const uint32_t value;  // The value within the enum, e.g. Position
-  const std::string name;
-  const uint32_t enum_value;  // Which enum, e.g. BuiltIn
-  const std::string enum_name;
+  uint32_t value;  // The value within the enum, e.g. Position
+  std::string name;
+  uint32_t enum_value;  // Which enum, e.g. BuiltIn
+  std::string enum_name;
 };
 
 using OpDecorateEnumTest = test_fixture::TextToBinaryTestBase<
@@ -254,9 +254,9 @@ TEST_F(TextToBinaryTest, CombinedFPFastMathMask) {
 
 // A single test case for a linkage
 struct DecorateLinkageCase {
-  const uint32_t linkage_type_value;
-  const std::string linkage_type_name;
-  const std::string external_name;
+  uint32_t linkage_type_value;
+  std::string linkage_type_name;
+  std::string external_name;
 };
 
 using OpDecorateLinkageTest = test_fixture::TextToBinaryTestBase<
old mode 100644 (file)
new mode 100755 (executable)
index 804de7b..70b7f91
@@ -37,13 +37,6 @@ namespace {
 using spvtest::MakeInstruction;
 using ::testing::Eq;
 
-// An example case for an enumerated value.
-template <typename E>
-struct EnumCase {
-  E value;
-  std::string name;
-};
-
 // Test Sampler Addressing Mode enum values
 
 using SamplerAddressingModeTest = test_fixture::TextToBinaryTestBase<
@@ -54,7 +47,7 @@ TEST_P(SamplerAddressingModeTest, AnySamplerAddressingMode) {
       "%result = OpConstantSampler %type " + GetParam().name + " 0 Nearest";
   EXPECT_THAT(CompiledInstructions(input),
               Eq(MakeInstruction(spv::OpConstantSampler,
-                                 {1, 2, GetParam().value, 0, 0})));
+                                 {1, 2, GetParam().get_value(), 0, 0})));
 }
 
 // clang-format off
@@ -81,7 +74,7 @@ TEST_P(SamplerFilterModeTest, AnySamplerFilterMode) {
       "%result = OpConstantSampler %type Clamp 0 " + GetParam().name;
   EXPECT_THAT(CompiledInstructions(input),
               Eq(MakeInstruction(spv::OpConstantSampler,
-                                 {1, 2, 2, 0, GetParam().value})));
+                                 {1, 2, 2, 0, GetParam().get_value()})));
 }
 
 // clang-format off
old mode 100644 (file)
new mode 100755 (executable)
index 4ff33b7..06d817e
@@ -38,13 +38,6 @@ using spvtest::MakeInstruction;
 using ::testing::Eq;
 using test_fixture::TextToBinaryTest;
 
-// An example case for an enumerated value.
-template <typename E>
-struct EnumCase {
-  E value;
-  std::string name;
-};
-
 // Test OpSelectionMerge
 
 using OpSelectionMergeTest = test_fixture::TextToBinaryTestBase<
@@ -54,7 +47,7 @@ TEST_P(OpSelectionMergeTest, AnySingleSelectionControlMask) {
   std::string input = "OpSelectionMerge %1 " + GetParam().name;
   EXPECT_THAT(
       CompiledInstructions(input),
-      Eq(MakeInstruction(spv::OpSelectionMerge, {1, GetParam().value})));
+      Eq(MakeInstruction(spv::OpSelectionMerge, {1, GetParam().get_value()})));
 }
 
 // clang-format off
@@ -83,8 +76,9 @@ using OpLoopMergeTest = test_fixture::TextToBinaryTestBase<
 
 TEST_P(OpLoopMergeTest, AnySingleLoopControlMask) {
   std::string input = "OpLoopMerge %1 " + GetParam().name;
-  EXPECT_THAT(CompiledInstructions(input),
-              Eq(MakeInstruction(spv::OpLoopMerge, {1, GetParam().value})));
+  EXPECT_THAT(
+      CompiledInstructions(input),
+      Eq(MakeInstruction(spv::OpLoopMerge, {1, GetParam().get_value()})));
 }
 
 // clang-format off
old mode 100644 (file)
new mode 100755 (executable)
index 3a1aad4..11f8260
@@ -44,9 +44,12 @@ using ::testing::Eq;
 
 // A single test case for OpSource
 struct LanguageCase {
-  const char* language_name;
-  const spv::SourceLanguage language_value;
-  const uint32_t version;
+  uint32_t get_language_value() const {
+    return static_cast<uint32_t>(language_value);
+  }
+  char* language_name;
+  spv::SourceLanguage language_value;
+  uint32_t version;
 };
 
 // clang-format off
@@ -70,7 +73,7 @@ TEST_P(OpSourceTest, AnyLanguage) {
   std::string input = std::string("OpSource ") + GetParam().language_name +
                       " " + std::to_string(GetParam().version);
   EXPECT_THAT(CompiledInstructions(input),
-              Eq(MakeInstruction(spv::OpSource, {GetParam().language_value,
+              Eq(MakeInstruction(spv::OpSource, {GetParam().get_language_value(),
                                                  GetParam().version})));
 }
 
old mode 100644 (file)
new mode 100755 (executable)
index cebbf19..39e8a1c
@@ -38,13 +38,6 @@ using spvtest::MakeInstruction;
 using ::testing::Eq;
 using test_fixture::TextToBinaryTest;;
 
-// An example case for an enumerated value.
-template <typename E>
-struct EnumCase {
-  E value;
-  std::string name;
-};
-
 // Test OpFunction
 
 using OpFunctionControlTest = test_fixture::TextToBinaryTestBase<
@@ -55,7 +48,7 @@ TEST_P(OpFunctionControlTest, AnySingleFunctionControlMask) {
                       GetParam().name + " %function_type ";
   EXPECT_THAT(
       CompiledInstructions(input),
-      Eq(MakeInstruction(spv::OpFunction, {1, 2, GetParam().value, 3})));
+      Eq(MakeInstruction(spv::OpFunction, {1, 2, GetParam().get_value(), 3})));
 }
 
 // clang-format off
old mode 100644 (file)
new mode 100755 (executable)
index 259ed2b..dc0d214
@@ -37,25 +37,17 @@ namespace {
 using spvtest::MakeInstruction;
 using ::testing::Eq;
 
-// An example case for an enumerated value.
-template <typename E>
-struct EnumCase {
-  E value;
-  std::string name;
-};
-
 // Test GroupOperation enum
 
-using GroupOperationTest =
-    test_fixture::TextToBinaryTestBase <
+using GroupOperationTest = test_fixture::TextToBinaryTestBase<
     ::testing::TestWithParam<EnumCase<spv::GroupOperation>>>;
 
 TEST_P(GroupOperationTest, AnyGroupOperation) {
   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().get_value(), 4})));
 }
 
 // clang-format off
old mode 100644 (file)
new mode 100755 (executable)
index c09a998..dbb4725
@@ -43,6 +43,7 @@ using test_fixture::TextToBinaryTest;
 // An example case for an enumerated value.
 template <typename E>
 struct EnumCaseWithOperands {
+  uint32_t get_value() const { return static_cast<uint32_t>(value); }
   E value;
   std::string name;
   std::vector<uint32_t> operands;
@@ -57,7 +58,7 @@ TEST_P(MemoryAccessTest, AnySingleMemoryAccessMask) {
   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};
+  std::vector<uint32_t> expected_operands{1, 2, GetParam().get_value()};
   expected_operands.insert(expected_operands.end(), GetParam().operands.begin(),
                            GetParam().operands.end());
   EXPECT_THAT(CompiledInstructions(input.str()),
@@ -91,7 +92,7 @@ using StorageClassTest = test_fixture::TextToBinaryTestBase<
 TEST_P(StorageClassTest, AnyStorageClass) {
   std::string input = "%1 = OpVariable %2 " + GetParam().name;
   EXPECT_THAT(CompiledInstructions(input),
-              Eq(MakeInstruction(spv::OpVariable, {2, 1, GetParam().value})));
+              Eq(MakeInstruction(spv::OpVariable, {2, 1, GetParam().get_value()})));
 }
 
 // clang-format off
old mode 100644 (file)
new mode 100755 (executable)
index 803e3c2..2bad4c5
@@ -42,6 +42,12 @@ using ::testing::Eq;
 
 // An example case for OpMemoryModel
 struct MemoryModelCase {
+  uint32_t get_addressing_value() const {
+    return static_cast<uint32_t>(addressing_value);
+  }
+  uint32_t get_memory_value() const {
+    return static_cast<uint32_t>(memory_value);
+  }
   spv::AddressingModel addressing_value;
   std::string addressing_name;
   spv::MemoryModel memory_value;
@@ -56,8 +62,8 @@ TEST_P(OpMemoryModelTest, AnyMemoryModelCase) {
                       GetParam().memory_name;
   EXPECT_THAT(
       CompiledInstructions(input),
-      Eq(MakeInstruction(spv::OpMemoryModel, {GetParam().addressing_value,
-                                              GetParam().memory_value})));
+      Eq(MakeInstruction(spv::OpMemoryModel, {GetParam().get_addressing_value(),
+                                              GetParam().get_memory_value()})));
 }
 
 #define CASE(ADDRESSING, MEMORY)                                             \
@@ -83,6 +89,9 @@ INSTANTIATE_TEST_CASE_P(TextToBinaryMemoryModel, OpMemoryModelTest,
 
 // An example case for OpEntryPoint
 struct EntryPointCase {
+  uint32_t get_execution_value() const {
+    return static_cast<uint32_t>(execution_value);
+  }
   spv::ExecutionModel execution_value;
   std::string execution_name;
   std::string entry_point_name;
@@ -93,9 +102,9 @@ using OpEntryPointTest = test_fixture::TextToBinaryTestBase<
 
 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 + "\"";
-  std::vector<uint32_t> expected_operands{GetParam().execution_value, 1};
+  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(),
@@ -125,9 +134,10 @@ INSTANTIATE_TEST_CASE_P(TextToBinaryEntryPoint, OpEntryPointTest,
 // A single test case for a simple OpExecutionMode.
 // An execution mode has no operands, or just literal numbers as operands.
 struct ExecutionModeCase {
-  const spv::ExecutionMode mode_value;
-  const std::string mode_name;
-  const std::vector<uint32_t> operands;
+  uint32_t get_mode_value() const { return static_cast<uint32_t>(mode_value); }
+  spv::ExecutionMode mode_value;
+  std::string mode_name;
+  std::vector<uint32_t> operands;
 };
 
 using OpExecutionModeTest = test_fixture::TextToBinaryTestBase<
@@ -138,7 +148,7 @@ TEST_P(OpExecutionModeTest, AnyExecutionMode) {
   std::stringstream input;
   input << "OpExecutionMode %1 " << GetParam().mode_name;
   for (auto operand : GetParam().operands) input << " " << operand;
-  std::vector<uint32_t> expected_operands{1, GetParam().mode_value};
+  std::vector<uint32_t> expected_operands{1, GetParam().get_mode_value()};
   expected_operands.insert(expected_operands.end(), GetParam().operands.begin(),
                            GetParam().operands.end());
   EXPECT_THAT(CompiledInstructions(input.str()),
@@ -189,24 +199,19 @@ INSTANTIATE_TEST_CASE_P(TextToBinaryExecutionMode, OpExecutionModeTest,
 
 // Test OpCapability
 
-struct CapabilityCase {
-  spv::Capability value;
-  std::string name;
-};
-
 using OpCapabilityTest = test_fixture::TextToBinaryTestBase<
-    ::testing::TestWithParam<CapabilityCase>>;
+    ::testing::TestWithParam<EnumCase<spv::Capability>>>;
 
 TEST_P(OpCapabilityTest, AnyCapability) {
   std::string input = "OpCapability " + GetParam().name;
   EXPECT_THAT(CompiledInstructions(input),
-              Eq(MakeInstruction(spv::OpCapability, {GetParam().value})));
+              Eq(MakeInstruction(spv::OpCapability, {GetParam().get_value()})));
 }
 
 // clang-format off
 #define CASE(NAME) { spv::Capability##NAME, #NAME }
 INSTANTIATE_TEST_CASE_P(TextToBinaryCapability, OpCapabilityTest,
-                        ::testing::ValuesIn(std::vector<CapabilityCase>{
+                        ::testing::ValuesIn(std::vector<EnumCase<spv::Capability>>{
                             CASE(Matrix),
                             CASE(Shader),
                             CASE(Geometry),
old mode 100644 (file)
new mode 100755 (executable)
index bd111a1..9648218
@@ -37,13 +37,6 @@ namespace {
 using spvtest::MakeInstruction;
 using ::testing::Eq;
 
-// An example case for an enumerated value.
-template <typename E>
-struct EnumCase {
-  const E value;
-  const std::string name;
-};
-
 // Test Dim enums via OpTypeImage
 
 using DimTest = test_fixture::TextToBinaryTestBase<
@@ -54,7 +47,7 @@ TEST_P(DimTest, AnyDim) {
                       GetParam().name + " 2 3 0 4 Rgba8";
   EXPECT_THAT(
       CompiledInstructions(input),
-      Eq(MakeInstruction(spv::OpTypeImage, {1, 2, GetParam().value, 2, 3, 0, 4,
+      Eq(MakeInstruction(spv::OpTypeImage, {1, 2, GetParam().get_value(), 2, 3, 0, 4,
                                             spv::ImageFormatRgba8})));
 }
 
@@ -84,7 +77,7 @@ TEST_P(ImageFormatTest, AnyImageFormat) {
       "%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,
-                                                    4, GetParam().value})));
+                                                    4, GetParam().get_value()})));
 }
 
 // clang-format off
@@ -146,8 +139,9 @@ TEST_P(OpTypePipeTest, AnyAccessQualifier) {
   // TODO(dneto): In Rev31 and later, pipes are opaque, and so the %2, which
   // is the type-of-element operand, should be dropped.
   std::string input = "%1 = OpTypePipe %2 " + GetParam().name;
-  EXPECT_THAT(CompiledInstructions(input),
-              Eq(MakeInstruction(spv::OpTypePipe, {1, 2, GetParam().value})));
+  EXPECT_THAT(
+      CompiledInstructions(input),
+      Eq(MakeInstruction(spv::OpTypePipe, {1, 2, GetParam().get_value()})));
 }
 
 // clang-format off
@@ -155,10 +149,10 @@ TEST_P(OpTypePipeTest, AnyAccessQualifier) {
 INSTANTIATE_TEST_CASE_P(
     TextToBinaryTypePipe, OpTypePipeTest,
     ::testing::ValuesIn(std::vector<EnumCase<spv::AccessQualifier>>{
-        CASE(ReadOnly),
-        CASE(WriteOnly),
-        CASE(ReadWrite),
-    }));
+                            CASE(ReadOnly),
+                            CASE(WriteOnly),
+                            CASE(ReadWrite),
+                        }));
 #undef CASE
 // clang-format on
 
old mode 100644 (file)
new mode 100755 (executable)
index 5e96b1d..9e469b5
@@ -53,9 +53,9 @@ TEST(GetWord, Simple) {
 
 // An mask parsing test case.
 struct MaskCase {
-  const spv_operand_type_t which_enum;
-  const uint32_t expected_value;
-  const char* expression;
+  spv_operand_type_t which_enum;
+  uint32_t expected_value;
+  char* expression;
 };
 
 using GoodMaskParseTest = ::testing::TestWithParam<MaskCase>;
@@ -428,7 +428,7 @@ TEST_F(TextToBinaryTest, GoodSwitch) {
 )");
 
   // Minimal check: The OpSwitch opcode word is correct.
-  EXPECT_EQ(int(spv::OpSwitch) || (7 << 16), code[14]);
+  EXPECT_EQ((int(spv::OpSwitch) | (7 << 16)), code[14 + SPV_INDEX_INSTRUCTION]);
 }
 
 TEST_F(TextToBinaryTest, GoodSwitchZeroCasesOneDefault) {
@@ -441,7 +441,7 @@ TEST_F(TextToBinaryTest, GoodSwitchZeroCasesOneDefault) {
 )");
 
   // Minimal check: The OpSwitch opcode word is correct.
-  EXPECT_EQ(int(spv::OpSwitch) || (3 << 16), code[10]);
+  EXPECT_EQ((int(spv::OpSwitch) | (3 << 16)), code[10 + SPV_INDEX_INSTRUCTION]);
 }
 
 TEST_F(TextToBinaryTest, BadSwitchTruncatedCase) {
old mode 100644 (file)
new mode 100755 (executable)
index 674d26e..04ee974
@@ -150,6 +150,14 @@ struct AutoText {
   spv_text_t text;
 };
 
+// An example case for an enumerated value.
+template <typename E>
+struct EnumCase {
+  uint32_t get_value() const { return static_cast<uint32_t>(value); }
+  E value;
+  std::string name;
+};
+
 #define I32_ENDIAN_HOST (o32_host_order.value)
 
 #endif