GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
test-date-converting.c
1 
2 #include "config.h"
3 
4 #include "test-stuff.h"
5 #include "test-engine-stuff.h"
6 #include "test-file-stuff.h"
7 
8 #include <stdlib.h>
9 
10 #include "sixtp-utils.h"
11 #include "sixtp-dom-generators.h"
12 
13 #define GNC_V2_STRING "gnc-v2"
14 const gchar *gnc_v2_xml_version_string = GNC_V2_STRING;
15 
16 int
17 main(int argc, char **argv)
18 {
19  int i;
20 
21  for (i = 0; i < 20; i++)
22  {
23  Timespec *spec1;
24  Timespec spec2;
25  gchar *sec_str;
26  gchar *nsec_str;
27 
28  spec1 = get_random_timespec();
29 
30  sec_str = timespec_sec_to_string(spec1);
31  nsec_str = timespec_nsec_to_string(spec1);
32 
33  if (!string_to_timespec_secs(sec_str, &spec2))
34  {
35  failure_args("string_to_timespec_secs", __FILE__, __LINE__,
36  "string is %s", sec_str);
37  }
38 
39  else if (!string_to_timespec_nsecs(nsec_str, &spec2))
40  {
41  failure_args("string_to_timespec_nsecs", __FILE__, __LINE__,
42  "string is %s", nsec_str);
43  }
44 
45  else if (spec1->tv_sec != spec2.tv_sec)
46  {
47  failure_args("timespec_secs", __FILE__, __LINE__,
48  "not equal ints are %" G_GINT64_FORMAT
49  " and %" G_GINT64_FORMAT "\n",
50  spec1->tv_sec, spec2.tv_sec);
51  }
52 
53  else if (spec1->tv_nsec != spec2.tv_nsec)
54  {
55  failure_args("timespec_nsecs", __FILE__, __LINE__,
56  "not equal ints are %ld and %ld\n",
57  spec1->tv_nsec, spec2.tv_nsec);
58  }
59 
60  else
61  {
62  success("timespec");
63  }
64 
65  g_free(spec1);
66  g_free(sec_str);
67  g_free(nsec_str);
68  }
69  print_test_results();
70  exit(get_rv());
71 }
Use a 64-bit unsigned int timespec.
Definition: gnc-date.h:299