//
// PositiveFloatTest.java
//
/*
* ome.xml.utests
*
*-----------------------------------------------------------------------------
*
* Copyright (C) 2007-2008 Open Microscopy Environment
* Massachusetts Institute of Technology,
* National Institutes of Health,
* University of Dundee,
* University of Wisconsin-Madison
*
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*-----------------------------------------------------------------------------
*/
package ome.xml.utests;
import static org.testng.AssertJUnit.*;
import ome.xml.model.primitives.PositiveFloat;
import org.testng.annotations.Test;
/**
*
* <dl><dt><b>Source code:</b></dt>
* <dd><a href="http://trac.openmicroscopy.org.uk/ome/browser/bioformats.git/components/ome-xml/test/ome/xml/utests/PositiveFloatTest.java">Trac</a>,
* <a href="http://git.openmicroscopy.org/?p=bioformats.git;a=blob;f=components/ome-xml/test/ome/xml/utests/PositiveFloatTest.java;hb=HEAD">Gitweb</a></dd></dl>
*/
public class PositiveFloatTest {
@Test(expectedExceptions={IllegalArgumentException.class})
public void testMinusOne() {
new PositiveFloat(-1.0);
}
@Test(expectedExceptions={IllegalArgumentException.class})
public void testZero() {
new PositiveFloat(0.0);
}
@Test
public void testPositiveOne() {
new PositiveFloat(1.0);
}
@Test
public void testEquivalence() {
PositiveFloat a = new PositiveFloat(0.1);
PositiveFloat b = new PositiveFloat(0.1);
PositiveFloat c = new PositiveFloat(2.0);
Double d = new Double(0.1);
Double e = new Double(2.0);
Double f = new Double(3.0);
assertFalse(a == b);
assertFalse(a == c);
assertTrue(a.equals(b));
assertFalse(a.equals(c));
assertTrue(a.equals(d));
assertFalse(a.equals(e));
assertTrue(c.equals(e));
assertFalse(a.equals(f));
}
@Test
public void testToString() {
assertEquals("0.1", new PositiveFloat(0.1).toString());
}
}