fluentasserts.core.operations.endWith 22/22(100%) line coverage

      
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
1737
180
1937
2037
2137
220
2337
2458
250
2637
2718
288
298
308
318
328
330
348
350
360
370
3819
399
409
419
429
439
440
459
460
470
480
490
5037
510
module fluentasserts.core.operations.endWith; import std.string; import fluentasserts.core.results; import fluentasserts.core.evaluation; import fluentasserts.core.serializers; import fluentasserts.core.lifecycle; version(unittest) { import fluentasserts.core.expect; } /// IResult[] endWith(ref Evaluation evaluation) @safe nothrow { Lifecycle.instance.addText("."); IResult[] results = []; auto current = evaluation.currentValue.strValue.cleanString; auto expected = evaluation.expectedValue.strValue.cleanString; auto index = current.indexOf(expected); auto doesEndWith = index >= 0 && index == current.length - expected.length; if(evaluation.isNegated) { if(doesEndWith) { Lifecycle.instance.addText(" "); Lifecycle.instance.addValue(evaluation.currentValue.strValue); Lifecycle.instance.addText(" ends with "); Lifecycle.instance.addValue(evaluation.expectedValue.strValue); Lifecycle.instance.addText("."); try results ~= new ExpectedActualResult("to not end with " ~ evaluation.expectedValue.strValue, evaluation.currentValue.strValue); catch(Exception e) {} } } else { if(!doesEndWith) { Lifecycle.instance.addText(" "); Lifecycle.instance.addValue(evaluation.currentValue.strValue); Lifecycle.instance.addText(" does not end with "); Lifecycle.instance.addValue(evaluation.expectedValue.strValue); Lifecycle.instance.addText("."); try results ~= new ExpectedActualResult("to end with " ~ evaluation.expectedValue.strValue, evaluation.currentValue.strValue); catch(Exception e) {} } } return results; }