PageRenderTime 21ms CodeModel.GetById 9ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llcommon/tests/llbase64_test.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 77 lines | 38 code | 13 blank | 26 comment | 4 complexity | a00c6f49cc5ad25da55f370c636a3eb5 MD5 | raw file
 1/** 
 2 * @file llbase64_test.cpp
 3 * @author James Cook
 4 * @date 2007-02-04
 5 *
 6 * $LicenseInfo:firstyear=2007&license=viewerlgpl$
 7 * Second Life Viewer Source Code
 8 * Copyright (C) 2010, Linden Research, Inc.
 9 * 
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation;
13 * version 2.1 of the License only.
14 * 
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 * Lesser General Public License for more details.
19 * 
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23 * 
24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
25 * $/LicenseInfo$
26 */
27
28#include <string>
29
30#include "linden_common.h"
31
32#include "../llbase64.h"
33#include "../lluuid.h"
34
35#include "../test/lltut.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("LLBase64");
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}