aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/test/llsdmessagebuilder_tut.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-30 13:04:20 -0500
committerJacek Antonelli2009-04-30 13:07:16 -0500
commitca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch)
tree8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/test/llsdmessagebuilder_tut.cpp
parentSecond Life viewer sources 1.22.11 (diff)
downloadmeta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz
Second Life viewer sources 1.23.0-RC
Diffstat (limited to 'linden/indra/test/llsdmessagebuilder_tut.cpp')
-rwxr-xr-xlinden/indra/test/llsdmessagebuilder_tut.cpp561
1 files changed, 559 insertions, 2 deletions
diff --git a/linden/indra/test/llsdmessagebuilder_tut.cpp b/linden/indra/test/llsdmessagebuilder_tut.cpp
index 81a5b96..27ab127 100755
--- a/linden/indra/test/llsdmessagebuilder_tut.cpp
+++ b/linden/indra/test/llsdmessagebuilder_tut.cpp
@@ -18,7 +18,8 @@
18 * There are special exceptions to the terms and conditions of the GPL as 18 * There are special exceptions to the terms and conditions of the GPL as
19 * it is applied to this Source Code. View the full text of the exception 19 * it is applied to this Source Code. View the full text of the exception
20 * in the file doc/FLOSS-exception.txt in this software distribution, or 20 * in the file doc/FLOSS-exception.txt in this software distribution, or
21 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 21 * online at
22 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
22 * 23 *
23 * By copying, modifying or distributing this software, you acknowledge 24 * By copying, modifying or distributing this software, you acknowledge
24 * that you have read and understood your obligations described above, 25 * that you have read and understood your obligations described above,
@@ -30,10 +31,11 @@
30 * $/LicenseInfo$ 31 * $/LicenseInfo$
31 */ 32 */
32 33
33#include <tut/tut.h> 34#include <tut/tut.hpp>
34 35
35#include "linden_common.h" 36#include "linden_common.h"
36#include "lltut.h" 37#include "lltut.h"
38#include "llmessagetemplate.h"
37#include "llsdmessagebuilder.h" 39#include "llsdmessagebuilder.h"
38#include "llsdmessagereader.h" 40#include "llsdmessagereader.h"
39#include "llsdtraits.h" 41#include "llsdtraits.h"
@@ -42,10 +44,24 @@
42#include "v3dmath.h" 44#include "v3dmath.h"
43#include "v3math.h" 45#include "v3math.h"
44#include "v4math.h" 46#include "v4math.h"
47#include "llsdutil_math.cpp"
48#include "lltemplatemessagebuilder.h"
45 49
46namespace tut 50namespace tut
47{ 51{
52 static LLTemplateMessageBuilder::message_template_name_map_t templateNameMap;
53
54 LLMsgData* messageData = NULL;
55 LLMsgBlkData* messageBlockData = NULL;
56
48 struct LLSDMessageBuilderTestData { 57 struct LLSDMessageBuilderTestData {
58
59 LLSDMessageBuilderTestData()
60 {
61 messageData = new LLMsgData("testMessage");
62 messageBlockData = new LLMsgBlkData("testBlock", 0);
63 }
64
49 static LLSDMessageBuilder defaultBuilder() 65 static LLSDMessageBuilder defaultBuilder()
50 { 66 {
51 LLSDMessageBuilder builder; 67 LLSDMessageBuilder builder;
@@ -60,6 +76,43 @@ namespace tut
60 reader.setMessage("name", builder.getMessage()); 76 reader.setMessage("name", builder.getMessage());
61 return reader; 77 return reader;
62 } 78 }
79
80 static void addValue(LLMsgBlkData* mbd, char* name, void* v, EMsgVariableType type, int size, int data_size = -1)
81 {
82 LLMsgVarData tmp(name, type);
83 tmp.addData(v, size, type, data_size);
84 mbd->mMemberVarData[name] = tmp;
85 }
86
87
88 static LLMessageBlock* defaultTemplateBlock(const EMsgVariableType type = MVT_NULL, const S32 size = 0, EMsgBlockType block = MBT_VARIABLE)
89 {
90 return createTemplateBlock(_PREHASH_Test0, type, size, block);
91 }
92
93 static LLMessageBlock* createTemplateBlock(char* name, const EMsgVariableType type = MVT_NULL, const S32 size = 0, EMsgBlockType block = MBT_VARIABLE)
94 {
95 LLMessageBlock* result = new LLMessageBlock(name, block);
96 if(type != MVT_NULL)
97 {
98 result->addVariable(_PREHASH_Test0, type, size);
99 }
100 return result;
101 }
102
103 static LLTemplateMessageBuilder* defaultTemplateBuilder(LLMessageTemplate& messageTemplate, char* name = _PREHASH_Test0)
104 {
105 templateNameMap[_PREHASH_TestMessage] = &messageTemplate;
106 LLTemplateMessageBuilder* builder = new LLTemplateMessageBuilder(templateNameMap);
107 builder->newMessage(_PREHASH_TestMessage);
108 builder->nextBlock(name);
109 return builder;
110 }
111
112 static LLMessageTemplate defaultTemplate()
113 {
114 return LLMessageTemplate(_PREHASH_TestMessage, 1, MFT_HIGH);
115 }
63 }; 116 };
64 117
65 typedef test_group<LLSDMessageBuilderTestData> LLSDMessageBuilderTestGroup; 118 typedef test_group<LLSDMessageBuilderTestData> LLSDMessageBuilderTestGroup;
@@ -279,5 +332,509 @@ namespace tut
279 outValue = buffer; 332 outValue = buffer;
280 ensure_equals("Ensure String", inValue, outValue); 333 ensure_equals("Ensure String", inValue, outValue);
281 } 334 }
335
336 template<> template<>
337 void LLSDMessageBuilderTestObject::test<19>()
338 {
339 LLMsgBlkData* mbd = new LLMsgBlkData("testBlock", 0);
340 LLMsgData* md = new LLMsgData("testMessage");
341 md->addBlock(mbd);
342 LLSDMessageBuilder builder = defaultBuilder();
343
344 builder.copyFromMessageData(*md);
345 LLSD output = builder.getMessage();
346
347 ensure("Ensure message block created when copied from legacy message to llsd", output["testBlock"].isDefined());
348 }
349
350 // MVT_FIXED
351 template<> template<>
352 void LLSDMessageBuilderTestObject::test<20>()
353 {
354 char binData[] = "abcdefghijklmnop";
355
356 addValue(messageBlockData, "testBinData", &binData, MVT_FIXED, sizeof(binData));
357 messageData->addBlock(messageBlockData);
358 LLSDMessageBuilder builder = defaultBuilder();
359
360 builder.copyFromMessageData(*messageData);
361 LLSD output = builder.getMessage();
362
363 std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary();
364 ensure("Ensure MVT_S16Array data copied from legacy to llsd give a valid vector", v.size() > 0);
365
366 ensure_memory_matches("Ensure fixed binary data works in a message copied from legacy to llsd",
367 &v[0], sizeof(binData), binData, sizeof(binData));
368 }
369
370 // MVT_VARIABLE data_size 1 (U8's)
371 template<> template<>
372 void LLSDMessageBuilderTestObject::test<21>()
373 {
374 /* U8 binData[] = "abcdefghijklmnop";
375
376 addValue(messageBlockData, "testBinData", &binData, MVT_VARIABLE, sizeof(binData), 1);
377 messageData->addBlock(messageBlockData);
378 LLSDMessageBuilder builder = defaultBuilder();
379
380 builder.copyFromMessageData(*messageData);
381 LLSD output = builder.getMessage();
382
383 std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary();
384 ensure("Ensure MVT_S16Array data copied from legacy to llsd give a valid vector", v.size() > 0);
385
386 ensure_memory_matches("Ensure MVT_VARIABLE U8 binary data works in a message copied from legacy to llsd",
387 &v[0], sizeof(binData), binData, sizeof(binData));*/
388 }
389
390 // MVT_VARIABLE data_size 2 (U16's)
391 template<> template<>
392 void LLSDMessageBuilderTestObject::test<22>()
393 {
394 U16 binData[] = {1,2,3,4,5,6,7,8,9}; //9 shorts
395
396 addValue(messageBlockData, "testBinData", &binData, MVT_VARIABLE, sizeof(binData) >> 1, 2);
397 messageData->addBlock(messageBlockData);
398 LLSDMessageBuilder builder = defaultBuilder();
399
400 builder.copyFromMessageData(*messageData);
401 LLSD output = builder.getMessage();
402
403 std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary();
404 ensure("Ensure MVT_S16Array data copied from legacy to llsd give a valid vector", v.size() > 0);
405
406 ensure_memory_matches("Ensure MVT_VARIABLE U16 binary data works in a message copied from legacy to llsd",
407 &v[0], sizeof(binData) >> 1, binData, sizeof(binData) >> 1);
408 }
409
410 // MVT_VARIABLE data_size 4 (S32's)
411 template<> template<>
412 void LLSDMessageBuilderTestObject::test<23>()
413 {
414 U32 binData[] = {9,8,7,6,5,4,3,2,1};
415
416 addValue(messageBlockData, "testBinData", &binData, MVT_VARIABLE, sizeof(binData) >> 2, 4);
417 messageData->addBlock(messageBlockData);
418 LLSDMessageBuilder builder = defaultBuilder();
419
420 builder.copyFromMessageData(*messageData);
421 LLSD output = builder.getMessage();
422
423 std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary();
424 ensure("Ensure MVT_S16Array data copied from legacy to llsd give a valid vector", v.size() > 0);
425
426 ensure_memory_matches("Ensure MVT_VARIABLE S32 binary data works in a message copied from legacy to llsd",
427 &v[0], sizeof(binData) >> 2, binData, sizeof(binData) >> 2);
428 }
429
430 // MVT_U8
431 template<> template<>
432 void LLSDMessageBuilderTestObject::test<24>()
433 {
434 U8 data = 0xa5;
435
436 addValue(messageBlockData, "testBinData", &data, MVT_U8, sizeof(data));
437 messageData->addBlock(messageBlockData);
438 LLSDMessageBuilder builder = defaultBuilder();
439
440 builder.copyFromMessageData(*messageData);
441 LLSD output = builder.getMessage();
442
443 ensure_equals("Ensure MVT_U8 data works in a message copied from legacy to llsd",
444 output["testBlock"][0]["testBinData"].asInteger(), data);
445 }
446
447 // MVT_U16
448 template<> template<>
449 void LLSDMessageBuilderTestObject::test<25>()
450 {
451 U16 data = 0xa55a;
452
453 addValue(messageBlockData, "testBinData", &data, MVT_U16, sizeof(data));
454 messageData->addBlock(messageBlockData);
455 LLSDMessageBuilder builder = defaultBuilder();
456
457 builder.copyFromMessageData(*messageData);
458 LLSD output = builder.getMessage();
459
460 ensure_equals("Ensure MVT_U16 data works in a message copied from legacy to llsd",
461 output["testBlock"][0]["testBinData"].asInteger(), data);
462 }
463
464 // MVT_U32
465 template<> template<>
466 void LLSDMessageBuilderTestObject::test<26>()
467 {
468 U32 data = 0xa55a7117;
469
470 addValue(messageBlockData, "testBinData", &data, MVT_U32, sizeof(data));
471 messageData->addBlock(messageBlockData);
472 LLSDMessageBuilder builder = defaultBuilder();
473
474 builder.copyFromMessageData(*messageData);
475 LLSD output = builder.getMessage();
476
477 ensure_equals("Ensure MVT_U32 data works in a message copied from legacy to llsd",
478 ll_U32_from_sd(output["testBlock"][0]["testBinData"]), data);
479 }
480
481 // MVT_U64 - crush into an s32: LLSD does not support 64 bit values
482 template<> template<>
483 void LLSDMessageBuilderTestObject::test<27>()
484 {
485 U64 data = U64L(0xa55a711711223344);
486 addValue(messageBlockData, "testBinData", &data, MVT_U64, sizeof(data));
487 messageData->addBlock(messageBlockData);
488 LLSDMessageBuilder builder = defaultBuilder();
489
490 builder.copyFromMessageData(*messageData);
491 LLSD output = builder.getMessage();
492
493 ensure_equals("Ensure MVT_U64 data works in a message copied from legacy to llsd",
494 ll_U64_from_sd(output["testBlock"][0]["testBinData"]), data);
495 }
496
497 // MVT_S8
498 template<> template<>
499 void LLSDMessageBuilderTestObject::test<28>()
500 {
501 S8 data = -31;
502
503 addValue(messageBlockData, "testBinData", &data, MVT_S8, sizeof(data));
504 messageData->addBlock(messageBlockData);
505 LLSDMessageBuilder builder = defaultBuilder();
506
507 builder.copyFromMessageData(*messageData);
508 LLSD output = builder.getMessage();
509
510 ensure_equals("Ensure MVT_S8 data works in a message copied from legacy to llsd",
511 output["testBlock"][0]["testBinData"].asInteger(), data);
512 }
513
514 // MVT_S16
515 template<> template<>
516 void LLSDMessageBuilderTestObject::test<29>()
517 {
518 S16 data = -31;
519
520 addValue(messageBlockData, "testBinData", &data, MVT_S16, sizeof(data));
521 messageData->addBlock(messageBlockData);
522 LLSDMessageBuilder builder = defaultBuilder();
523
524 builder.copyFromMessageData(*messageData);
525 LLSD output = builder.getMessage();
526
527 ensure_equals("Ensure MVT_S16 data works in a message copied from legacy to llsd",
528 output["testBlock"][0]["testBinData"].asInteger(), data);
529 }
530
531 // MVT_S32
532 template<> template<>
533 void LLSDMessageBuilderTestObject::test<30>()
534 {
535 S32 data = -3100;
536
537 addValue(messageBlockData, "testBinData", &data, MVT_S32, sizeof(data));
538 messageData->addBlock(messageBlockData);
539 LLSDMessageBuilder builder = defaultBuilder();
540
541 builder.copyFromMessageData(*messageData);
542 LLSD output = builder.getMessage();
543
544 ensure_equals("Ensure MVT_S32 data works in a message copied from legacy to llsd",
545 output["testBlock"][0]["testBinData"].asInteger(), data);
546 }
547
548 // MVT_S64 - crush into an s32: LLSD does not support 64 bit values
549 template<> template<>
550 void LLSDMessageBuilderTestObject::test<31>()
551 {
552 S64 data = -31003100;
553
554 addValue(messageBlockData, "testBinData", &data, MVT_S64, sizeof(data));
555 messageData->addBlock(messageBlockData);
556 LLSDMessageBuilder builder = defaultBuilder();
557
558 builder.copyFromMessageData(*messageData);
559 LLSD output = builder.getMessage();
560
561 ensure_equals("Ensure MVT_S64 data works in a message copied from legacy to llsd",
562 output["testBlock"][0]["testBinData"].asInteger(), (S32)data);
563 }
564
565 // MVT_F32
566 template<> template<>
567 void LLSDMessageBuilderTestObject::test<32>()
568 {
569 F32 data = 1234.1234f;
570
571 addValue(messageBlockData, "testBinData", &data, MVT_F32, sizeof(data));
572 messageData->addBlock(messageBlockData);
573 LLSDMessageBuilder builder = defaultBuilder();
574
575 builder.copyFromMessageData(*messageData);
576 LLSD output = builder.getMessage();
577
578 ensure_equals("Ensure MVT_F32 data works in a message copied from legacy to llsd",
579 output["testBlock"][0]["testBinData"].asReal(), data);
580 }
581
582 // MVT_F64
583 template<> template<>
584 void LLSDMessageBuilderTestObject::test<33>()
585 {
586 F64 data = 1234.1234;
587
588 addValue(messageBlockData, "testBinData", &data, MVT_F64, sizeof(data));
589 messageData->addBlock(messageBlockData);
590 LLSDMessageBuilder builder = defaultBuilder();
591
592 builder.copyFromMessageData(*messageData);
593 LLSD output = builder.getMessage();
594
595 ensure_equals("Ensure MVT_F64 data works in a message copied from legacy to llsd",
596 output["testBlock"][0]["testBinData"].asReal(), data);
597 }
598
599 // MVT_LLVector3
600 template<> template<>
601 void LLSDMessageBuilderTestObject::test<34>()
602 {
603 LLVector3 data(1,2,3);
604
605 addValue(messageBlockData, "testBinData", &data, MVT_LLVector3, sizeof(data));
606 messageData->addBlock(messageBlockData);
607 LLSDMessageBuilder builder = defaultBuilder();
608
609 builder.copyFromMessageData(*messageData);
610 LLSD output = builder.getMessage();
611
612 ensure_equals("Ensure MVT_LLVector3 data works in a message copied from legacy to llsd",
613 ll_vector3_from_sd(output["testBlock"][0]["testBinData"]), data);
614 }
615
616 // MVT_LLVector3d
617 template<> template<>
618 void LLSDMessageBuilderTestObject::test<35>()
619 {
620 LLVector3d data(1,2,3);
621
622 addValue(messageBlockData, "testBinData", &data, MVT_LLVector3d, sizeof(data));
623 messageData->addBlock(messageBlockData);
624 LLSDMessageBuilder builder = defaultBuilder();
625
626 builder.copyFromMessageData(*messageData);
627 LLSD output = builder.getMessage();
628
629 ensure_equals("Ensure MVT_LLVector3 data works in a message copied from legacy to llsd",
630 ll_vector3d_from_sd(output["testBlock"][0]["testBinData"]), data);
631 }
632
633 // MVT_LLVector4
634 template<> template<>
635 void LLSDMessageBuilderTestObject::test<36>()
636 {
637 LLVector4 data(1,2,3,4);
638 LLSD v = ll_sd_from_vector4(data);
639
640 addValue(messageBlockData, "testBinData", &data, MVT_LLVector4, sizeof(data));
641 messageData->addBlock(messageBlockData);
642 LLSDMessageBuilder builder = defaultBuilder();
643
644 builder.copyFromMessageData(*messageData);
645 LLSD output = builder.getMessage();
646
647 ensure_equals("Ensure MVT_LLVector4 data works in a message copied from legacy to llsd",
648 output["testBlock"][0]["testBinData"], v);
649 }
650
651 // MVT_LLQuaternion
652 template<> template<>
653 void LLSDMessageBuilderTestObject::test<37>()
654 {
655 LLQuaternion data(1,2,3,0);
656
657 //we send a quaternion packed into a vec3 (w is infered) - so sizeof(vec) == 12 bytes not 16.
658 LLVector3 vec = data.packToVector3();
659
660 addValue(messageBlockData, "testBinData", &vec, MVT_LLQuaternion, sizeof(vec));
661 messageData->addBlock(messageBlockData);
662 LLSDMessageBuilder builder = defaultBuilder();
663
664 builder.copyFromMessageData(*messageData);
665 LLSD output = builder.getMessage();
666
667 ensure_equals("Ensure MVT_LLQuaternion data works in a message copied from legacy to llsd",
668 ll_quaternion_from_sd(output["testBlock"][0]["testBinData"]), data);
669 }
670
671 // MVT_LLUUID
672 template<> template<>
673 void LLSDMessageBuilderTestObject::test<38>()
674 {
675 LLUUID data("01234567-0123-0123-0123-234567abcdef");
676
677 addValue(messageBlockData, "testBinData", &data, MVT_LLUUID, sizeof(data));
678 messageData->addBlock(messageBlockData);
679 LLSDMessageBuilder builder = defaultBuilder();
680
681 builder.copyFromMessageData(*messageData);
682 LLSD output = builder.getMessage();
683
684 std::string v = output["testBlock"][0]["testBinData"].asUUID().asString();
685
686 ensure_equals("Ensure MVT_LLUUID data works in a message copied from legacy to llsd",
687 output["testBlock"][0]["testBinData"].asUUID(), data);
688 }
689
690 // MVT_BOOL
691 template<> template<>
692 void LLSDMessageBuilderTestObject::test<39>()
693 {
694 BOOL valueTrue = true;
695 BOOL valueFalse = false;
696
697 LLMsgData* md = new LLMsgData("testMessage");
698 LLMsgBlkData* mbd = new LLMsgBlkData("testBlock", 0);
699 addValue(mbd, "testBoolFalse", &valueFalse, MVT_BOOL, sizeof(BOOL));
700 addValue(mbd, "testBoolTrue", &valueTrue, MVT_BOOL, sizeof(BOOL));
701 md->addBlock(mbd);
702 LLSDMessageBuilder builder = defaultBuilder();
703
704 builder.copyFromMessageData(*md);
705 LLSD output = builder.getMessage();
706
707 ensure("Ensure bools work in a message copied from legacy to llsd",
708 output["testBlock"][0]["testBoolTrue"].asBoolean() && !output["testBlock"][0]["testBoolFalse"].asBoolean());
709 }
710
711 // MVT_IP_ADDR
712 template<> template<>
713 void LLSDMessageBuilderTestObject::test<40>()
714 {
715 U32 data(0xff887766);
716 LLSD v = ll_sd_from_ipaddr(data);
717
718 addValue(messageBlockData, "testBinData", &data, MVT_IP_ADDR, sizeof(data));
719 messageData->addBlock(messageBlockData);
720 LLSDMessageBuilder builder = defaultBuilder();
721
722 builder.copyFromMessageData(*messageData);
723 LLSD output = builder.getMessage();
724
725 ensure_equals("Ensure MVT_IP_ADDR data works in a message copied from legacy to llsd",
726 output["testBlock"][0]["testBinData"], v);
727 }
728
729 // MVT_IP_PORT
730 template<> template<>
731 void LLSDMessageBuilderTestObject::test<41>()
732 {
733 U16 data = 0xff88;
734
735 addValue(messageBlockData, "testBinData", &data, MVT_IP_PORT, sizeof(data));
736 messageData->addBlock(messageBlockData);
737 LLSDMessageBuilder builder = defaultBuilder();
738
739 builder.copyFromMessageData(*messageData);
740 LLSD output = builder.getMessage();
741
742 ensure_equals("Ensure MVT_IP_PORT data works in a message copied from legacy to llsd",
743 output["testBlock"][0]["testBinData"].asInteger(), data);
744 }
745
746 // MVT_U16Vec3
747 template<> template<>
748 void LLSDMessageBuilderTestObject::test<42>()
749 {
750 U16 data[3] = {0,1,2};
751
752 addValue(messageBlockData, "testBinData", &data, MVT_U16Vec3, sizeof(data));
753 messageData->addBlock(messageBlockData);
754 LLSDMessageBuilder builder = defaultBuilder();
755
756 builder.copyFromMessageData(*messageData);
757 LLSD output = builder.getMessage();
758
759 std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary();
760 ensure("Ensure MVT_U16Vec3 data copied from legacy to llsd give a valid vector", v.size() > 0);
761
762 ensure_memory_matches("Ensure MVT_U16Vec3 data works in a message copied from legacy to llsd",
763 (U16*)&v[0], 6, data, 6);
764 }
765
766 // MVT_U16Quat
767 template<> template<>
768 void LLSDMessageBuilderTestObject::test<43>()
769 {
770 U16 data[4] = {0,1,2,4};
771
772 addValue(messageBlockData, "testBinData", &data, MVT_U16Quat, sizeof(data));
773 messageData->addBlock(messageBlockData);
774 LLSDMessageBuilder builder = defaultBuilder();
775
776 builder.copyFromMessageData(*messageData);
777 LLSD output = builder.getMessage();
778
779 std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary();
780 ensure("Ensure MVT_U16Quat data copied from legacy to llsd give a valid vector", v.size() > 0);
781
782 ensure_memory_matches("Ensure MVT_U16Quat data works in a message copied from legacy to llsd",
783 (U16*)&v[0], 8, data, 8);
784 }
785
786 // MVT_S16Array
787 template<> template<>
788 void LLSDMessageBuilderTestObject::test<44>()
789 {
790 S16 data[19] = {0,-1,2,-4,5,-6,7,-8,9,-10,11,-12,13,-14,15,16,17,18};
791
792 addValue(messageBlockData, "testBinData", &data, MVT_S16Array, sizeof(data));
793 messageData->addBlock(messageBlockData);
794 LLSDMessageBuilder builder = defaultBuilder();
795
796 builder.copyFromMessageData(*messageData);
797 LLSD output = builder.getMessage();
798
799 std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary();
800 ensure("Ensure MVT_S16Array data copied from legacy to llsd give a valid vector", v.size() > 0);
801
802 ensure_memory_matches("Ensure MVT_S16Array data works in a message copied from legacy to llsd",
803 (U16*)&v[0], 19, data, 19);
804 }
805
806 template<> template<>
807 void LLSDMessageBuilderTestObject::test<45>()
808 {
809 LLMessageTemplate messageTemplate = defaultTemplate();
810 messageTemplate.addBlock(defaultTemplateBlock(MVT_U8, 1));
811 U8 inValue = 2;
812 LLTemplateMessageBuilder* template_builder = defaultTemplateBuilder(messageTemplate);
813 template_builder->addU8(_PREHASH_Test0, inValue);
814
815 LLSDMessageBuilder builder;
816 builder.copyFromMessageData(*template_builder->getCurrentMessage());
817 LLSD output = builder.getMessage();
818
819 ensure_equals(output["Test0"][0]["Test0"].asInteger(), 2);
820
821 }
822
823 template<> template<>
824 void LLSDMessageBuilderTestObject::test<46>()
825 {
826 LLMessageTemplate messageTemplate = defaultTemplate();
827 messageTemplate.addBlock(defaultTemplateBlock(MVT_VARIABLE, 1));
828 std::string inValue = "testing";
829 LLTemplateMessageBuilder* builder = defaultTemplateBuilder(messageTemplate);
830 builder->addString(_PREHASH_Test0, inValue.c_str());
831
832 LLSDMessageBuilder sd_builder;
833 sd_builder.copyFromMessageData(*builder->getCurrentMessage());
834 LLSD output = sd_builder.getMessage();
835
836 ensure_equals(output["Test0"][0]["Test0"].asString(), std::string("testing"));
837 }
838
282} 839}
283 840