javaclass

Changeset

133:3e197ad55b82
2005-01-18 Paul Boddie raw files shortlog changelog graph Added more test programs.
tests/ArrayTest.java (file) tests/ComparisonTest.java (file)
     1.1 --- a/tests/ArrayTest.java	Tue Jan 18 17:17:29 2005 +0100
     1.2 +++ b/tests/ArrayTest.java	Tue Jan 18 17:47:24 2005 +0100
     1.3 @@ -8,4 +8,25 @@
     1.4      public int get(int index) {
     1.5          return array[index];
     1.6      }
     1.7 +
     1.8 +    public static void main(String[] args) {
     1.9 +        ArrayTest test = new ArrayTest(10);
    1.10 +        if (test.array.length != 10) {
    1.11 +            System.err.println("test.array.length failed!");
    1.12 +        } else {
    1.13 +            System.out.println("test.array.length correct: " + test.array.length);
    1.14 +        }
    1.15 +        for (int i = 0; i < test.array.length; i++) {
    1.16 +            test.array[i] = i + 10;
    1.17 +        }
    1.18 +        for (int j = 0; j < test.array.length; j++) {
    1.19 +            if (test.get(j) != j + 10) {
    1.20 +                System.err.println("test.get(" + j + ") failed!");
    1.21 +            } else {
    1.22 +                System.out.println("test.get(" + j + ") correct: " + test.get(j));
    1.23 +            }
    1.24 +        }
    1.25 +    }
    1.26  }
    1.27 +
    1.28 +// vim: tabstop=4 expandtab shiftwidth=4
     2.1 --- a/tests/ComparisonTest.java	Tue Jan 18 17:17:29 2005 +0100
     2.2 +++ b/tests/ComparisonTest.java	Tue Jan 18 17:47:24 2005 +0100
     2.3 @@ -23,4 +23,40 @@
     2.4              return false;
     2.5          }
     2.6      }
     2.7 +
     2.8 +    public static void main(String[] args) {
     2.9 +        ComparisonTest test = new ComparisonTest();
    2.10 +        if (test.equals(1, -1)) {
    2.11 +            System.err.println("test.equals(1, -1) failed!");
    2.12 +        } else {
    2.13 +            System.out.println("test.equals(1, -1) correct: " + test.equals(1, -1));
    2.14 +        }
    2.15 +        if (!test.equals(10, 10)) {
    2.16 +            System.err.println("test.equals(10, 10) failed!");
    2.17 +        } else {
    2.18 +            System.out.println("test.equals(10, 10) correct: " + test.equals(10, 10));
    2.19 +        }
    2.20 +        if (test.lessThan(1, -1)) {
    2.21 +            System.err.println("test.lessThan(1, -1) failed!");
    2.22 +        } else {
    2.23 +            System.out.println("test.lessThan(1, -1) correct: " + test.lessThan(1, -1));
    2.24 +        }
    2.25 +        if (!test.lessThan(1, 15)) {
    2.26 +            System.err.println("test.lessThan(1, 15) failed!");
    2.27 +        } else {
    2.28 +            System.out.println("test.lessThan(1, 15) correct: " + test.lessThan(1, 15));
    2.29 +        }
    2.30 +        if (test.greaterThan(23, 29)) {
    2.31 +            System.err.println("test.greaterThan(23, 29) failed!");
    2.32 +        } else {
    2.33 +            System.out.println("test.greaterThan(23, 29) correct: " + test.greaterThan(23, 29));
    2.34 +        }
    2.35 +        if (!test.greaterThan(-23, -29)) {
    2.36 +            System.err.println("test.greaterThan(-23, -29) failed!");
    2.37 +        } else {
    2.38 +            System.out.println("test.greaterThan(-23, -29) correct: " + test.greaterThan(-23, -29));
    2.39 +        }
    2.40 +    }
    2.41  }
    2.42 +
    2.43 +// vim: tabstop=4 expandtab shiftwidth=4