summaryrefslogtreecommitdiff
path: root/indra/test/llsdmessagebuilder_tut.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/test/llsdmessagebuilder_tut.cpp')
-rw-r--r--[-rwxr-xr-x]indra/test/llsdmessagebuilder_tut.cpp595
1 files changed, 574 insertions, 21 deletions
diff --git a/indra/test/llsdmessagebuilder_tut.cpp b/indra/test/llsdmessagebuilder_tut.cpp
index 96b37cc262..cc6f78decd 100755..100644
--- a/indra/test/llsdmessagebuilder_tut.cpp
+++ b/indra/test/llsdmessagebuilder_tut.cpp
@@ -3,37 +3,33 @@
* @date February 2006
* @brief LLSDMessageBuilder unit tests
*
- * $LicenseInfo:firstyear=2006&license=viewergpl$
- *
- * Copyright (c) 2006-2007, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2006&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlife.com/developers/opensource/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at http://secondlife.com/developers/opensource/flossexception
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-#include <tut/tut.h>
+#include <tut/tut.hpp>
#include "linden_common.h"
#include "lltut.h"
+#include "llmessagetemplate.h"
#include "llsdmessagebuilder.h"
#include "llsdmessagereader.h"
#include "llsdtraits.h"
@@ -42,10 +38,26 @@
#include "v3dmath.h"
#include "v3math.h"
#include "v4math.h"
+#include "llsdutil.h"
+//#include "llsdutil.cpp"
+#include "llsdutil_math.cpp"
+#include "lltemplatemessagebuilder.h"
namespace tut
{
+ static LLTemplateMessageBuilder::message_template_name_map_t templateNameMap;
+
+ LLMsgData* messageData = NULL;
+ LLMsgBlkData* messageBlockData = NULL;
+
struct LLSDMessageBuilderTestData {
+
+ LLSDMessageBuilderTestData()
+ {
+ messageData = new LLMsgData("testMessage");
+ messageBlockData = new LLMsgBlkData("testBlock", 0);
+ }
+
static LLSDMessageBuilder defaultBuilder()
{
LLSDMessageBuilder builder;
@@ -60,6 +72,43 @@ namespace tut
reader.setMessage("name", builder.getMessage());
return reader;
}
+
+ static void addValue(LLMsgBlkData* mbd, char* name, void* v, EMsgVariableType type, int size, int data_size = -1)
+ {
+ LLMsgVarData tmp(name, type);
+ tmp.addData(v, size, type, data_size);
+ mbd->mMemberVarData[name] = tmp;
+ }
+
+
+ static LLMessageBlock* defaultTemplateBlock(const EMsgVariableType type = MVT_NULL, const S32 size = 0, EMsgBlockType block = MBT_VARIABLE)
+ {
+ return createTemplateBlock(_PREHASH_Test0, type, size, block);
+ }
+
+ static LLMessageBlock* createTemplateBlock(char* name, const EMsgVariableType type = MVT_NULL, const S32 size = 0, EMsgBlockType block = MBT_VARIABLE)
+ {
+ LLMessageBlock* result = new LLMessageBlock(name, block);
+ if(type != MVT_NULL)
+ {
+ result->addVariable(_PREHASH_Test0, type, size);
+ }
+ return result;
+ }
+
+ static LLTemplateMessageBuilder* defaultTemplateBuilder(LLMessageTemplate& messageTemplate, char* name = _PREHASH_Test0)
+ {
+ templateNameMap[_PREHASH_TestMessage] = &messageTemplate;
+ LLTemplateMessageBuilder* builder = new LLTemplateMessageBuilder(templateNameMap);
+ builder->newMessage(_PREHASH_TestMessage);
+ builder->nextBlock(name);
+ return builder;
+ }
+
+ static LLMessageTemplate defaultTemplate()
+ {
+ return LLMessageTemplate(_PREHASH_TestMessage, 1, MFT_HIGH);
+ }
};
typedef test_group<LLSDMessageBuilderTestData> LLSDMessageBuilderTestGroup;
@@ -279,5 +328,509 @@ namespace tut
outValue = buffer;
ensure_equals("Ensure String", inValue, outValue);
}
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<19>()
+ {
+ LLMsgBlkData* mbd = new LLMsgBlkData("testBlock", 0);
+ LLMsgData* md = new LLMsgData("testMessage");
+ md->addBlock(mbd);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*md);
+ LLSD output = builder.getMessage();
+
+ ensure("Ensure message block created when copied from legacy message to llsd", output["testBlock"].isDefined());
+ }
+
+ // MVT_FIXED
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<20>()
+ {
+ char binData[] = "abcdefghijklmnop";
+
+ addValue(messageBlockData, (char *)"testBinData", &binData, MVT_FIXED, sizeof(binData));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary();
+ ensure("Ensure MVT_S16Array data copied from legacy to llsd give a valid vector", v.size() > 0);
+
+ ensure_memory_matches("Ensure fixed binary data works in a message copied from legacy to llsd",
+ &v[0], sizeof(binData), binData, sizeof(binData));
+ }
+
+ // MVT_VARIABLE data_size 1 (U8's)
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<21>()
+ {
+ /* U8 binData[] = "abcdefghijklmnop";
+
+ addValue(messageBlockData, "testBinData", &binData, MVT_VARIABLE, sizeof(binData), 1);
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary();
+ ensure("Ensure MVT_S16Array data copied from legacy to llsd give a valid vector", v.size() > 0);
+
+ ensure_memory_matches("Ensure MVT_VARIABLE U8 binary data works in a message copied from legacy to llsd",
+ &v[0], sizeof(binData), binData, sizeof(binData));*/
+ }
+
+ // MVT_VARIABLE data_size 2 (U16's)
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<22>()
+ {
+ U16 binData[] = {1,2,3,4,5,6,7,8,9}; //9 shorts
+
+ addValue(messageBlockData, (char *)"testBinData", &binData, MVT_VARIABLE, sizeof(binData) >> 1, 2);
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary();
+ ensure("Ensure MVT_S16Array data copied from legacy to llsd give a valid vector", v.size() > 0);
+
+ ensure_memory_matches("Ensure MVT_VARIABLE U16 binary data works in a message copied from legacy to llsd",
+ &v[0], sizeof(binData) >> 1, binData, sizeof(binData) >> 1);
+ }
+
+ // MVT_VARIABLE data_size 4 (S32's)
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<23>()
+ {
+ U32 binData[] = {9,8,7,6,5,4,3,2,1};
+
+ addValue(messageBlockData, (char *)"testBinData", &binData, MVT_VARIABLE, sizeof(binData) >> 2, 4);
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary();
+ ensure("Ensure MVT_S16Array data copied from legacy to llsd give a valid vector", v.size() > 0);
+
+ ensure_memory_matches("Ensure MVT_VARIABLE S32 binary data works in a message copied from legacy to llsd",
+ &v[0], sizeof(binData) >> 2, binData, sizeof(binData) >> 2);
+ }
+
+ // MVT_U8
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<24>()
+ {
+ U8 data = 0xa5;
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_U8, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ ensure_equals("Ensure MVT_U8 data works in a message copied from legacy to llsd",
+ output["testBlock"][0]["testBinData"].asInteger(), data);
+ }
+
+ // MVT_U16
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<25>()
+ {
+ U16 data = 0xa55a;
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_U16, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ ensure_equals("Ensure MVT_U16 data works in a message copied from legacy to llsd",
+ output["testBlock"][0]["testBinData"].asInteger(), data);
+ }
+
+ // MVT_U32
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<26>()
+ {
+ U32 data = 0xa55a7117;
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_U32, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ ensure_equals("Ensure MVT_U32 data works in a message copied from legacy to llsd",
+ ll_U32_from_sd(output["testBlock"][0]["testBinData"]), data);
+ }
+
+ // MVT_U64 - crush into an s32: LLSD does not support 64 bit values
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<27>()
+ {
+ U64 data = U64L(0xa55a711711223344);
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_U64, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ ensure_equals("Ensure MVT_U64 data works in a message copied from legacy to llsd",
+ ll_U64_from_sd(output["testBlock"][0]["testBinData"]), data);
+ }
+
+ // MVT_S8
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<28>()
+ {
+ S8 data = -31;
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_S8, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ ensure_equals("Ensure MVT_S8 data works in a message copied from legacy to llsd",
+ output["testBlock"][0]["testBinData"].asInteger(), data);
+ }
+
+ // MVT_S16
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<29>()
+ {
+ S16 data = -31;
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_S16, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ ensure_equals("Ensure MVT_S16 data works in a message copied from legacy to llsd",
+ output["testBlock"][0]["testBinData"].asInteger(), data);
+ }
+
+ // MVT_S32
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<30>()
+ {
+ S32 data = -3100;
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_S32, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ ensure_equals("Ensure MVT_S32 data works in a message copied from legacy to llsd",
+ output["testBlock"][0]["testBinData"].asInteger(), data);
+ }
+
+ // MVT_S64 - crush into an s32: LLSD does not support 64 bit values
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<31>()
+ {
+ S64 data = -31003100;
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_S64, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ ensure_equals("Ensure MVT_S64 data works in a message copied from legacy to llsd",
+ output["testBlock"][0]["testBinData"].asInteger(), (S32)data);
+ }
+
+ // MVT_F32
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<32>()
+ {
+ F32 data = 1234.1234f;
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_F32, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ ensure_equals("Ensure MVT_F32 data works in a message copied from legacy to llsd",
+ output["testBlock"][0]["testBinData"].asReal(), data);
+ }
+
+ // MVT_F64
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<33>()
+ {
+ F64 data = 1234.1234;
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_F64, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ ensure_equals("Ensure MVT_F64 data works in a message copied from legacy to llsd",
+ output["testBlock"][0]["testBinData"].asReal(), data);
+ }
+
+ // MVT_LLVector3
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<34>()
+ {
+ LLVector3 data(1,2,3);
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_LLVector3, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ ensure_equals("Ensure MVT_LLVector3 data works in a message copied from legacy to llsd",
+ ll_vector3_from_sd(output["testBlock"][0]["testBinData"]), data);
+ }
+
+ // MVT_LLVector3d
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<35>()
+ {
+ LLVector3d data(1,2,3);
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_LLVector3d, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ ensure_equals("Ensure MVT_LLVector3 data works in a message copied from legacy to llsd",
+ ll_vector3d_from_sd(output["testBlock"][0]["testBinData"]), data);
+ }
+
+ // MVT_LLVector4
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<36>()
+ {
+ LLVector4 data(1,2,3,4);
+ LLSD v = ll_sd_from_vector4(data);
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_LLVector4, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ ensure_equals("Ensure MVT_LLVector4 data works in a message copied from legacy to llsd",
+ output["testBlock"][0]["testBinData"], v);
+ }
+
+ // MVT_LLQuaternion
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<37>()
+ {
+ LLQuaternion data(1,2,3,0);
+
+ //we send a quaternion packed into a vec3 (w is infered) - so sizeof(vec) == 12 bytes not 16.
+ LLVector3 vec = data.packToVector3();
+
+ addValue(messageBlockData, (char *)"testBinData", &vec, MVT_LLQuaternion, sizeof(vec));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ ensure_equals("Ensure MVT_LLQuaternion data works in a message copied from legacy to llsd",
+ ll_quaternion_from_sd(output["testBlock"][0]["testBinData"]), data);
+ }
+
+ // MVT_LLUUID
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<38>()
+ {
+ LLUUID data("01234567-0123-0123-0123-234567abcdef");
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_LLUUID, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ std::string v = output["testBlock"][0]["testBinData"].asUUID().asString();
+
+ ensure_equals("Ensure MVT_LLUUID data works in a message copied from legacy to llsd",
+ output["testBlock"][0]["testBinData"].asUUID(), data);
+ }
+
+ // MVT_BOOL
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<39>()
+ {
+ BOOL valueTrue = true;
+ BOOL valueFalse = false;
+
+ LLMsgData* md = new LLMsgData("testMessage");
+ LLMsgBlkData* mbd = new LLMsgBlkData("testBlock", 0);
+ addValue(mbd, (char *)"testBoolFalse", &valueFalse, MVT_BOOL, sizeof(BOOL));
+ addValue(mbd, (char *)"testBoolTrue", &valueTrue, MVT_BOOL, sizeof(BOOL));
+ md->addBlock(mbd);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*md);
+ LLSD output = builder.getMessage();
+
+ ensure("Ensure bools work in a message copied from legacy to llsd",
+ output["testBlock"][0]["testBoolTrue"].asBoolean() && !output["testBlock"][0]["testBoolFalse"].asBoolean());
+ }
+
+ // MVT_IP_ADDR
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<40>()
+ {
+ U32 data(0xff887766);
+ LLSD v = ll_sd_from_ipaddr(data);
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_IP_ADDR, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ ensure_equals("Ensure MVT_IP_ADDR data works in a message copied from legacy to llsd",
+ output["testBlock"][0]["testBinData"], v);
+ }
+
+ // MVT_IP_PORT
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<41>()
+ {
+ U16 data = 0xff88;
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_IP_PORT, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ ensure_equals("Ensure MVT_IP_PORT data works in a message copied from legacy to llsd",
+ output["testBlock"][0]["testBinData"].asInteger(), data);
+ }
+
+ // MVT_U16Vec3
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<42>()
+ {
+ U16 data[3] = {0,1,2};
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_U16Vec3, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary();
+ ensure("Ensure MVT_U16Vec3 data copied from legacy to llsd give a valid vector", v.size() > 0);
+
+ ensure_memory_matches("Ensure MVT_U16Vec3 data works in a message copied from legacy to llsd",
+ (U16*)&v[0], 6, data, 6);
+ }
+
+ // MVT_U16Quat
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<43>()
+ {
+ U16 data[4] = {0,1,2,4};
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_U16Quat, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary();
+ ensure("Ensure MVT_U16Quat data copied from legacy to llsd give a valid vector", v.size() > 0);
+
+ ensure_memory_matches("Ensure MVT_U16Quat data works in a message copied from legacy to llsd",
+ (U16*)&v[0], 8, data, 8);
+ }
+
+ // MVT_S16Array
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<44>()
+ {
+ S16 data[19] = {0,-1,2,-4,5,-6,7,-8,9,-10,11,-12,13,-14,15,16,17,18};
+
+ addValue(messageBlockData, (char *)"testBinData", &data, MVT_S16Array, sizeof(data));
+ messageData->addBlock(messageBlockData);
+ LLSDMessageBuilder builder = defaultBuilder();
+
+ builder.copyFromMessageData(*messageData);
+ LLSD output = builder.getMessage();
+
+ std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary();
+ ensure("Ensure MVT_S16Array data copied from legacy to llsd give a valid vector", v.size() > 0);
+
+ ensure_memory_matches("Ensure MVT_S16Array data works in a message copied from legacy to llsd",
+ (U16*)&v[0], 19, data, 19);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<45>()
+ {
+ LLMessageTemplate messageTemplate = defaultTemplate();
+ messageTemplate.addBlock(defaultTemplateBlock(MVT_U8, 1));
+ U8 inValue = 2;
+ LLTemplateMessageBuilder* template_builder = defaultTemplateBuilder(messageTemplate);
+ template_builder->addU8(_PREHASH_Test0, inValue);
+
+ LLSDMessageBuilder builder;
+ builder.copyFromMessageData(*template_builder->getCurrentMessage());
+ LLSD output = builder.getMessage();
+
+ ensure_equals(output["Test0"][0]["Test0"].asInteger(), 2);
+
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<46>()
+ {
+ LLMessageTemplate messageTemplate = defaultTemplate();
+ messageTemplate.addBlock(defaultTemplateBlock(MVT_VARIABLE, 1));
+ std::string inValue = "testing";
+ LLTemplateMessageBuilder* builder = defaultTemplateBuilder(messageTemplate);
+ builder->addString(_PREHASH_Test0, inValue.c_str());
+
+ LLSDMessageBuilder sd_builder;
+ sd_builder.copyFromMessageData(*builder->getCurrentMessage());
+ LLSD output = sd_builder.getMessage();
+
+ ensure_equals(output["Test0"][0]["Test0"].asString(), std::string("testing"));
+ }
+
}