aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/test/llmodularmath_tut.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/test/llmodularmath_tut.cpp80
1 files changed, 80 insertions, 0 deletions
diff --git a/linden/indra/test/llmodularmath_tut.cpp b/linden/indra/test/llmodularmath_tut.cpp
new file mode 100644
index 0000000..190ca47
--- /dev/null
+++ b/linden/indra/test/llmodularmath_tut.cpp
@@ -0,0 +1,80 @@
1/**
2 * @file modularmath_tut.cpp
3 * @author babbage
4 * @date 2008-09
5 * @brief llcircuit tests
6 *
7 * $LicenseInfo:firstyear=2007&license=viewergpl$
8 *
9 * Copyright (c) 2007-2008, Linden Research, Inc.
10 *
11 * Second Life Viewer Source Code
12 * The source code in this file ("Source Code") is provided by Linden Lab
13 * to you under the terms of the GNU General Public License, version 2.0
14 * ("GPL"), unless you have obtained a separate licensing agreement
15 * ("Other License"), formally executed by you and Linden Lab. Terms of
16 * the GPL can be found in doc/GPL-license.txt in this distribution, or
17 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
18 *
19 * There are special exceptions to the terms and conditions of the GPL as
20 * it is applied to this Source Code. View the full text of the exception
21 * in the file doc/FLOSS-exception.txt in this software distribution, or
22 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
23 *
24 * By copying, modifying or distributing this software, you acknowledge
25 * that you have read and understood your obligations described above,
26 * and agree to abide by those obligations.
27 *
28 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
29 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
30 * COMPLETENESS OR PERFORMANCE.
31 * $/LicenseInfo$
32 */
33
34#include <tut/tut.h>
35#include "linden_common.h"
36#include "lltut.h"
37#include "llmodularmath.h"
38
39namespace tut
40{
41 struct modularmath_data
42 {
43 };
44 typedef test_group<modularmath_data> modularmath_test;
45 typedef modularmath_test::object modularmath_object;
46 tut::modularmath_test modularmath_testcase("modularmath");
47
48 template<> template<>
49 void modularmath_object::test<1>()
50 {
51 // lhs < rhs
52 const U32 lhs = 0x000001;
53 const U32 rhs = 0xFFFFFF;
54 const U32 width = 24;
55 U32 result = LLModularMath::subtract<width>(lhs, rhs);
56 ensure_equals("diff(0x000001, 0xFFFFFF, 24)", result, 2);
57 }
58
59 template<> template<>
60 void modularmath_object::test<2>()
61 {
62 // lhs > rhs
63 const U32 lhs = 0x000002;
64 const U32 rhs = 0x000001;
65 const U32 width = 24;
66 U32 result = LLModularMath::subtract<width>(lhs, rhs);
67 ensure_equals("diff(0x000002, 0x000001, 24)", result, 1);
68 }
69
70 template<> template<>
71 void modularmath_object::test<3>()
72 {
73 // lhs == rhs
74 const U32 lhs = 0xABCDEF;
75 const U32 rhs = 0xABCDEF;
76 const U32 width = 24;
77 U32 result = LLModularMath::subtract<width>(lhs, rhs);
78 ensure_equals("diff(0xABCDEF, 0xABCDEF, 24)", result, 0);
79 }
80}