summaryrefslogtreecommitdiff
path: root/c,cc/stringutil_test.c
blob: 798bccd332298cfc6d969cc54441c9b88a239caf (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
43
44
45
46
47
48
49
50
51
52
53
#include "filelib.h"
#include "stringutil.h"


int
main(void)
{
  /*
   * strend
   *
   */
  char* s= "";
  char* end = strend(s);
  if (end)
    printf("should not output: %s\n", end);

  s = "asdf.gz";
  end = strend(s);
  if (end)
    printf("expect 'z': %s\n", end);

  /*
   * endswith
   *
   */
  if (endswith(s, ".gz"))
    printf("%s ends with %s\n", s, ".gz");

  if (endswith(".gz", ".gz"))
    printf(".gz ends with .gz\n");

  if(!endswith("gz", ".gz"))
    printf("gz does not end with .gz\n");

  /*
   * filelib
   *
   */
  hFile* f = makef("-", "a");
  if (!f)
    printf("Error creating file '%s'\n", "-");
  writeln("this goes to stdout", f);
  closef(f);

  hFile* g = makef("gzfile.gz", "a");
  if (!g)
    printf("Error creating file '%s'\n", "-");
  writeln("this should be compressed", g);
  closef(g);

  return 0;
}