diff options
| author | J08nY | 2017-11-10 22:18:07 +0100 |
|---|---|---|
| committer | J08nY | 2017-11-10 22:18:07 +0100 |
| commit | 84a3a55be957900e0417a5afa77b65bfa6d19270 (patch) | |
| tree | 0b2da8b46c78e4660dacc2e06a1c96929627d783 /src/cz/crcs/ectester/common/test/Result.java | |
| parent | 59a043192903918a68e8d9df629c09221a13c641 (diff) | |
| download | ECTester-84a3a55be957900e0417a5afa77b65bfa6d19270.tar.gz ECTester-84a3a55be957900e0417a5afa77b65bfa6d19270.tar.zst ECTester-84a3a55be957900e0417a5afa77b65bfa6d19270.zip | |
Split test package into common.
Diffstat (limited to 'src/cz/crcs/ectester/common/test/Result.java')
| -rw-r--r-- | src/cz/crcs/ectester/common/test/Result.java | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/src/cz/crcs/ectester/common/test/Result.java b/src/cz/crcs/ectester/common/test/Result.java new file mode 100644 index 0000000..523a9d7 --- /dev/null +++ b/src/cz/crcs/ectester/common/test/Result.java @@ -0,0 +1,96 @@ +package cz.crcs.ectester.common.test; + +/** + * A Result of a Test. Has a Value and an optional String cause. + * + * @author Jan Jancar johny@neuromancer.sk + */ +public class Result { + + private Value value; + private String cause; + + public Result(Value value) { + this.value = value; + } + + public Result(Value value, String cause) { + this(value); + this.cause = cause; + } + + public Value getValue() { + return value; + } + + public String getCause() { + return cause; + } + + public boolean ok() { + return value.ok(); + } + + public boolean compareTo(Result other) { + if (other == null) { + return false; + } + return value == other.value; + } + + public boolean compareTo(Value other) { + if (other == null) { + return false; + } + return value == other; + } + + /** + * + */ + public enum Value { + SUCCESS(true), + FAILURE(false), + UXSUCCESS(false), + XFAILURE(true), + ERROR(false); + + private boolean ok; + + Value(boolean ok) { + this.ok = ok; + } + + public static Value fromExpected(ExpectedValue expected, boolean successful) { + switch (expected) { + case SUCCESS: + return successful ? SUCCESS : FAILURE; + case FAILURE: + return successful ? UXSUCCESS : XFAILURE; + case ANY: + return SUCCESS; + } + return SUCCESS; + } + + public static Value fromExpected(ExpectedValue expected, boolean successful, boolean error) { + if (error) { + return ERROR; + } + return fromExpected(expected, successful); + } + + public boolean ok() { + return ok; + } + } + + /** + * + */ + public enum ExpectedValue { + SUCCESS, + FAILURE, + ANY + } +} |
