Subversion Repository Public Repository

litesoft

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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// This Source Code is in the Public Domain per: http://unlicense.org
package org.litesoft.codec;

import junit.framework.*;

public class SixBitCodecTest extends TestCase
{
    public static TestSuite suite()
    {
        return new TestSuite( SixBitCodecTest.class );
    }

    public SixBitCodecTest( String name )
    {
        super( name );
    }

    public static void main( String[] args )
    {
        junit.textui.TestRunner.run( suite() );
    }

    private void testRT( char pExpected, int pValue )
    {
        assertEquals( pExpected, SixBitCodec.encode( pValue ) );
        assertEquals( pValue, SixBitCodec.decode( pExpected ) );
    }

    public void test_BadChar()
            throws Exception
    {
        try
        {
            SixBitCodec.decode( '~' );
            fail("Bad Char OK?");
        }
        catch ( IllegalArgumentException expected )
        {
            // OK
        }
    }

    public void test_HiBits()
            throws Exception
    {
        assertEquals( '0', SixBitCodec.encode( 64 ) );
        assertEquals( '1', SixBitCodec.encode( 65 ) );
    }

    public void test_HappyCases()
            throws Exception
    {
        testRT( '0', 0 );
        testRT( '1', 1 );
        testRT( '2', 2 );
        testRT( '3', 3 );
        testRT( '4', 4 );
        testRT( '5', 5 );
        testRT( '6', 6 );
        testRT( '7', 7 );
        testRT( '8', 8 );
        testRT( '9', 9 );
        testRT( 'A', 10 );
        testRT( 'B', 11 );
        testRT( 'C', 12 );
        testRT( 'D', 13 );
        testRT( 'E', 14 );
        testRT( 'F', 15 );
        testRT( 'G', 16 );
        testRT( 'H', 17 );
        testRT( 'I', 18 );
        testRT( 'J', 19 );
        testRT( 'K', 20 );
        testRT( 'L', 21 );
        testRT( 'M', 22 );
        testRT( 'N', 23 );
        testRT( 'O', 24 );
        testRT( 'P', 25 );
        testRT( 'Q', 26 );
        testRT( 'R', 27 );
        testRT( 'S', 28 );
        testRT( 'T', 29 );
        testRT( 'U', 30 );
        testRT( 'V', 31 );
        testRT( 'W', 32 );
        testRT( 'X', 33 );
        testRT( 'Y', 34 );
        testRT( 'Z', 35 );
        testRT( 'a', 36 );
        testRT( 'b', 37 );
        testRT( 'c', 38 );
        testRT( 'd', 39 );
        testRT( 'e', 40 );
        testRT( 'f', 41 );
        testRT( 'g', 42 );
        testRT( 'h', 43 );
        testRT( 'i', 44 );
        testRT( 'j', 45 );
        testRT( 'k', 46 );
        testRT( 'l', 47 );
        testRT( 'm', 48 );
        testRT( 'n', 49 );
        testRT( 'o', 50 );
        testRT( 'p', 51 );
        testRT( 'q', 52 );
        testRT( 'r', 53 );
        testRT( 's', 54 );
        testRT( 't', 55 );
        testRT( 'u', 56 );
        testRT( 'v', 57 );
        testRT( 'w', 58 );
        testRT( 'x', 59 );
        testRT( 'y', 60 );
        testRT( 'z', 61 );
        testRT( '-', 62 );
        testRT( '.', 63 );
    }
}

Commits for litesoft/trunk/Java/core/Anywhere/tests/org/litesoft/codec/SixBitCodecTest.java

Diff revisions: vs.
Revision Author Commited Message
947 Diff Diff GeorgeS picture GeorgeS Fri 06 Jun, 2014 23:36:56 +0000

Correct Spelling of package!

766 Diff Diff GeorgeS picture GeorgeS Sat 14 Jul, 2012 16:38:04 +0000

!

490 Diff Diff GeorgeS picture GeorgeS Fri 09 Sep, 2011 18:11:40 +0000

Encoding

49 Diff Diff GeorgeS picture GeorgeS Mon 12 Apr, 2010 02:59:10 +0000

License Text

2 GeorgeS picture GeorgeS Sun 07 Feb, 2010 12:50:58 +0000