@@ -19,11 +19,9 @@ public void testEquals(){
1919
2020 assertEquals (new ProtocolSectionPartial (atom ),new ProtocolSectionPartial (atom ));
2121
22- assertNotEquals (new ProtocolSectionPartial (atom ),null );
23- assertNotEquals (null ,new ProtocolSectionPartial (atom ));
24-
25- assertNotEquals (new ProtocolSectionPartial (atom ),atom );
26- assertNotEquals (atom ,new ProtocolSectionPartial (atom ));
22+ Object unknown = new ProtocolAtom ("ab" );
23+ assertNotEquals (new ProtocolSectionPartial (atom ),unknown );
24+ assertNotEquals (unknown ,new ProtocolSectionPartial (atom ));
2725 }
2826
2927 @ Test
@@ -64,4 +62,36 @@ public void testGetPartialLength(){
6462 }),123 ,456 ).getPartialLength ());
6563 }
6664
65+ @ Test
66+ public void testToProtocolString (){
67+ ProtocolAtom atom = new ProtocolAtom ("a" );
68+ ProtocolSubordinate subordinate = new ProtocolSubordinate (new ProtocolObject []{
69+ new ProtocolAtom ("ab" ),
70+ new ProtocolAtom ("abc" ),
71+ });
72+
73+ assertEquals ("a[ab abc]<123.456>" ,new ProtocolSectionPartial (atom ,subordinate ,123 ,456 ).toProtocolString ());
74+ assertEquals ("a[ab abc]<123>" ,new ProtocolSectionPartial (atom ,subordinate ,123 ).toProtocolString ());
75+ assertEquals ("a[ab abc]" ,new ProtocolSectionPartial (atom ,subordinate ).toProtocolString ());
76+ assertEquals ("a<123.456>" ,new ProtocolSectionPartial (atom ,123 ,456 ).toProtocolString ());
77+ assertEquals ("a<123>" ,new ProtocolSectionPartial (atom ,123 ).toProtocolString ());
78+ assertEquals ("a" ,new ProtocolSectionPartial (atom ).toProtocolString ());
79+ }
80+
81+ @ Test
82+ public void testToString (){
83+ ProtocolAtom atom = new ProtocolAtom ("a" );
84+ ProtocolSubordinate subordinate = new ProtocolSubordinate (new ProtocolObject []{
85+ new ProtocolAtom ("ab" ),
86+ new ProtocolAtom ("abc" ),
87+ });
88+
89+ assertEquals ("ProtocolSectionPartial{atom=ProtocolAtom{value='a'}, subordinate=ProtocolSubordinate{objects=[ProtocolAtom{value='ab'}, ProtocolAtom{value='abc'}]}, partialOffset=123, partialLength=456}" ,new ProtocolSectionPartial (atom ,subordinate ,123 ,456 ).toString ());
90+ assertEquals ("ProtocolSectionPartial{atom=ProtocolAtom{value='a'}, subordinate=ProtocolSubordinate{objects=[ProtocolAtom{value='ab'}, ProtocolAtom{value='abc'}]}, partialOffset=123, partialLength=null}" ,new ProtocolSectionPartial (atom ,subordinate ,123 ).toString ());
91+ assertEquals ("ProtocolSectionPartial{atom=ProtocolAtom{value='a'}, subordinate=ProtocolSubordinate{objects=[ProtocolAtom{value='ab'}, ProtocolAtom{value='abc'}]}, partialOffset=null, partialLength=null}" ,new ProtocolSectionPartial (atom ,subordinate ).toString ());
92+ assertEquals ("ProtocolSectionPartial{atom=ProtocolAtom{value='a'}, subordinate=null, partialOffset=123, partialLength=456}" ,new ProtocolSectionPartial (atom ,123 ,456 ).toString ());
93+ assertEquals ("ProtocolSectionPartial{atom=ProtocolAtom{value='a'}, subordinate=null, partialOffset=123, partialLength=null}" ,new ProtocolSectionPartial (atom ,123 ).toString ());
94+ assertEquals ("ProtocolSectionPartial{atom=ProtocolAtom{value='a'}, subordinate=null, partialOffset=null, partialLength=null}" ,new ProtocolSectionPartial (atom ).toString ());
95+ }
96+
6797}
0 commit comments