01: package fit;
02:
03: // Copyright (c) 2002 Cunningham & Cunningham, Inc.
04: // Released under the terms of the GNU General Public License version 2 or later.
05:
06: public class PrimitiveFixture extends Fixture {
07:
08: // format converters ////////////////////////
09:
10: public static long parseLong(Parse cell) {
11: return Long.parseLong(cell.text());
12: }
13:
14: public static double parseDouble(Parse cell) {
15: return Double.parseDouble(cell.text());
16: }
17:
18: public static boolean parseBoolean(Parse cell) {
19: return Boolean.valueOf(cell.text()).booleanValue();
20: }
21:
22: // answer comparisons ///////////////////////
23:
24: public void check(Parse cell, String value) {
25: if (cell.text().equals(value)) {
26: right(cell);
27: } else {
28: wrong(cell, value);
29: }
30: }
31:
32: public void check(Parse cell, long value) {
33: if (parseLong(cell) == value) {
34: right(cell);
35: } else {
36: wrong(cell, Long.toString(value));
37: }
38: }
39:
40: public void check(Parse cell, double value) {
41: if (parseDouble(cell) == value) {
42: right(cell);
43: } else {
44: wrong(cell, Double.toString(value));
45: }
46: }
47:
48: public void check(Parse cell, boolean value) {
49: if (parseBoolean(cell) == value) {
50: right(cell);
51: } else {
52: wrong(cell, "" + value);
53: }
54: }
55:
56: }
|