@@ -2,80 +2,46 @@ project('string formatting', 'c')
2
2
3
3
templ = ' @0@bar@1@'
4
4
5
- if templ.format(' foo' , ' baz' ) != ' foobarbaz'
6
- error (' Basic string formatting is broken.' )
7
- endif
5
+ assert (templ.format(' foo' , ' baz' ) == ' foobarbaz' , ' Basic string formatting is broken.' )
8
6
9
- if ' @0@' .format(1 ) != ' 1'
10
- error (' String number formatting is broken.' )
11
- endif
7
+ assert (' @0@' .format(1 ) == ' 1' , ' String number formatting is broken.' )
12
8
13
- if ' @0@' .format(true ) != ' true'
14
- error (' String boolean formatting is broken.' )
15
- endif
9
+ assert (' @0@' .format(true ) == ' true' , ' String boolean formatting is broken.' )
16
10
17
11
templ2 = ' @0@'
18
12
subs2 = ' 42'
19
13
20
- if templ2.format(subs2) != ' 42'
21
- error (' String formatting with variables is broken.' )
22
- endif
14
+ assert (templ2.format(subs2) == ' 42' , ' String formatting with variables is broken.' )
23
15
24
16
long = ' abcde'
25
17
prefix = ' abc'
26
18
suffix = ' cde'
27
19
28
- if not long.startswith(prefix)
29
- error (' Prefix.' )
30
- endif
20
+ assert (long.startswith(prefix), ' Prefix.' )
31
21
32
- if long.startswith(suffix)
33
- error (' Not prefix.' )
34
- endif
22
+ assert (not long.startswith(suffix), ' Not prefix.' )
35
23
36
- if not long.endswith(suffix)
37
- error (' Suffix.' )
38
- endif
24
+ assert (long.endswith(suffix), ' Suffix.' )
39
25
40
- if long.endswith(prefix)
41
- error (' Not suffix.' )
42
- endif
26
+ assert (not long.endswith(prefix), ' Not suffix.' )
43
27
44
- if not long.contains(prefix)
45
- error (' Does not contain prefix' )
46
- endif
28
+ assert (long.contains(prefix), ' Does not contain prefix' )
47
29
48
- if not long.contains(suffix)
49
- error (' Does not contain suffix' )
50
- endif
30
+ assert (long.contains(suffix), ' Does not contain suffix' )
51
31
52
- if not long.contains(' bcd' )
53
- error (' Does not contain middle part' )
54
- endif
32
+ assert (long.contains(' bcd' ), ' Does not contain middle part' )
55
33
56
- if long.contains(' dc' )
57
- error (' Broken contains' )
58
- endif
34
+ assert (not long.contains(' dc' ), ' Broken contains' )
59
35
60
- if long.to_upper() != ' ABCDE'
61
- error (' Broken to_upper' )
62
- endif
36
+ assert (long.to_upper() == ' ABCDE' , ' Broken to_upper' )
63
37
64
- if long.to_upper().to_lower() != long
65
- error (' Broken to_lower' )
66
- endif
38
+ assert (long.to_upper().to_lower() == long, ' Broken to_lower' )
67
39
68
- if ' struct stat.st_foo' .underscorify() != ' struct_stat_st_foo'
69
- error (' Broken underscorify' )
70
- endif
40
+ assert (' struct stat.st_foo' .underscorify() == ' struct_stat_st_foo' , ' Broken underscorify' )
71
41
72
- if ' #include <foo/bar.h>' .underscorify() != ' _include__foo_bar_h_'
73
- error (' Broken underscorify' )
74
- endif
42
+ assert (' #include <foo/bar.h>' .underscorify() == ' _include__foo_bar_h_' , ' Broken underscorify' )
75
43
76
44
# case should not change, space should be replaced, numbers are ok too
77
- if ' Do SomeThing 09' .underscorify() != ' Do_SomeThing_09'
78
- error (' Broken underscorify' )
79
- endif
45
+ assert (' Do SomeThing 09' .underscorify() == ' Do_SomeThing_09' , ' Broken underscorify' )
80
46
81
47
assert (' 3' .to_int() == 3 , ' String int conversion does not work.' )
0 commit comments