aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/test
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/test')
-rw-r--r--linden/indra/test/common.cpp173
-rw-r--r--linden/indra/test/files.lst5
-rw-r--r--linden/indra/test/inventory.cpp1
-rw-r--r--linden/indra/test/io.cpp129
-rw-r--r--linden/indra/test/llapp_tut.cpp1
-rw-r--r--linden/indra/test/llbase64_tut.cpp1
-rw-r--r--linden/indra/test/llblowfish_tut.cpp1
-rw-r--r--linden/indra/test/llerror_tut.cpp1
-rw-r--r--linden/indra/test/llhttpclient_tut.cpp3
-rw-r--r--linden/indra/test/llhttpnode_tut.cpp1
-rw-r--r--linden/indra/test/lliohttpserver_tut.cpp30
-rw-r--r--linden/indra/test/llmessageconfig_tut.cpp227
-rw-r--r--linden/indra/test/llmime_tut.cpp1
-rw-r--r--linden/indra/test/llpipeutil.cpp1
-rw-r--r--linden/indra/test/llpipeutil.h1
-rwxr-xr-xlinden/indra/test/llrandom_tut.cpp1
-rw-r--r--linden/indra/test/llsd_message_system_tut.cpp144
-rw-r--r--linden/indra/test/llsd_new_tut.cpp78
-rwxr-xr-xlinden/indra/test/llsdmessagebuilder_tut.cpp279
-rwxr-xr-xlinden/indra/test/llsdmessagereader_tut.cpp320
-rw-r--r--linden/indra/test/llsdserialize_tut.cpp25
-rw-r--r--linden/indra/test/llsdtraits.h78
-rw-r--r--linden/indra/test/llservicebuilder_tut.cpp96
-rw-r--r--linden/indra/test/lltiming_tut.cpp1
-rw-r--r--linden/indra/test/lltut.cpp1
-rw-r--r--linden/indra/test/lltut.h17
-rw-r--r--linden/indra/test/lluri_tut.cpp12
-rw-r--r--linden/indra/test/lluserrelations_tut.cpp1
-rw-r--r--linden/indra/test/math.cpp143
-rw-r--r--linden/indra/test/reflection_tut.cpp1
-rw-r--r--linden/indra/test/test.cpp24
-rw-r--r--linden/indra/test/test.vcproj15
-rw-r--r--linden/indra/test/test_llmanifest.py3
33 files changed, 1577 insertions, 238 deletions
diff --git a/linden/indra/test/common.cpp b/linden/indra/test/common.cpp
index 97ff21c..2a88ba0 100644
--- a/linden/indra/test/common.cpp
+++ b/linden/indra/test/common.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * 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 * 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 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -43,6 +44,7 @@
43#include "llmemorystream.h" 44#include "llmemorystream.h"
44#include "llsd.h" 45#include "llsd.h"
45#include "llsdserialize.h" 46#include "llsdserialize.h"
47#include "u64.h"
46 48
47namespace tut 49namespace tut
48{ 50{
@@ -445,3 +447,174 @@ namespace tut
445 } 447 }
446} 448}
447 449
450namespace tut
451{
452 struct U64_data
453 {
454 };
455 typedef test_group<U64_data> U64_test;
456 typedef U64_test::object U64_object;
457 tut::U64_test U64_testcase("U64_conversion");
458
459 // U64_to_str
460 template<> template<>
461 void U64_object::test<1>()
462 {
463 U64 val;
464 std::string val_str;
465 char result[256];
466 std::string result_str;
467
468 val = U64L(18446744073709551610); // slightly less than MAX_U64
469 val_str = "18446744073709551610";
470
471 U64_to_str(val, result, sizeof(result));
472 result_str = (const char*) result;
473 ensure_equals("U64_to_str converted 1.1", val_str, result_str);
474
475 val = 0;
476 val_str = "0";
477 U64_to_str(val, result, sizeof(result));
478 result_str = (const char*) result;
479 ensure_equals("U64_to_str converted 1.2", val_str, result_str);
480
481 val = U64L(18446744073709551615); // 0xFFFFFFFFFFFFFFFF
482 val_str = "18446744073709551615";
483 U64_to_str(val, result, sizeof(result));
484 result_str = (const char*) result;
485 ensure_equals("U64_to_str converted 1.3", val_str, result_str);
486
487 // overflow - will result in warning at compile time
488 val = U64L(18446744073709551615) + 1; // overflow 0xFFFFFFFFFFFFFFFF + 1 == 0
489 val_str = "0";
490 U64_to_str(val, result, sizeof(result));
491 result_str = (const char*) result;
492 ensure_equals("U64_to_str converted 1.4", val_str, result_str);
493
494 val = U64L(-1); // 0xFFFFFFFFFFFFFFFF == 18446744073709551615
495 val_str = "18446744073709551615";
496 U64_to_str(val, result, sizeof(result));
497 result_str = (const char*) result;
498 ensure_equals("U64_to_str converted 1.5", val_str, result_str);
499
500 val = U64L(10000000000000000000); // testing preserving of 0s
501 val_str = "10000000000000000000";
502 U64_to_str(val, result, sizeof(result));
503 result_str = (const char*) result;
504 ensure_equals("U64_to_str converted 1.6", val_str, result_str);
505
506 val = 1; // testing no leading 0s
507 val_str = "1";
508 U64_to_str(val, result, sizeof(result));
509 result_str = (const char*) result;
510 ensure_equals("U64_to_str converted 1.7", val_str, result_str);
511
512 val = U64L(18446744073709551615); // testing exact sized buffer for result
513 val_str = "18446744073709551615";
514 memset(result, 'A', sizeof(result)); // initialize buffer with all 'A'
515 U64_to_str(val, result, sizeof("18446744073709551615")); //pass in the exact size
516 result_str = (const char*) result;
517 ensure_equals("U64_to_str converted 1.8", val_str, result_str);
518
519 val = U64L(18446744073709551615); // testing smaller sized buffer for result
520 val_str = "1844";
521 memset(result, 'A', sizeof(result)); // initialize buffer with all 'A'
522 U64_to_str(val, result, 5); //pass in a size of 5. should only copy first 4 integers and add a null terminator
523 result_str = (const char*) result;
524 ensure_equals("U64_to_str converted 1.9", val_str, result_str);
525 }
526
527 // str_to_U64
528 template<> template<>
529 void U64_object::test<2>()
530 {
531 U64 val;
532 U64 result;
533
534 val = U64L(18446744073709551610); // slightly less than MAX_U64
535 result = str_to_U64("18446744073709551610");
536 ensure_equals("str_to_U64 converted 2.1", val, result);
537
538 val = U64L(0); // empty string
539 result = str_to_U64("");
540 ensure_equals("str_to_U64 converted 2.2", val, result);
541
542 val = U64L(0); // 0
543 result = str_to_U64("0");
544 ensure_equals("str_to_U64 converted 2.3", val, result);
545
546 val = U64L(18446744073709551615); // 0xFFFFFFFFFFFFFFFF
547 result = str_to_U64("18446744073709551615");
548 ensure_equals("str_to_U64 converted 2.4", val, result);
549
550 // overflow - will result in warning at compile time
551 val = U64L(18446744073709551615) + 1; // overflow 0xFFFFFFFFFFFFFFFF + 1 == 0
552 result = str_to_U64("18446744073709551616");
553 ensure_equals("str_to_U64 converted 2.5", val, result);
554
555 val = U64L(1234); // process till first non-integral character
556 result = str_to_U64("1234A5678");
557 ensure_equals("str_to_U64 converted 2.6", val, result);
558
559 val = U64L(5678); // skip all non-integral characters
560 result = str_to_U64("ABCD5678");
561 ensure_equals("str_to_U64 converted 2.7", val, result);
562
563 // should it skip negative sign and process
564 // rest of string or return 0
565 val = U64L(1234); // skip initial negative sign
566 result = str_to_U64("-1234");
567 ensure_equals("str_to_U64 converted 2.8", val, result);
568
569 val = U64L(5678); // stop at negative sign in the middle
570 result = str_to_U64("5678-1234");
571 ensure_equals("str_to_U64 converted 2.9", val, result);
572
573 val = U64L(0); // no integers
574 result = str_to_U64("AaCD");
575 ensure_equals("str_to_U64 converted 2.10", val, result);
576 }
577
578 // U64_to_F64
579 template<> template<>
580 void U64_object::test<3>()
581 {
582 F64 val;
583 F64 result;
584
585 result = 18446744073709551610.0;
586 val = U64_to_F64(U64L(18446744073709551610));
587 ensure_equals("U64_to_F64 converted 3.1", val, result);
588
589 result = 18446744073709551615.0; // 0xFFFFFFFFFFFFFFFF
590 val = U64_to_F64(U64L(18446744073709551615));
591 ensure_equals("U64_to_F64 converted 3.2", val, result);
592
593 result = 0.0; // overflow 0xFFFFFFFFFFFFFFFF + 1 == 0
594 // overflow - will result in warning at compile time
595 val = U64_to_F64(U64L(18446744073709551615)+1);
596 ensure_equals("U64_to_F64 converted 3.3", val, result);
597
598 result = 0.0; // 0
599 val = U64_to_F64(U64L(0));
600 ensure_equals("U64_to_F64 converted 3.4", val, result);
601
602 result = 1.0; // odd
603 val = U64_to_F64(U64L(1));
604 ensure_equals("U64_to_F64 converted 3.5", val, result);
605
606 result = 2.0; // even
607 val = U64_to_F64(U64L(2));
608 ensure_equals("U64_to_F64 converted 3.6", val, result);
609
610 result = U64L(0x7FFFFFFFFFFFFFFF) * 1.0L; // 0x7FFFFFFFFFFFFFFF
611 val = U64_to_F64(U64L(0x7FFFFFFFFFFFFFFF));
612 ensure_equals("U64_to_F64 converted 3.7", val, result);
613 }
614
615 // llstrtou64
616 // seems to be deprecated - could not find it being used
617 // anywhere in the tarball - skipping unit tests for now
618}
619
620
diff --git a/linden/indra/test/files.lst b/linden/indra/test/files.lst
index 77ce9f4..b04b0ac 100644
--- a/linden/indra/test/files.lst
+++ b/linden/indra/test/files.lst
@@ -9,11 +9,14 @@ test/llhttpclient_tut.cpp
9test/llhttpnode_tut.cpp 9test/llhttpnode_tut.cpp
10test/lliohttpserver_tut.cpp 10test/lliohttpserver_tut.cpp
11test/llmime_tut.cpp 11test/llmime_tut.cpp
12test/llmessageconfig_tut.cpp
12test/llpipeutil.cpp 13test/llpipeutil.cpp
13test/llrandom_tut.cpp 14test/llrandom_tut.cpp
15test/llsdmessagebuilder_tut.cpp
16test/llsdmessagereader_tut.cpp
14test/llsd_new_tut.cpp 17test/llsd_new_tut.cpp
15test/llsdserialize_tut.cpp 18test/llsdserialize_tut.cpp
16test/llsd_message_system_tut.cpp 19test/llservicebuilder_tut.cpp
17test/lltiming_tut.cpp 20test/lltiming_tut.cpp
18test/lltut.cpp 21test/lltut.cpp
19test/lluri_tut.cpp 22test/lluri_tut.cpp
diff --git a/linden/indra/test/inventory.cpp b/linden/indra/test/inventory.cpp
index 2099da3..0539910 100644
--- a/linden/indra/test/inventory.cpp
+++ b/linden/indra/test/inventory.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * 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 * 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 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/test/io.cpp b/linden/indra/test/io.cpp
index a86711a..412c010 100644
--- a/linden/indra/test/io.cpp
+++ b/linden/indra/test/io.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * 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 * 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 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -50,6 +51,101 @@
50 51
51namespace tut 52namespace tut
52{ 53{
54 struct heap_buffer_data
55 {
56 heap_buffer_data() : mBuffer(NULL) {}
57 ~heap_buffer_data() { if(mBuffer) delete mBuffer; }
58 LLHeapBuffer* mBuffer;
59 };
60 typedef test_group<heap_buffer_data> heap_buffer_test;
61 typedef heap_buffer_test::object heap_buffer_object;
62 tut::heap_buffer_test thb("heap_buffer");
63
64 template<> template<>
65 void heap_buffer_object::test<1>()
66 {
67 const S32 BUF_SIZE = 100;
68 mBuffer = new LLHeapBuffer(BUF_SIZE);
69 ensure_equals("empty buffer capacity", mBuffer->capacity(), BUF_SIZE);
70 const S32 SEGMENT_SIZE = 50;
71 LLSegment segment;
72 mBuffer->createSegment(0, SEGMENT_SIZE, segment);
73 ensure_equals("used buffer capacity", mBuffer->capacity(), BUF_SIZE);
74 }
75
76 template<> template<>
77 void heap_buffer_object::test<2>()
78 {
79 const S32 BUF_SIZE = 10;
80 mBuffer = new LLHeapBuffer(BUF_SIZE);
81 LLSegment segment;
82 mBuffer->createSegment(0, BUF_SIZE, segment);
83 ensure("segment is in buffer", mBuffer->containsSegment(segment));
84 ensure_equals("buffer consumed", mBuffer->bytesLeft(), 0);
85 bool created;
86 created = mBuffer->createSegment(0, 0, segment);
87 ensure("Create zero size segment fails", !created);
88 created = mBuffer->createSegment(0, BUF_SIZE, segment);
89 ensure("Create segment fails", !created);
90 }
91
92 template<> template<>
93 void heap_buffer_object::test<3>()
94 {
95 const S32 BUF_SIZE = 10;
96 mBuffer = new LLHeapBuffer(BUF_SIZE);
97 LLSegment segment;
98 mBuffer->createSegment(0, BUF_SIZE, segment);
99 ensure("segment is in buffer", mBuffer->containsSegment(segment));
100 ensure_equals("buffer consumed", mBuffer->bytesLeft(), 0);
101 bool reclaimed = mBuffer->reclaimSegment(segment);
102 ensure("buffer reclaimed.", reclaimed);
103 ensure_equals("buffer available", mBuffer->bytesLeft(), BUF_SIZE);
104 bool created;
105 created = mBuffer->createSegment(0, 0, segment);
106 ensure("Create zero size segment fails", !created);
107 created = mBuffer->createSegment(0, BUF_SIZE, segment);
108 ensure("Create another segment succeeds", created);
109 }
110
111 template<> template<>
112 void heap_buffer_object::test<4>()
113 {
114 const S32 BUF_SIZE = 10;
115 const S32 SEGMENT_SIZE = 4;
116 mBuffer = new LLHeapBuffer(BUF_SIZE);
117 LLSegment seg1;
118 mBuffer->createSegment(0, SEGMENT_SIZE, seg1);
119 ensure("segment is in buffer", mBuffer->containsSegment(seg1));
120 LLSegment seg2;
121 mBuffer->createSegment(0, SEGMENT_SIZE, seg2);
122 ensure("segment is in buffer", mBuffer->containsSegment(seg2));
123 LLSegment seg3;
124 mBuffer->createSegment(0, SEGMENT_SIZE, seg3);
125 ensure("segment is in buffer", mBuffer->containsSegment(seg3));
126 ensure_equals("segment is truncated", seg3.size(), 2);
127 LLSegment seg4;
128 bool created;
129 created = mBuffer->createSegment(0, SEGMENT_SIZE, seg4);
130 ensure("Create segment fails", !created);
131 bool reclaimed;
132 reclaimed = mBuffer->reclaimSegment(seg1);
133 ensure("buffer reclaim succeed.", reclaimed);
134 ensure_equals("no buffer available", mBuffer->bytesLeft(), 0);
135 reclaimed = mBuffer->reclaimSegment(seg2);
136 ensure("buffer reclaim succeed.", reclaimed);
137 ensure_equals("buffer reclaimed", mBuffer->bytesLeft(), 0);
138 reclaimed = mBuffer->reclaimSegment(seg3);
139 ensure("buffer reclaim succeed.", reclaimed);
140 ensure_equals("buffer reclaimed", mBuffer->bytesLeft(), BUF_SIZE);
141 created = mBuffer->createSegment(0, SEGMENT_SIZE, seg1);
142 ensure("segment is in buffer", mBuffer->containsSegment(seg1));
143 ensure("Create segment succeds", created);
144 }
145}
146
147namespace tut
148{
53 struct buffer_data 149 struct buffer_data
54 { 150 {
55 LLBufferArray mBuffer; 151 LLBufferArray mBuffer;
@@ -228,6 +324,37 @@ namespace tut
228 delete[] temp; 324 delete[] temp;
229 } 325 }
230 326
327 template<> template<>
328 void buffer_object::test<9>()
329 {
330 LLChannelDescriptors ch = mBuffer.nextChannel();
331 mBuffer.append(ch.in(), (U8*)"1", 1);
332 S32 capacity = mBuffer.capacity();
333 ensure("has capacity", capacity > 0);
334 U8* temp = new U8[capacity - 1];
335 mBuffer.append(ch.in(), temp, capacity - 1);
336 capacity = mBuffer.capacity();
337 ensure("has capacity when full", capacity > 0);
338 S32 used = mBuffer.countAfter(ch.in(), NULL);
339 ensure_equals("used equals capacity", used, capacity);
340
341 LLBufferArray::segment_iterator_t iter = mBuffer.beginSegment();
342 while(iter != mBuffer.endSegment())
343 {
344 mBuffer.eraseSegment(iter++);
345 }
346
347 used = mBuffer.countAfter(ch.in(), NULL);
348 ensure_equals("used is zero", used, 0);
349 S32 capacity2 = mBuffer.capacity();
350 ensure_equals("capacity the same after erase", capacity2, capacity);
351 mBuffer.append(ch.in(), temp, capacity - 1);
352 capacity2 = mBuffer.capacity();
353 ensure_equals("capacity the same after append", capacity2, capacity);
354
355 delete[] temp;
356 }
357
231#if 0 358#if 0
232 template<> template<> 359 template<> template<>
233 void buffer_object::test<9>() 360 void buffer_object::test<9>()
@@ -287,7 +414,7 @@ namespace tut
287 void bas_object::test<1>() 414 void bas_object::test<1>()
288 { 415 {
289 const char HELLO_WORLD[] = "hello world"; 416 const char HELLO_WORLD[] = "hello world";
290 const S32 str_len = strlen(HELLO_WORLD); /* Flawfinder: ignore */ 417 const S32 str_len = strlen(HELLO_WORLD); /* Flawfinder: ignore */
291 LLChannelDescriptors ch = mBuffer.nextChannel(); 418 LLChannelDescriptors ch = mBuffer.nextChannel();
292 LLBufferStream str(ch, &mBuffer); 419 LLBufferStream str(ch, &mBuffer);
293 mBuffer.append(ch.in(), (U8*)HELLO_WORLD, str_len); 420 mBuffer.append(ch.in(), (U8*)HELLO_WORLD, str_len);
diff --git a/linden/indra/test/llapp_tut.cpp b/linden/indra/test/llapp_tut.cpp
index 3223f91..60995ba 100644
--- a/linden/indra/test/llapp_tut.cpp
+++ b/linden/indra/test/llapp_tut.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc. 6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/test/llbase64_tut.cpp b/linden/indra/test/llbase64_tut.cpp
index fe02397..1d059dce 100644
--- a/linden/indra/test/llbase64_tut.cpp
+++ b/linden/indra/test/llbase64_tut.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2007-2007, Linden Research, Inc. 6 * Copyright (c) 2007-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/test/llblowfish_tut.cpp b/linden/indra/test/llblowfish_tut.cpp
index 0d85ade..ba63860 100644
--- a/linden/indra/test/llblowfish_tut.cpp
+++ b/linden/indra/test/llblowfish_tut.cpp
@@ -9,6 +9,7 @@
9 * 9 *
10 * Copyright (c) 2007-2007, Linden Research, Inc. 10 * Copyright (c) 2007-2007, Linden Research, Inc.
11 * 11 *
12 * Second Life Viewer Source Code
12 * The source code in this file ("Source Code") is provided by Linden Lab 13 * 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 * 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 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/test/llerror_tut.cpp b/linden/indra/test/llerror_tut.cpp
index a4b4258..6c3df43 100644
--- a/linden/indra/test/llerror_tut.cpp
+++ b/linden/indra/test/llerror_tut.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc. 6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/test/llhttpclient_tut.cpp b/linden/indra/test/llhttpclient_tut.cpp
index ef53e71..7918205 100644
--- a/linden/indra/test/llhttpclient_tut.cpp
+++ b/linden/indra/test/llhttpclient_tut.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * 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 * 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 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -235,7 +236,7 @@ namespace tut
235 template<> template<> 236 template<> template<>
236 void HTTPClientTestObject::test<1>() 237 void HTTPClientTestObject::test<1>()
237 { 238 {
238 LLHTTPClient::get("http://www.google.com/", newResult()); 239 LLHTTPClient::get("http://www.secondlife.com/", newResult());
239 runThePump(); 240 runThePump();
240 ensureStatusOK(); 241 ensureStatusOK();
241 ensure("result object wasn't destroyed", mResultDeleted); 242 ensure("result object wasn't destroyed", mResultDeleted);
diff --git a/linden/indra/test/llhttpnode_tut.cpp b/linden/indra/test/llhttpnode_tut.cpp
index 006ba09..fb35f77 100644
--- a/linden/indra/test/llhttpnode_tut.cpp
+++ b/linden/indra/test/llhttpnode_tut.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc. 6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/test/lliohttpserver_tut.cpp b/linden/indra/test/lliohttpserver_tut.cpp
index 1cc94bb..0d914f2 100644
--- a/linden/indra/test/lliohttpserver_tut.cpp
+++ b/linden/indra/test/lliohttpserver_tut.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc. 6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -116,7 +117,7 @@ namespace tut
116 LLSD context; 117 LLSD context;
117 118
118 chain.push_back(LLIOPipe::ptr_t(injector)); 119 chain.push_back(LLIOPipe::ptr_t(injector));
119 LLCreateHTTPPipe(chain, mRoot); 120 LLCreateHTTPPipe(chain, mRoot, LLSD());
120 chain.push_back(LLIOPipe::ptr_t(extractor)); 121 chain.push_back(LLIOPipe::ptr_t(extractor));
121 122
122 pump->addChain(chain, DEFAULT_CHAIN_EXPIRY_SECS); 123 pump->addChain(chain, DEFAULT_CHAIN_EXPIRY_SECS);
@@ -297,6 +298,33 @@ namespace tut
297 ); 298 );
298 } 299 }
299 300
301 template<> template<>
302 void HTTPServiceTestObject::test<7>()
303 {
304 // test large request
305 std::stringstream stream;
306
307 //U32 size = 36 * 1024 * 1024;
308 //U32 size = 36 * 1024;
309 //std::vector<char> data(size);
310 //memset(&(data[0]), '1', size);
311 //data[size - 1] = '\0';
312
313
314 //std::string result = httpPOST("web/echo", &(data[0]));
315
316 stream << "<llsd><array>";
317 for(U32 i = 0; i < 1000000; ++i)
318 {
319 stream << "<integer>42</integer>";
320 }
321 stream << "</array></llsd>";
322 llinfos << "HTTPServiceTestObject::test<7>"
323 << stream.str().length() << llendl;
324 std::string result = httpPOST("web/echo", stream.str());
325 ensure_starts_with("large echo status", result, "HTTP/1.0 200 OK\r\n");
326 }
327
300 /* TO DO: 328 /* TO DO:
301 test generation of not found and method not allowed errors 329 test generation of not found and method not allowed errors
302 */ 330 */
diff --git a/linden/indra/test/llmessageconfig_tut.cpp b/linden/indra/test/llmessageconfig_tut.cpp
new file mode 100644
index 0000000..07e8e72
--- /dev/null
+++ b/linden/indra/test/llmessageconfig_tut.cpp
@@ -0,0 +1,227 @@
1/**
2 * @file llmessageconfig_tut.cpp
3 * @date March 2007
4 * @brief LLMessageConfig unit tests
5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 *
8 * Second Life Viewer Source Code
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 <tut/tut.h>
31#include "lltut.h"
32#include "llmessageconfig.h"
33#include "llsdserialize.h"
34#include "llfile.h"
35#include "lltimer.h"
36#include "llframetimer.h"
37
38namespace tut
39{
40 ///var/tmp/babbage/dev/message-liberation/etc
41 static const char file_name[] = "/tmp/message.xml";
42 static const F32 refreshRate = 6.0*1000.0; // milliseconds
43
44 struct LLMessageConfigTestData {
45
46 LLSD getCurrentConfig()
47 {
48 LLSD data;
49 // store aside the current config to overwrite the test ones
50 // when the test finishes
51 llifstream in_file(file_name);
52 if (in_file.is_open())
53 {
54 LLSDSerialize::fromXML(data, in_file);
55 }
56 return data;
57 }
58
59 void writeConfigFile(const LLSD& config)
60 {
61 LLMessageConfig::initClass("simulator", "/tmp");
62 llofstream file(file_name);
63 if (file.is_open())
64 {
65 LLSDSerialize::toPrettyXML(config, file);
66 }
67 file.close();
68 ms_sleep(refreshRate);
69 LLFrameTimer::updateFrameTime();
70 }
71 };
72
73 typedef test_group<LLMessageConfigTestData> LLMessageConfigTestGroup;
74 typedef LLMessageConfigTestGroup::object LLMessageConfigTestObject;
75 LLMessageConfigTestGroup llMessageConfigTestGroup("LLMessageConfig");
76
77 template<> template<>
78 void LLMessageConfigTestObject::test<1>()
79 // tests server defaults
80 {
81 LLSD config_backup = getCurrentConfig();
82 LLSD config;
83 config["serverDefaults"]["simulator"] = "template";
84 writeConfigFile(config);
85 ensure_equals("Ensure server default is not llsd",
86 LLMessageConfig::isServerDefaultBuilderLLSD(),
87 false);
88 ensure_equals("Ensure server default is template",
89 LLMessageConfig::isServerDefaultBuilderTemplate(),
90 true);
91 writeConfigFile(config_backup);
92 }
93
94 template<> template<>
95 void LLMessageConfigTestObject::test<2>()
96 // tests message builders
97 {
98 LLSD config_backup = getCurrentConfig();
99 LLSD config;
100 config["serverDefaults"]["simulator"] = "template";
101 config["messages"]["msg1"]["builder"] = "template";
102 config["messages"]["msg2"]["builder"] = "llsd";
103 writeConfigFile(config);
104 ensure_equals("Ensure msg template builder not llsd",
105 LLMessageConfig::isMessageBuiltLLSD("msg1"),
106 false);
107 ensure_equals("Ensure msg template builder",
108 LLMessageConfig::isMessageBuiltTemplate("msg1"),
109 true);
110 ensure_equals("Ensure msg llsd builder",
111 LLMessageConfig::isMessageBuiltLLSD("msg2"),
112 true);
113 ensure_equals("Ensure msg llsd builder not template",
114 LLMessageConfig::isMessageBuiltTemplate("msg2"),
115 false);
116 writeConfigFile(config_backup);
117 }
118
119 template<> template<>
120 void LLMessageConfigTestObject::test<4>()
121 // tests message builder defaults
122 {
123 LLSD config_backup = getCurrentConfig();
124 LLSD config;
125 config["serverDefaults"]["simulator"] = "llsd";
126 config["messages"]["msg1"]["trusted-sender"] = true;
127 writeConfigFile(config);
128 ensure_equals("Ensure missing message defaults to server builder, not template",
129 LLMessageConfig::isMessageBuiltTemplate("Test"),
130 false);
131 ensure_equals("Ensure missing message default to server builder llsd",
132 LLMessageConfig::isMessageBuiltLLSD("Test"),
133 true);
134 ensure_equals("Ensure missing builder defaults to server builder, not template",
135 LLMessageConfig::isMessageBuiltTemplate("msg1"),
136 false);
137 ensure_equals("Ensure missing builder default to server builder llsd",
138 LLMessageConfig::isMessageBuiltLLSD("msg1"),
139 true);
140
141 ensure_equals("Ensure server default is not llsd",
142 LLMessageConfig::isServerDefaultBuilderLLSD(),
143 true);
144 ensure_equals("Ensure server default is template",
145 LLMessageConfig::isServerDefaultBuilderTemplate(),
146 false);
147
148 writeConfigFile(config_backup);
149 }
150
151 template<> template<>
152 void LLMessageConfigTestObject::test<3>()
153 // tests trusted/untrusted senders
154 {
155 LLSD config_backup = getCurrentConfig();
156 LLSD config;
157 config["serverDefaults"]["simulator"] = "template";
158 config["messages"]["msg1"]["builder"] = "llsd";
159 config["messages"]["msg1"]["trusted-sender"] = false;
160 config["messages"]["msg2"]["builder"] = "llsd";
161 config["messages"]["msg2"]["trusted-sender"] = true;
162 writeConfigFile(config);
163 ensure_equals("Ensure untrusted is not trusted",
164 LLMessageConfig::isMessageTrusted("msg1"),
165 false);
166 ensure_equals("Ensure untrusted is untrusted",
167 LLMessageConfig::isValidUntrustedMessage("msg1"),
168 true);
169 ensure_equals("Ensure trusted is trusted",
170 LLMessageConfig::isMessageTrusted("msg2"),
171 true);
172 ensure_equals("Ensure trusted is not untrusted",
173 LLMessageConfig::isValidUntrustedMessage("msg2"),
174 false);
175 writeConfigFile(config_backup);
176 }
177
178 template<> template<>
179 void LLMessageConfigTestObject::test<5>()
180 // tests trusted/untrusted without flag, only builder
181 {
182 LLSD config_backup = getCurrentConfig();
183 LLSD config;
184 config["serverDefaults"]["simulator"] = "template";
185 config["messages"]["msg1"]["builder"] = "llsd";
186 writeConfigFile(config);
187 ensure_equals("Ensure missing trusted is not trusted",
188 LLMessageConfig::isMessageTrusted("msg1"),
189 false);
190 ensure_equals("Ensure missing trusted is not untrusted",
191 LLMessageConfig::isValidUntrustedMessage("msg1"),
192 false);
193 writeConfigFile(config_backup);
194 }
195
196 template<> template<>
197 void LLMessageConfigTestObject::test<6>()
198 // tests message builder defaults
199 {
200 LLSD config_backup = getCurrentConfig();
201 LLSD config;
202 config["serverDefaults"]["simulator"] = "template";
203 config["messages"]["msg1"]["trusted-sender"] = true;
204 writeConfigFile(config);
205 ensure_equals("Ensure missing message defaults to server builder, not template",
206 LLMessageConfig::isMessageBuiltTemplate("Test"),
207 true);
208 ensure_equals("Ensure missing message default to server builder llsd",
209 LLMessageConfig::isMessageBuiltLLSD("Test"),
210 false);
211 ensure_equals("Ensure missing builder defaults to server builder, not template",
212 LLMessageConfig::isMessageBuiltTemplate("msg1"),
213 true);
214 ensure_equals("Ensure missing builder default to server builder llsd",
215 LLMessageConfig::isMessageBuiltLLSD("msg1"),
216 false);
217
218 ensure_equals("Ensure server default is not llsd",
219 LLMessageConfig::isServerDefaultBuilderLLSD(),
220 false);
221 ensure_equals("Ensure server default is template",
222 LLMessageConfig::isServerDefaultBuilderTemplate(),
223 true);
224
225 writeConfigFile(config_backup);
226 }
227}
diff --git a/linden/indra/test/llmime_tut.cpp b/linden/indra/test/llmime_tut.cpp
index f5cf38f..ac1a036 100644
--- a/linden/indra/test/llmime_tut.cpp
+++ b/linden/indra/test/llmime_tut.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2006-2007, Linden Research, Inc. 7 * Copyright (c) 2006-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * 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 * 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 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/test/llpipeutil.cpp b/linden/indra/test/llpipeutil.cpp
index 2857f12..085d883 100644
--- a/linden/indra/test/llpipeutil.cpp
+++ b/linden/indra/test/llpipeutil.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc. 6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/test/llpipeutil.h b/linden/indra/test/llpipeutil.h
index 7fda905..a2c59dd 100644
--- a/linden/indra/test/llpipeutil.h
+++ b/linden/indra/test/llpipeutil.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc. 6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/test/llrandom_tut.cpp b/linden/indra/test/llrandom_tut.cpp
index a842dfd..c5b0488 100755
--- a/linden/indra/test/llrandom_tut.cpp
+++ b/linden/indra/test/llrandom_tut.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2007-2007, Linden Research, Inc. 6 * Copyright (c) 2007-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/test/llsd_message_system_tut.cpp b/linden/indra/test/llsd_message_system_tut.cpp
deleted file mode 100644
index 9fcc6b5..0000000
--- a/linden/indra/test/llsd_message_system_tut.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
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 "linden_common.h"
35
36#include <tut/tut.h>
37#include "llsdmessagesystem.h"
38#include "llsdutil.h"
39
40namespace tut
41{
42 class LLSDMessageSystemTestData
43 {
44 public:
45 LLSDMessageSystemTestData() {;}
46 ~LLSDMessageSystemTestData() {;}
47
48 LLSDMessageSystem mMsgSystem;
49 };
50
51 typedef test_group<LLSDMessageSystemTestData> LLSDMessageSystemTestGroup;
52 typedef LLSDMessageSystemTestGroup::object LLSDMessageSystemTestObject;
53 LLSDMessageSystemTestGroup llsdMessageSystemTestGroup("llsd_message_system");
54
55 template<> template<>
56 void LLSDMessageSystemTestObject::test<1>()
57 {
58 LLSD input;
59 U32 valueIn, valueOut;
60 valueIn = 42;
61 input["Block"]["Var"] = ll_sd_from_U32(valueIn);
62 mMsgSystem.setInput(input);
63 mMsgSystem.getU32Fast("Block", "Var", valueOut);
64 ensure_equals("U32 from message system matches input U32", valueIn, valueOut);
65 }
66
67 template<> template<>
68 void LLSDMessageSystemTestObject::test<2>()
69 {
70 LLSD input;
71 LLUUID valueIn, valueOut;
72 valueIn.generate();
73 input["Block"]["Var"] = valueIn;
74 mMsgSystem.setInput(input);
75 mMsgSystem.getUUIDFast("Block", "Var", valueOut);
76 ensure_equals("UUID from message system matches input UUID", valueIn, valueOut);
77 }
78
79 template<> template<>
80 void LLSDMessageSystemTestObject::test<3>()
81 {
82 LLSD input;
83 U32 valueIn, valueOut;
84 LLHost host("127.0.0.1:80");
85 valueIn = host.getAddress();
86 input["Block"]["Var"] = ll_sd_from_U32(valueIn);
87 mMsgSystem.setInput(input);
88 mMsgSystem.getIPAddrFast("Block", "Var", valueOut);
89 ensure_equals("IP from message system matches input IP", valueIn, valueOut);
90 }
91
92 template<> template<>
93 void LLSDMessageSystemTestObject::test<4>()
94 {
95 LLSD input;
96 U16 valueIn, valueOut;
97 LLHost host("127.0.0.1:80");
98 valueIn = host.getPort();
99 input["Block"]["Var"] = (S32)valueIn;
100 mMsgSystem.setInput(input);
101 mMsgSystem.getIPPortFast("Block", "Var", valueOut);
102 ensure_equals("Port from message system matches input port", valueIn, valueOut);
103 }
104
105 template<> template<>
106 void LLSDMessageSystemTestObject::test<5>()
107 {
108 LLSD input;
109 U64 valueIn, valueOut;
110 valueIn = 42;
111 input["Block"]["Var"] = ll_sd_from_U64(valueIn);
112 mMsgSystem.setInput(input);
113 mMsgSystem.getU64Fast("Block", "Var", valueOut);
114 ensure_equals("Port from message system matches input port", valueIn, valueOut);
115 }
116
117 template<> template<>
118 void LLSDMessageSystemTestObject::test<6>()
119 {
120 LLSD input;
121 std::string valueIn = "Value";
122 input["Block"]["Var"] = valueIn;
123 mMsgSystem.setInput(input);
124 const U32 buffLen = 16;
125 char buff[buffLen];
126 mMsgSystem.getStringFast("Block", "Var", buffLen, buff);
127 ensure_equals("string read from message system matches llsd input", std::string(buff), valueIn);
128 }
129
130 template<> template<>
131 void LLSDMessageSystemTestObject::test<7>()
132 {
133 LLSD input;
134 U32 valueIn, valueOut;
135 valueIn = 42;
136 input["Block"][0]["Var"] = ll_sd_from_U32(valueIn);
137 input["Block"][1]["Var"] = ll_sd_from_U32(valueIn + 1);
138 mMsgSystem.setInput(input);
139 mMsgSystem.getU32Fast("Block", "Var", valueOut, 0);
140 ensure_equals("U32 from message system matches input U32", valueIn, valueOut);
141 mMsgSystem.getU32Fast("Block", "Var", valueOut, 1);
142 ensure_equals("U32 from message system matches input U32", (valueIn + 1), valueOut);
143 }
144}
diff --git a/linden/indra/test/llsd_new_tut.cpp b/linden/indra/test/llsd_new_tut.cpp
index d278a78..55e259d 100644
--- a/linden/indra/test/llsd_new_tut.cpp
+++ b/linden/indra/test/llsd_new_tut.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc. 6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -31,82 +32,11 @@
31#include "linden_common.h" 32#include "linden_common.h"
32#include "lltut.h" 33#include "lltut.h"
33 34
34#include "llsd.h" 35#include "llsdtraits.h"
35#include "llstring.h" 36#include "llstring.h"
36 37
37namespace tut 38namespace tut
38{ 39{
39 template<class T>
40 class SDTraits
41 {
42 protected:
43 typedef T (LLSD::*Getter)() const;
44
45 LLSD::Type type;
46 Getter getter;
47
48 public:
49 SDTraits();
50
51 T get(const LLSD& actual)
52 {
53 return (actual.*getter)();
54 }
55
56 bool checkType(const LLSD& actual)
57 {
58 return actual.type() == type;
59 }
60 };
61
62 template<>
63 SDTraits<LLSD::Boolean>::SDTraits()
64 : type(LLSD::TypeBoolean), getter(&LLSD::asBoolean)
65 { }
66
67 template<>
68 SDTraits<LLSD::Integer>::SDTraits()
69 : type(LLSD::TypeInteger), getter(&LLSD::asInteger)
70 { }
71
72 template<>
73 SDTraits<LLSD::Real>::SDTraits()
74 : type(LLSD::TypeReal), getter(&LLSD::asReal)
75 { }
76
77 template<>
78 SDTraits<LLSD::UUID>::SDTraits()
79 : type(LLSD::TypeUUID), getter(&LLSD::asUUID)
80 { }
81
82 template<>
83 SDTraits<LLSD::String>::SDTraits()
84 : type(LLSD::TypeString), getter(&LLSD::asString)
85 { }
86
87 template<>
88 class SDTraits<LLString> : public SDTraits<LLSD::String>
89 { };
90
91 template<>
92 class SDTraits<const char*> : public SDTraits<LLSD::String>
93 { };
94
95 template<>
96 SDTraits<LLSD::Date>::SDTraits()
97 : type(LLSD::TypeDate), getter(&LLSD::asDate)
98 { }
99
100 template<>
101 SDTraits<LLSD::URI>::SDTraits()
102 : type(LLSD::TypeURI), getter(&LLSD::asURI)
103 { }
104
105 template<>
106 SDTraits<LLSD::Binary>::SDTraits()
107 : type(LLSD::TypeBinary), getter(&LLSD::asBinary)
108 { }
109
110 class SDCleanupCheck 40 class SDCleanupCheck
111 { 41 {
112 private: 42 private:
@@ -145,7 +75,7 @@ namespace tut
145 static void ensureTypeAndValue(const char* msg, const LLSD& actual, 75 static void ensureTypeAndValue(const char* msg, const LLSD& actual,
146 T expectedValue) 76 T expectedValue)
147 { 77 {
148 SDTraits<T> traits; 78 LLSDTraits<T> traits;
149 79
150 std::string s(msg); 80 std::string s(msg);
151 81
@@ -353,7 +283,7 @@ namespace tut
353 } 283 }
354 284
355 LLSD u(str); 285 LLSD u(str);
356 SDTraits<T> traits; 286 LLSDTraits<T> traits;
357 287
358 ensure_equals(msg + " value", traits.get(u), vExpected); 288 ensure_equals(msg + " value", traits.get(u), vExpected);
359 } 289 }
diff --git a/linden/indra/test/llsdmessagebuilder_tut.cpp b/linden/indra/test/llsdmessagebuilder_tut.cpp
new file mode 100755
index 0000000..d48584a
--- /dev/null
+++ b/linden/indra/test/llsdmessagebuilder_tut.cpp
@@ -0,0 +1,279 @@
1/**
2 * @file llsdmessagebuilder_tut.cpp
3 * @date February 2006
4 * @brief LLSDMessageBuilder unit tests
5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 *
8 * Second Life Viewer Source Code
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 <tut/tut.h>
31#include "lltut.h"
32
33#include "llsdmessagebuilder.h"
34#include "llsdmessagereader.h"
35#include "llsdtraits.h"
36#include "llquaternion.h"
37#include "u64.h"
38#include "v3dmath.h"
39#include "v3math.h"
40#include "v4math.h"
41
42namespace tut
43{
44 struct LLSDMessageBuilderTestData {
45 static LLSDMessageBuilder defaultBuilder()
46 {
47 LLSDMessageBuilder builder;
48 builder.newMessage("name");
49 builder.nextBlock("block");
50 return builder;
51 }
52
53 static LLSDMessageReader setReader(const LLSDMessageBuilder& builder)
54 {
55 LLSDMessageReader reader;
56 reader.setMessage("name", builder.getMessage());
57 return reader;
58 }
59 };
60
61 typedef test_group<LLSDMessageBuilderTestData> LLSDMessageBuilderTestGroup;
62 typedef LLSDMessageBuilderTestGroup::object LLSDMessageBuilderTestObject;
63 LLSDMessageBuilderTestGroup llsdMessageBuilderTestGroup("LLSDMessageBuilder");
64
65 template<> template<>
66 void LLSDMessageBuilderTestObject::test<1>()
67 // construction and test of undefined
68 {
69 LLSDMessageBuilder builder = defaultBuilder();
70 LLSDMessageReader reader = setReader(builder);
71 }
72
73 template<> template<>
74 void LLSDMessageBuilderTestObject::test<2>()
75 // BOOL
76 {
77 BOOL outValue, inValue = TRUE;
78 LLSDMessageBuilder builder = defaultBuilder();
79 builder.addBOOL("var", inValue);
80 LLSDMessageReader reader = setReader(builder);
81 reader.getBOOL("block", "var", outValue);
82 ensure_equals("Ensure BOOL", inValue, outValue);
83 }
84
85 template<> template<>
86 void LLSDMessageBuilderTestObject::test<3>()
87 // U8
88 {
89 U8 outValue, inValue = 2;
90 LLSDMessageBuilder builder = defaultBuilder();
91 builder.addU8("var", inValue);
92 LLSDMessageReader reader = setReader(builder);
93 reader.getU8("block", "var", outValue);
94 ensure_equals("Ensure U8", inValue, outValue);
95 }
96
97 template<> template<>
98 void LLSDMessageBuilderTestObject::test<4>()
99 // S16
100 {
101 S16 outValue, inValue = 90;
102 LLSDMessageBuilder builder = defaultBuilder();
103 builder.addS16("var", inValue);
104 LLSDMessageReader reader = setReader(builder);
105 reader.getS16("block", "var", outValue);
106 ensure_equals("Ensure S16", inValue, outValue);
107 }
108
109 template<> template<>
110 void LLSDMessageBuilderTestObject::test<5>()
111 // U16
112 {
113 U16 outValue, inValue = 3;
114 LLSDMessageBuilder builder = defaultBuilder();
115 builder.addU16("var", inValue);
116 LLSDMessageReader reader = setReader(builder);
117 reader.getU16("block", "var", outValue);
118 ensure_equals("Ensure U16", inValue, outValue);
119 }
120
121 template<> template<>
122 void LLSDMessageBuilderTestObject::test<6>()
123 // S32
124 {
125 S32 outValue, inValue = 44;
126 LLSDMessageBuilder builder = defaultBuilder();
127 builder.addS32("var", inValue);
128 LLSDMessageReader reader = setReader(builder);
129 reader.getS32("block", "var", outValue);
130 ensure_equals("Ensure S32", inValue, outValue);
131 }
132
133 template<> template<>
134 void LLSDMessageBuilderTestObject::test<7>()
135 // F32
136 {
137 F32 outValue, inValue = 121.44;
138 LLSDMessageBuilder builder = defaultBuilder();
139 builder.addF32("var", inValue);
140 LLSDMessageReader reader = setReader(builder);
141 reader.getF32("block", "var", outValue);
142 ensure_equals("Ensure F32", inValue, outValue);
143 }
144
145 template<> template<>
146 void LLSDMessageBuilderTestObject::test<8>()
147 // U32
148 {
149 U32 outValue, inValue = 88;
150 LLSDMessageBuilder builder = defaultBuilder();
151 builder.addU32("var", inValue);
152 LLSDMessageReader reader = setReader(builder);
153 reader.getU32("block", "var", outValue);
154 ensure_equals("Ensure U32", inValue, outValue);
155 }
156
157 template<> template<>
158 void LLSDMessageBuilderTestObject::test<9>()
159 // U64
160 {
161 U64 outValue, inValue = 121;
162 LLSDMessageBuilder builder = defaultBuilder();
163 builder.addU64("var", inValue);
164 LLSDMessageReader reader = setReader(builder);
165 reader.getU64("block", "var", outValue);
166 ensure_equals("Ensure U64", inValue, outValue);
167 }
168
169 template<> template<>
170 void LLSDMessageBuilderTestObject::test<10>()
171 // F64
172 {
173 F64 outValue, inValue = 3232143.33;
174 LLSDMessageBuilder builder = defaultBuilder();
175 builder.addF64("var", inValue);
176 LLSDMessageReader reader = setReader(builder);
177 reader.getF64("block", "var", outValue);
178 ensure_equals("Ensure F64", inValue, outValue);
179 }
180
181 template<> template<>
182 void LLSDMessageBuilderTestObject::test<11>()
183 // Vector3
184 {
185 LLVector3 outValue, inValue = LLVector3(1,2,3);
186 LLSDMessageBuilder builder = defaultBuilder();
187 builder.addVector3("var", inValue);
188 LLSDMessageReader reader = setReader(builder);
189 reader.getVector3("block", "var", outValue);
190 ensure_equals("Ensure Vector3", inValue, outValue);
191 }
192
193 template<> template<>
194 void LLSDMessageBuilderTestObject::test<12>()
195 // Vector4
196 {
197 LLVector4 outValue, inValue = LLVector4(1,2,3,4);
198 LLSDMessageBuilder builder = defaultBuilder();
199 builder.addVector4("var", inValue);
200 LLSDMessageReader reader = setReader(builder);
201 reader.getVector4("block", "var", outValue);
202 ensure_equals("Ensure Vector4", inValue, outValue);
203 }
204
205 template<> template<>
206 void LLSDMessageBuilderTestObject::test<13>()
207 // Vector3d
208 {
209 LLVector3d outValue, inValue = LLVector3d(1,2,3);
210 LLSDMessageBuilder builder = defaultBuilder();
211 builder.addVector3d("var", inValue);
212 LLSDMessageReader reader = setReader(builder);
213 reader.getVector3d("block", "var", outValue);
214 ensure_equals("Ensure Vector3d", inValue, outValue);
215 }
216
217 template<> template<>
218 void LLSDMessageBuilderTestObject::test<14>()
219 // Quaternion
220 {
221 LLQuaternion outValue, inValue = LLQuaternion(1,2,3,4);
222 LLSDMessageBuilder builder = defaultBuilder();
223 builder.addQuat("var", inValue);
224 LLSDMessageReader reader = setReader(builder);
225 reader.getQuat("block", "var", outValue);
226 ensure_equals("Ensure Quaternion", inValue, outValue);
227 }
228
229 template<> template<>
230 void LLSDMessageBuilderTestObject::test<15>()
231 // UUID
232 {
233 LLUUID outValue, inValue;
234 inValue.generate();
235 LLSDMessageBuilder builder = defaultBuilder();
236 builder.addUUID("var", inValue);
237 LLSDMessageReader reader = setReader(builder);
238 reader.getUUID("block", "var", outValue);
239 ensure_equals("Ensure UUID", inValue, outValue);
240 }
241
242 template<> template<>
243 void LLSDMessageBuilderTestObject::test<16>()
244 // IPAddr
245 {
246 U32 outValue, inValue = 12344556;
247 LLSDMessageBuilder builder = defaultBuilder();
248 builder.addIPAddr("var", inValue);
249 LLSDMessageReader reader = setReader(builder);
250 reader.getIPAddr("block", "var", outValue);
251 ensure_equals("Ensure IPAddr", inValue, outValue);
252 }
253
254 template<> template<>
255 void LLSDMessageBuilderTestObject::test<17>()
256 // IPPort
257 {
258 U16 outValue, inValue = 80;
259 LLSDMessageBuilder builder = defaultBuilder();
260 builder.addIPPort("var", inValue);
261 LLSDMessageReader reader = setReader(builder);
262 reader.getIPPort("block", "var", outValue);
263 ensure_equals("Ensure IPPort", inValue, outValue);
264 }
265
266 template<> template<>
267 void LLSDMessageBuilderTestObject::test<18>()
268 {
269 std::string outValue, inValue = "testing";
270 LLSDMessageBuilder builder = defaultBuilder();
271 builder.addString("var", inValue.c_str());
272 LLSDMessageReader reader = setReader(builder);
273 char buffer[MAX_STRING];
274 reader.getString("block", "var", MAX_STRING, buffer);
275 outValue = buffer;
276 ensure_equals("Ensure String", inValue, outValue);
277 }
278}
279
diff --git a/linden/indra/test/llsdmessagereader_tut.cpp b/linden/indra/test/llsdmessagereader_tut.cpp
new file mode 100755
index 0000000..707cf31
--- /dev/null
+++ b/linden/indra/test/llsdmessagereader_tut.cpp
@@ -0,0 +1,320 @@
1/**
2 * @file llsdmessagereader_tut.cpp
3 * @date February 2006
4 * @brief LLSDMessageReader unit tests
5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 *
8 * Second Life Viewer Source Code
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 <tut/tut.h>
31#include "lltut.h"
32
33#include "llsdmessagereader.h"
34#include "llsdutil.h"
35
36namespace tut
37{
38 struct LLSDMessageReaderTestData {
39 static void ensureMessageName(const std::string& msg_name,
40 const LLSD& msg_data,
41 const std::string& expected_name)
42 {
43 LLSDMessageReader msg;
44 msg.setMessage(msg_name, msg_data);
45 ensure_equals("Ensure name", std::string(msg.getMessageName()),
46 expected_name);
47 }
48
49 static void ensureNumberOfBlocks(const LLSD& msg_data,
50 const std::string& block,
51 S32 expected_number)
52 {
53 LLSDMessageReader msg;
54 msg.setMessage("fakename", msg_data);
55 ensure_equals("Ensure number of blocks", msg.getNumberOfBlocks(block.c_str()),
56 expected_number);
57 }
58
59 static void ensureMessageSize(const LLSD& msg_data,
60 S32 expected_size)
61 {
62 LLSDMessageReader msg;
63 msg.setMessage("fakename", msg_data);
64 ensure_equals( "Ensure size", msg.getMessageSize(), expected_size);
65 }
66
67 static void ensureBool(const LLSD& msg_data,
68 const std::string& block,
69 const std::string& var,
70 S32 blocknum,
71 BOOL expected)
72 {
73 LLSDMessageReader msg;
74 msg.setMessage("fakename", msg_data);
75 BOOL test_data;
76 msg.getBOOL(block.c_str(), var.c_str(), test_data, blocknum);
77 ensure_equals( "Ensure bool field", test_data, expected);
78 }
79 };
80
81 typedef test_group<LLSDMessageReaderTestData> LLSDMessageReaderTestGroup;
82 typedef LLSDMessageReaderTestGroup::object LLSDMessageReaderTestObject;
83 LLSDMessageReaderTestGroup llsdMessageReaderTestGroup("LLSDMessageReader");
84
85 template<> template<>
86 void LLSDMessageReaderTestObject::test<1>()
87 // construction and test of empty LLSD
88 {
89 LLSD message = LLSD::emptyMap();
90
91 ensureMessageName("", message, "");
92 ensureNumberOfBlocks(message, "Fakeblock", 0);
93 ensureMessageSize(message, 0);
94 }
95
96 template<> template<>
97 void LLSDMessageReaderTestObject::test<2>()
98 // construction and test of simple message with one block
99 {
100 LLSD message = LLSD::emptyMap();
101 message["block1"] = LLSD::emptyArray();
102 message["block1"][0] = LLSD::emptyMap();
103 message["block1"][0]["Field1"] = 0;
104
105 ensureMessageName("name2", message, "name2");
106 ensureNumberOfBlocks(message, "block1", 1);
107 ensureMessageSize(message, 0);
108 }
109
110 template<> template<>
111 void LLSDMessageReaderTestObject::test<3>()
112 // multiple blocks
113 {
114 LLSD message = LLSD::emptyMap();
115 message["block1"] = LLSD::emptyArray();
116 BOOL bool_true = TRUE;
117 BOOL bool_false = FALSE;
118 message["block1"][0] = LLSD::emptyMap();
119 message["block1"][0]["BoolField1"] = bool_true;
120 message["block1"][1] = LLSD::emptyMap();
121 message["block1"][1]["BoolField1"] = bool_false;
122 message["block1"][1]["BoolField2"] = bool_true;
123
124 ensureMessageName("name3", message, "name3");
125 ensureBool(message, "block1", "BoolField1", 0, TRUE);
126 ensureBool(message, "block1", "BoolField1", 1, FALSE);
127 ensureBool(message, "block1", "BoolField2", 1, TRUE);
128 ensureNumberOfBlocks(message, "block1", 2);
129 ensureMessageSize(message, 0);
130 }
131
132 template<typename T>
133 LLSDMessageReader testType(const T& value)
134 {
135 LLSD message = LLSD::emptyMap();
136 message["block"][0]["var"] = value;
137 LLSDMessageReader msg;
138 msg.setMessage("fakename", message);
139 return msg;
140 }
141
142 template<> template<>
143 void LLSDMessageReaderTestObject::test<4>()
144 // S8
145 {
146 S8 outValue, inValue = -3;
147 LLSDMessageReader msg = testType(inValue);
148 msg.getS8("block", "var", outValue);
149 ensure_equals("Ensure S8", outValue, inValue);
150 }
151 template<> template<>
152 void
153 LLSDMessageReaderTestObject::test<5>()
154 // U8
155 {
156 U8 outValue, inValue = 2;
157 LLSDMessageReader msg = testType(inValue);
158 msg.getU8("block", "var", outValue);
159 ensure_equals("Ensure U8", outValue, inValue);
160 }
161 template<> template<>
162 void LLSDMessageReaderTestObject::test<6>()
163 // S16
164 {
165 S16 outValue, inValue = 90;
166 LLSDMessageReader msg = testType(inValue);
167 msg.getS16("block", "var", outValue);
168 ensure_equals("Ensure S16", outValue, inValue);
169 }
170 template<> template<>
171 void LLSDMessageReaderTestObject::test<7>()
172 // U16
173 {
174 U16 outValue, inValue = 3;
175 LLSDMessageReader msg = testType(inValue);
176 msg.getU16("block", "var", outValue);
177 ensure_equals("Ensure S16", outValue, inValue);
178 }
179 template<> template<>
180 void LLSDMessageReaderTestObject::test<8>()
181 // S32
182 {
183 S32 outValue, inValue = 44;
184 LLSDMessageReader msg = testType(inValue);
185 msg.getS32("block", "var", outValue);
186 ensure_equals("Ensure S32", outValue, inValue);
187 }
188 template<> template<>
189 void LLSDMessageReaderTestObject::test<9>()
190 // F32
191 {
192 F32 outValue, inValue = 121.44;
193 LLSDMessageReader msg = testType(inValue);
194 msg.getF32("block", "var", outValue);
195 ensure_equals("Ensure F32", outValue, inValue);
196 }
197 template<> template<>
198 void LLSDMessageReaderTestObject::test<10>()
199 // U32
200 {
201 U32 outValue, inValue = 88;
202 LLSD sdValue = ll_sd_from_U32(inValue);
203 LLSDMessageReader msg = testType(sdValue);
204 msg.getU32("block", "var", outValue);
205 ensure_equals("Ensure U32", outValue, inValue);
206 }
207 template<> template<>
208 void LLSDMessageReaderTestObject::test<11>()
209 // U64
210 {
211 U64 outValue, inValue = 121;
212 LLSD sdValue = ll_sd_from_U64(inValue);
213 LLSDMessageReader msg = testType(sdValue);
214 msg.getU64("block", "var", outValue);
215 ensure_equals("Ensure U64", outValue, inValue);
216 }
217 template<> template<>
218 void LLSDMessageReaderTestObject::test<12>()
219 // F64
220 {
221 F64 outValue, inValue = 3232143.33;
222 LLSDMessageReader msg = testType(inValue);
223 msg.getF64("block", "var", outValue);
224 ensure_equals("Ensure F64", outValue, inValue);
225 }
226 template<> template<>
227 void LLSDMessageReaderTestObject::test<13>()
228 // String
229 {
230 std::string outValue, inValue = "testing";
231 LLSDMessageReader msg = testType<std::string>(inValue.c_str());
232
233 char buffer[MAX_STRING];
234 msg.getString("block", "var", MAX_STRING, buffer);
235 outValue = buffer;
236 ensure_equals("Ensure String", outValue, inValue);
237 }
238 template<> template<>
239 void LLSDMessageReaderTestObject::test<14>()
240 // Vector3
241 {
242 LLVector3 outValue, inValue = LLVector3(1,2,3);
243 LLSD sdValue = ll_sd_from_vector3(inValue);
244 LLSDMessageReader msg = testType(sdValue);
245 msg.getVector3("block", "var", outValue);
246 ensure_equals("Ensure Vector3", outValue, inValue);
247 }
248 template<> template<>
249 void LLSDMessageReaderTestObject::test<15>()
250 // Vector4
251 {
252 LLVector4 outValue, inValue = LLVector4(1,2,3,4);
253 LLSD sdValue = ll_sd_from_vector4(inValue);
254 LLSDMessageReader msg = testType(sdValue);
255 msg.getVector4("block", "var", outValue);
256 ensure_equals("Ensure Vector4", outValue, inValue);
257 }
258 template<> template<>
259 void LLSDMessageReaderTestObject::test<16>()
260 // Vector3d
261 {
262 LLVector3d outValue, inValue = LLVector3d(1,2,3);
263 LLSD sdValue = ll_sd_from_vector3d(inValue);
264 LLSDMessageReader msg = testType(sdValue);
265 msg.getVector3d("block", "var", outValue);
266 ensure_equals("Ensure Vector3d", outValue, inValue);
267 }
268 template<> template<>
269 void LLSDMessageReaderTestObject::test<17>()
270 // Quaternion
271 {
272 LLQuaternion outValue, inValue = LLQuaternion(1,2,3,4);
273 LLSD sdValue = ll_sd_from_quaternion(inValue);
274 LLSDMessageReader msg = testType(sdValue);
275 msg.getQuat("block", "var", outValue);
276 ensure_equals("Ensure Quaternion", outValue, inValue);
277 }
278 template<> template<>
279 void LLSDMessageReaderTestObject::test<18>()
280 // UUID
281 {
282 LLUUID outValue, inValue;
283 inValue.generate();
284 LLSDMessageReader msg = testType(inValue);
285 msg.getUUID("block", "var", outValue);
286 ensure_equals("Ensure UUID", outValue, inValue);
287 }
288 template<> template<>
289 void LLSDMessageReaderTestObject::test<19>()
290 // IPAddr
291 {
292 U32 outValue, inValue = 12344556;
293 LLSD sdValue = ll_sd_from_ipaddr(inValue);
294 LLSDMessageReader msg = testType(sdValue);
295 msg.getIPAddr("block", "var", outValue);
296 ensure_equals("Ensure IPAddr", outValue, inValue);
297 }
298 template<> template<>
299 void LLSDMessageReaderTestObject::test<20>()
300 // IPPort
301 {
302 U16 outValue, inValue = 80;
303 LLSDMessageReader msg = testType(inValue);
304 msg.getIPPort("block", "var", outValue);
305 ensure_equals("Ensure IPPort", outValue, inValue);
306 }
307 template<> template<>
308 void LLSDMessageReaderTestObject::test<21>()
309 // Binary
310 {
311 std::vector<U8> outValue(2), inValue(2);
312 inValue[0] = 0;
313 inValue[1] = 1;
314
315 LLSDMessageReader msg = testType(inValue);
316 msg.getBinaryData("block", "var", &(outValue[0]), inValue.size());
317 ensure_equals("Ensure Binary", outValue, inValue);
318 }
319}
320
diff --git a/linden/indra/test/llsdserialize_tut.cpp b/linden/indra/test/llsdserialize_tut.cpp
index c87d7d1..80a4336 100644
--- a/linden/indra/test/llsdserialize_tut.cpp
+++ b/linden/indra/test/llsdserialize_tut.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc. 6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -33,7 +34,7 @@
33#include "llsd.h" 34#include "llsd.h"
34#include "llsdserialize.h" 35#include "llsdserialize.h"
35#include "lltut.h" 36#include "lltut.h"
36 37#include "llformat.h"
37 38
38namespace tut 39namespace tut
39{ 40{
@@ -212,6 +213,7 @@ namespace tut
212 { 213 {
213 std::stringstream stream; 214 std::stringstream stream;
214 mFormatter->format(v, stream); 215 mFormatter->format(v, stream);
216 //llinfos << "checkRoundTrip: length " << stream.str().length() << llendl;
215 LLSD w; 217 LLSD w;
216 mParser->parse(stream, w); 218 mParser->parse(stream, w);
217 219
@@ -226,6 +228,22 @@ namespace tut
226 throw; 228 throw;
227 } 229 }
228 } 230 }
231
232 static void fillmap(LLSD& root, U32 width, U32 depth)
233 {
234 if(depth == 0)
235 {
236 root["foo"] = "bar";
237 return;
238 }
239
240 for(U32 i = 0; i < width; ++i)
241 {
242 std::string key = llformat("child %d", i);
243 root[key] = LLSD::emptyMap();
244 fillmap(root[key], width, depth - 1);
245 }
246 }
229 247
230 void TestLLSDSerializeData::doRoundTripTests(const std::string& msg) 248 void TestLLSDSerializeData::doRoundTripTests(const std::string& msg)
231 { 249 {
@@ -389,6 +407,10 @@ namespace tut
389 v[0][0] = true; 407 v[0][0] = true;
390 v[1][0] = false; 408 v[1][0] = false;
391 checkRoundTrip(msg + " nested arrays", v); 409 checkRoundTrip(msg + " nested arrays", v);
410
411 v = LLSD::emptyMap();
412 fillmap(v, 10, 6); // 10^6 maps
413 checkRoundTrip(msg + " many nested maps", v);
392 } 414 }
393 415
394 typedef tut::test_group<TestLLSDSerializeData> TestLLSDSerialzeGroup; 416 typedef tut::test_group<TestLLSDSerializeData> TestLLSDSerialzeGroup;
@@ -547,7 +569,6 @@ namespace tut
547 "</array></llsd>", v); 569 "</array></llsd>", v);
548 } 570 }
549 571
550
551 /* 572 /*
552 TODO: 573 TODO:
553 test XML parsing 574 test XML parsing
diff --git a/linden/indra/test/llsdtraits.h b/linden/indra/test/llsdtraits.h
new file mode 100644
index 0000000..2e6a96a
--- /dev/null
+++ b/linden/indra/test/llsdtraits.h
@@ -0,0 +1,78 @@
1#ifndef LLSDTRAITS_H
2#define LLSDTRAITS_H
3
4#include "llsd.h"
5#include "llstring.h"
6
7template<class T>
8class LLSDTraits
9{
10 protected:
11 typedef T (LLSD::*Getter)() const;
12
13 LLSD::Type type;
14 Getter getter;
15
16 public:
17 LLSDTraits();
18
19 T get(const LLSD& actual)
20 {
21 return (actual.*getter)();
22 }
23
24 bool checkType(const LLSD& actual)
25 {
26 return actual.type() == type;
27 }
28};
29
30template<> inline
31LLSDTraits<LLSD::Boolean>::LLSDTraits()
32 : type(LLSD::TypeBoolean), getter(&LLSD::asBoolean)
33{ }
34
35template<> inline
36LLSDTraits<LLSD::Integer>::LLSDTraits()
37 : type(LLSD::TypeInteger), getter(&LLSD::asInteger)
38{ }
39
40template<> inline
41LLSDTraits<LLSD::Real>::LLSDTraits()
42 : type(LLSD::TypeReal), getter(&LLSD::asReal)
43{ }
44
45template<> inline
46LLSDTraits<LLSD::UUID>::LLSDTraits()
47 : type(LLSD::TypeUUID), getter(&LLSD::asUUID)
48{ }
49
50template<> inline
51LLSDTraits<LLSD::String>::LLSDTraits()
52 : type(LLSD::TypeString), getter(&LLSD::asString)
53{ }
54
55template<>
56class LLSDTraits<LLString> : public LLSDTraits<LLSD::String>
57{ };
58
59template<>
60class LLSDTraits<const char*> : public LLSDTraits<LLSD::String>
61{ };
62
63template<> inline
64LLSDTraits<LLSD::Date>::LLSDTraits()
65 : type(LLSD::TypeDate), getter(&LLSD::asDate)
66{ }
67
68template<> inline
69LLSDTraits<LLSD::URI>::LLSDTraits()
70 : type(LLSD::TypeURI), getter(&LLSD::asURI)
71{ }
72
73template<> inline
74LLSDTraits<LLSD::Binary>::LLSDTraits()
75 : type(LLSD::TypeBinary), getter(&LLSD::asBinary)
76{ }
77
78#endif // LLSDTRAITS_H
diff --git a/linden/indra/test/llservicebuilder_tut.cpp b/linden/indra/test/llservicebuilder_tut.cpp
new file mode 100644
index 0000000..fde0564
--- /dev/null
+++ b/linden/indra/test/llservicebuilder_tut.cpp
@@ -0,0 +1,96 @@
1/**
2* @file llservicebuilder_tut.cpp
3* @brief LLServiceBuilder unit tests
4* @date March 2007
5*
6* Copyright (c) 2006-2007, Linden Research, Inc.
7*
8 * Second Life Viewer Source Code
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 <tut/tut.h>
31#include "lltut.h"
32
33#include "llsd.h"
34#include "llservicebuilder.h"
35
36namespace tut
37{
38
39 struct ServiceBuilderTestData {
40 LLServiceBuilder mServiceBuilder;
41 };
42
43 typedef test_group<ServiceBuilderTestData> ServiceBuilderTestGroup;
44 typedef ServiceBuilderTestGroup::object ServiceBuilderTestObject;
45
46 ServiceBuilderTestGroup serviceBuilderTestGroup("ServiceBuilder");
47
48 template<> template<>
49 void ServiceBuilderTestObject::test<1>()
50 {
51 //Simple service build and reply with no mapping
52 LLSD test_block;
53 test_block["service-builder"] = "/agent/name";
54 mServiceBuilder.createServiceDefinition("ServiceBuilderTest", test_block["service-builder"]);
55 std::string test_url = mServiceBuilder.buildServiceURI("ServiceBuilderTest");
56 ensure_equals("Basic URL Creation", test_url , "/agent/name");
57 }
58
59 template<> template<>
60 void ServiceBuilderTestObject::test<2>()
61 {
62 //Simple replace test
63 LLSD test_block;
64 test_block["service-builder"] = "/agent/{$agent-id}/name";
65 mServiceBuilder.createServiceDefinition("ServiceBuilderTest", test_block["service-builder"]);
66 LLSD data_map;
67 data_map["agent-id"] = "257c631f-a0c5-4f29-8a9f-9031feaae6c6";
68 std::string test_url = mServiceBuilder.buildServiceURI("ServiceBuilderTest", data_map);
69 ensure_equals("Replacement URL Creation", test_url , "/agent/257c631f-a0c5-4f29-8a9f-9031feaae6c6/name");
70 }
71
72 template<> template<>
73 void ServiceBuilderTestObject::test<3>()
74 {
75 //Incorrect service test
76 LLSD test_block;
77 test_block["service-builder"] = "/agent/{$agent-id}/name";
78 mServiceBuilder.createServiceDefinition("ServiceBuilderTest", test_block["service-builder"]);
79 std::string test_url = mServiceBuilder.buildServiceURI("ServiceBuilder");
80 ensure_equals("Replacement URL Creation for Non-existant Service", test_url , "");
81 }
82
83 template<> template<>
84 void ServiceBuilderTestObject::test<4>()
85 {
86 //Incorrect service test
87 LLSD test_block;
88 test_block["service-builder"] = "/agent/{$agent-id}/name";
89 mServiceBuilder.createServiceDefinition("ServiceBuilderTest", test_block["service-builder"]);
90 LLSD data_map;
91 data_map["agent_id"] = "257c631f-a0c5-4f29-8a9f-9031feaae6c6";
92 std::string test_url = mServiceBuilder.buildServiceURI("ServiceBuilderTest", data_map);
93 ensure_equals("Replacement URL Creation for Non-existant Service", test_url , "/agent/{$agent-id}/name");
94 }
95}
96
diff --git a/linden/indra/test/lltiming_tut.cpp b/linden/indra/test/lltiming_tut.cpp
index 0b503cb..c2c9fd8 100644
--- a/linden/indra/test/lltiming_tut.cpp
+++ b/linden/indra/test/lltiming_tut.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc. 6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/test/lltut.cpp b/linden/indra/test/lltut.cpp
index 1127f72..c872077 100644
--- a/linden/indra/test/lltut.cpp
+++ b/linden/indra/test/lltut.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2006-2007, Linden Research, Inc. 7 * Copyright (c) 2006-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * 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 * 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 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/test/lltut.h b/linden/indra/test/lltut.h
index c8fb6bc..3e43df8 100644
--- a/linden/indra/test/lltut.h
+++ b/linden/indra/test/lltut.h
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * 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 * 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 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -45,6 +46,22 @@ class LLSD;
45 46
46namespace tut 47namespace tut
47{ 48{
49 inline void ensure_memory_matches(const char* msg,const void* actual, U32 actual_len, const void* expected,U32 expected_len)
50 {
51 if((expected_len != actual_len) ||
52 (memcmp(actual, expected, actual_len) != 0))
53 {
54 std::stringstream ss;
55 ss << (msg?msg:"") << (msg?": ":"") << "not equal";
56 throw tut::failure(ss.str().c_str());
57 }
58 }
59
60 inline void ensure_memory_matches(const void* actual, U32 actual_len, const void* expected,U32 expected_len)
61 {
62 ensure_memory_matches(NULL, actual, actual_len, expected, expected_len);
63 }
64
48 template <class T,class Q> 65 template <class T,class Q>
49 void ensure_not_equals(const char* msg,const Q& actual,const T& expected) 66 void ensure_not_equals(const char* msg,const Q& actual,const T& expected)
50 { 67 {
diff --git a/linden/indra/test/lluri_tut.cpp b/linden/indra/test/lluri_tut.cpp
index 31ea7d6..a08fe4e 100644
--- a/linden/indra/test/lluri_tut.cpp
+++ b/linden/indra/test/lluri_tut.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc. 6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -242,6 +243,8 @@ namespace tut
242 "http:%2F%2F10.0.1.4:12032%2Fagent%2Fgod%2Fagent-id%2Fmap%2Flayer%2F%3Fresume=http:%2F%2Fstation3.ll.com:12032%2Fagent%2F203ad6df-b522-491d-ba48-4e24eb57aeff%2Fsend-postcard"); 243 "http:%2F%2F10.0.1.4:12032%2Fagent%2Fgod%2Fagent-id%2Fmap%2Flayer%2F%3Fresume=http:%2F%2Fstation3.ll.com:12032%2Fagent%2F203ad6df-b522-491d-ba48-4e24eb57aeff%2Fsend-postcard");
243 } 244 }
244 245
246
247#if LL_ENABLE_JANKY_DEPRECATED_WEB_SERVICE_CALLS
245 template<> template<> 248 template<> template<>
246 void URITestObject::test<14>() 249 void URITestObject::test<14>()
247 { 250 {
@@ -250,14 +253,6 @@ namespace tut
250 LLUUID id("11111111-2222-3333-4444-5566778899aa"); 253 LLUUID id("11111111-2222-3333-4444-5566778899aa");
251 254
252 255
253 checkParts(LLURI::buildAgentPresenceURI(id, NULL),
254 "http", "//localhost:12040/agent/11111111-2222-3333-4444-5566778899aa/presence",
255 "localhost:12040", "/agent/11111111-2222-3333-4444-5566778899aa/presence");
256
257 checkParts(LLURI::buildBulkAgentPresenceURI(NULL),
258 "http", "//localhost:12040/agent/presence",
259 "localhost:12040", "/agent/presence");
260
261 checkParts(LLURI::buildAgentSessionURI(id, NULL), 256 checkParts(LLURI::buildAgentSessionURI(id, NULL),
262 "http", "//localhost:12040/agent/11111111-2222-3333-4444-5566778899aa/session", 257 "http", "//localhost:12040/agent/11111111-2222-3333-4444-5566778899aa/session",
263 "localhost:12040", "/agent/11111111-2222-3333-4444-5566778899aa/session"); 258 "localhost:12040", "/agent/11111111-2222-3333-4444-5566778899aa/session");
@@ -266,5 +261,6 @@ namespace tut
266 "http", "//datasever:12345/agent/11111111-2222-3333-4444-5566778899aa/logininfo", 261 "http", "//datasever:12345/agent/11111111-2222-3333-4444-5566778899aa/logininfo",
267 "datasever:12345", "/agent/11111111-2222-3333-4444-5566778899aa/logininfo"); 262 "datasever:12345", "/agent/11111111-2222-3333-4444-5566778899aa/logininfo");
268 } 263 }
264#endif // LL_ENABLE_JANKY_DEPRECATED_WEB_SERVICE_CALLS
269} 265}
270 266
diff --git a/linden/indra/test/lluserrelations_tut.cpp b/linden/indra/test/lluserrelations_tut.cpp
index e683803..f9b4615 100644
--- a/linden/indra/test/lluserrelations_tut.cpp
+++ b/linden/indra/test/lluserrelations_tut.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2006-2007, Linden Research, Inc. 7 * Copyright (c) 2006-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * 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 * 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 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/test/math.cpp b/linden/indra/test/math.cpp
index be8a398..3f5a15c 100644
--- a/linden/indra/test/math.cpp
+++ b/linden/indra/test/math.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * 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 * 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 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -32,6 +33,7 @@
32 33
33#include "llmath.h" 34#include "llmath.h"
34#include "lluuid.h" 35#include "lluuid.h"
36#include "llcrc.h"
35 37
36namespace tut 38namespace tut
37{ 39{
@@ -74,6 +76,95 @@ namespace tut
74 val = llabs(val); 76 val = llabs(val);
75 ensure("double absolute value 2", (8937843.9394878 == val)); 77 ensure("double absolute value 2", (8937843.9394878 == val));
76 } 78 }
79
80 template<> template<>
81 void math_object::test<4>()
82 {
83 F32 val = 430903.9f;
84 S32 val1 = lltrunc(val);
85 ensure("float truncate value 1", (430903 == val1));
86 val = -2303.9f;
87 val1 = lltrunc(val);
88 ensure("float truncate value 2", (-2303 == val1));
89 }
90
91 template<> template<>
92 void math_object::test<5>()
93 {
94 F64 val = 387439393.987329839 ;
95 S32 val1 = lltrunc(val);
96 ensure("float truncate value 1", (387439393 == val1));
97 val = -387439393.987329839;
98 val1 = lltrunc(val);
99 ensure("float truncate value 2", (-387439393 == val1));
100 }
101
102 template<> template<>
103 void math_object::test<6>()
104 {
105 F32 val = 430903.2f;
106 S32 val1 = llfloor(val);
107 ensure("float llfloor value 1", (430903 == val1));
108 val = -430903.9f;
109 val1 = llfloor(val);
110 ensure("float llfloor value 2", (-430904 == val1));
111 }
112
113 template<> template<>
114 void math_object::test<7>()
115 {
116 F32 val = 430903.2f;
117 S32 val1 = llceil(val);
118 ensure("float llceil value 1", (430904 == val1));
119 val = -430903.9f;
120 val1 = llceil(val);
121 ensure("float llceil value 2", (-430903 == val1));
122 }
123
124 template<> template<>
125 void math_object::test<8>()
126 {
127 F32 val = 430903.2f;
128 S32 val1 = llround(val);
129 ensure("float llround value 1", (430903 == val1));
130 val = -430903.9f;
131 val1 = llround(val);
132 ensure("float llround value 2", (-430904 == val1));
133 }
134
135 template<> template<>
136 void math_object::test<9>()
137 {
138 F32 val = 430905.2654f, nearest = 100.f;
139 val = llround(val, nearest);
140 ensure("float llround value 1", (430900 == val));
141 val = -430905.2654f, nearest = 10.f;
142 val = llround(val, nearest);
143 ensure("float llround value 1", (-430910 == val));
144 }
145
146 template<> template<>
147 void math_object::test<10>()
148 {
149 F64 val = 430905.2654, nearest = 100.0;
150 val = llround(val, nearest);
151 ensure("double llround value 1", (430900 == val));
152 val = -430905.2654, nearest = 10.0;
153 val = llround(val, nearest);
154 ensure("double llround value 1", (-430910.00000 == val));
155 }
156
157 template<> template<>
158 void math_object::test<11>()
159 {
160 const F32 F_PI = 3.1415926535897932384626433832795f;
161 F32 angle = 3506.f;
162 angle = llsimple_angle(angle);
163 ensure("llsimple_angle value 1", (angle <=F_PI && angle >= -F_PI));
164 angle = -431.f;
165 angle = llsimple_angle(angle);
166 ensure("llsimple_angle value 1", (angle <=F_PI && angle >= -F_PI));
167 }
77} 168}
78 169
79namespace tut 170namespace tut
@@ -131,3 +222,55 @@ namespace tut
131 } 222 }
132 223
133} 224}
225
226namespace tut
227{
228 struct crc_data
229 {
230 };
231 typedef test_group<crc_data> crc_test;
232 typedef crc_test::object crc_object;
233 tut::crc_test tc("crc");
234
235 template<> template<>
236 void crc_object::test<1>()
237 {
238 /* Test buffer update and individual char update */
239 const char TEST_BUFFER[] = "hello &#$)$&Nd0";
240 LLCRC c1, c2;
241 c1.update((U8*)TEST_BUFFER, sizeof(TEST_BUFFER) - 1);
242 char* rh = (char*)TEST_BUFFER;
243 while(*rh != '\0')
244 {
245 c2.update(*rh);
246 ++rh;
247 }
248 ensure_equals("crc update 1", c1.getCRC(), c2.getCRC());
249 }
250
251 template<> template<>
252 void crc_object::test<2>()
253 {
254 /* Test mixing of buffer and individual char update */
255 const char TEST_BUFFER1[] = "Split Buffer one $^%$%#@$";
256 const char TEST_BUFFER2[] = "Split Buffer two )(8723#5dsds";
257 LLCRC c1, c2;
258 c1.update((U8*)TEST_BUFFER1, sizeof(TEST_BUFFER1) - 1);
259 char* rh = (char*)TEST_BUFFER2;
260 while(*rh != '\0')
261 {
262 c1.update(*rh);
263 ++rh;
264 }
265
266 rh = (char*)TEST_BUFFER1;
267 while(*rh != '\0')
268 {
269 c2.update(*rh);
270 ++rh;
271 }
272 c2.update((U8*)TEST_BUFFER2, sizeof(TEST_BUFFER2) - 1);
273
274 ensure_equals("crc update 2", c1.getCRC(), c2.getCRC());
275 }
276}
diff --git a/linden/indra/test/reflection_tut.cpp b/linden/indra/test/reflection_tut.cpp
index a7b46d4..7230c60 100644
--- a/linden/indra/test/reflection_tut.cpp
+++ b/linden/indra/test/reflection_tut.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc. 6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/test/test.cpp b/linden/indra/test/test.cpp
index 9eb1639..8f6f672 100644
--- a/linden/indra/test/test.cpp
+++ b/linden/indra/test/test.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * 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 * 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 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -62,7 +63,8 @@ public:
62 mVerboseMode(verbose_mode), 63 mVerboseMode(verbose_mode),
63 mTotalTests(0), 64 mTotalTests(0),
64 mPassedTests(0), 65 mPassedTests(0),
65 mFailedTests(0) 66 mFailedTests(0),
67 mSkippedTests(0)
66 { 68 {
67 } 69 }
68 70
@@ -98,6 +100,10 @@ public:
98 ++mFailedTests; 100 ++mFailedTests;
99 out << "abnormal termination"; 101 out << "abnormal termination";
100 break; 102 break;
103 case tut::test_result::skip:
104 ++mSkippedTests;
105 out << "skipped";
106 break;
101 default: 107 default:
102 ++mFailedTests; 108 ++mFailedTests;
103 out << "unknown"; 109 out << "unknown";
@@ -113,6 +119,12 @@ public:
113 std::cout << std::endl; 119 std::cout << std::endl;
114 std::cout << "Total Tests: " << mTotalTests << std::endl; 120 std::cout << "Total Tests: " << mTotalTests << std::endl;
115 std::cout << "Passed Tests : " << mPassedTests << std::endl; 121 std::cout << "Passed Tests : " << mPassedTests << std::endl;
122
123 if (mSkippedTests > 0)
124 {
125 std::cout << "Skipped Tests : " << mSkippedTests << std::endl;
126 }
127
116 if(mFailedTests > 0) 128 if(mFailedTests > 0)
117 { 129 {
118 std::cout << "*********************************" << std::endl; 130 std::cout << "*********************************" << std::endl;
@@ -128,6 +140,7 @@ protected:
128 S32 mTotalTests; 140 S32 mTotalTests;
129 S32 mPassedTests; 141 S32 mPassedTests;
130 S32 mFailedTests; 142 S32 mFailedTests;
143 S32 mSkippedTests;
131}; 144};
132 145
133static const apr_getopt_option_t TEST_CL_OPTIONS[] = 146static const apr_getopt_option_t TEST_CL_OPTIONS[] =
@@ -136,6 +149,7 @@ static const apr_getopt_option_t TEST_CL_OPTIONS[] =
136 {"list", 'l', 0, "List available test groups."}, 149 {"list", 'l', 0, "List available test groups."},
137 {"verbose", 'v', 0, "Verbose output."}, 150 {"verbose", 'v', 0, "Verbose output."},
138 {"group", 'g', 1, "Run test group specified by option argument."}, 151 {"group", 'g', 1, "Run test group specified by option argument."},
152 {"skip", 's', 1, "Skip test number specified by option argument. Only works when a specific group is being tested"},
139 {"wait", 'w', 0, "Wait for input before exit."}, 153 {"wait", 'w', 0, "Wait for input before exit."},
140 {0, 0, 0, 0} 154 {0, 0, 0, 0}
141}; 155};
@@ -165,6 +179,8 @@ void stream_usage(std::ostream& s, const char* app)
165 s << "\tList all available test groups." << std::endl; 179 s << "\tList all available test groups." << std::endl;
166 s << " " << app << " --group=uuid" << std::endl; 180 s << " " << app << " --group=uuid" << std::endl;
167 s << "\tRun the test group 'uuid'." << std::endl; 181 s << "\tRun the test group 'uuid'." << std::endl;
182 s << " " << app << " --skip=2" << std::endl;
183 s << "\tSkip test case 2." << std::endl;
168} 184}
169 185
170void stream_groups(std::ostream& s, const char* app) 186void stream_groups(std::ostream& s, const char* app)
@@ -212,6 +228,7 @@ int main(int argc, char **argv)
212 // values used for controlling application 228 // values used for controlling application
213 bool verbose_mode = false; 229 bool verbose_mode = false;
214 bool wait_at_exit = false; 230 bool wait_at_exit = false;
231 int skip_test_id = 0;
215 std::string test_group; 232 std::string test_group;
216 233
217 // values use for options parsing 234 // values use for options parsing
@@ -234,6 +251,9 @@ int main(int argc, char **argv)
234 case 'g': 251 case 'g':
235 test_group.assign(opt_arg); 252 test_group.assign(opt_arg);
236 break; 253 break;
254 case 's':
255 skip_test_id = atoi(opt_arg);
256 break;
237 case 'h': 257 case 'h':
238 stream_usage(std::cout, argv[0]); 258 stream_usage(std::cout, argv[0]);
239 return 0; 259 return 0;
@@ -264,7 +284,7 @@ int main(int argc, char **argv)
264 } 284 }
265 else 285 else
266 { 286 {
267 tut::runner.get().run_tests(test_group); 287 tut::runner.get().run_tests(test_group, skip_test_id);
268 } 288 }
269 289
270 if (wait_at_exit) 290 if (wait_at_exit)
diff --git a/linden/indra/test/test.vcproj b/linden/indra/test/test.vcproj
index 9255315..5df197a 100644
--- a/linden/indra/test/test.vcproj
+++ b/linden/indra/test/test.vcproj
@@ -145,7 +145,7 @@
145 Name="VCCustomBuildTool"/> 145 Name="VCCustomBuildTool"/>
146 <Tool 146 <Tool
147 Name="VCLinkerTool" 147 Name="VCLinkerTool"
148 AdditionalDependencies="advapi32.lib apr-1.lib aprutil-1.lib comdlg32.lib dinput8.lib dsound.lib dxerr8.lib dxguid.lib freetype.lib gdi32.lib glu32.lib jpeglib_6b.lib kernel32.lib libboost_regex-vc71-mt-s.lib libcurl.lib libeay32.lib libexpatMT.lib llcommon.lib llprimitive.lib llvfs.lib llxml.lib lscript_library.lib mswsock.lib netapi32.lib odbc32.lib odbccp32.lib ole32.lib oleaut32.lib opengl32.lib shell32.lib ssleay32.lib user32.lib Vfw32.lib winmm.lib winspool.lib ws2_32.lib xmlrpcepi.lib zlib.lib" 148 AdditionalDependencies="advapi32.lib apr-1.lib aprutil-1.lib comdlg32.lib gdi32.lib jpeglib_6b.lib kernel32.lib libboost_regex-vc71-mt-s.lib libcurl.lib libeay32.lib libexpatMT.lib mswsock.lib netapi32.lib odbc32.lib odbccp32.lib ole32.lib oleaut32.lib shell32.lib ssleay32.lib user32.lib winmm.lib winspool.lib ws2_32.lib xmlrpcepi.lib zlib.lib"
149 OutputFile="$(OutDir)/test.exe" 149 OutputFile="$(OutDir)/test.exe"
150 LinkIncremental="2" 150 LinkIncremental="2"
151 AdditionalLibraryDirectories="&quot;../lib_$(ConfigurationName)/i686-win32&quot;;&quot;../../libraries/i686-win32/lib_release&quot;" 151 AdditionalLibraryDirectories="&quot;../lib_$(ConfigurationName)/i686-win32&quot;;&quot;../../libraries/i686-win32/lib_release&quot;"
@@ -210,15 +210,24 @@
210 RelativePath=".\llrandom_tut.cpp"> 210 RelativePath=".\llrandom_tut.cpp">
211 </File> 211 </File>
212 <File 212 <File
213 RelativePath=".\llsd_message_system_tut.cpp"> 213 RelativePath=".\llsd_new_tut.cpp">
214 </File> 214 </File>
215 <File 215 <File
216 RelativePath=".\llsd_new_tut.cpp"> 216 RelativePath=".\llsdmessagebuilder_tut.cpp">
217 </File>
218 <File
219 RelativePath=".\llsdmessagereader_tut.cpp">
217 </File> 220 </File>
218 <File 221 <File
219 RelativePath=".\llsdserialize_tut.cpp"> 222 RelativePath=".\llsdserialize_tut.cpp">
220 </File> 223 </File>
221 <File 224 <File
225 RelativePath=".\llsdtraits.h">
226 </File>
227 <File
228 RelativePath=".\llservicebuilder_tut.cpp">
229 </File>
230 <File
222 RelativePath=".\lltiming_tut.cpp"> 231 RelativePath=".\lltiming_tut.cpp">
223 </File> 232 </File>
224 <File 233 <File
diff --git a/linden/indra/test/test_llmanifest.py b/linden/indra/test/test_llmanifest.py
index b20b6c1..f503cbe 100644
--- a/linden/indra/test/test_llmanifest.py
+++ b/linden/indra/test/test_llmanifest.py
@@ -5,6 +5,7 @@
5# 5#
6# Copyright (c) 2006-2007, Linden Research, Inc. 6# Copyright (c) 2006-2007, Linden Research, Inc.
7# 7#
8# Second Life Viewer Source Code
8# The source code in this file ("Source Code") is provided by Linden Lab 9# The source code in this file ("Source Code") is provided by Linden Lab
9# to you under the terms of the GNU General Public License, version 2.0 10# to you under the terms of the GNU General Public License, version 2.0
10# ("GPL"), unless you have obtained a separate licensing agreement 11# ("GPL"), unless you have obtained a separate licensing agreement
@@ -106,7 +107,7 @@ class TestLLManifest(unittest.TestCase):
106 def testruncommand(self): 107 def testruncommand(self):
107 self.assertEqual("Hello\n", self.m.run_command("echo Hello")) 108 self.assertEqual("Hello\n", self.m.run_command("echo Hello"))
108 def tmp_test(): 109 def tmp_test():
109 self.m.run_command("fff_garbage") 110 self.m.run_command("test_command_that_should_not_be_found")
110 self.assertRaises(RuntimeError, tmp_test) 111 self.assertRaises(RuntimeError, tmp_test)
111 112
112 def testpathof(self): 113 def testpathof(self):