diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/test/llsd_message_system_tut.cpp | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/linden/indra/test/llsd_message_system_tut.cpp b/linden/indra/test/llsd_message_system_tut.cpp new file mode 100644 index 0000000..b46701c --- /dev/null +++ b/linden/indra/test/llsd_message_system_tut.cpp | |||
@@ -0,0 +1,142 @@ | |||
1 | /** | ||
2 | * @file llsd_message_system_tut.cpp | ||
3 | * @brief Testing the LLSDMessageSystem. | ||
4 | * | ||
5 | * Copyright (c) 2006-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | /** | ||
29 | * | ||
30 | * These classes test the LLSDMessageSystem. | ||
31 | * | ||
32 | */ | ||
33 | |||
34 | #include <tut/tut.h> | ||
35 | #include "llsdmessagesystem.h" | ||
36 | #include "llsdutil.h" | ||
37 | |||
38 | namespace tut | ||
39 | { | ||
40 | class LLSDMessageSystemTestData | ||
41 | { | ||
42 | public: | ||
43 | LLSDMessageSystemTestData() {;} | ||
44 | ~LLSDMessageSystemTestData() {;} | ||
45 | |||
46 | LLSDMessageSystem mMsgSystem; | ||
47 | }; | ||
48 | |||
49 | typedef test_group<LLSDMessageSystemTestData> LLSDMessageSystemTestGroup; | ||
50 | typedef LLSDMessageSystemTestGroup::object LLSDMessageSystemTestObject; | ||
51 | LLSDMessageSystemTestGroup llsdMessageSystemTestGroup("llsd_message_system"); | ||
52 | |||
53 | template<> template<> | ||
54 | void LLSDMessageSystemTestObject::test<1>() | ||
55 | { | ||
56 | LLSD input; | ||
57 | U32 valueIn, valueOut; | ||
58 | valueIn = 42; | ||
59 | input["Block"]["Var"] = ll_sd_from_U32(valueIn); | ||
60 | mMsgSystem.setInput(input); | ||
61 | mMsgSystem.getU32Fast("Block", "Var", valueOut); | ||
62 | ensure_equals("U32 from message system matches input U32", valueIn, valueOut); | ||
63 | } | ||
64 | |||
65 | template<> template<> | ||
66 | void LLSDMessageSystemTestObject::test<2>() | ||
67 | { | ||
68 | LLSD input; | ||
69 | LLUUID valueIn, valueOut; | ||
70 | valueIn.generate(); | ||
71 | input["Block"]["Var"] = valueIn; | ||
72 | mMsgSystem.setInput(input); | ||
73 | mMsgSystem.getUUIDFast("Block", "Var", valueOut); | ||
74 | ensure_equals("UUID from message system matches input UUID", valueIn, valueOut); | ||
75 | } | ||
76 | |||
77 | template<> template<> | ||
78 | void LLSDMessageSystemTestObject::test<3>() | ||
79 | { | ||
80 | LLSD input; | ||
81 | U32 valueIn, valueOut; | ||
82 | LLHost host("127.0.0.1:80"); | ||
83 | valueIn = host.getAddress(); | ||
84 | input["Block"]["Var"] = ll_sd_from_U32(valueIn); | ||
85 | mMsgSystem.setInput(input); | ||
86 | mMsgSystem.getIPAddrFast("Block", "Var", valueOut); | ||
87 | ensure_equals("IP from message system matches input IP", valueIn, valueOut); | ||
88 | } | ||
89 | |||
90 | template<> template<> | ||
91 | void LLSDMessageSystemTestObject::test<4>() | ||
92 | { | ||
93 | LLSD input; | ||
94 | U16 valueIn, valueOut; | ||
95 | LLHost host("127.0.0.1:80"); | ||
96 | valueIn = host.getPort(); | ||
97 | input["Block"]["Var"] = (S32)valueIn; | ||
98 | mMsgSystem.setInput(input); | ||
99 | mMsgSystem.getIPPortFast("Block", "Var", valueOut); | ||
100 | ensure_equals("Port from message system matches input port", valueIn, valueOut); | ||
101 | } | ||
102 | |||
103 | template<> template<> | ||
104 | void LLSDMessageSystemTestObject::test<5>() | ||
105 | { | ||
106 | LLSD input; | ||
107 | U64 valueIn, valueOut; | ||
108 | valueIn = 42; | ||
109 | input["Block"]["Var"] = ll_sd_from_U64(valueIn); | ||
110 | mMsgSystem.setInput(input); | ||
111 | mMsgSystem.getU64Fast("Block", "Var", valueOut); | ||
112 | ensure_equals("Port from message system matches input port", valueIn, valueOut); | ||
113 | } | ||
114 | |||
115 | template<> template<> | ||
116 | void LLSDMessageSystemTestObject::test<6>() | ||
117 | { | ||
118 | LLSD input; | ||
119 | std::string valueIn = "Value"; | ||
120 | input["Block"]["Var"] = valueIn; | ||
121 | mMsgSystem.setInput(input); | ||
122 | const U32 buffLen = 16; | ||
123 | char buff[buffLen]; | ||
124 | mMsgSystem.getStringFast("Block", "Var", buffLen, buff); | ||
125 | ensure_equals("string read from message system matches llsd input", std::string(buff), valueIn); | ||
126 | } | ||
127 | |||
128 | template<> template<> | ||
129 | void LLSDMessageSystemTestObject::test<7>() | ||
130 | { | ||
131 | LLSD input; | ||
132 | U32 valueIn, valueOut; | ||
133 | valueIn = 42; | ||
134 | input["Block"][0]["Var"] = ll_sd_from_U32(valueIn); | ||
135 | input["Block"][1]["Var"] = ll_sd_from_U32(valueIn + 1); | ||
136 | mMsgSystem.setInput(input); | ||
137 | mMsgSystem.getU32Fast("Block", "Var", valueOut, 0); | ||
138 | ensure_equals("U32 from message system matches input U32", valueIn, valueOut); | ||
139 | mMsgSystem.getU32Fast("Block", "Var", valueOut, 1); | ||
140 | ensure_equals("U32 from message system matches input U32", (valueIn + 1), valueOut); | ||
141 | } | ||
142 | } | ||