Update contrib.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
25 // This test case is part automated and part manual. On running the test case
26 // an output is expected on the screen. All the other APIs which are tested,
27 // if they fail will write in the log file.
29 #undef G_DISABLE_ASSERT
37 #include "mrt2_glib2_test.h"
40 void myLogHandler(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,gpointer user_data)
42 char *data = (char *)user_data;
43 sprintf(data,"%s",message);
46 int main (int argc,char *argv[])
48 gchar message[100],message1[100];
56 log_func = g_log_set_default_handler(myLogHandler,message);
57 g_log(NULL,G_LOG_LEVEL_MESSAGE,"test message");
59 // checks g_log_set_default_handler. The new handler
60 // will put the message in the message array and the
61 // same is tested using the assert below.
62 g_assert(!strcmp(message,"test message"));
64 log_func = g_log_set_default_handler(log_func,message);
66 g_assert(log_func == myLogHandler);
68 id = g_log_set_handler ("test domain",G_LOG_LEVEL_MESSAGE, &myLogHandler, message1);
70 g_log("test domain",G_LOG_LEVEL_MESSAGE,"test message2");
72 // checks g_log_set_handler. The new handler
73 // will put the message in the message1 array and the
74 // same is tested using the assert below.
75 g_assert(id != -1 && !strcmp(message1,"test message2"));
77 g_log_remove_handler("test domain",id);
79 // This log message should print on stdout
80 // as the handler is removed.
81 g_log("test domain",G_LOG_LEVEL_MESSAGE,"test message printed \nsuccessfully\n");
82 printf("Press any key to exit");