From b6a8898fa580391694c59f7597d69fd575e188c0 Mon Sep 17 00:00:00 2001 From: David Neto Date: Tue, 8 Sep 2015 09:55:52 -0400 Subject: [PATCH] Enable OpcodeMake test, by sampling values. The previous version of the test was disabled, presumably because it took to long to run. --- test/OpcodeMake.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/test/OpcodeMake.cpp b/test/OpcodeMake.cpp index 35cef98..c6e4422 100644 --- a/test/OpcodeMake.cpp +++ b/test/OpcodeMake.cpp @@ -26,19 +26,27 @@ #include "UnitSPIRV.h" -#include - namespace { -TEST(OpcodeMake, DISABLED_Default) { - for (uint16_t wordCount = 0; wordCount < std::numeric_limits::max(); - ++wordCount) { - for (uint16_t code = 0; code < std::numeric_limits::max(); - ++code) { - uint32_t opcode = 0; - opcode |= (uint32_t)code; - opcode |= (uint32_t)wordCount << 16; - ASSERT_EQ(opcode, spvOpcodeMake(wordCount, (Op)code)); +// A sampling of word counts. Covers extreme points well, and all bit +// positions, and some combinations of bit positions. +const uint16_t kSampleWordCounts[] = { + 0, 1, 2, 3, 4, 8, 16, 32, 64, 127, 128, + 256, 511, 512, 1024, 2048, 4096, 8192, 16384, 32768, 0xfffe, 0xffff}; + +// A sampling of opcode values. Covers the lower values well, a few samples +// around the number of core instructions (as of this writing), and some +// higher values. +const uint16_t kSampleOpcodes[] = {0, 1, 2, 3, 4, 100, + 300, 305, 1023, 0xfffe, 0xffff}; + +TEST(OpcodeMake, Samples) { + for (auto wordCount : kSampleWordCounts) { + for (auto opcode : kSampleOpcodes) { + uint32_t word = 0; + word |= uint32_t(opcode); + word |= uint32_t(wordCount) << 16; + EXPECT_EQ(word, spvOpcodeMake(wordCount, Op(opcode))); } } } -- 2.7.4