diff options
| author | J08nY | 2017-11-10 12:56:47 +0100 |
|---|---|---|
| committer | J08nY | 2017-11-10 12:56:47 +0100 |
| commit | 588aa02a37ffd6e0ee2d164540023d1692109e89 (patch) | |
| tree | 609505ab9461fa341bb468caf092af6a563dcc61 /src/cz/crcs/ectester/reader/test/Result.java | |
| parent | 631edcfe145a558dd645dae5d83f3825a74471b1 (diff) | |
| parent | 4248ae9d9e3f6b79c9874c49ba901fba0f332211 (diff) | |
| download | ECTester-588aa02a37ffd6e0ee2d164540023d1692109e89.tar.gz ECTester-588aa02a37ffd6e0ee2d164540023d1692109e89.tar.zst ECTester-588aa02a37ffd6e0ee2d164540023d1692109e89.zip | |
Merge branch 'devel'
Diffstat (limited to '')
| -rw-r--r-- | src/cz/crcs/ectester/reader/test/Result.java | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src/cz/crcs/ectester/reader/test/Result.java b/src/cz/crcs/ectester/reader/test/Result.java new file mode 100644 index 0000000..82f0f32 --- /dev/null +++ b/src/cz/crcs/ectester/reader/test/Result.java @@ -0,0 +1,94 @@ +package cz.crcs.ectester.reader.test; + +/** + * @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 + } +} |
