aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/test/llbase64_tut.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/test/llbase64_tut.cpp')
-rw-r--r--linden/indra/test/llbase64_tut.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/linden/indra/test/llbase64_tut.cpp b/linden/indra/test/llbase64_tut.cpp
new file mode 100644
index 0000000..fe02397
--- /dev/null
+++ b/linden/indra/test/llbase64_tut.cpp
@@ -0,0 +1,77 @@
1/**
2 * @file llbase64_tut.cpp
3 * @author James Cook
4 * @date 2007-02-04
5 *
6 * Copyright (c) 2007-2007, Linden Research, Inc.
7 *
8 * 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 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27 */
28
29#include "linden_common.h"
30#include "lltut.h"
31
32#include "llbase64.h"
33
34#include <string>
35#include "lluuid.h"
36
37namespace tut
38{
39 struct base64_data
40 {
41 };
42 typedef test_group<base64_data> base64_test;
43 typedef base64_test::object base64_object;
44 tut::base64_test base64("base64");
45
46 template<> template<>
47 void base64_object::test<1>()
48 {
49 std::string result;
50
51 result = LLBase64::encode(NULL, 0);
52 ensure("encode nothing", (result == "") );
53
54 LLUUID nothing;
55 result = LLBase64::encode(&nothing.mData[0], UUID_BYTES);
56 ensure("encode blank uuid",
57 (result == "AAAAAAAAAAAAAAAAAAAAAA==") );
58
59 LLUUID id("526a1e07-a19d-baed-84c4-ff08a488d15e");
60 result = LLBase64::encode(&id.mData[0], UUID_BYTES);
61 ensure("encode random uuid",
62 (result == "UmoeB6Gduu2ExP8IpIjRXg==") );
63
64 }
65
66 template<> template<>
67 void base64_object::test<2>()
68 {
69 std::string result;
70
71 U8 blob[40] = { 115, 223, 172, 255, 140, 70, 49, 125, 236, 155, 45, 199, 101, 17, 164, 131, 230, 19, 80, 64, 112, 53, 135, 98, 237, 12, 26, 72, 126, 14, 145, 143, 118, 196, 11, 177, 132, 169, 195, 134 };
72 result = LLBase64::encode(&blob[0], 40);
73 ensure("encode 40 bytes",
74 (result == "c9+s/4xGMX3smy3HZRGkg+YTUEBwNYdi7QwaSH4OkY92xAuxhKnDhg==") );
75 }
76
77}