}
private void testConstructor4(TestHarness harness)
{
harness.checkPoint("Number, Comparable, Comparable, Number");
SpinnerNumberModel m = new SpinnerNumberModel(new Long(20), new Long(10),
new Long(30), new Long(5));
harness.check(m.getValue(), new Long(20));
harness.check(m.getMinimum(), new Long(10));
harness.check(m.getMaximum(), new Long(30));
harness.check(m.getStepSize(), new Long(5));
// value equal to minimum
m = new SpinnerNumberModel(new Double(1.0), new Double(1.0),
new Double(3.0), new Double(0.5));
harness.check(m.getValue(), new Double(1.0));
harness.check(m.getMinimum(), new Double(1.0));
harness.check(m.getMaximum(), new Double(3.0));
harness.check(m.getStepSize(), new Double(0.5));
// value below minimum
boolean pass = false;
try
{
m = new SpinnerNumberModel(new Double(0.9), new Double(1.0),
new Double(3.0), new Double(0.5));
}
catch (IllegalArgumentException e)
{
pass = true;
}
harness.check(pass);
// value equal to maximum
m = new SpinnerNumberModel(new Double(3.0), new Double(1.0),
new Double(3.0), new Double(0.5));
harness.check(m.getValue(), new Double(3.0));
harness.check(m.getMinimum(), new Double(1.0));
harness.check(m.getMaximum(), new Double(3.0));
harness.check(m.getStepSize(), new Double(0.5));
// value above maximum
pass = false;
try
{
m = new SpinnerNumberModel(new Double(3.1), new Double(1.0),
new Double(3.0), new Double(0.5));
}
catch (IllegalArgumentException e)
{
pass = true;
}
harness.check(pass);
// step size 0
m = new SpinnerNumberModel(new Double(2.0), new Double(1.0),
new Double(3.0), new Double(0.0));
harness.check(m.getValue(), new Double(2.0));
harness.check(m.getMinimum(), new Double(1.0));
harness.check(m.getMaximum(), new Double(3.0));
harness.check(m.getStepSize(), new Double(0.0));
// step size negative
m = new SpinnerNumberModel(new Double(2.0), new Double(1.0),
new Double(3.0), new Double(-0.5));
harness.check(m.getValue(), new Double(2.0));
harness.check(m.getMinimum(), new Double(1.0));
harness.check(m.getMaximum(), new Double(3.0));
harness.check(m.getStepSize(), new Double(-0.5));
// check null value
pass = false;
try
{
/*SpinnerNumberModel m =*/ new SpinnerNumberModel(null, new Long(10),
new Long(30), new Long(5));
}
catch (IllegalArgumentException e)
{
pass = true;
}
harness.check(pass);
// check null minimum
// check null maximum
// check null step size
pass = false;
try
{
/*SpinnerNumberModel m =*/ new SpinnerNumberModel(new Long(20),
new Long(10), new Long(30), null);
}
catch (IllegalArgumentException e)
{
pass = true;