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
// This Source Code is in the Public Domain per: http://unlicense.org
package org.litesoft.core.util;

import junit.framework.*;

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

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

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

    public void test_newFirstBefore()
            throws Exception
    {
        String[] testStrings = { //
                                 "a", "am", // Weird case should NOT happen if all generated
                                 "aaaaaa", "aaaaaam", // Weird case should NOT happen if all generated
                                 "b", "am", //
                                 "z", "m", //
                                 "test", "j", //
                                 "aaab", "aaaam", //
        };

        for ( int i = 0; i < testStrings.length; )
        {
            String s = testStrings[i++];
            String expected = testStrings[i++];
            String result = SortableBuilder.newFirstBefore( s );

            assertEquals( s, expected, result );
        }
    }

    public void test_newBetween()
            throws Exception
    {
        String[] testStrings = { //
                                 "a", "a", "a", // Special Case should NOT happen if all generated
                                 "test", "test", "test", // Special Case should NOT happen if all generated
                                 "a", "aa", "aam", // Weird case should NOT happen if all generated
                                 "b", "z", "n", //
                                 "z", "zz", "zm", //
                                 "test", "testm", "testg", //
                                 "testam", "testb", "testas", //
                                 "testam", "testbm", "testas", //
                                 "testaz", "testbm", "testazm", //
                                 "testabc", "testbbc", "testan", //
        };

        for ( int i = 0; i < testStrings.length; )
        {
            String s1 = testStrings[i++];
            String s2 = testStrings[i++];
            String expected = testStrings[i++];
            String result = SortableBuilder.newBetween( s1, s2 );

            assertEquals( s1 + " <-> " + s2, expected, result );
        }
    }

    public void test_newLastAfter()
            throws Exception
    {
        String[] testStrings = { //
                                 "a", "m", //
                                 "aa", "m", //
                                 "b", "n", //
                                 "z", "zm", //
                                 "test", "w", //
        };

        for ( int i = 0; i < testStrings.length; )
        {
            String s = testStrings[i++];
            String expected = testStrings[i++];
            String result = SortableBuilder.newLastAfter( s );

            assertEquals( s, expected, result );
        }
    }
}

Commits for litesoft/trunk/Java/core/Server/tests/org/litesoft/core/util/SortableBuilderTest.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!

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