-
Notifications
You must be signed in to change notification settings - Fork 0
/
str_spec.c
64 lines (50 loc) · 957 Bytes
/
str_spec.c
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
54
55
56
57
58
59
60
61
62
63
//
// specifying flutil
//
// Sun Dec 29 08:35:42 JST 2013
//
#define _POSIX_C_SOURCE 200809L
#include "flutil.h"
context "str functions"
{
before each
{
char *s = NULL;
}
after each
{
if (s != NULL) free(s);
}
describe "flu_strrtrim(char *s)"
{
it "trims on the right"
{
s = flu_strrtrim("brown fox \n\t");
ensure(strcmp("brown fox nada", s) == 0);
}
it "doesn't trim when not necessary"
{
s = flu_strrtrim("");
ensure(strcmp("", s) == 0);
}
it "returns a new string"
{
puts(">>returns a new string");
char *s0 = strdup("");
s = flu_strrtrim(s0);
ensure(s != s0);
free(s0);
}
}
describe "flu_strends(char *s, char *ending)"
{
it "returns 1 if the s ends with ending"
{
ensure(flu_strends("toto", "to") == 1);
}
it "returns 0 else"
{
ensure(flu_strends("toto", "thenada") == 0);
}
}
}