fluentasserts.core.operations.lessOrEqualTo 21/22(95%) line coverage

      
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
1955
200
2155
2255
230
240
2555
2655
270
280
290
300
3155
320
3355
3422
350
360
3755
3833
390
400
4122
4222
430
4422
450
4622
4711
4811
490
5011
5111
520
530
5422
5522
560
5722
580
module fluentasserts.core.operations.lessOrEqualTo; import fluentasserts.core.results; import fluentasserts.core.evaluation; import fluentasserts.core.lifecycle; import std.conv; import std.datetime; version(unittest) { import fluentasserts.core.expect; } static immutable lessOrEqualToDescription = "Asserts that the tested value is less or equal than the tested value. However, it's often best to assert that the target is equal to its expected value."; /// IResult[] lessOrEqualTo(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 or equal to "); results ~= new ExpectedActualResult("greater than " ~ evaluation.expectedValue.niceValue, evaluation.currentValue.niceValue); } else { evaluation.message.addText(" is greater than "); results ~= new ExpectedActualResult("less or equal to " ~ evaluation.expectedValue.niceValue, evaluation.currentValue.niceValue); } evaluation.message.addValue(evaluation.expectedValue.niceValue); evaluation.message.addText("."); return results; }