2 * License : The MIT License
3 * Copyright(c) 2009 olyutorskii
6 package jp.sourceforge.jovsonz;
8 import org.junit.After;
9 import org.junit.AfterClass;
10 import org.junit.Before;
11 import org.junit.BeforeClass;
12 import org.junit.Test;
14 import static org.junit.Assert.*;
19 public class JsNullTest {
25 public static void setUpClass() throws Exception{
29 public static void tearDownClass() throws Exception{
37 public void tearDown() {
41 * Test of etc of class JsNull.
44 public void testEtc(){
45 System.out.println("etc");
46 assertNotNull(JsNull.NULL);
47 assertTrue(JsNull.NULL instanceof JsNull);
52 * Test of traverse method, of class JsNull.
55 public void testTraverse(){
56 System.out.println("traverse");
58 JsNull.NULL.traverse(new ValueVisitor(){
61 public void visitValue(JsValue value)
62 throws JsVisitException{
63 assertEquals(JsNull.NULL, value);
64 assertTrue(this.ct++ <= 0);
67 public void visitPairName(String name)
68 throws JsVisitException{
69 throw new JsVisitException();
72 public void visitCompositionClose(JsComposition<?> composite)
73 throws JsVisitException{
74 throw new JsVisitException();
77 }catch(JsVisitException e){
84 * Test of compareTo method, of class JsNull.
87 public void testCompareTo(){
88 System.out.println("compareTo");
89 assertEquals(0, JsNull.NULL.compareTo(JsNull.NULL));
91 JsNull.NULL.compareTo(null);
93 }catch(NullPointerException e){
100 * Test of toString method, of class JsNull.
103 public void testToString(){
104 System.out.println("toString");
105 assertEquals("null", JsNull.NULL.toString());
110 * Test of getJsTypes method, of class JsNull.
113 public void testGetJsTypes() {
114 System.out.println("getJsTypes");
116 JsNull instance = JsNull.NULL;
118 assertEquals(JsTypes.NULL, instance.getJsTypes());
124 * Test of equals method, of class JsNull.
127 public void testEquals(){
128 System.out.println("equals");
130 assertTrue(JsNull.NULL.equals(JsNull.NULL));
132 JsNull nullVal = null;
133 assertFalse(JsNull.NULL.equals(nullVal));
135 assertFalse(JsNull.NULL.equals(""));
141 * Test of hashCode method, of class JsNull.
144 public void testHashCode(){
145 System.out.println("hashCode");
147 assertEquals(JsNull.NULL.hashCode(), JsNull.NULL.hashCode());
153 * Test of parseNull method, of class JsNull.
156 public void testParseNull() throws Exception{
157 System.out.println("parseNull");
162 source = new JsonSource("null");
163 result = JsNull.parseNull(source);
164 assertEquals(JsNull.NULL, result);
166 source = new JsonSource("X");
167 result = JsNull.parseNull(source);
171 source = new JsonSource("nX");
172 result = JsNull.parseNull(source);
174 }catch(JsParseException e){
179 source = new JsonSource("nuX");
180 result = JsNull.parseNull(source);
182 }catch(JsParseException e){
187 source = new JsonSource("nulX");
188 result = JsNull.parseNull(source);
190 }catch(JsParseException e){