From 2ab98cf9501aed53b6f990eff38ffde48c7abc3e Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 3 Mar 2020 07:42:56 +0100 Subject: [PATCH] Clean up test suite so that it no longer includes . --- lol-core | 2 +- src/engine/entity.h | 6 ++-- src/engine/worldentity.h | 3 +- src/lol/image/image.h | 1 + src/t/base/string.cpp | 6 +++- src/t/base/types.cpp | 24 ++++++--------- src/t/entity/camera.cpp | 7 ++++- src/t/image/color.cpp | 6 +++- src/t/image/image.cpp | 9 ++++-- src/t/math/array2d.cpp | 6 +++- src/t/math/array3d.cpp | 6 +++- src/t/math/arraynd.cpp | 6 +++- src/t/math/bigint.cpp | 9 +++--- src/t/math/box.cpp | 7 ++++- src/t/math/cmplx.cpp | 6 +++- src/t/math/half.cpp | 10 +++++-- src/t/math/matrix.cpp | 10 ++++++- src/t/math/noise/simplex.cpp | 8 +++-- src/t/math/numbers.cpp | 6 +++- src/t/math/polynomial.cpp | 5 +++- src/t/math/quat.cpp | 15 ++++++++-- src/t/math/rand.cpp | 17 ++++++----- src/t/math/real.cpp | 58 +++++++++++++++++++----------------- src/t/math/rotation.cpp | 8 ++++- src/t/math/sqt.cpp | 7 ++++- src/t/math/trig.cpp | 8 +++-- src/t/math/vector.cpp | 6 +++- src/t/sys/thread.cpp | 17 ++++------- src/t/sys/timer.cpp | 16 ++++------ src/t/test-common.cpp | 9 +++--- 30 files changed, 191 insertions(+), 113 deletions(-) diff --git a/lol-core b/lol-core index 2235ce16..d05eb966 160000 --- a/lol-core +++ b/lol-core @@ -1 +1 @@ -Subproject commit 2235ce1635fa404fc8e7f700258de7c0a903136a +Subproject commit d05eb966657babec841907e9fa0e618643ca115f diff --git a/src/engine/entity.h b/src/engine/entity.h index ff117e81..a500cd2b 100644 --- a/src/engine/entity.h +++ b/src/engine/entity.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2019 Sam Hocevar +// Copyright © 2010—2020 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -20,7 +20,9 @@ // Ticker class for the ticking logic and the linked list implementation. // -#include +#include // std::map +#include // std::string +#include #include diff --git a/src/engine/worldentity.h b/src/engine/worldentity.h index 54e8a033..19192fca 100644 --- a/src/engine/worldentity.h +++ b/src/engine/worldentity.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2019 Sam Hocevar +// Copyright © 2010—2020 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -18,6 +18,7 @@ // #include +#include <../legacy/lol/math/geometry.h> // box3 #include "engine/entity.h" diff --git a/src/lol/image/image.h b/src/lol/image/image.h index 9bf80b3d..f39c92a9 100644 --- a/src/lol/image/image.h +++ b/src/lol/image/image.h @@ -20,6 +20,7 @@ #include <../legacy/lol/math/arraynd.h> #include #include <../legacy/lol/image/pixel.h> +#include <../legacy/lol/math/geometry.h> // ibox2 #include diff --git a/src/t/base/string.cpp b/src/t/base/string.cpp index 70bbbc1e..1944f7a1 100644 --- a/src/t/base/string.cpp +++ b/src/t/base/string.cpp @@ -11,8 +11,12 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include #include diff --git a/src/t/base/types.cpp b/src/t/base/types.cpp index fab5bbb4..6d035c43 100644 --- a/src/t/base/types.cpp +++ b/src/t/base/types.cpp @@ -10,8 +10,16 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include <../legacy/lol/base/types.h> +#include <../legacy/lol/math/functions.h> +#include +#include +#include namespace lol { @@ -96,20 +104,6 @@ lolunit_declare_fixture(build_features) lolunit_assert_equal(sizeof(i64vec4), 32); lolunit_assert_equal(sizeof(u64vec4), 32); } - -#if !defined LOL_BUILD_DEBUG - lolunit_declare_test(fast_math) - { - double x, y; - - y = x = 1.0 + rand(0.1f, 0.2f); - y += 4503599627370496.0; - /* The compiler should optimise this away */ - y -= 4503599627370496.0; - - lolunit_assert_equal(x, y); - } -#endif }; } /* namespace lol */ diff --git a/src/t/entity/camera.cpp b/src/t/entity/camera.cpp index 6b80e770..11c6123a 100644 --- a/src/t/entity/camera.cpp +++ b/src/t/entity/camera.cpp @@ -11,8 +11,13 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include +#include #include diff --git a/src/t/image/color.cpp b/src/t/image/color.cpp index 967f0ff6..7a4a36e7 100644 --- a/src/t/image/color.cpp +++ b/src/t/image/color.cpp @@ -10,8 +10,12 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include namespace lol { diff --git a/src/t/image/image.cpp b/src/t/image/image.cpp index b36cd704..ad513fdd 100644 --- a/src/t/image/image.cpp +++ b/src/t/image/image.cpp @@ -10,10 +10,13 @@ // See http://www.wtfpl.net/ for more details. // -#include -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif -#include +#include +#include +#include namespace lol { diff --git a/src/t/math/array2d.cpp b/src/t/math/array2d.cpp index b75bfaf3..83f0f377 100644 --- a/src/t/math/array2d.cpp +++ b/src/t/math/array2d.cpp @@ -10,8 +10,12 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include <../legacy/lol/math/arraynd.h> namespace lol { diff --git a/src/t/math/array3d.cpp b/src/t/math/array3d.cpp index 73a9cd27..302e6a1d 100644 --- a/src/t/math/array3d.cpp +++ b/src/t/math/array3d.cpp @@ -10,8 +10,12 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include <../legacy/lol/math/arraynd.h> namespace lol { diff --git a/src/t/math/arraynd.cpp b/src/t/math/arraynd.cpp index 2da49476..6fe2a859 100644 --- a/src/t/math/arraynd.cpp +++ b/src/t/math/arraynd.cpp @@ -10,8 +10,12 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include <../legacy/lol/math/arraynd.h> namespace lol { diff --git a/src/t/math/bigint.cpp b/src/t/math/bigint.cpp index d74a94a7..1299a161 100644 --- a/src/t/math/bigint.cpp +++ b/src/t/math/bigint.cpp @@ -10,12 +10,13 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include #include -#include - namespace lol { @@ -27,7 +28,7 @@ lolunit_declare_fixture(bigint_test) bigint<0> b; bigint<32> c; - UNUSED(a, b,c); + (void)a, (void)b, (void)c; } lolunit_declare_test(int32_cast) diff --git a/src/t/math/box.cpp b/src/t/math/box.cpp index 6c9a52b6..e2dbec22 100644 --- a/src/t/math/box.cpp +++ b/src/t/math/box.cpp @@ -10,8 +10,13 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include +#include <../legacy/lol/math/geometry.h> namespace lol { diff --git a/src/t/math/cmplx.cpp b/src/t/math/cmplx.cpp index d9992952..a0ae586a 100644 --- a/src/t/math/cmplx.cpp +++ b/src/t/math/cmplx.cpp @@ -10,8 +10,12 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include namespace lol { diff --git a/src/t/math/half.cpp b/src/t/math/half.cpp index 107b9ec2..8423596f 100644 --- a/src/t/math/half.cpp +++ b/src/t/math/half.cpp @@ -10,10 +10,14 @@ // See http://www.wtfpl.net/ for more details. // -#include -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif -#include +#include +#include +#include // for the sizeof(f16vec2) etc. tests +#include // for the sizeof(f16mat2) etc. tests namespace lol { diff --git a/src/t/math/matrix.cpp b/src/t/math/matrix.cpp index 6f93dc92..73a0789d 100644 --- a/src/t/math/matrix.cpp +++ b/src/t/math/matrix.cpp @@ -10,8 +10,16 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include // vec_t +#include // mat_t +#include // lol::rand + +#include // FLT_MAX namespace lol { diff --git a/src/t/math/noise/simplex.cpp b/src/t/math/noise/simplex.cpp index 19c9c880..b55da2d0 100644 --- a/src/t/math/noise/simplex.cpp +++ b/src/t/math/noise/simplex.cpp @@ -2,8 +2,6 @@ // Lol Engine — Unit tests // // Copyright © 2010—2020 Sam Hocevar -// © 2013—2014 Benjamin “Touky” Huet -// © 2013—2014 Guillaume Bittoun // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -12,8 +10,12 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include <../legacy/lol/math/noise/simplex.h> namespace lol { diff --git a/src/t/math/numbers.cpp b/src/t/math/numbers.cpp index 946325d8..3c42badd 100644 --- a/src/t/math/numbers.cpp +++ b/src/t/math/numbers.cpp @@ -10,8 +10,12 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include <../legacy/lol/math/functions.h> namespace lol { diff --git a/src/t/math/polynomial.cpp b/src/t/math/polynomial.cpp index 6d4ee645..b7c47c4f 100644 --- a/src/t/math/polynomial.cpp +++ b/src/t/math/polynomial.cpp @@ -10,7 +10,10 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include #include #include diff --git a/src/t/math/quat.cpp b/src/t/math/quat.cpp index 11b9e96c..62cac849 100644 --- a/src/t/math/quat.cpp +++ b/src/t/math/quat.cpp @@ -10,8 +10,17 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include // vec_t +#include // quat_t +#include // rand() +#include <../legacy/lol/math/functions.h> // radians() + +#include // memset namespace lol { @@ -35,9 +44,9 @@ lolunit_declare_fixture(quaternion_test) /* Fill array with random test values */ for (int i = 0; i < 10000; ++i) { - vec3 v1 = lol::pow(10.f, rand(-5.f, 5.f)) + vec3 v1 = pow(10.f, rand(-5.f, 5.f)) * vec3(rand(-1.f, 1.f), rand(-1.f, 1.f), rand(-1.f, 1.f)); - vec3 v2 = lol::pow(10.f, rand(-5.f, 5.f)) + vec3 v2 = pow(10.f, rand(-5.f, 5.f)) * vec3(rand(-1.f, 1.f), rand(-1.f, 1.f), rand(-1.f, 1.f)); push_vector_pair(v1, v2); } diff --git a/src/t/math/rand.cpp b/src/t/math/rand.cpp index eac2abdf..ee595d42 100644 --- a/src/t/math/rand.cpp +++ b/src/t/math/rand.cpp @@ -10,8 +10,14 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include + +#include // FLT_MAX namespace lol { @@ -22,8 +28,7 @@ lolunit_declare_fixture(rand_test) { int const rolls = 2000; - int bits[32]; - memset(bits, 0, sizeof(bits)); + int bits[32] = { 0 }; for (int i = 0; i < rolls; ++i) { @@ -51,8 +56,7 @@ lolunit_declare_fixture(rand_test) { int const rolls = 2000; - int bits[16]; - memset(bits, 0, sizeof(bits)); + int bits[16] = { 0 }; for (int i = 0; i < rolls; ++i) { @@ -80,8 +84,7 @@ lolunit_declare_fixture(rand_test) { int const rolls = 2000; - int bits[8]; - memset(bits, 0, sizeof(bits)); + int bits[8] = { 0 }; for (int i = 0; i < rolls; ++i) { diff --git a/src/t/math/real.cpp b/src/t/math/real.cpp index a219be69..3dd7035d 100644 --- a/src/t/math/real.cpp +++ b/src/t/math/real.cpp @@ -10,9 +10,13 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include #include +#include // for rcmplx #include @@ -328,15 +332,15 @@ lolunit_declare_fixture(real_test) auto sqrt7 = sqrt(real(7)); auto sqrt8 = sqrt(real(8)); - lolunit_assert_doubles_equal(double(sqrt0), sqrt(0.0), 1e-8); - lolunit_assert_doubles_equal(double(sqrt1), sqrt(1.0), 1e-8); - lolunit_assert_doubles_equal(double(sqrt2), sqrt(2.0), 1e-8); - lolunit_assert_doubles_equal(double(sqrt3), sqrt(3.0), 1e-8); - lolunit_assert_doubles_equal(double(sqrt4), sqrt(4.0), 1e-8); - lolunit_assert_doubles_equal(double(sqrt5), sqrt(5.0), 1e-8); - lolunit_assert_doubles_equal(double(sqrt6), sqrt(6.0), 1e-8); - lolunit_assert_doubles_equal(double(sqrt7), sqrt(7.0), 1e-8); - lolunit_assert_doubles_equal(double(sqrt8), sqrt(8.0), 1e-8); + lolunit_assert_doubles_equal(double(sqrt0), std::sqrt(0.0), 1e-8); + lolunit_assert_doubles_equal(double(sqrt1), std::sqrt(1.0), 1e-8); + lolunit_assert_doubles_equal(double(sqrt2), std::sqrt(2.0), 1e-8); + lolunit_assert_doubles_equal(double(sqrt3), std::sqrt(3.0), 1e-8); + lolunit_assert_doubles_equal(double(sqrt4), std::sqrt(4.0), 1e-8); + lolunit_assert_doubles_equal(double(sqrt5), std::sqrt(5.0), 1e-8); + lolunit_assert_doubles_equal(double(sqrt6), std::sqrt(6.0), 1e-8); + lolunit_assert_doubles_equal(double(sqrt7), std::sqrt(7.0), 1e-8); + lolunit_assert_doubles_equal(double(sqrt8), std::sqrt(8.0), 1e-8); } lolunit_declare_test(real_cbrt) @@ -359,23 +363,23 @@ lolunit_declare_fixture(real_test) auto cbrt7 = cbrt(real(7)); auto cbrt8 = cbrt(real(8)); - lolunit_assert_doubles_equal(double(cbrtm8), cbrt(-8.0), 1e-8); - lolunit_assert_doubles_equal(double(cbrtm7), cbrt(-7.0), 1e-8); - lolunit_assert_doubles_equal(double(cbrtm6), cbrt(-6.0), 1e-8); - lolunit_assert_doubles_equal(double(cbrtm5), cbrt(-5.0), 1e-8); - lolunit_assert_doubles_equal(double(cbrtm4), cbrt(-4.0), 1e-8); - lolunit_assert_doubles_equal(double(cbrtm3), cbrt(-3.0), 1e-8); - lolunit_assert_doubles_equal(double(cbrtm2), cbrt(-2.0), 1e-8); - lolunit_assert_doubles_equal(double(cbrtm1), cbrt(-1.0), 1e-8); - lolunit_assert_doubles_equal(double(cbrt0), cbrt(0.0), 1e-8); - lolunit_assert_doubles_equal(double(cbrt1), cbrt(1.0), 1e-8); - lolunit_assert_doubles_equal(double(cbrt2), cbrt(2.0), 1e-8); - lolunit_assert_doubles_equal(double(cbrt3), cbrt(3.0), 1e-8); - lolunit_assert_doubles_equal(double(cbrt4), cbrt(4.0), 1e-8); - lolunit_assert_doubles_equal(double(cbrt5), cbrt(5.0), 1e-8); - lolunit_assert_doubles_equal(double(cbrt6), cbrt(6.0), 1e-8); - lolunit_assert_doubles_equal(double(cbrt7), cbrt(7.0), 1e-8); - lolunit_assert_doubles_equal(double(cbrt8), cbrt(8.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrtm8), std::cbrt(-8.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrtm7), std::cbrt(-7.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrtm6), std::cbrt(-6.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrtm5), std::cbrt(-5.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrtm4), std::cbrt(-4.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrtm3), std::cbrt(-3.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrtm2), std::cbrt(-2.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrtm1), std::cbrt(-1.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrt0), std::cbrt(0.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrt1), std::cbrt(1.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrt2), std::cbrt(2.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrt3), std::cbrt(3.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrt4), std::cbrt(4.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrt5), std::cbrt(5.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrt6), std::cbrt(6.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrt7), std::cbrt(7.0), 1e-8); + lolunit_assert_doubles_equal(double(cbrt8), std::cbrt(8.0), 1e-8); } lolunit_declare_test(real_ldexp) diff --git a/src/t/math/rotation.cpp b/src/t/math/rotation.cpp index c2c6e280..748c72ef 100644 --- a/src/t/math/rotation.cpp +++ b/src/t/math/rotation.cpp @@ -10,8 +10,14 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include +#include +#include <../legacy/lol/math/functions.h> namespace lol { diff --git a/src/t/math/sqt.cpp b/src/t/math/sqt.cpp index d2cde1b6..257b48dc 100644 --- a/src/t/math/sqt.cpp +++ b/src/t/math/sqt.cpp @@ -10,8 +10,13 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include +#include namespace lol { diff --git a/src/t/math/trig.cpp b/src/t/math/trig.cpp index 6735cf0a..2fe59677 100644 --- a/src/t/math/trig.cpp +++ b/src/t/math/trig.cpp @@ -10,10 +10,12 @@ // See http://www.wtfpl.net/ for more details. // -#include -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif -#include +#include +#include <../legacy/lol/math/functions.h> namespace lol { diff --git a/src/t/math/vector.cpp b/src/t/math/vector.cpp index b375af09..ad56de2e 100644 --- a/src/t/math/vector.cpp +++ b/src/t/math/vector.cpp @@ -10,8 +10,12 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include namespace lol { diff --git a/src/t/sys/thread.cpp b/src/t/sys/thread.cpp index 6a0c5220..c90502f5 100644 --- a/src/t/sys/thread.cpp +++ b/src/t/sys/thread.cpp @@ -11,25 +11,18 @@ // See http://www.wtfpl.net/ for more details. // -#include -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif -#include -#include +#include +#include namespace lol { lolunit_declare_fixture(thread_test) { - void setup() - { - } - - void teardown() - { - } - lolunit_declare_test(queue_try_push) { queue q; diff --git a/src/t/sys/timer.cpp b/src/t/sys/timer.cpp index 2e2d496b..05bac391 100644 --- a/src/t/sys/timer.cpp +++ b/src/t/sys/timer.cpp @@ -2,8 +2,6 @@ // Lol Engine — Unit tests // // Copyright © 2010—2020 Sam Hocevar -// © 2014—2015 Benjamin “Touky” Huet -// © 2014—2015 Guillaume Bittoun // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -12,22 +10,18 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include +#include namespace lol { lolunit_declare_fixture(timer_test) { - void setup() - { - } - - void teardown() - { - } - lolunit_declare_test(timers) { timer t0, t1; diff --git a/src/t/test-common.cpp b/src/t/test-common.cpp index ee992e84..b62e9a15 100644 --- a/src/t/test-common.cpp +++ b/src/t/test-common.cpp @@ -10,16 +10,17 @@ // See http://www.wtfpl.net/ for more details. // -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include #include #include -int main(int argc, char **argv) +int main(int, char **) { - UNUSED(argc, argv); - lol::text_runner runner; bool success = runner.Run(); return success ? EXIT_SUCCESS : EXIT_FAILURE;