javaclass

Changeset

143:0a9d421f9b34
2005-01-22 Paul Boddie raw files shortlog changelog graph Added more test programs.
tests/ConcreteClassTest.java (file) tests/FieldSubclassTest.java (file) tests/FieldTest.java (file) tests/MainTest.java (file) tests/MultiArrayTest.java (file)
     1.1 --- a/tests/ConcreteClassTest.java	Sat Jan 22 23:35:05 2005 +0100
     1.2 +++ b/tests/ConcreteClassTest.java	Sat Jan 22 23:35:05 2005 +0100
     1.3 @@ -1,2 +1,12 @@
     1.4  public class ConcreteClassTest extends AbstractClassTest {
     1.5 +    public static void main(String[] args) {
     1.6 +        ConcreteClassTest test = new ConcreteClassTest();
     1.7 +        if (test.member != null && test.member instanceof ConcreteClassTest) {
     1.8 +            System.out.println("test.member correct: " + test.member);
     1.9 +        } else {
    1.10 +            System.err.println("test.member failed!");
    1.11 +        }
    1.12 +    }
    1.13  }
    1.14 +
    1.15 +// vim: tabstop=4 expandtab shiftwidth=4
     2.1 --- a/tests/FieldSubclassTest.java	Sat Jan 22 23:35:05 2005 +0100
     2.2 +++ b/tests/FieldSubclassTest.java	Sat Jan 22 23:35:05 2005 +0100
     2.3 @@ -1,2 +1,27 @@
     2.4  public class FieldSubclassTest extends FieldTest {
     2.5 +    public static void main(String[] args) {
     2.6 +        if (FieldSubclassTest.h != null && FieldSubclassTest.h.a == 789) {
     2.7 +            System.out.println("FieldSubclassTest.h.a correct: " + FieldSubclassTest.h.a);
     2.8 +        } else {
     2.9 +            System.out.println("FieldSubclassTest.h.a failed!");
    2.10 +        }
    2.11 +        FieldSubclassTest test = new FieldSubclassTest();
    2.12 +        if (test.h != null && test.h.a == 789) {
    2.13 +            System.out.println("test.h.a correct: " + test.h.a);
    2.14 +        } else {
    2.15 +            System.out.println("test.h.a failed!");
    2.16 +        }
    2.17 +        if (test.e != null && test.e.a == 456) {
    2.18 +            System.out.println("test.e.a correct: " + test.e.a);
    2.19 +        } else {
    2.20 +            System.out.println("test.e.a failed!");
    2.21 +        }
    2.22 +        if (test.f != null && test.f.a == 579) {
    2.23 +            System.out.println("test.f.a correct: " + test.f.a);
    2.24 +        } else {
    2.25 +            System.out.println("test.f.a failed!");
    2.26 +        }
    2.27 +    }
    2.28  }
    2.29 +
    2.30 +// vim: tabstop=4 expandtab shiftwidth=4
     3.1 --- a/tests/FieldTest.java	Sat Jan 22 23:35:05 2005 +0100
     3.2 +++ b/tests/FieldTest.java	Sat Jan 22 23:35:05 2005 +0100
     3.3 @@ -7,6 +7,30 @@
     3.4      public FieldTestClass f = new FieldTestClass(b + e.a);
     3.5      public static FieldTestClass g;
     3.6      public static FieldTestClass h = new FieldTestClass(789);
     3.7 +
     3.8 +    public static void main(String[] args) {
     3.9 +        if (FieldTest.h != null && FieldTest.h.a == 789) {
    3.10 +            System.out.println("FieldTest.h.a correct: " + FieldTest.h.a);
    3.11 +        } else {
    3.12 +            System.out.println("FieldTest.h.a failed!");
    3.13 +        }
    3.14 +        FieldTest test = new FieldTest();
    3.15 +        if (test.h != null && test.h.a == 789) {
    3.16 +            System.out.println("test.h.a correct: " + test.h.a);
    3.17 +        } else {
    3.18 +            System.out.println("test.h.a failed!");
    3.19 +        }
    3.20 +        if (test.e != null && test.e.a == 456) {
    3.21 +            System.out.println("test.e.a correct: " + test.e.a);
    3.22 +        } else {
    3.23 +            System.out.println("test.e.a failed!");
    3.24 +        }
    3.25 +        if (test.f != null && test.f.a == 579) {
    3.26 +            System.out.println("test.f.a correct: " + test.f.a);
    3.27 +        } else {
    3.28 +            System.out.println("test.f.a failed!");
    3.29 +        }
    3.30 +    }
    3.31  }
    3.32  
    3.33  class FieldTestClass {
    3.34 @@ -16,3 +40,5 @@
    3.35          this.a = a;
    3.36      }
    3.37  }
    3.38 +
    3.39 +// vim: tabstop=4 expandtab shiftwidth=4
     4.1 --- a/tests/MainTest.java	Sat Jan 22 23:35:05 2005 +0100
     4.2 +++ b/tests/MainTest.java	Sat Jan 22 23:35:05 2005 +0100
     4.3 @@ -5,3 +5,5 @@
     4.4          }
     4.5      }
     4.6  }
     4.7 +
     4.8 +// vim: tabstop=4 expandtab shiftwidth=4
     5.1 --- a/tests/MultiArrayTest.java	Sat Jan 22 23:35:05 2005 +0100
     5.2 +++ b/tests/MultiArrayTest.java	Sat Jan 22 23:35:05 2005 +0100
     5.3 @@ -8,4 +8,32 @@
     5.4      public int get(int index1, int index2) {
     5.5          return multiArray[index1][index2];
     5.6      }
     5.7 +
     5.8 +    public static void main(String[] args) {
     5.9 +        int[] sizes = {4, 7};
    5.10 +        MultiArrayTest test = new MultiArrayTest(sizes);
    5.11 +        if (test.multiArray.length != 4) {
    5.12 +            System.err.println("test.multiArray.length failed!");
    5.13 +        } else {
    5.14 +            System.out.println("test.multiArray.length correct: " + test.multiArray.length);
    5.15 +        }
    5.16 +        if (test.multiArray[0].length != 7) {
    5.17 +            System.err.println("test.multiArray[0].length failed!");
    5.18 +        } else {
    5.19 +            System.out.println("test.multiArray[0].length correct: " + test.multiArray[0].length);
    5.20 +        }
    5.21 +        if (test.multiArray[3][6] != 0) {
    5.22 +            System.err.println("test.multiArray[3][6] failed!");
    5.23 +        } else {
    5.24 +            System.out.println("test.multiArray[3][6] correct: " + test.multiArray[3][6]);
    5.25 +        }
    5.26 +        test.multiArray[3][6] = 36;
    5.27 +        if (test.get(3, 6) != 36) {
    5.28 +            System.err.println("test.get(3, 6) failed!");
    5.29 +        } else {
    5.30 +            System.out.println("test.get(3, 6) correct: " + test.get(3, 6));
    5.31 +        }
    5.32 +    }
    5.33  }
    5.34 +
    5.35 +// vim: tabstop=4 expandtab shiftwidth=4