clean up some warnings and add some extra integer tests

This commit is contained in:
water
2020-10-09 21:28:41 -04:00
parent 0a231afdbb
commit f7abe9c5f8
20 changed files with 42 additions and 28 deletions
+4 -1
View File
@@ -24,7 +24,8 @@ if (CMAKE_COMPILER_IS_GNUCXX)
-Wmissing-include-dirs \
-Woverloaded-virtual \
-Wredundant-decls \
-Wsign-promo") # TODO - add back -Wshadow once fixed inside inja, lots of compiler warnings
-Wshadow \
-Wsign-promo")
else ()
set(CMAKE_CXX_FLAGS "/EHsc")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10000000")
@@ -51,6 +52,8 @@ endif()
# includes relative to top level jak-project folder
include_directories(./)
include_directories(SYSTEM third-party/inja)
# build spdlog as a shared library to improve compile times
# adding this as a SYSTEM include suppresses all the terrible warnings in spdlog
include_directories(SYSTEM third-party/spdlog/include)
+1
View File
@@ -18,6 +18,7 @@ add_executable(goalc-test
test_emitter_integer_math.cpp
test_common_util.cpp
test_deftype.cpp
test_pretty_print.cpp
${GOALC_TEST_FRAMEWORK_SOURCES}
${GOALC_TEST_CASES})
+1 -1
View File
@@ -4,7 +4,7 @@
#include <string>
#include "gtest/gtest.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"
#include "game/runtime.h"
+1 -1
View File
@@ -3,7 +3,7 @@
#include <string>
#include <vector>
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "goalc/compiler/Compiler.h"
namespace GoalTest {
+21 -11
View File
@@ -8,7 +8,7 @@
#include "goalc/listener/Listener.h"
#include "goalc/compiler/Compiler.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"
#include <test/goalc/framework/test_runner.h>
@@ -31,6 +31,10 @@
// See -
// https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#value-parameterized-tests
struct IntegerParam {
// Each integer test has a signed value, and can be represented as hex or an integral
s64 val;
bool hex;
// An index is needed to be explicitly set because I couldn't find a way to pull the test-index
// number from google's API
// TODO - if you can find a way, please improve!
@@ -38,11 +42,8 @@ struct IntegerParam {
// Why? - since you may choose to generate random values, it's nice for them to be stored after
// the tests complete. Some tests may be complex as well
int index;
// Each integer test has a signed value, and can be represented as hex or an integral
s64 val;
bool hex;
IntegerParam(s64 val, bool hex = false, int index = 0) : val(val), hex(hex), index(index) {}
IntegerParam(s64 _val, bool _hex = false, int _index = 0) : val(_val), hex(_hex), index(_index) {}
// This is used to generate the value that is passed into the template engine
// and injected into the file of lisp code.
@@ -81,26 +82,35 @@ std::vector<IntegerParam> genIntegerTests(int numTests,
std::mt19937 rng(dev());
std::uniform_int_distribution<std::mt19937::result_type> dist6(0, UINT32_MAX);
int testCases = 3;
for (int i = 0; i < numTests; i++) {
switch (i % testCases) {
int test_index = 0;
for (; test_index < numTests; test_index++) {
switch (test_index % testCases) {
case 0:
tests.push_back(IntegerParam(dist6(rng), false, i));
tests.push_back(IntegerParam(dist6(rng), false, test_index));
break;
case 1:
tests.push_back(IntegerParam((s64)dist6(rng) * -1, false, i));
tests.push_back(IntegerParam((s64)dist6(rng) * -1, false, test_index));
break;
case 2:
tests.push_back(IntegerParam(dist6(rng), true, i));
tests.push_back(IntegerParam(dist6(rng), true, test_index));
break;
}
}
for (int i = 0; i < additionalTests.size(); i++) {
for (int i = 0; i < int(additionalTests.size()); i++) {
IntegerParam test = additionalTests.at(i);
test.index = i + numTests - 1;
tests.push_back(test);
}
for (auto x :
{s64(UINT32_MAX), s64(INT32_MIN), s64(INT32_MAX), s64(0), s64(INT64_MAX), s64(INT64_MIN)}) {
for (auto y : {-1, 0, 1}) {
s64 value = x + s64(y);
tests.emplace_back(value, false, test_index++);
}
}
return tests;
}
+1 -1
View File
@@ -6,7 +6,7 @@
#include "goalc/listener/Listener.h"
#include "goalc/compiler/Compiler.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"
#include <test/goalc/framework/test_runner.h>
+1 -1
View File
@@ -6,7 +6,7 @@
#include "goalc/listener/Listener.h"
#include "goalc/compiler/Compiler.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"
#include <test/goalc/framework/test_runner.h>
+1 -1
View File
@@ -6,7 +6,7 @@
#include "goalc/listener/Listener.h"
#include "goalc/compiler/Compiler.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"
#include <test/goalc/framework/test_runner.h>
+1 -1
View File
@@ -6,7 +6,7 @@
#include "goalc/listener/Listener.h"
#include "goalc/compiler/Compiler.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"
#include <test/goalc/framework/test_runner.h>
+1 -1
View File
@@ -6,7 +6,7 @@
#include "goalc/listener/Listener.h"
#include "goalc/compiler/Compiler.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"
#include <test/goalc/framework/test_runner.h>
+1 -1
View File
@@ -6,7 +6,7 @@
#include "goalc/listener/Listener.h"
#include "goalc/compiler/Compiler.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"
#include <test/goalc/framework/test_runner.h>
+1 -1
View File
@@ -6,7 +6,7 @@
#include "goalc/listener/Listener.h"
#include "goalc/compiler/Compiler.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"
#include <test/goalc/framework/test_runner.h>
+1 -1
View File
@@ -6,7 +6,7 @@
#include "goalc/listener/Listener.h"
#include "goalc/compiler/Compiler.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"
#include <test/goalc/framework/test_runner.h>
+1 -1
View File
@@ -6,7 +6,7 @@
#include "goalc/listener/Listener.h"
#include "goalc/compiler/Compiler.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"
#include <test/goalc/framework/test_runner.h>
+1 -1
View File
@@ -6,7 +6,7 @@
#include "goalc/listener/Listener.h"
#include "goalc/compiler/Compiler.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"
#include <test/goalc/framework/test_runner.h>
+1 -1
View File
@@ -6,7 +6,7 @@
#include "goalc/listener/Listener.h"
#include "goalc/compiler/Compiler.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"
#include <test/goalc/framework/test_runner.h>
+1 -1
View File
@@ -6,7 +6,7 @@
#include "goalc/listener/Listener.h"
#include "goalc/compiler/Compiler.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"
#include <test/goalc/framework/test_runner.h>
+1 -1
View File
@@ -6,7 +6,7 @@
#include "goalc/listener/Listener.h"
#include "goalc/compiler/Compiler.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"
#include <test/goalc/framework/test_runner.h>
+1 -1
View File
@@ -6,7 +6,7 @@
#include "goalc/listener/Listener.h"
#include "goalc/compiler/Compiler.h"
#include "third-party/inja.hpp"
#include "inja.hpp"
#include "third-party/json.hpp"
#include "common/util/FileUtil.h"
#include <test/goalc/framework/test_runner.h>