From 73d7082245bc2920f3be0ffc573d44294589b45e Mon Sep 17 00:00:00 2001 From: Dejan Mircevski Date: Mon, 31 Aug 2015 15:24:32 -0400 Subject: [PATCH] Put test classes in anonymous namespace. Put TestFixture.h classes in a namespace. Remove unused #includes. --- test/BinaryEndianness.cpp | 4 ++++ test/BinaryHeaderGet.cpp | 4 ++++ test/BinaryToText.cpp | 4 ++++ test/Comment.cpp | 6 ++++++ test/DiagnosticPrint.cpp | 4 ++++ test/ExtInstGLSLstd450.cpp | 8 ++++++-- test/FixWord.cpp | 4 ++++ test/LibspirvMacros.cpp | 4 ++++ test/NamedId.cpp | 4 ++++ test/OpcodeIsVariable.cpp | 4 ++++ test/OpcodeMake.cpp | 4 ++++ test/OpcodeRequiresCapabilities.cpp | 4 ++++ test/OpcodeSplit.cpp | 4 ++++ test/OpcodeTableGet.cpp | 4 ++++ test/OperandTableGet.cpp | 4 ++++ test/TestFixture.h | 6 +++++- test/TextAdvance.cpp | 4 ++++ test/TextDestroy.cpp | 4 ++++ test/TextLiteral.cpp | 4 ++++ test/TextToBinary.cpp | 6 ++++++ test/TextWordGet.cpp | 4 ++++ test/Validate.cpp | 4 ++++ test/ValidateID.cpp | 4 ++++ 23 files changed, 99 insertions(+), 3 deletions(-) diff --git a/test/BinaryEndianness.cpp b/test/BinaryEndianness.cpp index 64da851..484f248 100644 --- a/test/BinaryEndianness.cpp +++ b/test/BinaryEndianness.cpp @@ -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 diff --git a/test/BinaryHeaderGet.cpp b/test/BinaryHeaderGet.cpp index 0cab66b..5016d68 100644 --- a/test/BinaryHeaderGet.cpp +++ b/test/BinaryHeaderGet.cpp @@ -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 diff --git a/test/BinaryToText.cpp b/test/BinaryToText.cpp index 2a7af87..94f135c 100644 --- a/test/BinaryToText.cpp +++ b/test/BinaryToText.cpp @@ -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 diff --git a/test/Comment.cpp b/test/Comment.cpp index c323023..401f2fa 100644 --- a/test/Comment.cpp +++ b/test/Comment.cpp @@ -27,6 +27,10 @@ #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 diff --git a/test/DiagnosticPrint.cpp b/test/DiagnosticPrint.cpp index bcbe6c2..9fe2792 100644 --- a/test/DiagnosticPrint.cpp +++ b/test/DiagnosticPrint.cpp @@ -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 diff --git a/test/ExtInstGLSLstd450.cpp b/test/ExtInstGLSLstd450.cpp index 31cb4f6..9cdc228 100644 --- a/test/ExtInstGLSLstd450.cpp +++ b/test/ExtInstGLSLstd450.cpp @@ -24,11 +24,13 @@ // 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 #include +#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 diff --git a/test/FixWord.cpp b/test/FixWord.cpp index 500ca64..e3ed4cc 100644 --- a/test/FixWord.cpp +++ b/test/FixWord.cpp @@ -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 diff --git a/test/LibspirvMacros.cpp b/test/LibspirvMacros.cpp index ebbded6..7c322ba 100644 --- a/test/LibspirvMacros.cpp +++ b/test/LibspirvMacros.cpp @@ -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 diff --git a/test/NamedId.cpp b/test/NamedId.cpp index 4a09799..12e6b01 100644 --- a/test/NamedId.cpp +++ b/test/NamedId.cpp @@ -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 diff --git a/test/OpcodeIsVariable.cpp b/test/OpcodeIsVariable.cpp index bb0b593..8e604e5 100644 --- a/test/OpcodeIsVariable.cpp +++ b/test/OpcodeIsVariable.cpp @@ -26,8 +26,12 @@ #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 diff --git a/test/OpcodeMake.cpp b/test/OpcodeMake.cpp index 755dd1a..35cef98 100644 --- a/test/OpcodeMake.cpp +++ b/test/OpcodeMake.cpp @@ -28,6 +28,8 @@ #include +namespace { + TEST(OpcodeMake, DISABLED_Default) { for (uint16_t wordCount = 0; wordCount < std::numeric_limits::max(); ++wordCount) { @@ -40,3 +42,5 @@ TEST(OpcodeMake, DISABLED_Default) { } } } + +} // anonymous namespace diff --git a/test/OpcodeRequiresCapabilities.cpp b/test/OpcodeRequiresCapabilities.cpp index be808f3..806d276 100644 --- a/test/OpcodeRequiresCapabilities.cpp +++ b/test/OpcodeRequiresCapabilities.cpp @@ -26,6 +26,8 @@ #include "UnitSPIRV.h" +namespace { + class Requires : public ::testing::TestWithParam { 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 diff --git a/test/OpcodeSplit.cpp b/test/OpcodeSplit.cpp index 1428232..4d4f279 100644 --- a/test/OpcodeSplit.cpp +++ b/test/OpcodeSplit.cpp @@ -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 diff --git a/test/OpcodeTableGet.cpp b/test/OpcodeTableGet.cpp index 99eab3d..03ffd4d 100644 --- a/test/OpcodeTableGet.cpp +++ b/test/OpcodeTableGet.cpp @@ -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 diff --git a/test/OperandTableGet.cpp b/test/OperandTableGet.cpp index b7c7bd5..f718e44 100644 --- a/test/OperandTableGet.cpp +++ b/test/OperandTableGet.cpp @@ -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 diff --git a/test/TestFixture.h b/test/TestFixture.h index d3ac4eb..5d7955f 100644 --- a/test/TestFixture.h +++ b/test/TestFixture.h @@ -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 @@ -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_ diff --git a/test/TextAdvance.cpp b/test/TextAdvance.cpp index 423ef9f..880b0f2 100644 --- a/test/TextAdvance.cpp +++ b/test/TextAdvance.cpp @@ -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 diff --git a/test/TextDestroy.cpp b/test/TextDestroy.cpp index 228879a..0494c32 100644 --- a/test/TextDestroy.cpp +++ b/test/TextDestroy.cpp @@ -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 diff --git a/test/TextLiteral.cpp b/test/TextLiteral.cpp index 75efbb0..088ffb0 100644 --- a/test/TextLiteral.cpp +++ b/test/TextLiteral.cpp @@ -28,6 +28,8 @@ #include +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 diff --git a/test/TextToBinary.cpp b/test/TextToBinary.cpp index 73c91e9..91e79f1 100644 --- a/test/TextToBinary.cpp +++ b/test/TextToBinary.cpp @@ -31,6 +31,10 @@ #include #include +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 diff --git a/test/TextWordGet.cpp b/test/TextWordGet.cpp index 133703a..8c5118d 100644 --- a/test/TextWordGet.cpp +++ b/test/TextWordGet.cpp @@ -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 diff --git a/test/Validate.cpp b/test/Validate.cpp index 351bb50..bd2bbaa 100644 --- a/test/Validate.cpp +++ b/test/Validate.cpp @@ -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 diff --git a/test/ValidateID.cpp b/test/ValidateID.cpp index 9ae66c1..b0ca2a5 100644 --- a/test/ValidateID.cpp +++ b/test/ValidateID.cpp @@ -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 -- 2.7.4