Ticket #131: all_delete_testsEditTextViewTests.st

File all_delete_testsEditTextViewTests.st, 3.7 KB (added by patrik.svestka@…, 6 years ago)

Adding tests for the delete key functionality

Line 
1"{ Encoding: utf8 }" !
2!EditTextViewTests methodsFor:'tests'!
3
4test_02a
5 "Testing deletion of space between words"
6
7 textView contents:'This text is to continue'.
8 textView setCursorCol:16.
9
10 textViewInteractor type: #BasicDelete.
11 self assert:textView contents asString = ('This text is tocontinue', Character cr).
12
13 "Modified (comment): / 03-10-2018 / 13:27:14 / svestkap"
14! !
15
16!EditTextViewTests methodsFor:'tests'!
17
18test_02b
19 "Testing a deletion of one of multiple spaces"
20
21 textView contents:'This text is to continue'.
22 textView setCursorCol:16.
23
24 textViewInteractor type: #BasicDelete.
25 self assert:textView contents asString = ('This text is to continue', Character cr).
26
27 "Modified (comment): / 03-10-2018 / 13:27:41 / svestkap"
28! !
29
30!EditTextViewTests methodsFor:'tests'!
31
32test_02c
33 "Testing if space at the end is deleted"
34
35 textView contents:'This text is to continue '.
36 textView setCursorCol:25.
37
38 textViewInteractor type: #BasicDelete.
39 self assert:textView contents asString = ('This text is to continue', Character cr).
40
41 "Modified (comment): / 03-10-2018 / 13:27:57 / svestkap"
42! !
43
44!EditTextViewTests methodsFor:'tests'!
45
46test_02d
47 "Testing if space is deleted from multiple spaces at the end of testing string"
48
49 textView contents:'This text is to continue '.
50 textView setCursorCol:25.
51
52 textViewInteractor type: #BasicDelete.
53 self assert:textView contents asString = ('This text is to continue ', Character cr).
54
55 "Modified (comment): / 03-10-2018 / 13:28:21 / svestkap"
56! !
57
58!EditTextViewTests methodsFor:'tests'!
59
60test_02e
61 "Testing multiple space deletion when there are multiple spaces between
62 last word and last character"
63
64 |text originalStringSize expectedStringSize|
65
66 text := 'This text is to continue .'.
67
68 textView contents: text.
69 originalStringSize := text size.
70 textView setCursorCol:25.
71
72 textViewInteractor type: #BasicDelete.
73 expectedStringSize := textView contents asString size.
74
75 self assert: expectedStringSize equals: originalStringSize - 1.
76
77 "Modified (comment): / 03-10-2018 / 13:29:26 / svestkap"
78! !
79
80!EditTextViewTests methodsFor:'tests'!
81
82test_02f
83 "This tests if there are spaces left at the end after moving the line up"
84
85 textView contents:'This text is to ', String lf, 'continue'.
86 textView setCursorCol:16.
87
88 textViewInteractor type: #BasicDelete.
89 self assert:textView contents asString = ('This text is to continue', Character cr).
90
91 "Modified: / 03-10-2018 / 13:21:51 / svestkap"
92! !
93
94!EditTextViewTests methodsFor:'tests'!
95
96test_02g
97 "Testing if the space at the end first line remains"
98
99 textView contents:'This text is to ', String lf, 'continue'.
100 textView setCursorCol:16.
101
102 textViewInteractor type: #BasicDelete.
103 self assert:textView contents asString ~= ('This text is tocontinue', Character cr).
104
105 "Created: / 11-07-2017 / 10:28:21 / svestkap"
106 "Modified (comment): / 03-10-2018 / 13:30:36 / svestkap"
107! !
108
109!EditTextViewTests methodsFor:'tests'!
110
111test_02h
112 "Testing if the $. moves a position when delete is pressed"
113
114 |text originalStringSize expectedStringSize|
115
116 text := 'This text is to continue .'.
117
118 textView contents: text.
119 originalStringSize := text indexOf: $. startingAt: 1.
120 textView setCursorCol:25.
121
122 textViewInteractor type: #BasicDelete.
123 expectedStringSize := (textView contents asString) indexOf: $. startingAt: 1.
124
125
126 "/self assert: expectedStringSize == (originalStringSize - 1).
127
128 self assert: expectedStringSize equals: originalStringSize - 1.
129
130 "Created: / 03-10-2018 / 13:19:10 / svestkap"
131! !
132