88#include "general.h"
99
1010#include "acutest.h"
11+ #include "fname.h"
1112#include "htable.h"
1213#include "routines.h"
1314#include <string.h>
1415
15- void test_htable_update (void )
16+ static void test_fname_absolute (void )
17+ {
18+ char * str ;
19+ char * in ;
20+
21+ #define T (INPUT ,OUTPUT ) \
22+ TEST_CHECK((in = eStrdup (INPUT), \
23+ strcmp((str = canonicalizeAbsoluteFileName (in)), OUTPUT) == 0)); \
24+ eFree (in); \
25+ eFree (str)
26+
27+ T ("/abc/efg/.." , "/abc" );
28+ T ("/abc/efg/hij/.." , "/abc/efg" );
29+ T ("/abc/efg/../" , "/abc" );
30+ T ("/abc/efg/./" , "/abc/efg" );
31+ T ("/abc/efg/./../." , "/abc" );
32+ T ("/abc/.." , "/" );
33+
34+ T (".." , "/" );
35+ T ("." , "/" );
36+ T ("a" , "/a" );
37+ T ("abc" , "/abc" );
38+ T ("" , "/" );
39+
40+ T ("../a" , "/a" );
41+ T ("../abc" , "/abc" );
42+ T ("./a" , "/a" );
43+ T ("./abc" , "/abc" );
44+ T ("a/../b" , "/b" );
45+ T ("abc/../efg" , "/efg" );
46+
47+ T ("..//////a" , "/a" );
48+ T ("..//..//..//a" , "/a" );
49+ }
50+
51+ static void test_htable_update (void )
1652{
1753 hashTable * htable = hashTableNew (3 , hashCstrhash , hashCstreq ,
1854 eFree , NULL );
@@ -28,12 +64,13 @@ void test_htable_update(void)
2864 hashTableDelete (htable );
2965}
3066
31- void test_routines_strrstr (void )
67+ static void test_routines_strrstr (void )
3268{
3369 TEST_CHECK (strcmp (strrstr ("abcdcdb" , "cd" ), "cdb" ) == 0 );
3470}
3571
3672TEST_LIST = {
73+ { "fname/absolute" , test_fname_absolute },
3774 { "htable/update" , test_htable_update },
3875 { "routines/strrstr" , test_routines_strrstr },
3976 { NULL , NULL } /* zeroed record marking the end of the list */
0 commit comments