glib/tests/base-name.c
changeset 50 79045913e4e9
child 72 403e7f6ed6c5
equal deleted inserted replaced
49:e5d77a29bdca 50:79045913e4e9
       
     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 #include <string.h>
       
    22 #define LOG_FILE "c:\\logs\\base_name_log.txt"
       
    23 #include "std_log_result.h"
       
    24 #define LOG_FILENAME_LINE __FILE__, __LINE__
       
    25 
       
    26 #define MAX_FILENAME_LENGTH	256
       
    27 #define MAX_PATH_LENGTH		256
       
    28 
       
    29 void create_xml(int result)
       
    30 {
       
    31     if(result)
       
    32         assert_failed = 1;
       
    33     
       
    34     testResultXml("base_name_log");
       
    35     close_log_file();
       
    36 }
       
    37 
       
    38 int main (int argc, char *argv[])
       
    39 {
       
    40 	char folder_name[] = "c:\\example\\test\\";
       
    41 	char file_name[]   = "test.txt";
       
    42 	const gchar *ret_file_name;
       
    43 
       
    44 	gchar input_file[MAX_PATH_LENGTH];
       
    45 	sprintf(input_file, "%s%s", folder_name, file_name);
       
    46 
       
    47 	ret_file_name = g_basename(input_file);
       
    48 	
       
    49 	if(ret_file_name != NULL)
       
    50 	    {
       
    51         if(g_strcmp0(ret_file_name, file_name) !=0 )
       
    52             {
       
    53             std_log(LOG_FILENAME_LINE, "g_basename returned wrong file name");
       
    54             assert_failed = 1;
       
    55             }
       
    56 	    }
       
    57 	else
       
    58 	    {
       
    59         std_log(LOG_FILENAME_LINE, "g_basename returned NULL. errno  = %d", errno);
       
    60         assert_failed = 1;
       
    61 	    }
       
    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 }