Initial import to Tizen
[profile/ivi/sphinxbase.git] / test / unit / test_util / test_filename.c
1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /**
3  * @file test_filename.c Test file name operations
4  * @author David Huggins-Daines <dhuggins@cs.cmu.edu>
5  */
6
7 #include "filename.h"
8 #include "test_macros.h"
9
10 #include <stdio.h>
11 #include <string.h>
12 #include <stdlib.h>
13
14 int
15 main(int argc, char *argv[])
16 {
17     char const testname[] = "/foo/bar/baz/quux.argh";
18     char const testname2[] = "foo/bar/baz";
19     char const testname3[] = "/foo";
20     char testout[32];
21
22     path2basename(testname, testout);
23     TEST_EQUAL(0, strcmp("quux.argh", testout));
24
25     path2dirname(testname, testout);
26     TEST_EQUAL(0, strcmp("/foo/bar/baz", testout));
27
28     path2dirname(testname2, testout);
29     TEST_EQUAL(0, strcmp("foo/bar", testout));
30
31     path2dirname(testname3, testout);
32     TEST_EQUAL(0, strcmp("", testout));
33
34     return 0;
35 }