1 module blerp.results; 2 3 import core.exception; 4 5 import std.conv: to; 6 7 struct exceptionInfo 8 { 9 bool hasInfo; 10 string msg; 11 string file; 12 ulong line; 13 string info; 14 } 15 16 17 class Results 18 19 { 20 this() 21 { 22 } 23 24 public void add(Result r) 25 { 26 this.results ~= r; 27 28 if (r.failed) 29 { 30 this.failedTotal++; 31 } 32 33 } 34 35 public int failedCount() 36 { 37 return this.failedTotal; 38 } 39 40 public int succeededCount() 41 { 42 return cast(int) this.results.length - this.failedTotal; 43 } 44 45 public int totalTests() 46 { 47 return cast(int) this.results.length; 48 } 49 50 public Result[] getResults() 51 { 52 return this.results; 53 } 54 55 private 56 { 57 Result[] results; 58 int failedTotal; 59 } 60 61 } 62 63 class Result 64 { 65 66 this(string name, exceptionInfo ex) 67 { 68 this.name = name; 69 this.exception = ex; 70 this.exception.hasInfo = true; 71 72 this.failed = true; 73 } 74 75 this(string name) 76 { 77 this.name = name; 78 this.exception.hasInfo = false; 79 } 80 81 public string getName() 82 { 83 return this.name; 84 } 85 86 public exceptionInfo getException() 87 { 88 return this.exception; 89 } 90 91 public bool hasException() 92 { 93 if (this.exception.hasInfo ) 94 { 95 return true; 96 } 97 98 return false; 99 } 100 101 private 102 { 103 string name; 104 exceptionInfo exception; 105 106 bool failed = false; 107 } 108 109 }