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