Преглед на файлове

Clean up test suite so that it no longer includes <lol/engine-internal.h>.

legacy
Sam Hocevar преди 4 години
родител
ревизия
2ab98cf950
променени са 30 файла, в които са добавени 191 реда и са изтрити 113 реда
  1. +1
    -1
      lol-core
  2. +4
    -2
      src/engine/entity.h
  3. +2
    -1
      src/engine/worldentity.h
  4. +1
    -0
      src/lol/image/image.h
  5. +5
    -1
      src/t/base/string.cpp
  6. +9
    -15
      src/t/base/types.cpp
  7. +6
    -1
      src/t/entity/camera.cpp
  8. +5
    -1
      src/t/image/color.cpp
  9. +6
    -3
      src/t/image/image.cpp
  10. +5
    -1
      src/t/math/array2d.cpp
  11. +5
    -1
      src/t/math/array3d.cpp
  12. +5
    -1
      src/t/math/arraynd.cpp
  13. +5
    -4
      src/t/math/bigint.cpp
  14. +6
    -1
      src/t/math/box.cpp
  15. +5
    -1
      src/t/math/cmplx.cpp
  16. +7
    -3
      src/t/math/half.cpp
  17. +9
    -1
      src/t/math/matrix.cpp
  18. +5
    -3
      src/t/math/noise/simplex.cpp
  19. +5
    -1
      src/t/math/numbers.cpp
  20. +4
    -1
      src/t/math/polynomial.cpp
  21. +12
    -3
      src/t/math/quat.cpp
  22. +10
    -7
      src/t/math/rand.cpp
  23. +31
    -27
      src/t/math/real.cpp
  24. +7
    -1
      src/t/math/rotation.cpp
  25. +6
    -1
      src/t/math/sqt.cpp
  26. +5
    -3
      src/t/math/trig.cpp
  27. +5
    -1
      src/t/math/vector.cpp
  28. +5
    -12
      src/t/sys/thread.cpp
  29. +5
    -11
      src/t/sys/timer.cpp
  30. +5
    -4
      src/t/test-common.cpp

+ 1
- 1
lol-core

@@ -1 +1 @@
Subproject commit 2235ce1635fa404fc8e7f700258de7c0a903136a
Subproject commit d05eb966657babec841907e9fa0e618643ca115f

+ 4
- 2
src/engine/entity.h Целия файл

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net>
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net>
//
// 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 <cstdint>
#include <map> // std::map
#include <string> // std::string
#include <stdint.h>

#include <lol/engine/tickable.h>



+ 2
- 1
src/engine/worldentity.h Целия файл

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net>
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net>
//
// 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 <lol/math/transform.h>
#include <../legacy/lol/math/geometry.h> // box3

#include "engine/entity.h"



+ 1
- 0
src/lol/image/image.h Целия файл

@@ -20,6 +20,7 @@
#include <../legacy/lol/math/arraynd.h>
#include <lol/math/vector.h>
#include <../legacy/lol/image/pixel.h>
#include <../legacy/lol/math/geometry.h> // ibox2

#include <string>



+ 5
- 1
src/t/base/string.cpp Целия файл

@@ -11,8 +11,12 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <lol/base/utils.h>

#include <string>



+ 9
- 15
src/t/base/types.cpp Целия файл

@@ -10,8 +10,16 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <../legacy/lol/base/types.h>
#include <../legacy/lol/math/functions.h>
#include <lol/math/vector.h>
#include <lol/math/transform.h>
#include <lol/types/half.h>

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 */


+ 6
- 1
src/t/entity/camera.cpp Целия файл

@@ -11,8 +11,13 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <lol/../camera.h>
#include <lol/../engine/ticker.h>

#include <memory>



+ 5
- 1
src/t/image/color.cpp Целия файл

@@ -10,8 +10,12 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <lol/image/color.h>

