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
|
package org.litesoft.core.util.text;
import java.util.*;
import junit.framework.*;
import org.litesoft.core.simpletypes.*;
import org.litesoft.core.util.*;
public class CodedTextAccessorTest extends TestCase
{
public static TestSuite suite()
{
return new TestSuite( CodedTextAccessorTest.class );
}
public CodedTextAccessorTest( String name )
{
super( name );
}
public static void main( String[] args )
{
junit.textui.TestRunner.run( suite() );
}
private void testList( String pExpected, CodedTextAccessor<CodedText> zCTA, String pCodeStartsWith )
{
List<CodedText> zList = zCTA.getListFor( pCodeStartsWith );
assertEquals( pCodeStartsWith, pExpected, UtilsCommon.singleQuoteToString( UtilsCommon.toStringList( zList ) ) );
}
public void test_Lists()
throws Exception
{
CodedTextAccessor<CodedText> zCTA = new CodedTextAccessor<CodedText>( "A2", //
"A1A", //
"A1B", //
"BB", //
"M", //
"1", //
"Z" );
testList( "[]", zCTA, "X" );
testList( "['M']", zCTA, "M" );
testList( "['A2']", zCTA, "A2" );
testList( "['A1A','A1B']", zCTA, "A1" );
testList( "['A1A','A1B','A2']", zCTA, "A" );
}
private void testCodedTextFor( String pExpected, CodedTextAccessor<CodedText> zCTA, String pCode )
{
CodedText zCT = zCTA.getCodedTextFor( pCode );
assertEquals( pCode, pExpected, zCT.getText() );
}
public void test_Text()
throws Exception
{
CodedTextAccessor<CodedText> zCTA = new CodedTextAccessor<CodedText>( new CodedText.Simple( "A", "A1B" ), //
new CodedText.Simple( "A2", "A2B" ), //
new CodedText.Simple( "1", "B" ) );
testCodedTextFor( "X", zCTA, "X" );
testCodedTextFor( "A2B", zCTA, "A2" );
testCodedTextFor( "A1B", zCTA, "A" );
testCodedTextFor( "B", zCTA, "1" );
}
}
|