~ubuntu-branches/debian/sid/alarm-clock-applet/sid

« back to all changes in this revision

Viewing changes to src/tests/test_util.c

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-05-30 23:24:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090530232427-88on1j2ily4ajxdz
Tags: upstream-0.2.6
ImportĀ upstreamĀ versionĀ 0.2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * glade_util.c -- Test for alarm utilities.
 
3
 * 
 
4
 * Copyright (C) 2007-2008 Johannes H. Jensen <joh@pseudoberries.com>
 
5
 * 
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License
 
8
 * as published by the Free Software Foundation; either version 2
 
9
 * of the License, or (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
19
 * 
 
20
 * Authors:
 
21
 *              Johannes H. Jensen <joh@pseudoberries.com>
 
22
 */
 
23
 
 
24
#include <time.h>
 
25
#include <glib.h>
 
26
 
 
27
#include "util.h"
 
28
 
 
29
#define FILENAME1 "some.file.ext"
 
30
#define FILENAME2 "some file"
 
31
 
 
32
#define CMD1 "ls"
 
33
#define CMD2 "not-found"
 
34
 
 
35
int main(void)
 
36
{
 
37
        gchar *tmp, ftime[256];
 
38
        gboolean ret;
 
39
        time_t now, ts;
 
40
        struct tm *tm;
 
41
        guint hour, min, sec;
 
42
        
 
43
        g_print ("Testing to_basename():\n\n");
 
44
        
 
45
        tmp = to_basename (FILENAME1);
 
46
        g_print ("to_basename (" FILENAME1 "): %s\n", tmp);
 
47
        g_free (tmp);
 
48
        
 
49
        tmp = to_basename (FILENAME2);
 
50
        g_print ("to_basename (" FILENAME2 "): %s\n", tmp);
 
51
        g_free (tmp);
 
52
        
 
53
        
 
54
        
 
55
        
 
56
        g_print ("\nTesting run_command():\n\n");
 
57
        
 
58
        ret = command_run (CMD1);
 
59
        g_print ("Running " CMD1 " = %d\n", ret);
 
60
        
 
61
        ret = command_run (CMD2);
 
62
        g_print ("Running " CMD2 " = %d\n", ret);
 
63
        
 
64
        
 
65
        
 
66
        
 
67
        g_print ("\nTesting get_alarm_timestamp()\n\n");
 
68
        
 
69
        time (&now);
 
70
        tm = localtime (&now);
 
71
        
 
72
        strftime (ftime, sizeof (ftime), "%c", tm);
 
73
        
 
74
        hour = tm->tm_hour;
 
75
        min = tm->tm_min;
 
76
        sec = tm->tm_sec;
 
77
        
 
78
        g_print ("Time: %s\n", ftime);
 
79
        ts = get_alarm_timestamp(hour, min, sec - 10);
 
80
        
 
81
        g_print ("For -10s: %d: %s\n", ts, ctime (&ts));
 
82
        ts = get_alarm_timestamp(hour, min, sec + 10);
 
83
                
 
84
        g_print ("For +10s: %d: %s\n", ts, ctime (&ts));
 
85
        
 
86
        return 0;
 
87
}