Use assert instead of if/error.

pull/445/head
Jussi Pakkanen 9 years ago
parent 9c5bda3f40
commit f3e20b2570
  1. 68
      test cases/common/42 string formatting/meson.build

@ -2,80 +2,46 @@ project('string formatting', 'c')
templ = '@0@bar@1@' templ = '@0@bar@1@'
if templ.format('foo', 'baz') != 'foobarbaz' assert(templ.format('foo', 'baz') == 'foobarbaz', 'Basic string formatting is broken.')
error('Basic string formatting is broken.')
endif
if '@0@'.format(1) != '1' assert('@0@'.format(1) == '1', 'String number formatting is broken.')
error('String number formatting is broken.')
endif
if '@0@'.format(true) != 'true' assert('@0@'.format(true) == 'true', 'String boolean formatting is broken.')
error('String boolean formatting is broken.')
endif
templ2 = '@0@' templ2 = '@0@'
subs2 = '42' subs2 = '42'
if templ2.format(subs2) != '42' assert(templ2.format(subs2) == '42', 'String formatting with variables is broken.')
error('String formatting with variables is broken.')
endif
long = 'abcde' long = 'abcde'
prefix = 'abc' prefix = 'abc'
suffix = 'cde' suffix = 'cde'
if not long.startswith(prefix) assert(long.startswith(prefix), 'Prefix.')
error('Prefix.')
endif
if long.startswith(suffix) assert(not long.startswith(suffix), 'Not prefix.')
error('Not prefix.')
endif
if not long.endswith(suffix) assert(long.endswith(suffix), 'Suffix.')
error('Suffix.')
endif
if long.endswith(prefix) assert(not long.endswith(prefix), 'Not suffix.')
error('Not suffix.')
endif
if not long.contains(prefix) assert(long.contains(prefix), 'Does not contain prefix')
error('Does not contain prefix')
endif
if not long.contains(suffix) assert(long.contains(suffix), 'Does not contain suffix')
error('Does not contain suffix')
endif
if not long.contains('bcd') assert(long.contains('bcd'), 'Does not contain middle part')
error('Does not contain middle part')
endif
if long.contains('dc') assert(not long.contains('dc'), 'Broken contains')
error('Broken contains')
endif
if long.to_upper() != 'ABCDE' assert(long.to_upper() == 'ABCDE', 'Broken to_upper')
error('Broken to_upper')
endif
if long.to_upper().to_lower() != long assert(long.to_upper().to_lower() == long, 'Broken to_lower')
error('Broken to_lower')
endif
if 'struct stat.st_foo'.underscorify() != 'struct_stat_st_foo' assert('struct stat.st_foo'.underscorify() == 'struct_stat_st_foo', 'Broken underscorify')
error('Broken underscorify')
endif
if '#include <foo/bar.h>'.underscorify() != '_include__foo_bar_h_' assert('#include <foo/bar.h>'.underscorify() == '_include__foo_bar_h_', 'Broken underscorify')
error('Broken underscorify')
endif
# case should not change, space should be replaced, numbers are ok too # case should not change, space should be replaced, numbers are ok too
if 'Do SomeThing 09'.underscorify() != 'Do_SomeThing_09' assert('Do SomeThing 09'.underscorify() == 'Do_SomeThing_09', 'Broken underscorify')
error('Broken underscorify')
endif
assert('3'.to_int() == 3, 'String int conversion does not work.') assert('3'.to_int() == 3, 'String int conversion does not work.')

Loading…
Cancel
Save