javaclass

Annotated tests/StringTest.java

146:1dc70ce13680
2005-01-23 Paul Boddie Added more tests.
paul@75 1
public class StringTest {
paul@75 2
    private String s;
paul@75 3
    private String s2 = new String("abc");
paul@75 4
    private static String s3;
paul@146 5
    public static String s4 = new String("xyz");
paul@75 6
paul@75 7
    public StringTest() {
paul@75 8
        s = s2;
paul@75 9
    }
paul@75 10
paul@75 11
    public StringTest(String newString) {
paul@75 12
        s = newString;
paul@75 13
    }
paul@125 14
paul@125 15
    public StringTest(String firstString, String secondString) {
paul@125 16
        s = firstString + secondString;
paul@125 17
    }
paul@146 18
paul@146 19
    public static void main(String[] args) {
paul@146 20
        if (StringTest.s4.equals("xyz")) {
paul@146 21
            System.out.println("StringTest.s4 correct: " + StringTest.s4);
paul@146 22
        } else {
paul@146 23
            System.err.println("StringTest.s4 failed!");
paul@146 24
        }
paul@146 25
        StringTest test0 = new StringTest();
paul@146 26
        if (test0.s.equals("abc")) {
paul@146 27
            System.out.println("test0.s correct: " + test0.s);
paul@146 28
        } else {
paul@146 29
            System.err.println("test0.s failed!");
paul@146 30
        }
paul@146 31
        StringTest test1 = new StringTest("Test");
paul@146 32
        if (test1.s.equals("Test")) {
paul@146 33
            System.out.println("test1.s correct: " + test1.s);
paul@146 34
        } else {
paul@146 35
            System.err.println("test1.s failed!");
paul@146 36
        }
paul@146 37
        StringTest test2 = new StringTest("Hello ", "world");
paul@146 38
        if (test2.s.equals("Hello world")) {
paul@146 39
            System.out.println("test2.s correct: " + test2.s);
paul@146 40
        } else {
paul@146 41
            System.err.println("test2.s failed!");
paul@146 42
        }
paul@146 43
    }
paul@75 44
}
paul@146 45
paul@146 46
// vim: tabstop=4 expandtab shiftwidth=4