PageRenderTime 88ms CodeModel.GetById 14ms app.highlight 69ms RepoModel.GetById 1ms app.codeStats 1ms

/indra/test/lldatapacker_tut.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 570 lines | 482 code | 58 blank | 30 comment | 26 complexity | 3c82e7e8e006ebe3d510b493c87644ed MD5 | raw file
  1/**
  2 * @file lldatapacker_tut.cpp
  3 * @author Adroit
  4 * @date 2007-02
  5 * @brief LLDataPacker test cases.
  6 *
  7 * $LicenseInfo:firstyear=2007&license=viewerlgpl$
  8 * Second Life Viewer Source Code
  9 * Copyright (C) 2010, Linden Research, Inc.
 10 * 
 11 * This library is free software; you can redistribute it and/or
 12 * modify it under the terms of the GNU Lesser General Public
 13 * License as published by the Free Software Foundation;
 14 * version 2.1 of the License only.
 15 * 
 16 * This library is distributed in the hope that it will be useful,
 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 19 * Lesser General Public License for more details.
 20 * 
 21 * You should have received a copy of the GNU Lesser General Public
 22 * License along with this library; if not, write to the Free Software
 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 24 * 
 25 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 26 * $/LicenseInfo$
 27 */
 28
 29#include <tut/tut.hpp>
 30#include "lltut.h"
 31#include "linden_common.h"
 32#include "lldatapacker.h"
 33#include "v4color.h"
 34#include "v4coloru.h"
 35#include "v2math.h"
 36#include "v3math.h"
 37#include "v4math.h"
 38#include "llsdserialize.h"
 39
 40#define TEST_FILE_NAME	"datapacker_test.txt"
 41namespace tut
 42{
 43	struct datapacker_test
 44	{
 45	};
 46	typedef test_group<datapacker_test> datapacker_test_t;
 47	typedef datapacker_test_t::object datapacker_test_object_t;
 48	tut::datapacker_test_t tut_datapacker_test("datapacker_test");
 49
 50	//*********LLDataPackerBinaryBuffer
 51	template<> template<>
 52	void datapacker_test_object_t::test<1>()
 53	{
 54		U8 packbuf[128];
 55		F32 f_val1 = 44.44f, f_unpkval1;
 56		F32 f_val2 = 12344.443232f, f_unpkval2;
 57		F32 f_val3 = 44.4456789f, f_unpkval3;
 58		LLDataPackerBinaryBuffer lldp(packbuf,128);
 59		lldp.packFixed( f_val1, "linden_lab", FALSE, 8, 8);
 60		lldp.packFixed( f_val2, "linden_lab", FALSE, 14, 16);
 61		lldp.packFixed( f_val3, "linden_lab", FALSE, 8, 23);
 62
 63		LLDataPackerBinaryBuffer lldp1(packbuf, lldp.getCurrentSize());
 64		lldp1.unpackFixed(f_unpkval1, "linden_lab", FALSE, 8, 8);
 65		lldp1.unpackFixed(f_unpkval2, "linden_lab", FALSE, 14, 16);
 66		lldp1.unpackFixed(f_unpkval3, "linden_lab", FALSE, 8, 23);
 67		ensure_approximately_equals("LLDataPackerBinaryBuffer::packFixed 8 failed", f_val1, f_unpkval1, 8);
 68		ensure_approximately_equals("LLDataPackerBinaryBuffer::packFixed 16 failed", f_val2, f_unpkval2, 16);
 69		ensure_approximately_equals("LLDataPackerBinaryBuffer::packFixed 23 failed", f_val3, f_unpkval3, 31);
 70	}
 71
 72	template<> template<>
 73	void datapacker_test_object_t::test<2>()
 74	{
 75		U8 packbuf[1024];
 76
 77		char str[] = "SecondLife is virtual World\0";
 78		char strBinary[] = "SecondLife is virtual World";
 79		char strBinaryFixed[] = "Fixed Data";
 80		S32 sizeBinaryFixed = sizeof(strBinaryFixed);
 81		U8 valU8 = 'C';
 82		U16 valU16 = 0xFFFF;
 83		U32 valU32 = 0xFFFFFFFF;
 84		S32 valS32 = -94967295;
 85		F32 valF32 = 4354355.44f ;
 86		LLColor4 llcol4(3.3f, 0, 4.4f, 5.5f);
 87		LLColor4U llcol4u(3, 128, 24, 33);
 88		LLVector2 llvec2(333.33f, 444.44f);
 89		LLVector3 llvec3(333.33f, 444.44f, 555.55f);
 90		LLVector4 llvec4(333.33f, 444.44f, 555.55f, 666.66f);
 91		LLUUID uuid;
 92
 93		std::string unpkstr;
 94		char unpkstrBinary[256];
 95		char unpkstrBinaryFixed[256];
 96		S32 unpksizeBinary;
 97		U8 unpkvalU8;
 98		U16 unpkvalU16;
 99		U32 unpkvalU32;
100		S32 unpkvalS32;
101		F32 unpkvalF32;
102		LLColor4 unpkllcol4;
103		LLColor4U unpkllcol4u;
104		LLVector2 unpkllvec2;
105		LLVector3 unpkllvec3;
106		LLVector4 unpkllvec4;
107		LLUUID unpkuuid;
108
109		LLDataPackerBinaryBuffer lldp(packbuf,1024);
110		lldp.packString(str , "linden_lab_str");
111		lldp.packBinaryData((U8*)strBinary, sizeof(strBinary), "linden_lab_bd");
112		lldp.packBinaryDataFixed((U8*)strBinaryFixed, sizeBinaryFixed, "linden_lab_bdf");
113		lldp.packU8(valU8,"linden_lab_u8");
114		lldp.packU16(valU16,"linden_lab_u16");
115		lldp.packU32(valU32, "linden_lab_u32");
116		lldp.packS32(valS32, "linden_lab_s32");
117		lldp.packF32(valF32, "linden_lab_f32");
118		lldp.packColor4(llcol4, "linden_lab_col4");
119		lldp.packColor4U(llcol4u, "linden_lab_col4u");
120		lldp.packVector2(llvec2, "linden_lab_vec2");
121		lldp.packVector3(llvec3, "linden_lab_vec3");
122		lldp.packVector4(llvec4, "linden_lab_vec4");
123		uuid.generate();
124		lldp.packUUID(uuid, "linden_lab_uuid");
125
126		S32 cur_size = lldp.getCurrentSize();
127
128		LLDataPackerBinaryBuffer lldp1(packbuf, cur_size);
129		lldp1.unpackString(unpkstr , "linden_lab_str");
130		lldp1.unpackBinaryData((U8*)unpkstrBinary, unpksizeBinary, "linden_lab_bd");
131		lldp1.unpackBinaryDataFixed((U8*)unpkstrBinaryFixed, sizeBinaryFixed, "linden_lab_bdf");
132		lldp1.unpackU8(unpkvalU8,"linden_lab_u8");
133		lldp1.unpackU16(unpkvalU16,"linden_lab_u16");
134		lldp1.unpackU32(unpkvalU32, "linden_lab_u32");
135		lldp1.unpackS32(unpkvalS32, "linden_lab_s32");
136		lldp1.unpackF32(unpkvalF32, "linden_lab_f32");
137		lldp1.unpackColor4(unpkllcol4, "linden_lab_col4");
138		lldp1.unpackColor4U(unpkllcol4u, "linden_lab_col4u");
139		lldp1.unpackVector2(unpkllvec2, "linden_lab_vec2");
140		lldp1.unpackVector3(unpkllvec3, "linden_lab_vec3");
141		lldp1.unpackVector4(unpkllvec4, "linden_lab_vec4");
142		lldp1.unpackUUID(unpkuuid, "linden_lab_uuid");
143
144		ensure("LLDataPackerBinaryBuffer::packString failed", strcmp(str, unpkstr.c_str())  == 0);
145		ensure("LLDataPackerBinaryBuffer::packBinaryData failed", strcmp(strBinary, unpkstrBinary)  == 0);
146		ensure("LLDataPackerBinaryBuffer::packBinaryDataFixed failed", strcmp(strBinaryFixed, unpkstrBinaryFixed) == 0);
147		ensure_equals("LLDataPackerBinaryBuffer::packU8 failed", valU8, unpkvalU8);
148		ensure_equals("LLDataPackerBinaryBuffer::packU16 failed", valU16, unpkvalU16);
149		ensure_equals("LLDataPackerBinaryBuffer::packU32 failed", valU32, unpkvalU32);
150		ensure_equals("LLDataPackerBinaryBuffer::packS32 failed", valS32, unpkvalS32);
151		ensure("LLDataPackerBinaryBuffer::packF32 failed", is_approx_equal(valF32, unpkvalF32));
152		ensure_equals("LLDataPackerBinaryBuffer::packColor4 failed", llcol4, unpkllcol4);
153		ensure_equals("LLDataPackerBinaryBuffer::packColor4U failed", llcol4u, unpkllcol4u);
154		ensure_equals("LLDataPackerBinaryBuffer::packVector2 failed", llvec2, unpkllvec2);
155		ensure_equals("LLDataPackerBinaryBuffer::packVector3 failed", llvec3, unpkllvec3);
156		ensure_equals("LLDataPackerBinaryBuffer::packVector4 failed", llvec4, unpkllvec4);
157		ensure_equals("LLDataPackerBinaryBuffer::packUUID failed", uuid, unpkuuid);
158	}
159
160	template<> template<>
161	void datapacker_test_object_t::test<3>()
162	{
163		U8 packbuf[128];
164		char str[] = "SecondLife is virtual World";
165		S32 strSize = sizeof(str); // include '\0'
166		LLDataPackerBinaryBuffer lldp(packbuf, 128);
167		lldp.packString(str , "linden_lab");
168
169		ensure("LLDataPackerBinaryBuffer: current size is wrong", strSize == lldp.getCurrentSize());
170		ensure("LLDataPackerBinaryBuffer: buffer size is wrong", 128 == lldp.getBufferSize());
171
172		lldp.reset();
173		ensure("LLDataPackerBinaryBuffer::reset failed",0 == lldp.getCurrentSize());
174	}
175
176	template<> template<>
177	void datapacker_test_object_t::test<4>()
178	{
179		U8* packbuf = new U8[128];
180		char str[] = "SecondLife is virtual World";
181		LLDataPackerBinaryBuffer lldp(packbuf, 128);
182		lldp.packString(str , "linden_lab");
183		lldp.freeBuffer();
184		ensure("LLDataPackerBinaryBuffer.freeBuffer failed" , 0 == lldp.getBufferSize());
185
186	}
187
188	template<> template<>
189	void datapacker_test_object_t::test<5>()
190	{
191		U8 buf[] = "SecondLife is virtual World";
192		S32 size = sizeof(buf);
193		LLDataPackerBinaryBuffer lldp(buf, size);
194		U8 new_buf[] = "Its Amazing";
195		size = sizeof(new_buf);
196		lldp.assignBuffer(new_buf, size);
197		ensure("LLDataPackerBinaryBuffer::assignBuffer failed" , ((lldp.getBufferSize() == size) && (0 == lldp.getCurrentSize()))) ;
198	}
199
200	template<> template<>
201	void datapacker_test_object_t::test<6>()
202	{
203		U8 packbuf[128];
204		char str[] = "SecondLife is virtual World";
205		LLDataPackerBinaryBuffer lldp(packbuf, 128);
206		lldp.packString(str , "linden_lab");
207		U8 new_buffer[128];
208		std::string unpkbuf;
209		LLDataPackerBinaryBuffer lldp1(new_buffer,128);	
210		lldp1 = lldp;
211		lldp1.unpackString(unpkbuf, "linden_lab");
212		ensure("1. LLDataPackerBinaryBuffer::operator= failed" , lldp1.getBufferSize() == lldp.getBufferSize());
213		ensure_equals("2.LLDataPackerBinaryBuffer::operator= failed", str,unpkbuf);
214	}
215
216	//*********LLDataPackerAsciiBuffer
217
218	template<> template<>
219	void datapacker_test_object_t::test<7>()
220	{
221		char packbuf[128];
222		F32 f_val = 44.44f, f_unpkval;
223		LLDataPackerAsciiBuffer lldp(packbuf,128);
224		lldp.packFixed( f_val, "linden_lab", FALSE, 8, 8);
225
226		LLDataPackerAsciiBuffer lldp1(packbuf, lldp.getCurrentSize());
227		lldp1.unpackFixed(f_unpkval, "linden_lab", FALSE, 8, 8);
228		ensure_approximately_equals("LLDataPackerAsciiBuffer::packFixed failed", f_val, f_unpkval, 8);
229	}
230
231	template<> template<>
232	void datapacker_test_object_t::test<8>()
233	{
234		char packbuf[1024];
235
236		char str[] = "SecondLife is virtual World\0";
237		char strBinary[] = "SecondLife is virtual World";
238		char strBinaryFixed[] = "Fixed Data";
239		S32 sizeBinaryFixed = sizeof(strBinaryFixed);
240		U8 valU8 = 'C';
241		U16 valU16 = 0xFFFF;
242		U32 valU32 = 0xFFFFFFFF;
243		S32 valS32 = -94967295;
244		F32 valF32 = 4354355.44f ;
245		LLColor4 llcol4(3.3f, 0, 4.4f, 5.5f);
246		LLColor4U llcol4u(3, 128, 24, 33);
247		LLVector2 llvec2(333.33f, 444.44f);
248		LLVector3 llvec3(333.33f, 444.44f, 555.55f);
249		LLVector4 llvec4(4354355.44f, 444.44f, 555.55f, 666.66f);
250		LLUUID uuid;
251
252		std::string unpkstr;
253		char unpkstrBinary[256];
254		char unpkstrBinaryFixed[256];
255		S32 unpksizeBinary;
256		U8 unpkvalU8;
257		U16 unpkvalU16;
258		U32 unpkvalU32;
259		S32 unpkvalS32;
260		F32 unpkvalF32;
261		LLColor4 unpkllcol4;
262		LLColor4U unpkllcol4u;
263		LLVector2 unpkllvec2;
264		LLVector3 unpkllvec3;
265		LLVector4 unpkllvec4;
266		LLUUID unpkuuid;
267
268		LLDataPackerAsciiBuffer lldp(packbuf,1024);
269		lldp.packString(str , "linden_lab_str");
270		lldp.packBinaryData((U8*)strBinary, sizeof(strBinary), "linden_lab_bd");
271		lldp.packBinaryDataFixed((U8*)strBinaryFixed, sizeBinaryFixed, "linden_lab_bdf");
272		lldp.packU8(valU8,"linden_lab_u8");
273		lldp.packU16(valU16,"linden_lab_u16");
274		lldp.packU32(valU32, "linden_lab_u32");
275		lldp.packS32(valS32, "linden_lab_s32");
276		lldp.packF32(valF32, "linden_lab_f32");
277		lldp.packColor4(llcol4, "linden_lab_col4");
278		lldp.packColor4U(llcol4u, "linden_lab_col4u");
279		lldp.packVector2(llvec2, "linden_lab_vec2");
280		lldp.packVector3(llvec3, "linden_lab_vec3");
281		lldp.packVector4(llvec4, "linden_lab_vec4");
282		uuid.generate();
283		lldp.packUUID(uuid, "linden_lab_uuid");
284
285		S32 cur_size = lldp.getCurrentSize();
286
287		LLDataPackerAsciiBuffer lldp1(packbuf, cur_size);
288		lldp1.unpackString(unpkstr , "linden_lab_str");
289		lldp1.unpackBinaryData((U8*)unpkstrBinary, unpksizeBinary, "linden_lab_bd");
290		lldp1.unpackBinaryDataFixed((U8*)unpkstrBinaryFixed, sizeBinaryFixed, "linden_lab_bdf");
291		lldp1.unpackU8(unpkvalU8,"linden_lab_u8");
292		lldp1.unpackU16(unpkvalU16,"linden_lab_u16");
293		lldp1.unpackU32(unpkvalU32, "linden_lab_u32");
294		lldp1.unpackS32(unpkvalS32, "linden_lab_s32");
295		lldp1.unpackF32(unpkvalF32, "linden_lab_f32");
296		lldp1.unpackColor4(unpkllcol4, "linden_lab_col4");
297		lldp1.unpackColor4U(unpkllcol4u, "linden_lab_col4u");
298		lldp1.unpackVector2(unpkllvec2, "linden_lab_vec2");
299		lldp1.unpackVector3(unpkllvec3, "linden_lab_vec3");
300		lldp1.unpackVector4(unpkllvec4, "linden_lab_vec4");
301		lldp1.unpackUUID(unpkuuid, "linden_lab_uuid");
302
303		ensure("LLDataPackerAsciiBuffer::packString failed", strcmp(str, unpkstr.c_str())  == 0);
304		ensure("LLDataPackerAsciiBuffer::packBinaryData failed", strcmp(strBinary, unpkstrBinary)  == 0);
305		ensure("LLDataPackerAsciiBuffer::packBinaryDataFixed failed", strcmp(strBinaryFixed, unpkstrBinaryFixed) == 0);
306		ensure_equals("LLDataPackerAsciiBuffer::packU8 failed", valU8, unpkvalU8);
307		ensure_equals("LLDataPackerAsciiBuffer::packU16 failed", valU16, unpkvalU16);
308		ensure_equals("LLDataPackerAsciiBuffer::packU32 failed", valU32, unpkvalU32);
309		ensure_equals("LLDataPackerAsciiBuffer::packS32 failed", valS32, unpkvalS32);
310		ensure("LLDataPackerAsciiBuffer::packF32 failed", is_approx_equal(valF32, unpkvalF32));
311		ensure_equals("LLDataPackerAsciiBuffer::packColor4 failed", llcol4, unpkllcol4);
312		ensure_equals("LLDataPackerAsciiBuffer::packColor4U failed", llcol4u, unpkllcol4u);
313		ensure_equals("LLDataPackerAsciiBuffer::packVector2 failed", llvec2, unpkllvec2);
314		ensure_equals("LLDataPackerAsciiBuffer::packVector3 failed", llvec3, unpkllvec3);
315		ensure_equals("LLDataPackerAsciiBuffer::packVector4 failed", llvec4, unpkllvec4);
316		ensure_equals("LLDataPackerAsciiBuffer::packUUID failed", uuid, unpkuuid);
317	}
318
319	template<> template<>
320	void datapacker_test_object_t::test<9>()
321	{
322		char* packbuf = new char[128];
323		char str[] = "SecondLife is virtual World";
324		LLDataPackerAsciiBuffer lldp(packbuf, 128);
325		lldp.packString(str , "linden_lab");
326		lldp.freeBuffer();
327		ensure("LLDataPackerAsciiBuffer::freeBuffer failed" , 0 == lldp.getBufferSize());
328	}
329
330	template<> template<>
331	void datapacker_test_object_t::test<10>()
332	{
333		char buf[] = "SecondLife is virtual World";
334		S32 size = sizeof(buf);
335		LLDataPackerAsciiBuffer lldp(buf, size);
336		char new_buf[] = "Its Amazing";
337		size = sizeof(new_buf);
338		lldp.assignBuffer(new_buf, size);
339		ensure("LLDataPackerAsciiBuffer::assignBuffer failed" , ((lldp.getBufferSize() == size) && (1 == lldp.getCurrentSize()))) ;
340	}
341
342	//*********LLDataPackerAsciiFile
343
344	template<> template<>
345	void datapacker_test_object_t::test<11>()
346	{
347		F32 f_val = 44.44f, f_unpkval;
348
349		LLFILE* fp = LLFile::fopen(TEST_FILE_NAME, "w+");
350		if(!fp)
351		{
352			llerrs << "File couldnt be open" <<llendl;
353			return;
354		}
355
356		LLDataPackerAsciiFile lldp(fp,2);
357		lldp.packFixed( f_val, "linden_lab", FALSE, 8, 8);
358
359		fflush(fp);	
360		fseek(fp,0,SEEK_SET);
361		LLDataPackerAsciiFile lldp1(fp,2);
362
363		lldp1.unpackFixed(f_unpkval, "linden_lab", FALSE, 8, 8);
364		fclose(fp);
365
366		ensure_approximately_equals("LLDataPackerAsciiFile::packFixed failed", f_val, f_unpkval, 8);
367	}
368
369	template<> template<>
370	void datapacker_test_object_t::test<12>()
371	{
372		char str[] = "SecondLife is virtual World\0";
373		char strBinary[] = "SecondLife is virtual World";
374		char strBinaryFixed[] = "Fixed Data";
375		S32 sizeBinaryFixed = sizeof(strBinaryFixed);
376		U8 valU8 = 'C';
377		U16 valU16 = 0xFFFF;
378		U32 valU32 = 0xFFFFFFFF;
379		S32 valS32 = -94967295;
380		F32 valF32 = 4354355.44f ;
381		LLColor4 llcol4(3.3f, 0, 4.4f, 5.5f);
382		LLColor4U llcol4u(3, 128, 24, 33);
383		LLVector2 llvec2(333.33f, 444.44f);
384		LLVector3 llvec3(333.33f, 444.44f, 555.55f);
385		LLVector4 llvec4(333.33f, 444.44f, 555.55f, 666.66f);
386		LLUUID uuid;
387
388		std::string unpkstr;
389		char unpkstrBinary[256];
390		char unpkstrBinaryFixed[256];
391		S32 unpksizeBinary;
392		U8 unpkvalU8;
393		U16 unpkvalU16;
394		U32 unpkvalU32;
395		S32 unpkvalS32;
396		F32 unpkvalF32;
397		LLColor4 unpkllcol4;
398		LLColor4U unpkllcol4u;
399		LLVector2 unpkllvec2;
400		LLVector3 unpkllvec3;
401		LLVector4 unpkllvec4;
402		LLUUID unpkuuid;
403
404		LLFILE* fp = LLFile::fopen(TEST_FILE_NAME,"w+");
405		if(!fp)
406		{
407			llerrs << "File couldnt be open" <<llendl;
408			return;
409		}
410
411		LLDataPackerAsciiFile lldp(fp,2);
412
413		lldp.packString(str , "linden_lab_str");
414		lldp.packBinaryData((U8*)strBinary, sizeof(strBinary), "linden_lab_bd");
415		lldp.packBinaryDataFixed((U8*)strBinaryFixed, sizeBinaryFixed, "linden_lab_bdf");
416		lldp.packU8(valU8,"linden_lab_u8");
417		lldp.packU16(valU16,"linden_lab_u16");
418		lldp.packU32(valU32, "linden_lab_u32");
419		lldp.packS32(valS32, "linden_lab_s32");
420		lldp.packF32(valF32, "linden_lab_f32");
421		lldp.packColor4(llcol4, "linden_lab_col4");
422		lldp.packColor4U(llcol4u, "linden_lab_col4u");
423		lldp.packVector2(llvec2, "linden_lab_vec2");
424		lldp.packVector3(llvec3, "linden_lab_vec3");
425		lldp.packVector4(llvec4, "linden_lab_vec4");
426		uuid.generate();
427		lldp.packUUID(uuid, "linden_lab_uuid");
428
429		fflush(fp);	
430		fseek(fp,0,SEEK_SET);
431		LLDataPackerAsciiFile lldp1(fp,2);
432
433		lldp1.unpackString(unpkstr , "linden_lab_str");
434		lldp1.unpackBinaryData((U8*)unpkstrBinary, unpksizeBinary, "linden_lab_bd");
435		lldp1.unpackBinaryDataFixed((U8*)unpkstrBinaryFixed, sizeBinaryFixed, "linden_lab_bdf");
436		lldp1.unpackU8(unpkvalU8,"linden_lab_u8");
437		lldp1.unpackU16(unpkvalU16,"linden_lab_u16");
438		lldp1.unpackU32(unpkvalU32, "linden_lab_u32");
439		lldp1.unpackS32(unpkvalS32, "linden_lab_s32");
440		lldp1.unpackF32(unpkvalF32, "linden_lab_f32");
441		lldp1.unpackColor4(unpkllcol4, "linden_lab_col4");
442		lldp1.unpackColor4U(unpkllcol4u, "linden_lab_col4u");
443		lldp1.unpackVector2(unpkllvec2, "linden_lab_vec2");
444		lldp1.unpackVector3(unpkllvec3, "linden_lab_vec3");
445		lldp1.unpackVector4(unpkllvec4, "linden_lab_vec4");
446		lldp1.unpackUUID(unpkuuid, "linden_lab_uuid");
447
448		fclose(fp);
449
450		ensure("LLDataPackerAsciiFile::packString failed", strcmp(str, unpkstr.c_str())  == 0);
451		ensure("LLDataPackerAsciiFile::packBinaryData failed", strcmp(strBinary, unpkstrBinary)  == 0);
452		ensure("LLDataPackerAsciiFile::packBinaryDataFixed failed", strcmp(strBinaryFixed, unpkstrBinaryFixed) == 0);
453		ensure_equals("LLDataPackerAsciiFile::packU8 failed", valU8, unpkvalU8);
454		ensure_equals("LLDataPackerAsciiFile::packU16 failed", valU16, unpkvalU16);
455		ensure_equals("LLDataPackerAsciiFile::packU32 failed", valU32, unpkvalU32);
456		ensure_equals("LLDataPackerAsciiFile::packS32 failed", valS32, unpkvalS32);
457		ensure("LLDataPackerAsciiFile::packF32 failed", is_approx_equal(valF32, unpkvalF32));
458		ensure_equals("LLDataPackerAsciiFile::packColor4 failed", llcol4, unpkllcol4);
459		ensure_equals("LLDataPackerAsciiFile::packColor4U failed", llcol4u, unpkllcol4u);
460		ensure_equals("LLDataPackerAsciiFile::packVector2 failed", llvec2, unpkllvec2);
461		ensure_equals("LLDataPackerAsciiFile::packVector3 failed", llvec3, unpkllvec3);
462		ensure_equals("LLDataPackerAsciiFile::packVector4 failed", llvec4, unpkllvec4);
463		ensure_equals("LLDataPackerAsciiFile::packUUID failed", uuid, unpkuuid);
464	}
465
466	template<> template<>
467	void datapacker_test_object_t::test<13>()
468	{
469		F32 f_val = 44.44f, f_unpkval;
470
471		std::ostringstream ostr;
472		LLDataPackerAsciiFile lldp(ostr,2);
473		lldp.packFixed( f_val, "linden_lab", FALSE, 8, 8);
474
475		std::istringstream istr(ostr.str());
476		LLDataPackerAsciiFile lldp1(istr,2);
477
478		lldp1.unpackFixed(f_unpkval, "linden_lab", FALSE, 8, 8);
479
480		ensure_approximately_equals("LLDataPackerAsciiFile::packFixed (iostring) failed", f_val, f_unpkval, 8);
481	}
482
483	template<> template<>
484	void datapacker_test_object_t::test<14>()
485	{
486		char str[] = "SecondLife is virtual World\0";
487		char strBinary[] = "SecondLife is virtual World";
488		char strBinaryFixed[] = "Fixed Data";
489		S32 sizeBinaryFixed = sizeof(strBinaryFixed);
490		U8 valU8 = 'C';
491		U16 valU16 = 0xFFFF;
492		U32 valU32 = 0xFFFFFFFF;
493		S32 valS32 = -94967295;
494		F32 valF32 = 4354355.44f ;
495		LLColor4 llcol4(3.3f, 0, 4.4f, 5.5f);
496		LLColor4U llcol4u(3, 128, 24, 33);
497		LLVector2 llvec2(3333333.33f, 444.333344f);
498		LLVector3 llvec3(3323233.33f, 444.4324f, 555.553232f);
499		LLVector4 llvec4(333.33233f, 444.4323234f, 55323225.55f, 6323236.66f);
500		LLUUID uuid;
501
502		std::string unpkstr;
503		char unpkstrBinary[256];
504		char unpkstrBinaryFixed[256];
505		S32 unpksizeBinary;
506		U8 unpkvalU8;
507		U16 unpkvalU16;
508		U32 unpkvalU32;
509		S32 unpkvalS32;
510		F32 unpkvalF32;
511		LLColor4 unpkllcol4;
512		LLColor4U unpkllcol4u;
513		LLVector2 unpkllvec2;
514		LLVector3 unpkllvec3;
515		LLVector4 unpkllvec4;
516		LLUUID unpkuuid;
517
518		std::ostringstream ostr;
519		LLDataPackerAsciiFile lldp(ostr,2);
520
521		lldp.packString(str , "linden_lab_str");
522		lldp.packBinaryData((U8*)strBinary, sizeof(strBinary), "linden_lab_bd");
523		lldp.packBinaryDataFixed((U8*)strBinaryFixed, sizeBinaryFixed, "linden_lab_bdf");
524		lldp.packU8(valU8,"linden_lab_u8");
525		lldp.packU16(valU16,"linden_lab_u16");
526		lldp.packU32(valU32, "linden_lab_u32");
527		lldp.packS32(valS32, "linden_lab_s32");
528		lldp.packF32(valF32, "linden_lab_f32");
529		lldp.packColor4(llcol4, "linden_lab_col4");
530		lldp.packColor4U(llcol4u, "linden_lab_col4u");
531		lldp.packVector2(llvec2, "linden_lab_vec2");
532		lldp.packVector3(llvec3, "linden_lab_vec3");
533		lldp.packVector4(llvec4, "linden_lab_vec4");
534		uuid.generate();
535		lldp.packUUID(uuid, "linden_lab_uuid");
536
537		std::istringstream istr(ostr.str());
538		LLDataPackerAsciiFile lldp1(istr,2);
539
540		lldp1.unpackString(unpkstr , "linden_lab_str");
541		lldp1.unpackBinaryData((U8*)unpkstrBinary, unpksizeBinary, "linden_lab_bd");
542		lldp1.unpackBinaryDataFixed((U8*)unpkstrBinaryFixed, sizeBinaryFixed, "linden_lab_bdf");
543		lldp1.unpackU8(unpkvalU8,"linden_lab_u8");
544		lldp1.unpackU16(unpkvalU16,"linden_lab_u16");
545		lldp1.unpackU32(unpkvalU32, "linden_lab_u32");
546		lldp1.unpackS32(unpkvalS32, "linden_lab_s32");
547		lldp1.unpackF32(unpkvalF32, "linden_lab_f32");
548		lldp1.unpackColor4(unpkllcol4, "linden_lab_col4");
549		lldp1.unpackColor4U(unpkllcol4u, "linden_lab_col4u");
550		lldp1.unpackVector2(unpkllvec2, "linden_lab_vec2");
551		lldp1.unpackVector3(unpkllvec3, "linden_lab_vec3");
552		lldp1.unpackVector4(unpkllvec4, "linden_lab_vec4");
553		lldp1.unpackUUID(unpkuuid, "linden_lab_uuid");
554
555		ensure("LLDataPackerAsciiFile::packString (iostring) failed", strcmp(str, unpkstr.c_str())  == 0);
556		ensure("LLDataPackerAsciiFile::packBinaryData (iostring) failed", strcmp(strBinary, unpkstrBinary)  == 0);
557		ensure("LLDataPackerAsciiFile::packBinaryDataFixed (iostring) failed", strcmp(strBinaryFixed, unpkstrBinaryFixed) == 0);
558		ensure_equals("LLDataPackerAsciiFile::packU8 (iostring) failed", valU8, unpkvalU8);
559		ensure_equals("LLDataPackerAsciiFile::packU16 (iostring) failed", valU16, unpkvalU16);
560		ensure_equals("LLDataPackerAsciiFile::packU32 (iostring) failed", valU32, unpkvalU32);
561		ensure_equals("LLDataPackerAsciiFile::packS32 (iostring) failed", valS32, unpkvalS32);
562		ensure("LLDataPackerAsciiFile::packF32 (iostring) failed", is_approx_equal(valF32, unpkvalF32));
563		ensure_equals("LLDataPackerAsciiFile::packColor4 (iostring) failed", llcol4, unpkllcol4);
564		ensure_equals("LLDataPackerAsciiFile::packColor4U (iostring) failed", llcol4u, unpkllcol4u);
565		ensure_equals("LLDataPackerAsciiFile::packVector2 (iostring) failed", llvec2, unpkllvec2);
566		ensure_equals("LLDataPackerAsciiFile::packVector3 (iostring) failed", llvec3, unpkllvec3);
567		ensure_equals("LLDataPackerAsciiFile::packVector4 (iostring) failed", llvec4, unpkllvec4);
568		ensure_equals("LLDataPackerAsciiFile::packUUID (iostring) failed", uuid, unpkuuid);
569	}
570}