Ver código fonte

test: add unit tests to check whether the build environment behaved as

expected.
legacy
Sam Hocevar sam 13 anos atrás
pai
commit
170050501f
2 arquivos alterados com 59 adições e 1 exclusões
  1. +1
    -1
      test/Makefile.am
  2. +58
    -0
      test/build.cpp

+ 1
- 1
test/Makefile.am Ver arquivo

@@ -16,7 +16,7 @@ noinst_PROGRAMS = quad sandbox lol-bench lol-test

TESTS = lol-test

lol_test_SOURCES = lol-test.cpp matrix.cpp half.cpp trig.cpp
lol_test_SOURCES = lol-test.cpp matrix.cpp half.cpp trig.cpp build.cpp
lol_test_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@
lol_test_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@
lol_test_DEPENDENCIES = $(top_builddir)/src/liblol.a


+ 58
- 0
test/build.cpp Ver arquivo

@@ -0,0 +1,58 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://sam.zoy.org/projects/COPYING.WTFPL for more details.
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include "core.h"
#include "lol/unit.h"

namespace lol
{

LOLUNIT_FIXTURE(BuildTest)
{
LOLUNIT_TEST(FastMath)
{
double x, y;

y = x = 1.0 + RandF(0.1f, 0.2f);
y += 4503599627370496.0;
/* The compiler should optimise this away */
y -= 4503599627370496.0;

LOLUNIT_ASSERT_EQUAL(x, y);
}

LOLUNIT_TEST(FastMathOverride)
{
double x, y;

y = x = 1.0 + RandF(0.1f, 0.2f);
y += 4503599627370496.0;
FP_USE(y);
/* The compiler should not optimise this away */
y -= 4503599627370496.0;

LOLUNIT_ASSERT_EQUAL(1.0, y);
}

LOLUNIT_TEST(IsNaN)
{
union { float f; uint32_t x; } u;

u.x = 0x7fc00000u;
LOLUNIT_ASSERT(isnan(u.f));
}
};

} /* namespace lol */


Carregando…
Cancelar
Salvar