This source file includes following definitions.
- main
- test
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 #include "ompi_config.h"
  21 
  22 #include <stdio.h>
  23 #include <string.h>
  24 #include <stdlib.h>
  25 
  26 #include "support.h"
  27 #include "opal/util/basename.h"
  28 #include "opal/util/printf.h"
  29 
  30 
  31 static void test(const char* in, const char* out);
  32 
  33 
  34 int main(int argc, char* argv[])
  35 {
  36   test_init("opal_basename()");
  37 
  38   test("foo.txt", "foo.txt");
  39   test("/foo/bar/baz", "baz");
  40   test("/yow.c", "yow.c");
  41   test("/", "/");
  42 
  43   test("foo.txt/", "foo.txt");
  44   test("/foo/bar/baz/", "baz");
  45   test("/yow.c/", "yow.c");
  46   test("//", "/");
  47 
  48   
  49   return test_finalize();
  50 }
  51 
  52 
  53 void test(const char* in, const char* out)
  54 {
  55     char *msg;
  56     char *ret = opal_basename(in);
  57 
  58     if (0 == strcmp(ret, out)) {
  59         test_success();
  60     } else {
  61         opal_asprintf(&msg, "Mismatch: input \"%s\", expected \"%s\", got \"%s\"\n",
  62                  in, out, ret);
  63         test_failure(msg);
  64         free(msg);
  65     }
  66     if (NULL != ret) {
  67         free(ret);
  68     }
  69 }
  70 
  71