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