source: trunk/test/unit/build.cpp @ 1028

Last change on this file since 1028 was 1028, checked in by sam, 9 years ago

test: minor fixes to the test suite: disable optimisation tests in debug
mode, and do not call "new" when we’re not sure "delete" can be called.

  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include "core.h"
16#include "lol/unit.h"
17
18namespace lol
19{
20
21LOLUNIT_FIXTURE(BuildTest)
22{
23#if !defined LOL_DEBUG
24    LOLUNIT_TEST(FastMath)
25    {
26        double x, y;
27
28        y = x = 1.0 + RandF(0.1f, 0.2f);
29        y += 4503599627370496.0;
30        /* The compiler should optimise this away */
31        y -= 4503599627370496.0;
32
33        LOLUNIT_ASSERT_EQUAL(x, y);
34    }
35#endif
36
37    LOLUNIT_TEST(FastMathOverride)
38    {
39        double x, y;
40
41        y = x = 1.0 + RandF(0.1f, 0.2f);
42        y += 4503599627370496.0;
43        FP_USE(y);
44        /* The compiler should not optimise this away */
45        y -= 4503599627370496.0;
46
47        LOLUNIT_ASSERT_EQUAL(1.0, y);
48    }
49
50    LOLUNIT_TEST(IsNaN)
51    {
52        union { float f; uint32_t x; } u;
53
54        u.x = 0x7fc00000u;
55        LOLUNIT_ASSERT(isnan(u.f));
56    }
57};
58
59} /* namespace lol */
60
Note: See TracBrowser for help on using the repository browser.