From: Rico Tzschichholz Date: Thu, 29 Aug 2019 15:08:46 +0000 (+0200) Subject: tests: Extend "pre- and post-condition" test to increase coverage X-Git-Tag: 0.46.0~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=378b9e66f5bcbc76e21936d1b75c3291f3ff1534;p=thirdparty%2Fvala.git tests: Extend "pre- and post-condition" test to increase coverage --- diff --git a/tests/methods/prepostconditions.vala b/tests/methods/prepostconditions.vala index f7c4eaf68..214c4800a 100644 --- a/tests/methods/prepostconditions.vala +++ b/tests/methods/prepostconditions.vala @@ -20,6 +20,24 @@ class Foo { assert (i == 4711); return i; } + + public int faz (int i) ensures (result > 23) { + switch (i) { + case 42: + return i; + default: + assert_not_reached (); + } + } + + public int faz_pre (int i) requires (i > 23) { + switch (i) { + case 4711: + return i; + default: + assert_not_reached (); + } + } } void main () { @@ -30,4 +48,6 @@ void main () { assert(foo.bar () == "bar"); foo.foo_pre (42); assert(foo.bar_pre (4711) == 4711); + assert (foo.faz (42) == 42); + assert (foo.faz_pre (4711) == 4711); }