diff options
author | Jacek Antonelli | 2008-08-15 23:45:02 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:02 -0500 |
commit | d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd (patch) | |
tree | 7ed0c2c27d717801238a2e6b5749cd5bf88c3059 /linden/indra/test/llsdutil_tut.cpp | |
parent | Second Life viewer sources 1.17.3.0 (diff) | |
download | meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.zip meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.tar.gz meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.tar.bz2 meta-impy-d644fc64407dcd14ffcee6a0e9fbe28ee3a4e9bd.tar.xz |
Second Life viewer sources 1.18.0.6
Diffstat (limited to 'linden/indra/test/llsdutil_tut.cpp')
-rw-r--r-- | linden/indra/test/llsdutil_tut.cpp | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/linden/indra/test/llsdutil_tut.cpp b/linden/indra/test/llsdutil_tut.cpp new file mode 100644 index 0000000..bb5d7fd --- /dev/null +++ b/linden/indra/test/llsdutil_tut.cpp | |||
@@ -0,0 +1,152 @@ | |||
1 | /** | ||
2 | * @file llsdutil_tut.cpp | ||
3 | * @author Adroit | ||
4 | * @date 2007-02 | ||
5 | * @brief LLSD conversion routines test cases. | ||
6 | * | ||
7 | * Copyright (c) 2007-2007, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at http://secondlife.com/developers/opensource/flossexception | ||
21 | * | ||
22 | * By copying, modifying or distributing this software, you acknowledge | ||
23 | * that you have read and understood your obligations described above, | ||
24 | * and agree to abide by those obligations. | ||
25 | * | ||
26 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
28 | * COMPLETENESS OR PERFORMANCE. | ||
29 | */ | ||
30 | |||
31 | #include "linden_common.h" | ||
32 | #include "lltut.h" | ||
33 | #include "v3color.h" | ||
34 | #include "v4math.h" | ||
35 | #include "m4math.h" | ||
36 | #include "llsdutil.h" | ||
37 | |||
38 | |||
39 | namespace tut | ||
40 | { | ||
41 | struct llsdutil_data | ||
42 | { | ||
43 | }; | ||
44 | typedef test_group<llsdutil_data> llsdutil_test;; | ||
45 | typedef llsdutil_test::object llsdutil_object; | ||
46 | tut::llsdutil_test tutil("llsdutil"); | ||
47 | |||
48 | template<> template<> | ||
49 | void llsdutil_object::test<1>() | ||
50 | { | ||
51 | LLSD sd; | ||
52 | U64 valueIn , valueOut; | ||
53 | valueIn = U64L(0xFEDCBA9876543210); | ||
54 | sd = ll_sd_from_U64(valueIn); | ||
55 | valueOut = ll_U64_from_sd(sd); | ||
56 | ensure_equals("U64 valueIn->sd->valueOut", valueIn, valueOut); | ||
57 | } | ||
58 | |||
59 | template<> template<> | ||
60 | void llsdutil_object::test<2>() | ||
61 | { | ||
62 | LLSD sd; | ||
63 | U32 valueIn, valueOut; | ||
64 | valueIn = 0x87654321; | ||
65 | sd = ll_sd_from_U32(valueIn); | ||
66 | valueOut = ll_U32_from_sd(sd); | ||
67 | ensure_equals("U32 valueIn->sd->valueOut", valueIn, valueOut); | ||
68 | } | ||
69 | |||
70 | template<> template<> | ||
71 | void llsdutil_object::test<3>() | ||
72 | { | ||
73 | U32 valueIn, valueOut; | ||
74 | valueIn = 0x87654321; | ||
75 | LLSD sd; | ||
76 | sd = ll_sd_from_ipaddr(valueIn); | ||
77 | valueOut = ll_ipaddr_from_sd(sd); | ||
78 | ensure_equals("valueIn->sd->valueOut", valueIn, valueOut); | ||
79 | } | ||
80 | |||
81 | template<> template<> | ||
82 | void llsdutil_object::test<4>() | ||
83 | { | ||
84 | LLSD sd; | ||
85 | LLVector3 vec1(-1.0, 2.0, -3.0); | ||
86 | sd = ll_sd_from_vector3(vec1); | ||
87 | LLVector3 vec2 = ll_vector3_from_sd(sd); | ||
88 | ensure_equals("vector3 -> sd -> vector3: 1", vec1, vec2); | ||
89 | |||
90 | LLVector3 vec3(sd); | ||
91 | ensure_equals("vector3 -> sd -> vector3: 2", vec1, vec3); | ||
92 | |||
93 | sd.clear(); | ||
94 | vec1.setVec(0., 0., 0.); | ||
95 | sd = ll_sd_from_vector3(vec1); | ||
96 | vec2 = ll_vector3_from_sd(sd); | ||
97 | ensure_equals("vector3 -> sd -> vector3: 3", vec1, vec2); | ||
98 | sd.clear(); | ||
99 | } | ||
100 | |||
101 | template<> template<> | ||
102 | void llsdutil_object::test<5>() | ||
103 | { | ||
104 | LLSD sd; | ||
105 | LLVector3d vec1((F64)(U64L(0xFEDCBA9876543210) << 2), -1., 0); | ||
106 | sd = ll_sd_from_vector3d(vec1); | ||
107 | LLVector3d vec2 = ll_vector3d_from_sd(sd); | ||
108 | ensure_equals("vector3d -> sd -> vector3d: 1", vec1, vec2); | ||
109 | |||
110 | LLVector3d vec3(sd); | ||
111 | ensure_equals("vector3d -> sd -> vector3d : 2", vec1, vec3); | ||
112 | } | ||
113 | |||
114 | template<> template<> | ||
115 | void llsdutil_object::test<6>() | ||
116 | { | ||
117 | LLSD sd; | ||
118 | LLVector2 vec((F32) -3., (F32) 4.2); | ||
119 | sd = ll_sd_from_vector2(vec); | ||
120 | LLVector2 vec1 = ll_vector2_from_sd(sd); | ||
121 | ensure_equals("vector2 -> sd -> vector2", vec, vec1); | ||
122 | |||
123 | LLSD sd2 = ll_sd_from_vector2(vec1); | ||
124 | ensure_equals("sd -> vector2 -> sd: 2", sd, sd2); | ||
125 | } | ||
126 | |||
127 | template<> template<> | ||
128 | void llsdutil_object::test<7>() | ||
129 | { | ||
130 | LLSD sd; | ||
131 | LLQuaternion quat((F32) 1., (F32) -0.98, (F32) 2.3, (F32) 0xffff); | ||
132 | sd = ll_sd_from_quaternion(quat); | ||
133 | LLQuaternion quat1 = ll_quaternion_from_sd(sd); | ||
134 | ensure_equals("LLQuaternion -> sd -> LLQuaternion", quat, quat1); | ||
135 | |||
136 | LLSD sd2 = ll_sd_from_quaternion(quat1); | ||
137 | ensure_equals("sd -> LLQuaternion -> sd ", sd, sd2); | ||
138 | } | ||
139 | |||
140 | template<> template<> | ||
141 | void llsdutil_object::test<8>() | ||
142 | { | ||
143 | LLSD sd; | ||
144 | LLColor4 c(1.0f, 2.2f, 4.0f, 7.f); | ||
145 | sd = ll_sd_from_color4(c); | ||
146 | LLColor4 c1 =ll_color4_from_sd(sd); | ||
147 | ensure_equals("LLColor4 -> sd -> LLColor4", c, c1); | ||
148 | |||
149 | LLSD sd1 = ll_sd_from_color4(c1); | ||
150 | ensure_equals("sd -> LLColor4 -> sd", sd, sd1); | ||
151 | } | ||
152 | } | ||