sl@0
|
1 |
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#undef G_DISABLE_ASSERT
|
sl@0
|
17 |
#undef G_LOG_DOMAIN
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <glib.h>
|
sl@0
|
20 |
#include <errno.h>
|
sl@0
|
21 |
#define LOG_FILE "c:\\logs\\utf8_string_log.txt"
|
sl@0
|
22 |
#include "std_log_result.h"
|
sl@0
|
23 |
#define LOG_FILENAME_LINE __FILE__, __LINE__
|
sl@0
|
24 |
|
sl@0
|
25 |
void create_xml(int result)
|
sl@0
|
26 |
{
|
sl@0
|
27 |
if(result)
|
sl@0
|
28 |
assert_failed = 1;
|
sl@0
|
29 |
|
sl@0
|
30 |
testResultXml("utf8_string_log");
|
sl@0
|
31 |
close_log_file();
|
sl@0
|
32 |
}
|
sl@0
|
33 |
|
sl@0
|
34 |
int main (int argc, char *argv[])
|
sl@0
|
35 |
{
|
sl@0
|
36 |
gchar *src = "TestString";
|
sl@0
|
37 |
gchar dest[20];
|
sl@0
|
38 |
gchar *p;
|
sl@0
|
39 |
|
sl@0
|
40 |
p = g_utf8_strncpy(dest, src, strlen(src));
|
sl@0
|
41 |
|
sl@0
|
42 |
if(p == dest)
|
sl@0
|
43 |
{
|
sl@0
|
44 |
if(strcmp(dest, src))
|
sl@0
|
45 |
{
|
sl@0
|
46 |
std_log(LOG_FILENAME_LINE,"g_utf8_strncpy didnt work as expected");
|
sl@0
|
47 |
assert_failed = 1;
|
sl@0
|
48 |
}
|
sl@0
|
49 |
}
|
sl@0
|
50 |
else
|
sl@0
|
51 |
{
|
sl@0
|
52 |
std_log(LOG_FILENAME_LINE,"g_utf8_strncpy's return value is invalid");
|
sl@0
|
53 |
assert_failed = 1;
|
sl@0
|
54 |
}
|
sl@0
|
55 |
|
sl@0
|
56 |
p = NULL;
|
sl@0
|
57 |
p = g_utf8_strrchr(src, strlen(src), 't');
|
sl@0
|
58 |
if(strcmp(p, "tring"))
|
sl@0
|
59 |
{
|
sl@0
|
60 |
std_log(LOG_FILENAME_LINE,"g_utf8_strrchr didnt work as expected");
|
sl@0
|
61 |
assert_failed = 1;
|
sl@0
|
62 |
}
|
sl@0
|
63 |
|
sl@0
|
64 |
if(assert_failed)
|
sl@0
|
65 |
std_log(LOG_FILENAME_LINE,"Test Failed");
|
sl@0
|
66 |
else
|
sl@0
|
67 |
std_log(LOG_FILENAME_LINE,"Test Successful");
|
sl@0
|
68 |
|
sl@0
|
69 |
create_xml(0);
|
sl@0
|
70 |
|
sl@0
|
71 |
return 0;
|
sl@0
|
72 |
}
|