aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/test/llsd_message_system_tut.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/test/llsd_message_system_tut.cpp')
-rw-r--r--linden/indra/test/llsd_message_system_tut.cpp248
1 files changed, 125 insertions, 123 deletions
diff --git a/linden/indra/test/llsd_message_system_tut.cpp b/linden/indra/test/llsd_message_system_tut.cpp
index b46701c..9fcc6b5 100644
--- a/linden/indra/test/llsd_message_system_tut.cpp
+++ b/linden/indra/test/llsd_message_system_tut.cpp
@@ -1,8 +1,8 @@
1/** 1/**
2 * @file llsd_message_system_tut.cpp 2 * @file llsd_message_system_tut.cpp
3 * @brief Testing the LLSDMessageSystem. 3 * @brief Testing the LLSDMessageSystem.
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab 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 8 * to you under the terms of the GNU General Public License, version 2.0
@@ -22,121 +22,123 @@
22 * 22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO 23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, 24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE. 25 * COMPLETENESS OR PERFORMANCE.
26 */ 26 */
27 27
28/** 28/**
29 * 29 *
30 * These classes test the LLSDMessageSystem. 30 * These classes test the LLSDMessageSystem.
31 * 31 *
32 */ 32 */
33 33
34#include <tut/tut.h> 34#include "linden_common.h"
35#include "llsdmessagesystem.h" 35
36#include "llsdutil.h" 36#include <tut/tut.h>
37 37#include "llsdmessagesystem.h"
38namespace tut 38#include "llsdutil.h"
39{ 39
40 class LLSDMessageSystemTestData 40namespace tut
41 { 41{
42 public: 42 class LLSDMessageSystemTestData
43 LLSDMessageSystemTestData() {;} 43 {
44 ~LLSDMessageSystemTestData() {;} 44 public:
45 45 LLSDMessageSystemTestData() {;}
46 LLSDMessageSystem mMsgSystem; 46 ~LLSDMessageSystemTestData() {;}
47 }; 47
48 48 LLSDMessageSystem mMsgSystem;
49 typedef test_group<LLSDMessageSystemTestData> LLSDMessageSystemTestGroup; 49 };
50 typedef LLSDMessageSystemTestGroup::object LLSDMessageSystemTestObject; 50
51 LLSDMessageSystemTestGroup llsdMessageSystemTestGroup("llsd_message_system"); 51 typedef test_group<LLSDMessageSystemTestData> LLSDMessageSystemTestGroup;
52 52 typedef LLSDMessageSystemTestGroup::object LLSDMessageSystemTestObject;
53 template<> template<> 53 LLSDMessageSystemTestGroup llsdMessageSystemTestGroup("llsd_message_system");
54 void LLSDMessageSystemTestObject::test<1>() 54
55 { 55 template<> template<>
56 LLSD input; 56 void LLSDMessageSystemTestObject::test<1>()
57 U32 valueIn, valueOut; 57 {
58 valueIn = 42; 58 LLSD input;
59 input["Block"]["Var"] = ll_sd_from_U32(valueIn); 59 U32 valueIn, valueOut;
60 mMsgSystem.setInput(input); 60 valueIn = 42;
61 mMsgSystem.getU32Fast("Block", "Var", valueOut); 61 input["Block"]["Var"] = ll_sd_from_U32(valueIn);
62 ensure_equals("U32 from message system matches input U32", valueIn, valueOut); 62 mMsgSystem.setInput(input);
63 } 63 mMsgSystem.getU32Fast("Block", "Var", valueOut);
64 64 ensure_equals("U32 from message system matches input U32", valueIn, valueOut);
65 template<> template<> 65 }
66 void LLSDMessageSystemTestObject::test<2>() 66
67 { 67 template<> template<>
68 LLSD input; 68 void LLSDMessageSystemTestObject::test<2>()
69 LLUUID valueIn, valueOut; 69 {
70 valueIn.generate(); 70 LLSD input;
71 input["Block"]["Var"] = valueIn; 71 LLUUID valueIn, valueOut;
72 mMsgSystem.setInput(input); 72 valueIn.generate();
73 mMsgSystem.getUUIDFast("Block", "Var", valueOut); 73 input["Block"]["Var"] = valueIn;
74 ensure_equals("UUID from message system matches input UUID", valueIn, valueOut); 74 mMsgSystem.setInput(input);
75 } 75 mMsgSystem.getUUIDFast("Block", "Var", valueOut);
76 76 ensure_equals("UUID from message system matches input UUID", valueIn, valueOut);
77 template<> template<> 77 }
78 void LLSDMessageSystemTestObject::test<3>() 78
79 { 79 template<> template<>
80 LLSD input; 80 void LLSDMessageSystemTestObject::test<3>()
81 U32 valueIn, valueOut; 81 {
82 LLHost host("127.0.0.1:80"); 82 LLSD input;
83 valueIn = host.getAddress(); 83 U32 valueIn, valueOut;
84 input["Block"]["Var"] = ll_sd_from_U32(valueIn); 84 LLHost host("127.0.0.1:80");
85 mMsgSystem.setInput(input); 85 valueIn = host.getAddress();
86 mMsgSystem.getIPAddrFast("Block", "Var", valueOut); 86 input["Block"]["Var"] = ll_sd_from_U32(valueIn);
87 ensure_equals("IP from message system matches input IP", valueIn, valueOut); 87 mMsgSystem.setInput(input);
88 } 88 mMsgSystem.getIPAddrFast("Block", "Var", valueOut);
89 89 ensure_equals("IP from message system matches input IP", valueIn, valueOut);
90 template<> template<> 90 }
91 void LLSDMessageSystemTestObject::test<4>() 91
92 { 92 template<> template<>
93 LLSD input; 93 void LLSDMessageSystemTestObject::test<4>()
94 U16 valueIn, valueOut; 94 {
95 LLHost host("127.0.0.1:80"); 95 LLSD input;
96 valueIn = host.getPort(); 96 U16 valueIn, valueOut;
97 input["Block"]["Var"] = (S32)valueIn; 97 LLHost host("127.0.0.1:80");
98 mMsgSystem.setInput(input); 98 valueIn = host.getPort();
99 mMsgSystem.getIPPortFast("Block", "Var", valueOut); 99 input["Block"]["Var"] = (S32)valueIn;
100 ensure_equals("Port from message system matches input port", valueIn, valueOut); 100 mMsgSystem.setInput(input);
101 } 101 mMsgSystem.getIPPortFast("Block", "Var", valueOut);
102 102 ensure_equals("Port from message system matches input port", valueIn, valueOut);
103 template<> template<> 103 }
104 void LLSDMessageSystemTestObject::test<5>() 104
105 { 105 template<> template<>
106 LLSD input; 106 void LLSDMessageSystemTestObject::test<5>()
107 U64 valueIn, valueOut; 107 {
108 valueIn = 42; 108 LLSD input;
109 input["Block"]["Var"] = ll_sd_from_U64(valueIn); 109 U64 valueIn, valueOut;
110 mMsgSystem.setInput(input); 110 valueIn = 42;
111 mMsgSystem.getU64Fast("Block", "Var", valueOut); 111 input["Block"]["Var"] = ll_sd_from_U64(valueIn);
112 ensure_equals("Port from message system matches input port", valueIn, valueOut); 112 mMsgSystem.setInput(input);
113 } 113 mMsgSystem.getU64Fast("Block", "Var", valueOut);
114 114 ensure_equals("Port from message system matches input port", valueIn, valueOut);
115 template<> template<> 115 }
116 void LLSDMessageSystemTestObject::test<6>() 116
117 { 117 template<> template<>
118 LLSD input; 118 void LLSDMessageSystemTestObject::test<6>()
119 std::string valueIn = "Value"; 119 {
120 input["Block"]["Var"] = valueIn; 120 LLSD input;
121 mMsgSystem.setInput(input); 121 std::string valueIn = "Value";
122 const U32 buffLen = 16; 122 input["Block"]["Var"] = valueIn;
123 char buff[buffLen]; 123 mMsgSystem.setInput(input);
124 mMsgSystem.getStringFast("Block", "Var", buffLen, buff); 124 const U32 buffLen = 16;
125 ensure_equals("string read from message system matches llsd input", std::string(buff), valueIn); 125 char buff[buffLen];
126 } 126 mMsgSystem.getStringFast("Block", "Var", buffLen, buff);
127 127 ensure_equals("string read from message system matches llsd input", std::string(buff), valueIn);
128 template<> template<> 128 }
129 void LLSDMessageSystemTestObject::test<7>() 129
130 { 130 template<> template<>
131 LLSD input; 131 void LLSDMessageSystemTestObject::test<7>()
132 U32 valueIn, valueOut; 132 {
133 valueIn = 42; 133 LLSD input;
134 input["Block"][0]["Var"] = ll_sd_from_U32(valueIn); 134 U32 valueIn, valueOut;
135 input["Block"][1]["Var"] = ll_sd_from_U32(valueIn + 1); 135 valueIn = 42;
136 mMsgSystem.setInput(input); 136 input["Block"][0]["Var"] = ll_sd_from_U32(valueIn);
137 mMsgSystem.getU32Fast("Block", "Var", valueOut, 0); 137 input["Block"][1]["Var"] = ll_sd_from_U32(valueIn + 1);
138 ensure_equals("U32 from message system matches input U32", valueIn, valueOut); 138 mMsgSystem.setInput(input);
139 mMsgSystem.getU32Fast("Block", "Var", valueOut, 1); 139 mMsgSystem.getU32Fast("Block", "Var", valueOut, 0);
140 ensure_equals("U32 from message system matches input U32", (valueIn + 1), valueOut); 140 ensure_equals("U32 from message system matches input U32", valueIn, valueOut);
141 } 141 mMsgSystem.getU32Fast("Block", "Var", valueOut, 1);
142} 142 ensure_equals("U32 from message system matches input U32", (valueIn + 1), valueOut);
143 }
144}