1   package org.rblasch.convert.type;
2   
3   import junit.framework.TestCase;
4   
5   import java.util.Arrays;
6   import java.util.Iterator;
7   import java.util.List;
8   
9   /***
10   * @author Ronald Blaschke
11   */
12  public class PrimitiveTypeTest extends TestCase {
13      public void testInitializer() {
14          new PrimitiveType(Integer.TYPE);
15      }
16  
17      public void testGetName() {
18          assertEquals("byte", new PrimitiveType(Byte.TYPE).getName());
19          assertEquals("short", new PrimitiveType(Short.TYPE).getName());
20          assertEquals("int", new PrimitiveType(Integer.TYPE).getName());
21          assertEquals("long", new PrimitiveType(Long.TYPE).getName());
22          assertEquals("float", new PrimitiveType(Float.TYPE).getName());
23          assertEquals("double", new PrimitiveType(Double.TYPE).getName());
24      }
25  
26      public void testValueOf() throws Exception {
27          final List/*<String>*/ primitives = Arrays.asList(new String[]{
28              "byte", "short", "int", "long", "float", "double"
29          });
30  
31          for (final Iterator i = primitives.iterator(); i.hasNext();) {
32              final String s = (String) i.next();
33              assertEquals(s, PrimitiveType.valueOf(s).getName());
34          }
35      }
36  }