mirror of
https://github.com/troglobit/libite.git
synced 2026-12-05 21:58:36 +00:00
Add unit test for chomp()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
75d4edb424
commit
682b662bd5
5 files changed
+26
-14
No files matched your search
@@ -45,18 +45,8 @@ char *chomp(char *str)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef UNITTEST
|
|
||||||
#include <stdio.h>
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
int i; char t[][16] = { "hej\ndej", "Slime\n\n\\n", "Tripple\n\n\n", "" };
|
|
||||||
for (i = 0; t[i][0]; i++) printf("[%02d]: '%s'\n", i, chomp(t[i])); return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
* compile-command: "make V=1 -f chomp.mk"
|
|
||||||
* indent-tabs-mode: t
|
* indent-tabs-mode: t
|
||||||
* c-file-style: "linux"
|
* c-file-style: "linux"
|
||||||
* End:
|
* End:
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
*.log
|
*.log
|
||||||
*.trs
|
*.trs
|
||||||
|
chomp
|
||||||
copyfile
|
copyfile
|
||||||
dir
|
dir
|
||||||
fexist
|
fexist
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ EXTRA_DIST = check.h
|
|||||||
CLEANFILES = *~ *.trs *.log
|
CLEANFILES = *~ *.trs *.log
|
||||||
|
|
||||||
TESTS =
|
TESTS =
|
||||||
|
TESTS += chomp
|
||||||
TESTS += copyfile
|
TESTS += copyfile
|
||||||
TESTS += dir
|
TESTS += dir
|
||||||
TESTS += fexist
|
TESTS += fexist
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#include "check.h"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
char t[][16] = {
|
||||||
|
"hej\ndej",
|
||||||
|
"Slime\n\n\\n",
|
||||||
|
"Tripple\n\n\n"
|
||||||
|
};
|
||||||
|
|
||||||
|
for (i = 0; i < NELEMS(t); i++) {
|
||||||
|
char *str = t[i];
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
chomp(str);
|
||||||
|
len = strlen(str);
|
||||||
|
printf("[%02zd]: '%s'\n", i, str);
|
||||||
|
|
||||||
|
fail_unless(str[len] != '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user