]>
git.argeo.org Git - gpl/argeo-slc.git/blob - legacy/org.argeo.slc.support/ext/test/org/argeo/slc/diff/LineTokenizerTest.java
58ed61a92021559547eef5724fdbaa53f2a3e738
1 package org
.argeo
.slc
.diff
;
5 import junit
.framework
.TestCase
;
7 public class LineTokenizerTest
extends TestCase
{
8 public void testSimple() throws Exception
{
9 testAndAssert("a,b,c", new String
[] { "a", "b", "c" });
10 testAndAssert("hello,bonjour,hallo,priviet", new String
[] { "hello",
11 "bonjour", "hallo", "priviet" });
14 public void testTricky() throws Exception
{
15 testAndAssert("alone", new String
[] { "alone" });
16 testAndAssert("", new String
[] { "" });
18 testAndAssert(",hello,bonjour,hallo,priviet", new String
[] { "",
19 "hello", "bonjour", "hallo", "priviet" });
20 testAndAssert("hello,bonjour,,hallo,priviet", new String
[] { "hello",
21 "bonjour", "", "hallo", "priviet" });
22 testAndAssert("hello,bonjour,hallo,priviet,", new String
[] { "hello",
23 "bonjour", "hallo", "priviet", "" });
24 testAndAssert(",hello,,bonjour,hallo,,,,priviet,", new String
[] { "",
25 "hello", "", "bonjour", "hallo", "", "", "", "priviet", "" });
27 testAndAssert(",,,", new String
[] { "", "", "", "" });
30 public void testComplex() throws Exception
{
31 testAndAssert("a#b#c", '#', "", new String
[] { "a", "b", "c" });
32 testAndAssert("hello!bonjour!hallo!priviet", '!', "", new String
[] {
33 "hello", "bonjour", "hallo", "priviet" });
35 testAndAssert("hello,,bonjour,,hallo,priviet", ',', "<EMPTY>",
36 new String
[] { "hello", "<EMPTY>", "bonjour", "<EMPTY>",
37 "hallo", "priviet" });
40 private void testAndAssert(String str
, String
[] expected
) {
41 testAndAssert(str
, ',', "", expected
);
44 private void testAndAssert(String str
, Character sep
, String noValueStr
,
46 List
<String
> res
= LineTokenizer
.tokenize(str
, sep
, noValueStr
);
47 assertEquals("Size", expected
.length
, res
.size());
48 for (int i
= 0; i
< res
.size(); i
++) {
49 String token
= res
.get(i
);
50 assertEquals("Value@" + i
, expected
[i
], token
);