UTF-8 Version of Simple Example | |||||||||||||||||||||||||||||||||
This version of Simple Example is to test the unicode support. Here is Ben Last's simple unicode test --> Москва. If this looks vaguely russian, you've got it right. If it's a bunch of boxes, then there's something else going on. Say we wanted to test division to see if it is acceptable. (We normally test more complicated things, things that we can control, but this is a simple example.) We will make two things to complete our test. The first is a description of what we want including a tabular list of test cases that we believe will show that division is working acceptably.
Part 1 -- The Specification We want division that works with positive and negative numbers.
This last case is the famous pentium bug. See http://www.cs.earlham.edu/~dusko/cs63/fdiv.html.
The second thing we make is a "fixture" that can take the data provided in the table and compute the expected results. The fixture is a java program that can perform the operations that we want to test.
Part 2 -- The Fixture public class Division extends ColumnFixture { public float numerator; public float denominator; public float quotient() { return numerator / denominator; } } Our two parts, the specification and the fixture, are connected by the fact that the table names the fixture (Division) in its first cell. The Division fixture knows how to make sense of the table because it extends a class that already does. A column fixture looks for variables and methods it might have that match the column headings in the table. After we've prepared these two parts and put them into appropriate files, we run the test to produce results, a copy of our input with right and wrong answers noted. c: java FileRunner input.html results.html 6 right, 0 wrong, 0 ignored, 0 exceptions |