fluentasserts.core.operations.lessThan 46/48(95%) line coverage

      
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
1777
180
1977
2077
210
220
2377
2477
250
260
270
280
2977
300
3177
3238
330
340
3577
3653
370
380
3924
4024
410
4224
430
4424
4512
4612
470
4812
4912
500
510
5224
5324
540
5524
560
570
580
598
600
618
628
638
648
650
660
678
688
690
708
718
720
730
740
750
768
770
788
793
800
810
828
835
840
850
863
873
880
893
900
913
921
931
940
952
962
970
980
993
1003
1010
1023
1030
module fluentasserts.core.operations.lessThan; 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[] lessThan(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; 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 less than "); results ~= new ExpectedActualResult("greater than or equal to " ~ evaluation.expectedValue.niceValue, evaluation.currentValue.niceValue); } else { evaluation.message.addText(" is greater than or equal to "); results ~= new ExpectedActualResult("less than " ~ evaluation.expectedValue.niceValue, evaluation.currentValue.niceValue); } evaluation.message.addValue(evaluation.expectedValue.niceValue); evaluation.message.addText("."); return results; } IResult[] lessThanDuration(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; 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 less than "); results ~= new ExpectedActualResult("greater than or equal to " ~ niceExpectedValue, niceCurrentValue); } else { evaluation.message.addText(" is greater than or equal to "); results ~= new ExpectedActualResult("less than " ~ niceExpectedValue, niceCurrentValue); } evaluation.message.addValue(niceExpectedValue); evaluation.message.addText("."); return results; }