Changes in / [9c54979:58b6ce5]


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tester.c

    r6a20996 r97cdbaf5  
    133133{
    134134  int numfailed=0;
    135   char *path, *home;
     135  char *s, *path, *home;
    136136
    137137  printf("# BEGIN testing owl_util\n");
     
    229229
    230230
    231   CHECK_STR_AND_FREE("baseclass barnowl",
    232                      "barnowl", owl_util_baseclass("barnowl"));
    233   CHECK_STR_AND_FREE("baseclass unbarnowl",
    234                      "barnowl", owl_util_baseclass("unbarnowl"));
    235   CHECK_STR_AND_FREE("baseclass unununbarnowl.d.d",
    236                      "barnowl", owl_util_baseclass("unununbarnowl.d.d"));
    237   CHECK_STR_AND_FREE("baseclass ununun.d.d",
    238                      "", owl_util_baseclass("ununun.d.d"));
    239   CHECK_STR_AND_FREE("baseclass d.d.d.d",
    240                      "d", owl_util_baseclass("d.d.d.d"));
    241   CHECK_STR_AND_FREE("baseclass n.d.d.d",
    242                      "n", owl_util_baseclass("n.d.d.d"));
    243   CHECK_STR_AND_FREE("baseclass ununun.",
    244                      ".", owl_util_baseclass("ununun."));
    245   CHECK_STR_AND_FREE("baseclass unununu",
    246                      "u", owl_util_baseclass("unununu"));
    247 
    248 
    249   CHECK_STR_AND_FREE("makepath foo/bar",
    250                      "foo/bar", owl_util_makepath("foo/bar"));
    251   CHECK_STR_AND_FREE("makepath //foo///bar",
    252                      "/foo/bar", owl_util_makepath("//foo///bar"));
    253   CHECK_STR_AND_FREE("makepath foo/~//bar/",
    254                      "foo/~/bar/", owl_util_makepath("foo/~//bar/"));
    255   CHECK_STR_AND_FREE("makepath ~thisuserhadreallybetternotexist/foobar/",
    256                      "~thisuserhadreallybetternotexist/foobar/",
    257                      owl_util_makepath("~thisuserhadreallybetternotexist/foobar/"));
     231  s = owl_util_baseclass("barnowl");
     232  FAIL_UNLESS("baseclass barnowl", !strcmp("barnowl", s));
     233  g_free(s);
     234  s = owl_util_baseclass("unbarnowl");
     235  FAIL_UNLESS("baseclass unbarnowl", !strcmp("barnowl", s));
     236  g_free(s);
     237  s = owl_util_baseclass("unununbarnowl.d.d");
     238  FAIL_UNLESS("baseclass unununbarnowl.d.d", !strcmp("barnowl", s));
     239  g_free(s);
     240  s = owl_util_baseclass("ununun.d.d");
     241  FAIL_UNLESS("baseclass ununun.d.d", !strcmp("", s));
     242  g_free(s);
     243  s = owl_util_baseclass("d.d.d.d");
     244  FAIL_UNLESS("baseclass d.d.d.d", !strcmp("d", s));
     245  g_free(s);
     246  s = owl_util_baseclass("n.d.d.d");
     247  FAIL_UNLESS("baseclass n.d.d.d", !strcmp("n", s));
     248  g_free(s);
     249  s = owl_util_baseclass("ununun.");
     250  FAIL_UNLESS("baseclass ununun.", !strcmp(".", s));
     251  g_free(s);
     252  s = owl_util_baseclass("unununu");
     253  FAIL_UNLESS("baseclass unununu", !strcmp("u", s));
     254  g_free(s);
     255
     256
     257  s = owl_util_makepath("foo/bar");
     258  FAIL_UNLESS("makepath foo/bar", !strcmp("foo/bar", s));
     259  g_free(s);
     260  s = owl_util_makepath("//foo///bar");
     261  FAIL_UNLESS("makepath //foo///bar", !strcmp("/foo/bar", s));
     262  g_free(s);
     263  s = owl_util_makepath("foo/~//bar/");
     264  FAIL_UNLESS("makepath foo/~//bar/", !strcmp("foo/~/bar/", s));
     265  g_free(s);
     266  s = owl_util_makepath("~thisuserhadreallybetternotexist/foobar/");
     267  FAIL_UNLESS("makepath ~thisuserhadreallybetternotexist/foobar/",
     268              !strcmp("~thisuserhadreallybetternotexist/foobar/", s));
     269  g_free(s);
    258270
    259271  home = g_strdup(owl_global_get_homedir(&g));
    260   CHECK_STR_AND_FREE("makepath ~",
    261                      home, owl_util_makepath("~"));
     272  s = owl_util_makepath("~");
     273  FAIL_UNLESS("makepath ~", !strcmp(home, s));
     274  g_free(s);
    262275
    263276  path = g_build_filename(home, "foo/bar/baz", NULL);
    264   CHECK_STR_AND_FREE("makepath ~///foo/bar//baz",
    265                      path, owl_util_makepath("~///foo/bar//baz"));
     277  s = owl_util_makepath("~///foo/bar//baz");
     278  FAIL_UNLESS("makepath ~///foo/bar//baz", !strcmp(path, s));
     279  g_free(s);
    266280  g_free(path);
    267281  g_free(home);
     
    274288  }
    275289
    276   CHECK_STR_AND_FREE("makepath ~root",
    277                      home, owl_util_makepath("~root"));
     290  s = owl_util_makepath("~root");
     291  FAIL_UNLESS("makepath ~root", !strcmp(home, s));
     292  g_free(s);
    278293
    279294  path = g_build_filename(home, "foo/bar/baz", NULL);
    280   CHECK_STR_AND_FREE("makepath ~root///foo/bar//baz",
    281                      path, owl_util_makepath("~root///foo/bar//baz"));
     295  s = owl_util_makepath("~root///foo/bar//baz");
     296  FAIL_UNLESS("makepath ~root///foo/bar//baz", !strcmp(path, s));
     297  g_free(s);
    282298  g_free(path);
    283299  g_free(home);
Note: See TracChangeset for help on using the changeset viewer.