From 378b9e66f5bcbc76e21936d1b75c3291f3ff1534 Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Thu, 29 Aug 2019 17:08:46 +0200 Subject: [PATCH] tests: Extend "pre- and post-condition" test to increase coverage --- tests/methods/prepostconditions.vala | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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); } -- 2.47.2