diff options
author | Jacek Antonelli | 2009-04-30 13:04:20 -0500 |
---|---|---|
committer | Jacek Antonelli | 2009-04-30 13:07:16 -0500 |
commit | ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch) | |
tree | 8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/test/lltranscode_tut.cpp | |
parent | Second Life viewer sources 1.22.11 (diff) | |
download | meta-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/lltranscode_tut.cpp')
-rw-r--r-- | linden/indra/test/lltranscode_tut.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/linden/indra/test/lltranscode_tut.cpp b/linden/indra/test/lltranscode_tut.cpp new file mode 100644 index 0000000..eb21979 --- /dev/null +++ b/linden/indra/test/lltranscode_tut.cpp | |||
@@ -0,0 +1,95 @@ | |||
1 | /** | ||
2 | * @file llscriptresource_tut.cpp | ||
3 | * @brief Test LLScriptResource | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2008&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2008-2009, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at | ||
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
22 | * | ||
23 | * By copying, modifying or distributing this software, you acknowledge | ||
24 | * that you have read and understood your obligations described above, | ||
25 | * and agree to abide by those obligations. | ||
26 | * | ||
27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
29 | * COMPLETENESS OR PERFORMANCE. | ||
30 | * $/LicenseInfo$ | ||
31 | */ | ||
32 | |||
33 | //#include <tut/tut.h> | ||
34 | #include "linden_common.h" | ||
35 | |||
36 | #include "lltut.h" | ||
37 | |||
38 | #include "../newsim/lltranscode.cpp" // include TU to pull in newsim implementation. | ||
39 | |||
40 | static const char test_utf8[] = "Edelwei\xc3\x9f"; | ||
41 | static const char test_utf7[] = "Edelwei+AN8-"; | ||
42 | static const char test_latin1[] = "Edelwei\xdf"; | ||
43 | static const char test_latin2[] = "Edelwei\xdf"; | ||
44 | |||
45 | namespace tut | ||
46 | { | ||
47 | class LLTranscodeTestData | ||
48 | { | ||
49 | }; | ||
50 | |||
51 | typedef test_group<LLTranscodeTestData> LLTranscodeTestGroup; | ||
52 | typedef LLTranscodeTestGroup::object LLTranscodeTestObject; | ||
53 | LLTranscodeTestGroup transcodeTestGroup("transcode"); | ||
54 | |||
55 | template<> template<> | ||
56 | void LLTranscodeTestObject::test<1>() | ||
57 | { | ||
58 | #if LL_WINDOWS | ||
59 | skip("Windows APR libs can't transcode."); | ||
60 | #endif | ||
61 | // Test utf8 | ||
62 | std::stringstream input; | ||
63 | std::stringstream output; | ||
64 | |||
65 | input.str(test_utf7); | ||
66 | output.clear(); | ||
67 | LLTranscode::transcode("charset=UTF-7", input, output); | ||
68 | ensure_equals("UTF-7 to UTF-8 transcoding", output.str(), | ||
69 | std::string(test_utf8)); | ||
70 | |||
71 | input.str(test_latin1); | ||
72 | output.clear(); | ||
73 | LLTranscode::transcode("", input, output); | ||
74 | ensure_equals("Default (latin_1) to UTF8 transcoding", output.str(), | ||
75 | std::string(test_utf8)); | ||
76 | |||
77 | input.str(test_latin1); | ||
78 | output.clear(); | ||
79 | LLTranscode::transcode("charset=iso-8859-1", input, output); | ||
80 | ensure_equals("latin_1 (ISO-8859-1) to UTF8 transcoding", output.str(), | ||
81 | std::string(test_utf8)); | ||
82 | |||
83 | input.str(test_latin2); | ||
84 | output.clear(); | ||
85 | LLTranscode::transcode("charset=iso-8859-2", input, output); | ||
86 | ensure_equals("latin_2 (ISO-8859-2) to UTF8 transcoding", output.str(), | ||
87 | std::string(test_utf8)); | ||
88 | |||
89 | input.str(test_utf8); | ||
90 | output.clear(); | ||
91 | LLTranscode::transcode("charset=utf-8", input, output); | ||
92 | ensure_equals("UTF8 to UTF8 transcoding", output.str(), | ||
93 | std::string(test_utf8)); | ||
94 | } | ||
95 | } | ||