1   /*
2    * @(#) MonitorTest.java Sep 28, 2004 Copyright (c) 2002-2005 Delft University
3    * of Technology Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights
4    * reserved. This software is proprietary information of Delft University of
5    * Technology The code is published under the Lesser General Public License
6    */
7   package nl.tudelft.simulation.language.primitive;
8   
9   import junit.framework.Assert;
10  import junit.framework.TestCase;
11  import nl.tudelft.simulation.language.primitives.Primitive;
12  
13  /***
14   * The JUNIT Test for the <code>Primitive</code>.
15   * <p>
16   * (c) copyright 2002-2005 <a href="http://www.simulation.tudelft.nl">Delft
17   * University of Technology </a>, the Netherlands.
18   * <p>
19   * See for project information <a
20   * href="http://www.simulation.tudelft.nl/dsol/language">www.simulation.tudelft.nl/language
21   * </a> <br>
22   * License of use: <a href="http://www.gnu.org/copyleft/lesser.html">Lesser
23   * General Public License (LGPL) </a>, no warranty
24   * 
25   * @author <a href="http://www.peter-jacobs.com/index.htm">Peter Jacobs </a>
26   * @version 1.2 Sep 28, 2004
27   * @since 1.5
28   */
29  public class PrimitiveTest extends TestCase
30  {
31  
32      /***
33       * constructs a new PrimitiveTest
34       */
35      public PrimitiveTest()
36      {
37          this("test");
38      }
39  
40      /***
41       * constructs a new PrimitiveTest
42       * 
43       * @param arg0
44       */
45      public PrimitiveTest(String arg0)
46      {
47          super(arg0);
48      }
49  
50      /***
51       * tests the Primitive
52       */
53      public void test()
54      {
55          Assert.assertEquals(Primitive.getPrimitive(Boolean.class),
56                  boolean.class);
57          Assert.assertEquals(Primitive.getPrimitive(Integer.class), int.class);
58          Assert.assertEquals(Primitive.getPrimitive(Double.class), double.class);
59          Assert.assertEquals(Primitive.getPrimitive(Float.class), float.class);
60          Assert
61                  .assertEquals(Primitive.getPrimitive(Character.class),
62                          char.class);
63          Assert.assertEquals(Primitive.getPrimitive(Byte.class), byte.class);
64          Assert.assertEquals(Primitive.getPrimitive(Short.class), short.class);
65          Assert.assertEquals(Primitive.getPrimitive(Long.class), long.class);
66  
67          Assert.assertEquals(Primitive.getWrapper(boolean.class), Boolean.class);
68          Assert.assertEquals(Primitive.getWrapper(int.class), Integer.class);
69          Assert.assertEquals(Primitive.getWrapper(double.class), Double.class);
70          Assert.assertEquals(Primitive.getWrapper(float.class), Float.class);
71          Assert.assertEquals(Primitive.getWrapper(char.class), Character.class);
72          Assert.assertEquals(Primitive.getWrapper(byte.class), Byte.class);
73          Assert.assertEquals(Primitive.getWrapper(long.class), Long.class);
74  
75          Assert.assertEquals(Primitive.toBoolean(new Integer(1)), Boolean.TRUE);
76          Assert.assertEquals(Primitive.toBoolean(new Double(1.0)), Boolean.TRUE);
77          Assert.assertEquals(Primitive.toBoolean(new Float(1.0)), Boolean.TRUE);
78          Assert.assertEquals(Primitive.toBoolean(new Short((short) 1.0)),
79                  Boolean.TRUE);
80          Assert.assertEquals(Primitive.toBoolean(new Long(1l)), Boolean.TRUE);
81  
82          Assert.assertEquals(Primitive.toBoolean(new Integer(0)), Boolean.FALSE);
83          Assert
84                  .assertEquals(Primitive.toBoolean(new Double(0.0)),
85                          Boolean.FALSE);
86          Assert.assertEquals(Primitive.toBoolean(new Float(0.0)), Boolean.FALSE);
87          Assert.assertEquals(Primitive.toBoolean(new Short((short) 0.0)),
88                  Boolean.FALSE);
89          Assert.assertEquals(Primitive.toBoolean(new Long(0l)), Boolean.FALSE);
90      }
91  }