diff --git a/test/Makefile.am b/test/Makefile.am index d6e03adb..f95a942a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -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 diff --git a/test/build.cpp b/test/build.cpp new file mode 100644 index 00000000..38c4372b --- /dev/null +++ b/test/build.cpp @@ -0,0 +1,58 @@ +// +// Lol Engine +// +// Copyright: (c) 2010-2011 Sam Hocevar +// 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 */ +