Last change
on this file since 964 was
942,
checked in by sam, 12 years ago
|
test: reorganise test suite and benchmark code.
|
-
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 | |
---|
18 | namespace lol |
---|
19 | { |
---|
20 | |
---|
21 | LOLUNIT_FIXTURE(BuildTest) |
---|
22 | { |
---|
23 | LOLUNIT_TEST(FastMath) |
---|
24 | { |
---|
25 | double x, y; |
---|
26 | |
---|
27 | y = x = 1.0 + RandF(0.1f, 0.2f); |
---|
28 | y += 4503599627370496.0; |
---|
29 | /* The compiler should optimise this away */ |
---|
30 | y -= 4503599627370496.0; |
---|
31 | |
---|
32 | LOLUNIT_ASSERT_EQUAL(x, y); |
---|
33 | } |
---|
34 | |
---|
35 | LOLUNIT_TEST(FastMathOverride) |
---|
36 | { |
---|
37 | double x, y; |
---|
38 | |
---|
39 | y = x = 1.0 + RandF(0.1f, 0.2f); |
---|
40 | y += 4503599627370496.0; |
---|
41 | FP_USE(y); |
---|
42 | /* The compiler should not optimise this away */ |
---|
43 | y -= 4503599627370496.0; |
---|
44 | |
---|
45 | LOLUNIT_ASSERT_EQUAL(1.0, y); |
---|
46 | } |
---|
47 | |
---|
48 | LOLUNIT_TEST(IsNaN) |
---|
49 | { |
---|
50 | union { float f; uint32_t x; } u; |
---|
51 | |
---|
52 | u.x = 0x7fc00000u; |
---|
53 | LOLUNIT_ASSERT(isnan(u.f)); |
---|
54 | } |
---|
55 | }; |
---|
56 | |
---|
57 | } /* namespace lol */ |
---|
58 | |
---|
Note: See
TracBrowser
for help on using the repository browser.