aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/test/math.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/test/math.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/test/math.cpp')
-rw-r--r--linden/indra/test/math.cpp133
1 files changed, 133 insertions, 0 deletions
diff --git a/linden/indra/test/math.cpp b/linden/indra/test/math.cpp
new file mode 100644
index 0000000..b14a798
--- /dev/null
+++ b/linden/indra/test/math.cpp
@@ -0,0 +1,133 @@
1/**
2 * @file math.cpp
3 * @author Phoenix
4 * @date 2005-09-26
5 * @brief Tests for the llmath library.
6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 *
9 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement
12 * ("Other License"), formally executed by you and Linden Lab. Terms of
13 * the GPL can be found in doc/GPL-license.txt in this distribution, or
14 * online at http://secondlife.com/developers/opensource/gplv2
15 *
16 * There are special exceptions to the terms and conditions of the GPL as
17 * it is applied to this Source Code. View the full text of the exception
18 * in the file doc/FLOSS-exception.txt in this software distribution, or
19 * online at http://secondlife.com/developers/opensource/flossexception
20 *
21 * By copying, modifying or distributing this software, you acknowledge
22 * that you have read and understood your obligations described above,
23 * and agree to abide by those obligations.
24 *
25 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
26 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
27 * COMPLETENESS OR PERFORMANCE.
28 */
29
30#include "linden_common.h"
31#include "lltut.h"
32
33#include "llmath.h"
34#include "lluuid.h"
35
36namespace tut
37{
38 struct math_data
39 {
40 };
41 typedef test_group<math_data> math_test;
42 typedef math_test::object math_object;
43 tut::math_test tm("basic_linden_math");
44
45 template<> template<>
46 void math_object::test<1>()
47 {
48 S32 val = 89543;
49 val = llabs(val);
50 ensure("integer absolute value 1", (89543 == val));
51 val = -500;
52 val = llabs(val);
53 ensure("integer absolute value 2", (500 == val));
54 }
55
56 template<> template<>
57 void math_object::test<2>()
58 {
59 F32 val = -2583.4f;
60 val = llabs(val);
61 ensure("float absolute value 1", (2583.4f == val));
62 val = 430903.f;
63 val = llabs(val);
64 ensure("float absolute value 2", (430903.f == val));
65 }
66
67 template<> template<>
68 void math_object::test<3>()
69 {
70 F64 val = 387439393.987329839;
71 val = llabs(val);
72 ensure("double absolute value 1", (387439393.987329839 == val));
73 val = -8937843.9394878;
74 val = llabs(val);
75 ensure("double absolute value 2", (8937843.9394878 == val));
76 }
77}
78
79namespace tut
80{
81 struct uuid_data
82 {
83 LLUUID id;
84 };
85 typedef test_group<uuid_data> uuid_test;
86 typedef uuid_test::object uuid_object;
87 tut::uuid_test tu("uuid");
88
89 template<> template<>
90 void uuid_object::test<1>()
91 {
92 ensure("uuid null", id.isNull());
93 id.generate();
94 ensure("generate not null", id.notNull());
95 id.setNull();
96 ensure("set null", id.isNull());
97 }
98
99 template<> template<>
100 void uuid_object::test<2>()
101 {
102 id.generate();
103 LLUUID a(id);
104 ensure_equals("copy equal", id, a);
105 a.generate();
106 ensure_not_equals("generate not equal", id, a);
107 a = id;
108 ensure_equals("assignment equal", id, a);
109 }
110
111 template<> template<>
112 void uuid_object::test<3>()
113 {
114 id.generate();
115 LLUUID copy(id);
116 LLUUID mask;
117 mask.generate();
118 copy ^= mask;
119 ensure_not_equals("mask not equal", id, copy);
120 copy ^= mask;
121 ensure_equals("mask back", id, copy);
122 }
123
124 template<> template<>
125 void uuid_object::test<4>()
126 {
127 id.generate();
128 LLString id_str = id.getString();
129 LLUUID copy(id_str.c_str());
130 ensure_equals("string serialization", id, copy);
131 }
132
133}