namespace lol
{


+ 6
- 3
src/t/image/image.cpp Целия файл

@@ -10,10 +10,13 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#include <lol/base/lolunit.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <cmath>
#include <lol/base/lolunit.h>
#include <lol/math/vector.h>
#include <lol/image/image.h>

namespace lol
{


+ 5
- 1
src/t/math/array2d.cpp Целия файл

@@ -10,8 +10,12 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <../legacy/lol/math/arraynd.h>

namespace lol
{


+ 5
- 1
src/t/math/array3d.cpp Целия файл

@@ -10,8 +10,12 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <../legacy/lol/math/arraynd.h>

namespace lol
{


+ 5
- 1
src/t/math/arraynd.cpp Целия файл

@@ -10,8 +10,12 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <../legacy/lol/math/arraynd.h>

namespace lol
{


+ 5
- 4
src/t/math/bigint.cpp Целия файл

@@ -10,12 +10,13 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <lol/types/bigint.h>

#include <cmath>

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)


+ 6
- 1
src/t/math/box.cpp Целия файл

@@ -10,8 +10,13 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <lol/math/vector.h>
#include <../legacy/lol/math/geometry.h>

namespace lol
{


+ 5
- 1
src/t/math/cmplx.cpp Целия файл

@@ -10,8 +10,12 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <lol/math/transform.h>

namespace lol
{


+ 7
- 3
src/t/math/half.cpp Целия файл

@@ -10,10 +10,14 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#include <lol/base/lolunit.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <cmath>
#include <lol/base/lolunit.h>
#include <lol/types/half.h>
#include <lol/math/vector.h> // for the sizeof(f16vec2) etc. tests
#include <lol/math/transform.h> // for the sizeof(f16mat2) etc. tests

namespace lol
{


+ 9
- 1
src/t/math/matrix.cpp Целия файл

@@ -10,8 +10,16 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <lol/math/vector.h> // vec_t
#include <lol/math/transform.h> // mat_t
#include <lol/math/rand.h> // lol::rand

#include <cfloat> // FLT_MAX

namespace lol
{


+ 5
- 3
src/t/math/noise/simplex.cpp Целия файл

@@ -2,8 +2,6 @@
// Lol Engine — Unit tests
//
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net>
// © 2013—2014 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
// © 2013—2014 Guillaume Bittoun <guillaume.bittoun@gmail.com>
//
// 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 <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <../legacy/lol/math/noise/simplex.h>

namespace lol
{


+ 5
- 1
src/t/math/numbers.cpp Целия файл

@@ -10,8 +10,12 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <../legacy/lol/math/functions.h>

namespace lol
{


+ 4
- 1
src/t/math/polynomial.cpp Целия файл

@@ -10,7 +10,10 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <lol/types/real.h>
#include <lol/math/polynomial.h>


+ 12
- 3
src/t/math/quat.cpp Целия файл

@@ -10,8 +10,17 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <lol/math/vector.h> // vec_t
#include <lol/math/transform.h> // quat_t
#include <lol/math/rand.h> // rand()
#include <../legacy/lol/math/functions.h> // radians()

#include <cstring> // 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);
}


+ 10
- 7
src/t/math/rand.cpp Целия файл

@@ -10,8 +10,14 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <lol/math/rand.h>

#include <cfloat> // 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)
{


+ 31
- 27
src/t/math/real.cpp Целия файл

@@ -10,9 +10,13 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <lol/types/real.h>
#include <lol/math/transform.h> // for rcmplx

#include <cmath>

@@ -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)


+ 7
- 1
src/t/math/rotation.cpp Целия файл

@@ -10,8 +10,14 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <lol/math/vector.h>
#include <lol/math/transform.h>
#include <../legacy/lol/math/functions.h>

namespace lol
{


+ 6
- 1
src/t/math/sqt.cpp Целия файл

@@ -10,8 +10,13 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <lol/math/vector.h>
#include <lol/math/transform.h>

namespace lol
{


+ 5
- 3
src/t/math/trig.cpp Целия файл

@@ -10,10 +10,12 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#include <lol/base/lolunit.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <cmath>
#include <lol/base/lolunit.h>
#include <../legacy/lol/math/functions.h>

namespace lol
{


+ 5
- 1
src/t/math/vector.cpp Целия файл

@@ -10,8 +10,12 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <lol/math/vector.h>

namespace lol
{


+ 5
- 12
src/t/sys/thread.cpp Целия файл

@@ -11,25 +11,18 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#include <lol/base/lolunit.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <string>
#include <map>
#include <lol/base/lolunit.h>
#include <lol/base/thread.h>

namespace lol
{

lolunit_declare_fixture(thread_test)
{
void setup()
{
}

void teardown()
{
}

lolunit_declare_test(queue_try_push)
{
queue<int, 1> q;


+ 5
- 11
src/t/sys/timer.cpp Целия файл

@@ -2,8 +2,6 @@
// Lol Engine — Unit tests
//
// Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net>
// © 2014—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
// © 2014—2015 Guillaume Bittoun <guillaume.bittoun@gmail.com>
//
// 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 <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>
#include <lol/base/thread.h>

namespace lol
{

lolunit_declare_fixture(timer_test)
{
void setup()
{
}

void teardown()
{
}

lolunit_declare_test(timers)
{
timer t0, t1;


+ 5
- 4
src/t/test-common.cpp Целия файл

@@ -10,16 +10,17 @@
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/base/lolunit.h>

#include <cstdio>
#include <cstdlib>

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;


Зареждане…
Отказ
Запис