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

      
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
1938
200
2138
2238
2338
240
2538
260
270
2838
290
300
3160
320
3338
3418
358
368
378
388
398
400
418
420
430
440
4520
469
479
489
499
509
510
529
530
540
550
560
5738
580
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; } static immutable endWithDescription = "Tests that the tested string ends with the expected value."; /// IResult[] endWith(ref Evaluation evaluation) @safe nothrow { evaluation.message.addText("."); IResult[] results = []; auto current = evaluation.currentValue.strValue.cleanString; auto expected = evaluation.expectedValue.strValue.cleanString; long index = -1; try { index = current.lastIndexOf(expected); } catch(Exception) { } auto doesEndWith = index >= 0 && index == current.length - expected.length; if(evaluation.isNegated) { if(doesEndWith) { evaluation.message.addText(" "); evaluation.message.addValue(evaluation.currentValue.strValue); evaluation.message.addText(" ends with "); evaluation.message.addValue(evaluation.expectedValue.strValue); evaluation.message.addText("."); try results ~= new ExpectedActualResult("to not end with " ~ evaluation.expectedValue.strValue, evaluation.currentValue.strValue); catch(Exception e) {} } } else { if(!doesEndWith) { evaluation.message.addText(" "); evaluation.message.addValue(evaluation.currentValue.strValue); evaluation.message.addText(" does not end with "); evaluation.message.addValue(evaluation.expectedValue.strValue); evaluation.message.addText("."); try results ~= new ExpectedActualResult("to end with " ~ evaluation.expectedValue.strValue, evaluation.currentValue.strValue); catch(Exception e) {} } } return results; }