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