From 386e01e2a47557acc9440001d40314374e5d982f Mon Sep 17 00:00:00 2001 From: J08nY Date: Fri, 2 Aug 2024 14:32:31 +0200 Subject: Make standalone Cofactor suite not use runTest. --- .../cz/crcs/ectester/common/test/CompoundTest.java | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'common') diff --git a/common/src/main/java/cz/crcs/ectester/common/test/CompoundTest.java b/common/src/main/java/cz/crcs/ectester/common/test/CompoundTest.java index ba4ad4f..ccb0f21 100644 --- a/common/src/main/java/cz/crcs/ectester/common/test/CompoundTest.java +++ b/common/src/main/java/cz/crcs/ectester/common/test/CompoundTest.java @@ -2,6 +2,7 @@ package cz.crcs.ectester.common.test; import java.util.Arrays; import java.util.Objects; +import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Function; @@ -16,13 +17,22 @@ public class CompoundTest extends Test implements Cloneable { private Test[] tests; private String description = ""; - private final static Consumer RUN_ALL = tests -> { + public final static BiFunction EXPECT_ALL = (what, tests) -> { + for (Test test : tests) { + if (!Result.Value.fromExpected(what, test.ok()).ok()) { + return new Result(Result.Value.FAILURE, "Some sub-tests did not have the expected result."); + } + } + return new Result(Result.Value.SUCCESS, "All sub-tests had the expected result."); + }; + + public final static Consumer RUN_ALL = tests -> { for (Test t : tests) { t.run(); } }; - private final static Consumer RUN_GREEDY_ALL = tests -> { + public final static Consumer RUN_GREEDY_ALL = tests -> { for (Test t : tests) { t.run(); if (!t.ok()) { @@ -31,7 +41,7 @@ public class CompoundTest extends Test implements Cloneable { } }; - private final static Consumer RUN_GREEDY_ANY = tests -> { + public final static Consumer RUN_GREEDY_ANY = tests -> { for (Test t : tests) { t.run(); if (t.ok()) { @@ -68,14 +78,7 @@ public class CompoundTest extends Test implements Cloneable { } private static CompoundTest expectAll(Result.ExpectedValue what, Consumer runCallback, Test[] all) { - return new CompoundTest((tests) -> { - for (Test test : tests) { - if (!Result.Value.fromExpected(what, test.ok()).ok()) { - return new Result(Result.Value.FAILURE, "Some sub-tests did not have the expected result."); - } - } - return new Result(Result.Value.SUCCESS, "All sub-tests had the expected result."); - }, runCallback, all); + return new CompoundTest((tests) -> EXPECT_ALL.apply(what, tests), runCallback, all); } public static CompoundTest all(Result.ExpectedValue what, Test... all) { -- cgit v1.2.3-70-g09d2