Permalink
Browse files

Updated unit tests

  • Loading branch information...
1 parent e06ad15 commit bc3ac95c43c200033697d66012cfc7ac0d95e9b1 @victor-homyakov victor-homyakov committed Jan 26, 2013
Showing with 25 additions and 1 deletion.
  1. +25 −1 test/unit/string_test.js
View
@@ -430,6 +430,11 @@ new Test.Unit.Runner({
this.assert(!'hello world'.startsWith('bye'));
this.assert(!''.startsWith('bye'));
this.assert(!'hell'.startsWith('hello'));
+
+ var str = "To be, or not to be, that is the question";
+ this.assert(str.startsWith("To be"), 'str.startsWith("To be")');
+ this.assert(!str.startsWith("not to be"), 'str.startsWith("not to be")');
+ this.assert(str.startsWith("not to be", 10), 'str.startsWith("not to be", 10)');
},
testEndsWith: function() {
@@ -439,6 +444,25 @@ new Test.Unit.Runner({
this.assert(!''.endsWith('planet'));
this.assert('hello world world'.endsWith(' world'));
this.assert(!'z'.endsWith('az'));
+
+ var str = "To be, or not to be, that is the question";
+ this.assert(str.endsWith("question"), 'str.endsWith("question")');
+ this.assert(!str.endsWith("to be"), 'str.endsWith("to be")');
+ this.assert(str.endsWith("to be", 19), 'str.endsWith("to be", 19)');
+
+ str = "12345";
+ this.assert(str.endsWith("5"));
+ this.assert(str.endsWith("5", 6));
+ this.assert(str.endsWith("5", 5));
+ this.assert(!str.endsWith("5", 4));
+ this.assert(!str.endsWith("5", 1));
+ this.assert(!str.endsWith("5", 0));
+
+ this.assert(str.endsWith("1", 1));
+ this.assert(!str.endsWith("1", 0));
+ this.assert(!str.endsWith("1", -1));
+
+ this.assert(str.endsWith("", 0));
},
testBlank: function() {
@@ -551,4 +575,4 @@ new Test.Unit.Runner({
this.assertIdentical(false, 'false'.evalJSON());
this.assertEqual('"', '"\\""'.evalJSON());
}
-});
+});

0 comments on commit bc3ac95

Please sign in to comment.