fluentasserts.core.operations.greaterThan 42/45(93%) line coverage

      
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
1788
180
1988
2088
210
220
2388
2488
250
260
270
280
2988
300
3188
320
330
340
350
366
370
386
396
406
416
420
430
446
456
460
476
486
490
500
510
520
536
540
556
560
570
580
590
606
610
626
636
646
656
660
670
686
696
700
710
720
730
746
750
766
770
780
790
80100
8144
820
830
84100
8560
860
870
8840
8940
900
9140
920
9340
9414
9514
960
9726
9826
990
1000
10140
10240
1030
10440
1050
module fluentasserts.core.operations.greaterThan; import fluentasserts.core.results; import fluentasserts.core.evaluation; import fluentasserts.core.lifecycle; import std.conv; import std.datetime; version(unittest) { import fluentasserts.core.expect; } /// IResult[] greaterThan(T)(ref Evaluation evaluation) @safe nothrow { evaluation.message.addText("."); T expectedValue; T currentValue; try { expectedValue = evaluation.expectedValue.strValue.to!T; currentValue = evaluation.currentValue.strValue.to!T; } catch(Exception e) { return [ new MessageResult("Can't convert the values to " ~ T.stringof) ]; } auto result = currentValue > expectedValue; return greaterThanResults(result, evaluation.expectedValue.strValue, evaluation.currentValue.strValue, evaluation); } /// IResult[] greaterThanDuration(ref Evaluation evaluation) @safe nothrow { evaluation.message.addText("."); Duration expectedValue; Duration currentValue; string niceExpectedValue; string niceCurrentValue; try { expectedValue = dur!"nsecs"(evaluation.expectedValue.strValue.to!size_t); currentValue = dur!"nsecs"(evaluation.currentValue.strValue.to!size_t); niceExpectedValue = expectedValue.to!string; niceCurrentValue = currentValue.to!string; } catch(Exception e) { return [ new MessageResult("Can't convert the values to Duration") ]; } auto result = currentValue > expectedValue; return greaterThanResults(result, niceExpectedValue, niceCurrentValue, evaluation); } /// IResult[] greaterThanSysTime(ref Evaluation evaluation) @safe nothrow { evaluation.message.addText("."); SysTime expectedValue; SysTime currentValue; string niceExpectedValue; string niceCurrentValue; try { expectedValue = SysTime.fromISOExtString(evaluation.expectedValue.strValue); currentValue = SysTime.fromISOExtString(evaluation.currentValue.strValue); } catch(Exception e) { return [ new MessageResult("Can't convert the values to SysTime") ]; } auto result = currentValue > expectedValue; return greaterThanResults(result, evaluation.expectedValue.strValue, evaluation.currentValue.strValue, evaluation); } private IResult[] greaterThanResults(bool result, string niceExpectedValue, string niceCurrentValue, ref Evaluation evaluation) @safe nothrow { if(evaluation.isNegated) { result = !result; } if(result) { return []; } evaluation.message.addText(" "); evaluation.message.addValue(evaluation.currentValue.niceValue); IResult[] results = []; if(evaluation.isNegated) { evaluation.message.addText(" is greater than "); results ~= new ExpectedActualResult("less than or equal to " ~ niceExpectedValue, niceCurrentValue); } else { evaluation.message.addText(" is less than or equal to "); results ~= new ExpectedActualResult("greater than " ~ niceExpectedValue, niceCurrentValue); } evaluation.message.addValue(niceExpectedValue); evaluation.message.addText("."); return results; }