~ubuntu-branches/ubuntu/maverick/vlock/maverick

« back to all changes in this revision

Viewing changes to tests/test_util.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Wirt
  • Date: 2008-06-17 17:13:25 UTC
  • mfrom: (1.1.2 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080617171325-ic8yy6tol0165i96
Tags: 2.2.2-3
* Don't try to chgrp to "vlock" during build time (Closes: #486665)
* Bump standards version (No changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdlib.h>
 
2
#include <time.h>
 
3
 
 
4
#include <CUnit/CUnit.h>
 
5
 
 
6
#include "util.h"
 
7
 
 
8
#include "test_util.h"
 
9
 
 
10
void test_parse_timespec(void)
 
11
{
 
12
  struct timespec *t = parse_seconds("123");
 
13
 
 
14
  CU_ASSERT_PTR_NOT_NULL(t);
 
15
  CU_ASSERT(t->tv_sec == 123);
 
16
  CU_ASSERT(t->tv_nsec == 0);
 
17
 
 
18
  free(t);
 
19
 
 
20
#if 0
 
21
  /* Fractions are not supported, yet. */
 
22
  t = parse_seconds("123.4");
 
23
 
 
24
  CU_ASSERT_PTR_NOT_NULL(t);
 
25
  CU_ASSERT(t->tv_sec == 123);
 
26
  CU_ASSERT(t->tv_nsec == 400000);
 
27
 
 
28
  free(t);
 
29
#else
 
30
  CU_ASSERT_PTR_NULL(parse_seconds("123.4"));
 
31
#endif
 
32
 
 
33
  CU_ASSERT_PTR_NULL(parse_seconds("-1"));
 
34
  CU_ASSERT_PTR_NULL(parse_seconds("hello"));
 
35
}
 
36
 
 
37
CU_TestInfo util_tests[] = {
 
38
  { "test_parse_timespec", test_parse_timespec },
 
39
  CU_TEST_INFO_NULL,
 
40
};