summaryrefslogtreecommitdiff
path: root/support/dktools/test-dk4path8.ctr
blob: 788aa705dd9a13bd603b4fac7de483bea893ad2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

#include <stdio.h>

#include "dk4path8.h"
#include "string.h"

static const char * const	p1[] = {
"/usr/local",
"my/file"
};

static const char * const	p2[] = {
"../erwin.txt",
"../../bla.blubb",
"../../../test.was.passiert",
"ganz-langer-test-was-nun-wohl-passiert"
};

int main(void)
{
  char buf[256];
  dk4_er_t	er;
  const size_t szp1 = sizeof(p1)/sizeof(DK4_PCHAR);
  const size_t szp2 = sizeof(p2)/sizeof(DK4_PCHAR);
  size_t i;
  size_t j;

  for (i = 0; i < szp1; i++) {
    for (j = 0; j < szp2; j++) {
      strcpy(buf, p1[i]);
      dk4error_init(&er);
      if (dk4path8_append(buf, sizeof(buf), p2[j], &er)) {
        printf("%u %u = \"%s\"\n", (unsigned)i, (unsigned)j, buf);
      } else {
        printf("%u %u ERROR %d\n", (unsigned)i, (unsigned)j, er.ec);
      }
    }
  }
  return 0;
}