Put TestFixture.h classes in a namespace.
Remove unused #includes.
#include "UnitSPIRV.h"
+namespace {
+
TEST(BinaryEndianness, InvalidCode) {
uint32_t invalidMagicNumber[] = {0};
spv_binary_t binary = {invalidMagicNumber, 1};
ASSERT_EQ(SPV_SUCCESS, spvBinaryEndianness(&binary, &endian));
ASSERT_EQ(SPV_ENDIANNESS_BIG, endian);
}
+
+} // anonymous namespace
#include "UnitSPIRV.h"
+namespace {
+
class BinaryHeaderGet : public ::testing::Test {
public:
BinaryHeaderGet() { memset(code, 0, sizeof(code)); }
ASSERT_EQ(SPV_ERROR_INVALID_POINTER,
spvBinaryHeaderGet(&binary, SPV_ENDIANNESS_LITTLE, nullptr));
}
+
+} // anonymous namespace
#include "UnitSPIRV.h"
+namespace {
+
class BinaryToText : public ::testing::Test {
public:
BinaryToText() : binary(), opcodeTable(nullptr), operandTable(nullptr) {}
spvBinaryToText(binary, SPV_BINARY_TO_TEXT_OPTION_NONE, opcodeTable,
operandTable, extInstTable, &text, nullptr));
}
+
+} // anonymous namespace
#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
spvDiagnosticPrint(diagnostic);
}
}
+
+} // anonymous namespace
#include "UnitSPIRV.h"
+namespace {
+
TEST(DiagnosticPrint, Default) {
char message[] = "Test Diagnostic!";
spv_diagnostic_t diagnostic = {{2, 3, 5}, message};
TEST(DiagnosticPrint, InvalidDiagnostic) {
ASSERT_EQ(SPV_ERROR_INVALID_DIAGNOSTIC, spvDiagnosticPrint(nullptr));
}
+
+} // anonymous namespace
// 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
{kU32Type, kI32Const, "%4", "UmulExtended", "%5 %5 %5 %5", 80, 9, {5, 5, 5, 5}},
// clang-format on
})));
+
+} // anonymous namespace
#include "UnitSPIRV.h"
+namespace {
+
TEST(FixWord, Default) {
spv_endianness_t endian;
if (I32_ENDIAN_HOST == I32_ENDIAN_LITTLE) {
uint32_t result = 0x21097853;
ASSERT_EQ(result, spvFixWord(word, endian));
}
+
+} // anonymous namespace
#include "UnitSPIRV.h"
+namespace {
+
TEST(Macros, BitShiftInnerParens) {
ASSERT_EQ(65536, SPV_BIT(2 << 3));
}
TEST(Macros, BitShiftOuterParens) {
ASSERT_EQ(15, SPV_BIT(4)-1);
}
+
+} // anonymous namespace
#include "UnitSPIRV.h"
+namespace {
+
TEST(NamedId, Default) {
const char *spirv = R"(
OpCapability Shader
}
spvBinaryDestroy(binary);
}
+
+} // anonymous namespace
#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
#include <limits>
+namespace {
+
TEST(OpcodeMake, DISABLED_Default) {
for (uint16_t wordCount = 0; wordCount < std::numeric_limits<uint16_t>::max();
++wordCount) {
}
}
}
+
+} // anonymous namespace
#include "UnitSPIRV.h"
+namespace {
+
class Requires : public ::testing::TestWithParam<Capability> {
public:
Requires()
spv_opcode_desc_t entry = {nullptr, 0, (Op)0, SPV_OPCODE_FLAGS_NONE, 0, {}};
ASSERT_EQ(0, spvOpcodeRequiresCapabilities(&entry));
}
+
+} // anonymous namespace
#include "UnitSPIRV.h"
+namespace {
+
TEST(OpcodeSplit, Default) {
uint32_t word = spvOpcodeMake(42, (Op)23);
uint16_t wordCount = 0;
ASSERT_EQ(42, wordCount);
ASSERT_EQ(23, opcode);
}
+
+} // anonymous namespace
#include "UnitSPIRV.h"
+namespace {
+
TEST(OpcodeTableGet, Default) {
spv_opcode_table table;
ASSERT_EQ(SPV_SUCCESS, spvOpcodeTableGet(&table));
TEST(OpcodeTableGet, InvalidPointerTable) {
ASSERT_EQ(SPV_ERROR_INVALID_POINTER, spvOpcodeTableGet(nullptr));
}
+
+} // anonymous namespace
#include "UnitSPIRV.h"
+namespace {
+
TEST(OperandTableGet, Default) {
spv_operand_table table;
ASSERT_EQ(SPV_SUCCESS, spvOperandTableGet(&table));
TEST(OperandTableGet, InvalidPointerTable) {
ASSERT_EQ(SPV_ERROR_INVALID_POINTER, spvOperandTableGet(nullptr));
}
+
+} // anonymous namespace
#include "UnitSPIRV.h"
+namespace test_fixture {
+
// Common setup for TextToBinary tests. SetText() should be called to populate
// the actual test text.
template<typename T>
spv_binary binary;
};
-class TextToBinaryTest : public TextToBinaryTestBase<::testing::Test> {};
+using TextToBinaryTest = TextToBinaryTestBase<::testing::Test>;
+
+} // namespace test_fixture
#endif// _TEXT_FIXTURE_H_
#include "UnitSPIRV.h"
+namespace {
+
TEST(TextAdvance, LeadingNewLines) {
char textStr[] = "\n\nWord";
spv_text_t text = {textStr, strlen(textStr)};
spv_position_t position = {};
ASSERT_EQ(SPV_END_OF_STREAM, spvTextAdvance(&text, &position));
}
+
+} // anonymous namespace
#include "UnitSPIRV.h"
+namespace {
+
TEST(TextDestroy, Default) {
spv_opcode_table opcodeTable;
ASSERT_EQ(SPV_SUCCESS, spvOpcodeTableGet(&opcodeTable));
EXPECT_NE(0, text.length);
spvTextDestroy(resultText);
}
+
+} // anonymous namespace
#include <string>
+namespace {
+
TEST(TextLiteral, GoodI32) {
spv_literal_t l;
EXPECT_EQ(SPV_LITERAL_TYPE_STRING, l.type);
EXPECT_STREQ(unquoted.data(), l.value.str);
}
+
+} // anonymous namespace
#include <utility>
#include <vector>
+namespace {
+
+using test_fixture::TextToBinaryTest;
+
union char_word_t {
char cs[4];
uint32_t u;
EXPECT_STREQ("Invalid Opcode prefix 'Wahahaha'.", diagnostic->error);
if (binary) spvBinaryDestroy(binary);
}
+
+} // anonymous namespace
#include "UnitSPIRV.h"
+namespace {
+
TEST(TextWordGet, NullTerminator) {
char textStr[] = "Word";
spv_text_t text = {textStr, strlen(textStr)};
}
}
}
+
+} // anonymous namespace
#include "UnitSPIRV.h"
+namespace {
+
class Validate : public ::testing::Test {
public:
Validate() : binary(), opcodeTable(nullptr), operandTable(nullptr) {}
spvDiagnosticPrint(diagnostic);
spvDiagnosticDestroy(diagnostic);
}
+
+} // anonymous namespace
// 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() {}
// TODO: OpGroupReserveWritePipePackets
// TODO: OpGroupCommitReadPipe
// TODO: OpGroupCommitWritePipe
+
+} // anonymous namespace