1.1 --- a/tests/Value.java Tue Jan 18 17:17:13 2005 +0100
1.2 +++ b/tests/Value.java Tue Jan 18 17:17:29 2005 +0100
1.3 @@ -34,6 +34,68 @@
1.4 public Value newValue() {
1.5 return new Value(this.getValue());
1.6 }
1.7 +
1.8 + public static void main(String[] args) {
1.9 + Value v = new Value(123);
1.10 + if (v.getValue() != 123) {
1.11 + System.err.println("v.getValue() failed!");
1.12 + } else {
1.13 + System.out.println("v.getValue() correct: " + v.getValue());
1.14 + }
1.15 + v.setValue(456);
1.16 + if (v.getValue() != 456) {
1.17 + System.err.println("v.setValue(456) or v.getValue() failed!");
1.18 + } else {
1.19 + System.out.println("v.getValue() correct: " + v.getValue());
1.20 + }
1.21 + if (!v.isPositive()) {
1.22 + System.err.println("v.isPositive() failed!");
1.23 + } else {
1.24 + System.out.println("v.isPositive() correct: " + v.isPositive());
1.25 + }
1.26 + v.setValue(-789);
1.27 + if (v.isPositive()) {
1.28 + System.err.println("v.isPositive() failed!");
1.29 + } else {
1.30 + System.out.println("v.isPositive() correct: " + v.isPositive());
1.31 + }
1.32 + if (v.compare(-790) != -1) {
1.33 + System.err.println("v.compare(-790) failed!");
1.34 + } else {
1.35 + System.out.println("v.compare(-790) correct: " + v.compare(-790));
1.36 + }
1.37 + if (v.compare(-788) != 1) {
1.38 + System.err.println("v.compare() failed!");
1.39 + } else {
1.40 + System.out.println("v.compare(-788) correct: " + v.compare(-788));
1.41 + }
1.42 + if (v.compare(-789) != 0) {
1.43 + System.err.println("v.compare() failed!");
1.44 + } else {
1.45 + System.out.println("v.compare(-789) correct: " + v.compare(-789));
1.46 + }
1.47 + Value v2 = v.newValue();
1.48 + if (v == v2) {
1.49 + System.err.println("v.newValue() failed!");
1.50 + }
1.51 + v2.setValue(123);
1.52 + if (v.getValue() == v2.getValue()) {
1.53 + System.err.println("v.newValue() failed (to establish separate members)!");
1.54 + } else {
1.55 + System.out.println("v.getValue() == v2.getValue() correct: " + (v.getValue() == v2.getValue()));
1.56 + }
1.57 + if (v2.add(-123) != 0) {
1.58 + System.err.println("v2.add(-123) failed!");
1.59 + } else {
1.60 + System.out.println("v2.add(-123) correct: " + v2.add(-123));
1.61 + }
1.62 + v2.setValue(255);
1.63 + if (v2.getValue() != 255) {
1.64 + System.err.println("v2.setValue(255) or v2.getValue() failed!");
1.65 + } else {
1.66 + System.out.println("v2.getValue() correct: " + v2.getValue());
1.67 + }
1.68 + }
1.69 }
1.70
1.71 // vim: tabstop=4 expandtab shiftwidth=4