sl@0
|
1 |
/* GLib testing framework examples and tests
|
sl@0
|
2 |
* Copyright (C) 2008 Asbjoern Pettersen
|
sl@0
|
3 |
* Portions copyright (c) 2009 Nokia Corporation. All rights reserved.
|
sl@0
|
4 |
* This work is provided "as is"; redistribution and modification
|
sl@0
|
5 |
* in whole or in part, in any medium, physical or electronic is
|
sl@0
|
6 |
* permitted without restriction.
|
sl@0
|
7 |
*
|
sl@0
|
8 |
* This work is distributed in the hope that it will be useful,
|
sl@0
|
9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
sl@0
|
10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* In no event shall the authors or contributors be liable for any
|
sl@0
|
13 |
* direct, indirect, incidental, special, exemplary, or consequential
|
sl@0
|
14 |
* damages (including, but not limited to, procurement of substitute
|
sl@0
|
15 |
* goods or services; loss of use, data, or profits; or business
|
sl@0
|
16 |
* interruption) however caused and on any theory of liability, whether
|
sl@0
|
17 |
* in contract, strict liability, or tort (including negligence or
|
sl@0
|
18 |
* otherwise) arising in any way out of the use of this software, even
|
sl@0
|
19 |
* if advised of the possibility of such damage.
|
sl@0
|
20 |
*/
|
sl@0
|
21 |
|
sl@0
|
22 |
#include <glib.h>
|
sl@0
|
23 |
#include <stdlib.h>
|
sl@0
|
24 |
#include <glib.h>
|
sl@0
|
25 |
#include <string.h>
|
sl@0
|
26 |
#ifdef HAVE_UNISTD_H
|
sl@0
|
27 |
#include <unistd.h>
|
sl@0
|
28 |
#endif
|
sl@0
|
29 |
#ifdef __SYMBIAN32__
|
sl@0
|
30 |
#include "mrt2_glib2_test.h"
|
sl@0
|
31 |
#endif /*__SYMBIAN32__*/
|
sl@0
|
32 |
#define DATA_SIZE 1024
|
sl@0
|
33 |
|
sl@0
|
34 |
struct MyRawData
|
sl@0
|
35 |
{
|
sl@0
|
36 |
gint length; /* of data */
|
sl@0
|
37 |
guchar data[DATA_SIZE];
|
sl@0
|
38 |
};
|
sl@0
|
39 |
|
sl@0
|
40 |
/* 100 pre-encoded string from data[] buffer. Data length from 1..100
|
sl@0
|
41 |
*/
|
sl@0
|
42 |
static const char *ok_100_encode_strs[] = {
|
sl@0
|
43 |
"AA==",
|
sl@0
|
44 |
"AAE=",
|
sl@0
|
45 |
"AAEC",
|
sl@0
|
46 |
"AAECAw==",
|
sl@0
|
47 |
"AAECAwQ=",
|
sl@0
|
48 |
"AAECAwQF",
|
sl@0
|
49 |
"AAECAwQFBg==",
|
sl@0
|
50 |
"AAECAwQFBgc=",
|
sl@0
|
51 |
"AAECAwQFBgcI",
|
sl@0
|
52 |
"AAECAwQFBgcICQ==",
|
sl@0
|
53 |
"AAECAwQFBgcICQo=",
|
sl@0
|
54 |
"AAECAwQFBgcICQoL",
|
sl@0
|
55 |
"AAECAwQFBgcICQoLDA==",
|
sl@0
|
56 |
"AAECAwQFBgcICQoLDA0=",
|
sl@0
|
57 |
"AAECAwQFBgcICQoLDA0O",
|
sl@0
|
58 |
"AAECAwQFBgcICQoLDA0ODw==",
|
sl@0
|
59 |
"AAECAwQFBgcICQoLDA0ODxA=",
|
sl@0
|
60 |
"AAECAwQFBgcICQoLDA0ODxAR",
|
sl@0
|
61 |
"AAECAwQFBgcICQoLDA0ODxAREg==",
|
sl@0
|
62 |
"AAECAwQFBgcICQoLDA0ODxAREhM=",
|
sl@0
|
63 |
"AAECAwQFBgcICQoLDA0ODxAREhMU",
|
sl@0
|
64 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFQ==",
|
sl@0
|
65 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRY=",
|
sl@0
|
66 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYX",
|
sl@0
|
67 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGA==",
|
sl@0
|
68 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBk=",
|
sl@0
|
69 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBka",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Hh8gISIjJCUmJygpKis=",
|
sl@0
|
87 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKiss",
|
sl@0
|
88 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLQ==",
|
sl@0
|
89 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4=",
|
sl@0
|
90 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4v",
|
sl@0
|
91 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMA==",
|
sl@0
|
92 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDE=",
|
sl@0
|
93 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEy",
|
sl@0
|
94 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMw==",
|
sl@0
|
95 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ=",
|
sl@0
|
96 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1",
|
sl@0
|
97 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Ng==",
|
sl@0
|
98 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc=",
|
sl@0
|
99 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4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ERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXQ==",
|
sl@0
|
137 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV4=",
|
sl@0
|
138 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5f",
|
sl@0
|
139 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYA==",
|
sl@0
|
140 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGE=",
|
sl@0
|
141 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFi",
|
sl@0
|
142 |
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiYw==",
|
sl@0
|
143 |
NULL
|
sl@0
|
144 |
};
|
sl@0
|
145 |
|
sl@0
|
146 |
static void
|
sl@0
|
147 |
generate_databuffer_for_base64 (struct MyRawData *p)
|
sl@0
|
148 |
{
|
sl@0
|
149 |
int i;
|
sl@0
|
150 |
for (i = 0; i < DATA_SIZE; i++)
|
sl@0
|
151 |
p->data[i] = i;
|
sl@0
|
152 |
}
|
sl@0
|
153 |
|
sl@0
|
154 |
static void
|
sl@0
|
155 |
test_base64_encode (void)
|
sl@0
|
156 |
{
|
sl@0
|
157 |
int i;
|
sl@0
|
158 |
gint length = 1;
|
sl@0
|
159 |
char *text;
|
sl@0
|
160 |
struct MyRawData myraw;
|
sl@0
|
161 |
|
sl@0
|
162 |
generate_databuffer_for_base64 (&myraw);
|
sl@0
|
163 |
|
sl@0
|
164 |
for (i = 0; ok_100_encode_strs[i]; i++)
|
sl@0
|
165 |
{
|
sl@0
|
166 |
length = i + 1;
|
sl@0
|
167 |
text = g_base64_encode (myraw.data, length);
|
sl@0
|
168 |
g_assert_cmpstr (text, ==, ok_100_encode_strs[i]);
|
sl@0
|
169 |
/* printf ("\"%s\",\n",text); */
|
sl@0
|
170 |
g_free (text);
|
sl@0
|
171 |
}
|
sl@0
|
172 |
}
|
sl@0
|
173 |
|
sl@0
|
174 |
|
sl@0
|
175 |
static void
|
sl@0
|
176 |
decode_and_compare (const gchar *datap,
|
sl@0
|
177 |
const struct MyRawData *p)
|
sl@0
|
178 |
{
|
sl@0
|
179 |
guchar *data2;
|
sl@0
|
180 |
gsize len;
|
sl@0
|
181 |
int memcmp_decode;
|
sl@0
|
182 |
|
sl@0
|
183 |
data2 = g_base64_decode (datap, &len);
|
sl@0
|
184 |
g_assert_cmpint (len, ==, p->length);
|
sl@0
|
185 |
/* g_print ("length: got %d, expected %d\n",len, length); */
|
sl@0
|
186 |
memcmp_decode = memcmp (p->data, data2, p->length);
|
sl@0
|
187 |
g_assert_cmpint (memcmp_decode, ==, 0);
|
sl@0
|
188 |
g_free (data2);
|
sl@0
|
189 |
}
|
sl@0
|
190 |
|
sl@0
|
191 |
static void
|
sl@0
|
192 |
test_base64_decode (void)
|
sl@0
|
193 |
{
|
sl@0
|
194 |
int i;
|
sl@0
|
195 |
struct MyRawData myraw;
|
sl@0
|
196 |
|
sl@0
|
197 |
generate_databuffer_for_base64 (&myraw);
|
sl@0
|
198 |
|
sl@0
|
199 |
for (i = 0; ok_100_encode_strs[i]; i++)
|
sl@0
|
200 |
{
|
sl@0
|
201 |
myraw.length = i + 1;
|
sl@0
|
202 |
decode_and_compare (ok_100_encode_strs[i], &myraw);
|
sl@0
|
203 |
}
|
sl@0
|
204 |
}
|
sl@0
|
205 |
|
sl@0
|
206 |
static void
|
sl@0
|
207 |
test_base64_encode_decode (void)
|
sl@0
|
208 |
{
|
sl@0
|
209 |
int i;
|
sl@0
|
210 |
char *text;
|
sl@0
|
211 |
struct MyRawData myraw;
|
sl@0
|
212 |
|
sl@0
|
213 |
generate_databuffer_for_base64 (&myraw);
|
sl@0
|
214 |
|
sl@0
|
215 |
for (i = 0; i < DATA_SIZE; i++)
|
sl@0
|
216 |
{
|
sl@0
|
217 |
myraw.length = i + 1;
|
sl@0
|
218 |
text = g_base64_encode (myraw.data, myraw.length);
|
sl@0
|
219 |
|
sl@0
|
220 |
decode_and_compare (text, &myraw);
|
sl@0
|
221 |
|
sl@0
|
222 |
g_free (text);
|
sl@0
|
223 |
}
|
sl@0
|
224 |
}
|
sl@0
|
225 |
|
sl@0
|
226 |
|
sl@0
|
227 |
int
|
sl@0
|
228 |
main (int argc,
|
sl@0
|
229 |
char *argv[])
|
sl@0
|
230 |
{
|
sl@0
|
231 |
int retval;
|
sl@0
|
232 |
#ifdef __SYMBIAN32__
|
sl@0
|
233 |
g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL);
|
sl@0
|
234 |
g_set_print_handler(mrtPrintHandler);
|
sl@0
|
235 |
#endif /*__SYMBIAN32__*/
|
sl@0
|
236 |
g_test_init (&argc, &argv, NULL);
|
sl@0
|
237 |
|
sl@0
|
238 |
g_test_add_func ("/misc/base64/encode", test_base64_encode);
|
sl@0
|
239 |
g_test_add_func ("/misc/base64/decode", test_base64_decode);
|
sl@0
|
240 |
g_test_add_func ("/misc/base64/encode_decode", test_base64_encode_decode);
|
sl@0
|
241 |
|
sl@0
|
242 |
retval = g_test_run();
|
sl@0
|
243 |
#if __SYMBIAN32__
|
sl@0
|
244 |
testResultXml("testingbase64");
|
sl@0
|
245 |
#endif /* EMULATOR */
|
sl@0
|
246 |
return retval;
|
sl@0
|
247 |
}
|