Put test classes in anonymous namespace.
authorDejan Mircevski <deki@google.com>
Mon, 31 Aug 2015 19:24:32 +0000 (15:24 -0400)
committerDavid Neto <dneto@google.com>
Mon, 26 Oct 2015 16:52:01 +0000 (12:52 -0400)
Put TestFixture.h classes in a namespace.

Remove unused #includes.

23 files changed:
test/BinaryEndianness.cpp
test/BinaryHeaderGet.cpp
test/BinaryToText.cpp
test/Comment.cpp
test/DiagnosticPrint.cpp
test/ExtInstGLSLstd450.cpp
test/FixWord.cpp
test/LibspirvMacros.cpp
test/NamedId.cpp
test/OpcodeIsVariable.cpp
test/OpcodeMake.cpp
test/OpcodeRequiresCapabilities.cpp
test/OpcodeSplit.cpp
test/OpcodeTableGet.cpp
test/OperandTableGet.cpp
test/TestFixture.h
test/TextAdvance.cpp
test/TextDestroy.cpp
test/TextLiteral.cpp
test/TextToBinary.cpp
test/TextWordGet.cpp
test/Validate.cpp
test/ValidateID.cpp

index 64da851..484f248 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "UnitSPIRV.h"
 
+namespace {
+
 TEST(BinaryEndianness, InvalidCode) {
   uint32_t invalidMagicNumber[] = {0};
   spv_binary_t binary = {invalidMagicNumber, 1};
@@ -58,3 +60,5 @@ TEST(BinaryEndianness, Big) {
   ASSERT_EQ(SPV_SUCCESS, spvBinaryEndianness(&binary, &endian));
   ASSERT_EQ(SPV_ENDIANNESS_BIG, endian);
 }
+
+}  // anonymous namespace
index 0cab66b..5016d68 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "UnitSPIRV.h"
 
+namespace {
+
 class BinaryHeaderGet : public ::testing::Test {
  public:
   BinaryHeaderGet() { memset(code, 0, sizeof(code)); }
@@ -74,3 +76,5 @@ TEST_F(BinaryHeaderGet, InvalidPointerHeader) {
   ASSERT_EQ(SPV_ERROR_INVALID_POINTER,
             spvBinaryHeaderGet(&binary, SPV_ENDIANNESS_LITTLE, nullptr));
 }
+
+}  // anonymous namespace
index 2a7af87..94f135c 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "UnitSPIRV.h"
 
+namespace {
+
 class BinaryToText : public ::testing::Test {
  public:
   BinaryToText() : binary(), opcodeTable(nullptr), operandTable(nullptr) {}
@@ -123,3 +125,5 @@ TEST_F(BinaryToText, InvalidDiagnostic) {
             spvBinaryToText(binary, SPV_BINARY_TO_TEXT_OPTION_NONE, opcodeTable,
                             operandTable, extInstTable, &text, nullptr));
 }
+
+}  // anonymous namespace
index c323023..401f2fa 100644 (file)
 #include "TestFixture.h"
 #include "UnitSPIRV.h"
 
+namespace {
+
+using  test_fixture::TextToBinaryTest;
+
 TEST_F(TextToBinaryTest, Whitespace) {
   SetText(R"(
 ; I'm a proud comment at the begining of the file
@@ -45,3 +49,5 @@ TEST_F(TextToBinaryTest, Whitespace) {
     spvDiagnosticPrint(diagnostic);
   }
 }
+
+}  // anonymous namespace
index bcbe6c2..9fe2792 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "UnitSPIRV.h"
 
+namespace {
+
 TEST(DiagnosticPrint, Default) {
   char message[] = "Test Diagnostic!";
   spv_diagnostic_t diagnostic = {{2, 3, 5}, message};
@@ -38,3 +40,5 @@ TEST(DiagnosticPrint, Default) {
 TEST(DiagnosticPrint, InvalidDiagnostic) {
   ASSERT_EQ(SPV_ERROR_INVALID_DIAGNOSTIC, spvDiagnosticPrint(nullptr));
 }
+
+}  // anonymous namespace
index 31cb4f6..9cdc228 100644 (file)
 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 // MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
 
-#include "TestFixture.h"
-#include "UnitSPIRV.h"
 #include <algorithm>
 #include <vector>
 
+#include "UnitSPIRV.h"
+
+namespace {
+
 /// Context for an extended instruction.
 ///
 /// Information about a GLSL extended instruction (including its opname, return
@@ -222,3 +224,5 @@ INSTANTIATE_TEST_CASE_P(
         {kU32Type, kI32Const, "%4", "UmulExtended", "%5 %5 %5 %5", 80, 9, {5, 5, 5, 5}},
         // clang-format on
     })));
+
+}  // anonymous namespace
index 500ca64..e3ed4cc 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "UnitSPIRV.h"
 
+namespace {
+
 TEST(FixWord, Default) {
   spv_endianness_t endian;
   if (I32_ENDIAN_HOST == I32_ENDIAN_LITTLE) {
@@ -48,3 +50,5 @@ TEST(FixWord, Reorder) {
   uint32_t result = 0x21097853;
   ASSERT_EQ(result, spvFixWord(word, endian));
 }
+
+}  // anonymous namespace
index ebbded6..7c322ba 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "UnitSPIRV.h"
 
+namespace {
+
 TEST(Macros, BitShiftInnerParens) {
   ASSERT_EQ(65536, SPV_BIT(2 << 3));
 }
@@ -33,3 +35,5 @@ TEST(Macros, BitShiftInnerParens) {
 TEST(Macros, BitShiftOuterParens) {
   ASSERT_EQ(15, SPV_BIT(4)-1);
 }
+
+}  // anonymous namespace
index 4a09799..12e6b01 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "UnitSPIRV.h"
 
+namespace {
+
 TEST(NamedId, Default) {
   const char *spirv = R"(
           OpCapability Shader
@@ -67,3 +69,5 @@ TEST(NamedId, Default) {
   }
   spvBinaryDestroy(binary);
 }
+
+}  // anonymous namespace
index bb0b593..8e604e5 100644 (file)
 
 #include "UnitSPIRV.h"
 
+namespace {
+
 TEST(OpcodeIsVariable, Default) {
   spv_opcode_desc_t entry = {
       nullptr, 0, (Op)0, SPV_OPCODE_FLAGS_VARIABLE, 0, {}};
   ASSERT_NE(0, spvOpcodeIsVariable(&entry));
 }
+
+}  // anonymous namespace
index 755dd1a..35cef98 100644 (file)
@@ -28,6 +28,8 @@
 
 #include <limits>
 
+namespace {
+
 TEST(OpcodeMake, DISABLED_Default) {
   for (uint16_t wordCount = 0; wordCount < std::numeric_limits<uint16_t>::max();
        ++wordCount) {
@@ -40,3 +42,5 @@ TEST(OpcodeMake, DISABLED_Default) {
     }
   }
 }
+
+}  // anonymous namespace
index be808f3..806d276 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "UnitSPIRV.h"
 
+namespace {
+
 class Requires : public ::testing::TestWithParam<Capability> {
  public:
   Requires()
@@ -58,3 +60,5 @@ TEST(OpcodeRequiresCapabilityaspvities, None) {
   spv_opcode_desc_t entry = {nullptr, 0, (Op)0, SPV_OPCODE_FLAGS_NONE, 0, {}};
   ASSERT_EQ(0, spvOpcodeRequiresCapabilities(&entry));
 }
+
+}  // anonymous namespace
index 1428232..4d4f279 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "UnitSPIRV.h"
 
+namespace {
+
 TEST(OpcodeSplit, Default) {
   uint32_t word = spvOpcodeMake(42, (Op)23);
   uint16_t wordCount = 0;
@@ -34,3 +36,5 @@ TEST(OpcodeSplit, Default) {
   ASSERT_EQ(42, wordCount);
   ASSERT_EQ(23, opcode);
 }
+
+}  // anonymous namespace
index 99eab3d..03ffd4d 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "UnitSPIRV.h"
 
+namespace {
+
 TEST(OpcodeTableGet, Default) {
   spv_opcode_table table;
   ASSERT_EQ(SPV_SUCCESS, spvOpcodeTableGet(&table));
@@ -36,3 +38,5 @@ TEST(OpcodeTableGet, Default) {
 TEST(OpcodeTableGet, InvalidPointerTable) {
   ASSERT_EQ(SPV_ERROR_INVALID_POINTER, spvOpcodeTableGet(nullptr));
 }
+
+}  // anonymous namespace
index b7c7bd5..f718e44 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "UnitSPIRV.h"
 
+namespace {
+
 TEST(OperandTableGet, Default) {
   spv_operand_table table;
   ASSERT_EQ(SPV_SUCCESS, spvOperandTableGet(&table));
@@ -36,3 +38,5 @@ TEST(OperandTableGet, Default) {
 TEST(OperandTableGet, InvalidPointerTable) {
   ASSERT_EQ(SPV_ERROR_INVALID_POINTER, spvOperandTableGet(nullptr));
 }
+
+}  // anonymous namespace
index d3ac4eb..5d7955f 100644 (file)
@@ -28,6 +28,8 @@
 
 #include "UnitSPIRV.h"
 
+namespace test_fixture {
+
 // Common setup for TextToBinary tests. SetText() should be called to populate
 // the actual test text.
 template<typename T>
@@ -68,6 +70,8 @@ class TextToBinaryTestBase : public T {
   spv_binary binary;
 };
 
-class TextToBinaryTest : public TextToBinaryTestBase<::testing::Test> {};
+using TextToBinaryTest = TextToBinaryTestBase<::testing::Test>;
+
+}  // namespace test_fixture
 
 #endif// _TEXT_FIXTURE_H_
index 423ef9f..880b0f2 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "UnitSPIRV.h"
 
+namespace {
+
 TEST(TextAdvance, LeadingNewLines) {
   char textStr[] = "\n\nWord";
   spv_text_t text = {textStr, strlen(textStr)};
@@ -89,3 +91,5 @@ TEST(TextAdvance, NullTerminator) {
   spv_position_t position = {};
   ASSERT_EQ(SPV_END_OF_STREAM, spvTextAdvance(&text, &position));
 }
+
+}  // anonymous namespace
index 228879a..0494c32 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "UnitSPIRV.h"
 
+namespace {
+
 TEST(TextDestroy, Default) {
   spv_opcode_table opcodeTable;
   ASSERT_EQ(SPV_SUCCESS, spvOpcodeTableGet(&opcodeTable));
@@ -83,3 +85,5 @@ TEST(TextDestroy, Default) {
   EXPECT_NE(0, text.length);
   spvTextDestroy(resultText);
 }
+
+}  // anonymous namespace
index 75efbb0..088ffb0 100644 (file)
@@ -28,6 +28,8 @@
 
 #include <string>
 
+namespace {
+
 TEST(TextLiteral, GoodI32) {
   spv_literal_t l;
 
@@ -140,3 +142,5 @@ TEST(TextLiteral, GoodLongString) {
   EXPECT_EQ(SPV_LITERAL_TYPE_STRING, l.type);
   EXPECT_STREQ(unquoted.data(), l.value.str);
 }
+
+}  // anonymous namespace
index 73c91e9..91e79f1 100644 (file)
 #include <utility>
 #include <vector>
 
+namespace {
+
+using  test_fixture::TextToBinaryTest;
+
 union char_word_t {
   char cs[4];
   uint32_t u;
@@ -384,3 +388,5 @@ TEST_F(TextToBinaryTest, WrongOpCode) {
   EXPECT_STREQ("Invalid Opcode prefix 'Wahahaha'.", diagnostic->error);
   if (binary) spvBinaryDestroy(binary);
 }
+
+}  // anonymous namespace
index 133703a..8c5118d 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "UnitSPIRV.h"
 
+namespace {
+
 TEST(TextWordGet, NullTerminator) {
   char textStr[] = "Word";
   spv_text_t text = {textStr, strlen(textStr)};
@@ -109,3 +111,5 @@ TEST(TextWordGet, MultipleWords) {
     }
   }
 }
+
+}  // anonymous namespace
index 351bb50..bd2bbaa 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "UnitSPIRV.h"
 
+namespace {
+
 class Validate : public ::testing::Test {
  public:
   Validate() : binary(), opcodeTable(nullptr), operandTable(nullptr) {}
@@ -117,3 +119,5 @@ OpFunctionEnd
   spvDiagnosticPrint(diagnostic);
   spvDiagnosticDestroy(diagnostic);
 }
+
+}  // anonymous namespace
index 9ae66c1..b0ca2a5 100644 (file)
@@ -32,6 +32,8 @@
 // in stages, ID validation is only one of these stages. All validation stages
 // are stand alone.
 
+namespace {
+
 class ValidateID : public ::testing::Test {
  public:
   ValidateID() : opcodeTable(nullptr), operandTable(nullptr), binary() {}
@@ -1340,3 +1342,5 @@ TEST_F(ValidateID, OpReturnValueBad) {
 // TODO: OpGroupReserveWritePipePackets
 // TODO: OpGroupCommitReadPipe
 // TODO: OpGroupCommitWritePipe
+
+}  // anonymous namespace