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;
13 import static org.junit.Assert.*;
18 public class JsNullTest {
24 public static void setUpClass() throws Exception{
28 public static void tearDownClass() throws Exception{
36 public void tearDown() {
40 * Test of etc of class JsNull.
43 public void testEtc(){
44 System.out.println("etc");
45 assertNotNull(JsNull.NULL);
46 assertTrue(JsNull.NULL instanceof JsNull);
51 * Test of traverse method, of class JsNull.
54 public void testTraverse(){
55 System.out.println("traverse");
57 JsNull.NULL.traverse(new ValueVisitor(){
60 public void visitValue(JsValue value)
61 throws JsVisitException{
62 assertEquals(JsNull.NULL, value);
63 assertTrue(this.ct++ <= 0);
66 public void visitPairName(String name)
67 throws JsVisitException{
68 throw new JsVisitException();
71 public void visitCompositionClose(JsComposition composite)
72 throws JsVisitException{
73 throw new JsVisitException();
76 }catch(JsVisitException e){
83 * Test of compareTo method, of class JsNull.
86 public void testCompareTo(){
87 System.out.println("compareTo");
88 assertEquals(0, JsNull.NULL.compareTo(JsNull.NULL));
90 JsNull.NULL.compareTo(null);
92 }catch(NullPointerException e){
99 * Test of toString method, of class JsNull.
102 public void testToString(){
103 System.out.println("toString");
104 assertEquals("null", JsNull.NULL.toString());
109 * Test of getJsTypes method, of class JsNull.
112 public void testGetJsTypes() {
113 System.out.println("getJsTypes");
115 JsNull instance = JsNull.NULL;
117 assertEquals(JsTypes.NULL, instance.getJsTypes());
123 * Test of equals method, of class JsNull.
126 public void testEquals(){
127 System.out.println("equals");
129 assertTrue(JsNull.NULL.equals(JsNull.NULL));
131 JsNull nullVal = null;
132 assertFalse(JsNull.NULL.equals(nullVal));
134 assertFalse(JsNull.NULL.equals(""));
140 * Test of hashCode method, of class JsNull.
143 public void testHashCode(){
144 System.out.println("hashCode");
146 assertEquals(JsNull.NULL.hashCode(), JsNull.NULL.hashCode());
152 * Test of parseNull method, of class JsNull.
155 public void testParseNull() throws Exception{
156 System.out.println("parseNull");
161 source = new JsonSource("null");
162 result = JsNull.parseNull(source);
163 assertEquals(JsNull.NULL, result);
165 source = new JsonSource("X");
166 result = JsNull.parseNull(source);
170 source = new JsonSource("nX");
171 result = JsNull.parseNull(source);
173 }catch(JsParseException e){
178 source = new JsonSource("nuX");
179 result = JsNull.parseNull(source);
181 }catch(JsParseException e){
186 source = new JsonSource("nulX");
187 result = JsNull.parseNull(source);
189 }catch(JsParseException e){