-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathStringBufferTest.cls
85 lines (73 loc) · 4.06 KB
/
StringBufferTest.cls
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
/* ============================================================
* This code is part of the "apex-lang" open source project avaiable at:
*
* http://code.google.com/p/apex-lang/
*
* This code is licensed under the Apache License, Version 2.0. You may obtain a
* copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
* ============================================================
*/
@IsTest
private class StringBufferTest {
private static testmethod void testDecimal(){
Decimal value = 3.14159;
System.assertEquals((new StringBuffer(value)).append(value).toStr(), ''+value+''+value);
System.assertEquals((new StringBuffer(value)).append(value).append(value).toStr(), ''+value+''+value+''+value);
}
private static testmethod void testDouble(){
Double value = 3.14159;
System.assertEquals((new StringBuffer(value)).append(value).toStr(), ''+value+''+value);
System.assertEquals((new StringBuffer(value)).append(value).append(value).toStr(), ''+value+''+value+''+value);
}
private static testmethod void testInteger(){
Integer value = 792392;
System.assertEquals((new StringBuffer(value)).append(value).toStr(), ''+value+''+value);
System.assertEquals((new StringBuffer(value)).append(value).append(value).toStr(), ''+value+''+value+''+value);
}
private static testmethod void testLong(){
Long value = 792392;
System.assertEquals((new StringBuffer(value)).append(value).toStr(), ''+value+''+value);
System.assertEquals((new StringBuffer(value)).append(value).append(value).toStr(), ''+value+''+value+''+value);
}
private static testmethod void testID(){
Account acct = new Account(name='test');
insert acct;
Id value = acct.id;
System.assertEquals((new StringBuffer(value)).append(value).toStr(), ''+value+''+value);
System.assertEquals((new StringBuffer(value)).append(value).append(value).toStr(), ''+value+''+value+''+value);
}
private static testmethod void testBoolean(){
Boolean value = true;
System.assertEquals((new StringBuffer(value)).append(value).toStr(), ''+value+''+value);
System.assertEquals((new StringBuffer(value)).append(value).append(!value).toStr(), ''+value+''+value+''+(!value));
}
private static testmethod void testString(){
String value = 'rwkrfkdekf';
System.assertEquals((new StringBuffer()).append(value).toStr(), ''+value);
System.assertEquals((new StringBuffer()).append(value).append(value).toStr(), ''+value+''+value);
System.assertEquals((new StringBuffer(value)).append(value).toStr(), ''+value+''+value);
System.assertEquals((new StringBuffer(value)).append(value).append(value).toStr(), ''+value+''+value+''+value);
}
private static testmethod void testDate(){
Date value = date.newinstance(1960, 2, 17);
System.assertEquals((new StringBuffer(value)).append(value).toStr(), ''+value+''+value);
System.assertEquals((new StringBuffer(value)).append(value).append(value).toStr(), ''+value+''+value+''+value);
}
private static testmethod void testDatetime(){
Datetime value = datetime.newInstance(2008, 12, 1);
System.assertEquals((new StringBuffer(value)).append(value).toStr(), ''+value+''+value);
System.assertEquals((new StringBuffer(value)).append(value).append(value).toStr(), ''+value+''+value+''+value);
}
private static testmethod void testTime(){
Time value = Time.newInstance(18, 30, 2, 20);
System.assertEquals((new StringBuffer(value)).append(value).toStr(), ''+value+''+value);
System.assertEquals((new StringBuffer(value)).append(value).append(value).toStr(), ''+value+''+value+''+value);
}
private static testmethod void testBlob(){
Blob value = Blob.valueOf('test123');
System.assertEquals((new StringBuffer(value)).append(value).toStr(), ''+value+''+value);
System.assertEquals((new StringBuffer(value)).append(value).append(value).toStr(), ''+value+''+value+''+value);
}
}