Skip to content

Commit f3e20b2

Browse files
committed
Use assert instead of if/error.
1 parent 9c5bda3 commit f3e20b2

File tree

1 file changed

+17
-51
lines changed

1 file changed

+17
-51
lines changed

test cases/common/42 string formatting/meson.build

Lines changed: 17 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,80 +2,46 @@ project('string formatting', 'c')
22

33
templ = '@0@bar@1@'
44

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.')
86

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.')
128

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.')
1610

1711
templ2 = '@0@'
1812
subs2 = '42'
1913

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.')
2315

2416
long = 'abcde'
2517
prefix = 'abc'
2618
suffix = 'cde'
2719

28-
if not long.startswith(prefix)
29-
error('Prefix.')
30-
endif
20+
assert(long.startswith(prefix), 'Prefix.')
3121

32-
if long.startswith(suffix)
33-
error('Not prefix.')
34-
endif
22+
assert(not long.startswith(suffix), 'Not prefix.')
3523

36-
if not long.endswith(suffix)
37-
error('Suffix.')
38-
endif
24+
assert(long.endswith(suffix), 'Suffix.')
3925

40-
if long.endswith(prefix)
41-
error('Not suffix.')
42-
endif
26+
assert(not long.endswith(prefix), 'Not suffix.')
4327

44-
if not long.contains(prefix)
45-
error('Does not contain prefix')
46-
endif
28+
assert(long.contains(prefix), 'Does not contain prefix')
4729

48-
if not long.contains(suffix)
49-
error('Does not contain suffix')
50-
endif
30+
assert(long.contains(suffix), 'Does not contain suffix')
5131

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')
5533

56-
if long.contains('dc')
57-
error('Broken contains')
58-
endif
34+
assert(not long.contains('dc'), 'Broken contains')
5935

60-
if long.to_upper() != 'ABCDE'
61-
error('Broken to_upper')
62-
endif
36+
assert(long.to_upper() == 'ABCDE', 'Broken to_upper')
6337

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')
6739

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')
7141

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')
7543

7644
# 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')
8046

8147
assert('3'.to_int() == 3, 'String int conversion does not work.')

0 commit comments

Comments
 (0)