fluentasserts.core.operations.startWith 20/20(100%) line coverage

      
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
1990
200
2190
220
2390
2490
250
2690
2718
288
298
308
318
328
330
348
350
360
370
3872
399
409
419
429
439
440
459
460
470
480
490
5090
510
module fluentasserts.core.operations.startWith; 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 startWithDescription = "Tests that the tested string starts with the expected value."; /// IResult[] startWith(ref Evaluation evaluation) @safe nothrow { evaluation.message.addText("."); IResult[] results = []; auto index = evaluation.currentValue.strValue.cleanString.indexOf(evaluation.expectedValue.strValue.cleanString); auto doesStartWith = index == 0; if(evaluation.isNegated) { if(doesStartWith) { evaluation.message.addText(" "); evaluation.message.addValue(evaluation.currentValue.strValue); evaluation.message.addText(" starts with "); evaluation.message.addValue(evaluation.expectedValue.strValue); evaluation.message.addText("."); try results ~= new ExpectedActualResult("to not start with " ~ evaluation.expectedValue.strValue, evaluation.currentValue.strValue); catch(Exception e) {} } } else { if(!doesStartWith) { evaluation.message.addText(" "); evaluation.message.addValue(evaluation.currentValue.strValue); evaluation.message.addText(" does not start with "); evaluation.message.addValue(evaluation.expectedValue.strValue); evaluation.message.addText("."); try results ~= new ExpectedActualResult("to start with " ~ evaluation.expectedValue.strValue, evaluation.currentValue.strValue); catch(Exception e) {} } } return results; }