Skip to content

Commit bc3ac95

Browse files
author
Victor Homyakov
committed
Updated unit tests
1 parent e06ad15 commit bc3ac95

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

test/unit/string_test.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,11 @@ new Test.Unit.Runner({
430430
this.assert(!'hello world'.startsWith('bye'));
431431
this.assert(!''.startsWith('bye'));
432432
this.assert(!'hell'.startsWith('hello'));
433+
434+
var str = "To be, or not to be, that is the question";
435+
this.assert(str.startsWith("To be"), 'str.startsWith("To be")');
436+
this.assert(!str.startsWith("not to be"), 'str.startsWith("not to be")');
437+
this.assert(str.startsWith("not to be", 10), 'str.startsWith("not to be", 10)');
433438
},
434439

435440
testEndsWith: function() {
@@ -439,6 +444,25 @@ new Test.Unit.Runner({
439444
this.assert(!''.endsWith('planet'));
440445
this.assert('hello world world'.endsWith(' world'));
441446
this.assert(!'z'.endsWith('az'));
447+
448+
var str = "To be, or not to be, that is the question";
449+
this.assert(str.endsWith("question"), 'str.endsWith("question")');
450+
this.assert(!str.endsWith("to be"), 'str.endsWith("to be")');
451+
this.assert(str.endsWith("to be", 19), 'str.endsWith("to be", 19)');
452+
453+
str = "12345";
454+
this.assert(str.endsWith("5"));
455+
this.assert(str.endsWith("5", 6));
456+
this.assert(str.endsWith("5", 5));
457+
this.assert(!str.endsWith("5", 4));
458+
this.assert(!str.endsWith("5", 1));
459+
this.assert(!str.endsWith("5", 0));
460+
461+
this.assert(str.endsWith("1", 1));
462+
this.assert(!str.endsWith("1", 0));
463+
this.assert(!str.endsWith("1", -1));
464+
465+
this.assert(str.endsWith("", 0));
442466
},
443467

444468
testBlank: function() {
@@ -551,4 +575,4 @@ new Test.Unit.Runner({
551575
this.assertIdentical(false, 'false'.evalJSON());
552576
this.assertEqual('"', '"\\""'.evalJSON());
553577
}
554-
});
578+
});

0 commit comments

Comments
 (0)