test.operations.endWith 0/0(100%) line coverage

      
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
190
200
210
220
230
240
250
260
270
280
290
300
310
320
330
340
350
360
370
380
390
400
410
420
430
440
450
460
470
480
490
500
510
520
530
540
550
560
570
580
590
600
610
620
630
640
650
660
670
680
690
700
710
720
730
740
750
760
770
780
790
800
810
module test.operations.endWith; import fluentasserts.core.expect; import fluent.asserts; import trial.discovery.spec; import std.string; import std.conv; import std.meta; alias s = Spec!({ alias StringTypes = AliasSeq!(string, wstring, dstring); static foreach(Type; StringTypes) { describe("using " ~ Type.stringof ~ " values", { Type testValue; before({ testValue = "test string".to!Type; }); it("should check that a string ends with a certain substring", { expect(testValue).to.endWith("string"); }); it("should check that a string ends with a certain char", { expect(testValue).to.endWith('g'); }); it("should check that a string does not end with a certain substring", { expect(testValue).to.not.endWith("other"); }); it("should check that a string does not end with a certain char", { expect(testValue).to.not.endWith('o'); }); it("should throw a detailed error when the string does not end with the substring what was expected", { auto msg = ({ expect(testValue).to.endWith("other"); }).should.throwException!TestException.msg; msg.split("\n")[0].should.contain(`"test string" should end with "other". "test string" does not end with "other".`); msg.split("\n")[2].strip.should.equal(`Expected:to end with "other"`); msg.split("\n")[3].strip.should.equal(`Actual:"test string"`); }); it("should throw a detailed error when the string does not end with the char what was expected", { auto msg = ({ expect(testValue).to.endWith('o'); }).should.throwException!TestException.msg; msg.split("\n")[0].should.contain(`"test string" should end with 'o'. "test string" does not end with 'o'.`); msg.split("\n")[2].strip.should.equal(`Expected:to end with 'o'`); msg.split("\n")[3].strip.should.equal(`Actual:"test string"`); }); it("should throw a detailed error when the string does end with the unexpected substring", { auto msg = ({ expect(testValue).to.not.endWith("string"); }).should.throwException!TestException.msg; msg.split("\n")[0].should.contain(`"test string" should not end with "string". "test string" ends with "string".`); msg.split("\n")[2].strip.should.equal(`Expected:to not end with "string"`); msg.split("\n")[3].strip.should.equal(`Actual:"test string"`); }); it("should throw a detailed error when the string does end with the unexpected char", { auto msg = ({ expect(testValue).to.not.endWith('g'); }).should.throwException!TestException.msg; msg.split("\n")[0].should.contain(`"test string" should not end with 'g'. "test string" ends with 'g'.`); msg.split("\n")[2].strip.should.equal(`Expected:to not end with 'g'`); msg.split("\n")[3].strip.should.equal(`Actual:"test string"`); }); }); } });