forked from nikhilk/scriptsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestString.htm
More file actions
108 lines (97 loc) · 4.63 KB
/
Copy pathTestString.htm
File metadata and controls
108 lines (97 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html>
<head>
<title>Test - String</title>
<link rel="stylesheet" href="QUnit.css" type="text/css" />
<script type="text/javascript" src="QUnit.js"></script>
<script type="text/javascript" src="QUnitExt.js"></script>
</head>
<body>
<h1 id="qunit-header">Test Results</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<br />
<textarea id="qunit-log" rows="10" cols="100"></textarea>
</body>
<script type="text/javascript" src="..\..\bin\Debug\mscorlib.debug.js"></script>
<script type="text/javascript">
module('String');
test('trim', function() {
QUnit.equal('Hello'.trim(), 'Hello');
QUnit.equal(' Hello'.trim(), 'Hello');
QUnit.equal('Hello '.trim(), 'Hello');
QUnit.equal(' Hello '.trim(), 'Hello');
QUnit.equal('\tHello '.trim(), 'Hello');
});
test('padLeft', function() {
QUnit.equal('Hello'.padLeft(5), 'Hello');
QUnit.equal('HelloWorld'.padLeft(5), 'HelloWorld');
QUnit.equal('Hey'.padLeft(5), ' Hey');
QUnit.equal('Hello'.padLeft(5), 'Hello');
QUnit.equal('HelloWorld'.padLeft(5), 'HelloWorld');
QUnit.equal('Hey'.padLeft(5, '.'), '..Hey');
});
test('padRight', function() {
QUnit.equal('Hello'.padRight(5), 'Hello');
QUnit.equal('HelloWorld'.padRight(5), 'HelloWorld');
QUnit.equal('Hey'.padRight(5), 'Hey ');
QUnit.equal('Hello'.padRight(5), 'Hello');
QUnit.equal('HelloWorld'.padRight(5), 'HelloWorld');
QUnit.equal('Hey'.padRight(5, '.'), 'Hey..');
});
test('compare', function() {
QUnit.equal(String.compare(null, null), 0, 'null vs null should be 0');
QUnit.equal(String.compare(null, 'x'), -1, 'null vs x should be -1');
QUnit.equal(String.compare('a', null), 1, 'a vs null should be 1');
QUnit.equal(String.compare('b', 'b'), 0, 'b vs b should be 0');
QUnit.equal(String.compare('aab', 'aaa'), 1, 'aab vs aaa should be 1');
QUnit.equal(String.compare('B', 'A'), 1, 'B vs A should be 1');
QUnit.equal(String.compare('e', 'E'), 1, 'e vs E should be 1');
QUnit.equal(String.compare(null, null, true), 0, 'null vs null should be 0');
QUnit.equal(String.compare(null, 'x', true), -1, 'null vs x should be -1');
QUnit.equal(String.compare('a', null, true), 1, 'a vs null should be 1');
QUnit.equal(String.compare('b', 'b', true), 0, 'b vs b should be 0');
QUnit.equal(String.compare('aab', 'aaa', true), 1, 'aab vs aaa should be 1');
QUnit.equal(String.compare('B', 'A', true), 1, 'B vs A should be 1');
QUnit.equal(String.compare('e', 'E', true), 0, 'e vs E should be 1');
});
test('endsWith', function() {
QUnit.equal('aaa'.endsWith('a'), true, 'aaa does end with a');
QUnit.equal('aaa'.endsWith('b'), false, 'aaa does not end with b');
QUnit.equal('aaa'.endsWith('aaa'), true, 'aaa does end with aaa');
QUnit.equal('aaa'.endsWith('aaaa'), false, 'aaa does not end with aaaa');
});
test('startsWith', function() {
QUnit.equal('aaa'.startsWith('a'), true, 'aaa does start with a');
QUnit.equal('aaa'.startsWith('b'), false, 'aaa does not start with b');
QUnit.equal('aaa'.startsWith('aaa'), true, 'aaa does start with aaa');
QUnit.equal('aaa'.startsWith('aaaa'), false, 'aaa does not start with aaaa');
});
test('htmlEncode', function() {
QUnit.equal('xyz'.htmlEncode(), 'xyz');
QUnit.equal('<h1>a "aaa" & a "bbb"</h1>'.htmlEncode(), '<h1>a "aaa" & a "bbb"</h1>');
});
test('htmlDecode', function() {
QUnit.equal('xyz'.htmlDecode(), 'xyz');
QUnit.equal('<h1>a "aaa" & a "bbb"</h1>'.htmlDecode(), '<h1>a "aaa" & a "bbb"</h1>');
});
test('isNullOrEmpty', function () {
QUnit.equal(String.isNullOrEmpty(null), true, 'null should be true');
QUnit.equal(String.isNullOrEmpty(undefined), true, 'undefined should be true');
QUnit.equal(String.isNullOrEmpty(), true, 'no param, should be true');
QUnit.equal(String.isNullOrEmpty(""), true, 'empty string, should be true');
QUnit.equal(String.isNullOrEmpty(" "), false, 'white space, should be false');
QUnit.equal(String.isNullOrEmpty("aaa"), false, 'aaa, should be false');
});
test('isNullOrWhiteSpace', function () {
QUnit.equal(String.isNullOrWhiteSpace(null), true, 'null should be true');
QUnit.equal(String.isNullOrWhiteSpace(undefined), true, 'undefined should be true');
QUnit.equal(String.isNullOrWhiteSpace(), true, 'no param, should be true');
QUnit.equal(String.isNullOrWhiteSpace(""), true, 'empty string, should be true');
QUnit.equal(String.isNullOrWhiteSpace(" "), true, 'white space, should be true');
QUnit.equal(String.isNullOrWhiteSpace(" "), true, 'triple white space, should be true');
QUnit.equal(String.isNullOrWhiteSpace("aaa"), false, 'aaa, should be false');
});
</script>
</html>