@@ -134,3 +134,98 @@ on TestSplitByEmpty
134134 end try
135135
136136end TestSplitByEmpty
137+
138+
139+
140+ on TestSplitByColumn
141+ local tResult , tExpected
142+
143+ put "a,b:c,d" into tResult
144+ put empty into tExpected
145+ put "a:c" into tExpected [1 ]
146+ put "b:d" into tExpected [2 ]
147+ set the columnDel to ","
148+ set the rowDel to ":"
149+ split tResult by column
150+
151+ TestAssert "split column (native, native, native)" , tResult is tExpected
152+
153+ -- --------
154+
155+ put "a,b:c,d" into tResult
156+ set the columnDel to empty
157+ set the rowDel to ":"
158+ try
159+ split tResult by column
160+ TestAssert "split column (native, empty, native)" , false
161+ catch tError
162+ TestAssert "split column (native, empty, native)" , true
163+ end try
164+
165+ put "a,b:c,d" into tResult
166+ set the columnDel to ","
167+ set the rowDel to empty
168+ try
169+ split tResult by column
170+ TestAssert "split column (native, native, empty)" , false
171+ catch tError
172+ TestAssert "split column (native, native, empty)" , true
173+ end try
174+ end TestSplitByColumn
175+
176+
177+
178+ on TestSplitByRow
179+ local tResult , tExpected
180+
181+ put "a,b:c,d" into tResult
182+ put empty into tExpected
183+ put "a,b" into tExpected [1 ]
184+ put "c,d" into tExpected [2 ]
185+ set the columnDel to ","
186+ set the rowDel to ":"
187+ split tResult by row
188+ TestAssert "split row (native, native, native)" , tResult is tExpected
189+
190+ -- The column delimiter isn't actually used when splitting by row.
191+ put "a,b:c,d" into tResult
192+ set the columnDel to empty
193+ set the rowDel to ":"
194+ split tResult by row
195+ TestAssert "split row (native, empty, native)" , tResult is tExpected
196+
197+ -- --------
198+
199+ put "a,b:c,d" into tResult
200+ set the columnDel to ","
201+ set the rowDel to empty
202+ try
203+ split tResult by row
204+ TestAssert "split row (native, native, empty)" , false
205+ catch tError
206+ TestAssert "split row (native, native, empty)" , true
207+ end try
208+ end TestSplitByRow
209+
210+
211+
212+ on TestSplitAsSet
213+ local tResult , tExpected , tError
214+
215+ put "a:b" into tResult
216+ put empty into tExpected
217+ put true into tExpected ["a" ]
218+ put true into tExpected ["b" ]
219+ split tResult with ":" as set
220+ TestAssert "split set (native, native)" , tResult is tExpected
221+
222+ -- --------
223+
224+ put "a:b" into tResult
225+ try
226+ split tResult with empty as set
227+ TestAssert "split set (native, empty)" , false
228+ catch tError
229+ TestAssert "split set (native, empty)" , true
230+ end try
231+ end TestSplitAsSet
0 commit comments