@@ -65,6 +65,13 @@ public void testBadPlusSign() throws IOException
6565 readWithParseException ("POINT ( +1e+01 1X02)" );
6666 }
6767
68+ public void testBadNumber () throws IOException
69+ {
70+ readWithParseException ("POINT (0x 0)" );
71+ readWithParseException ("POINT (0e 0)" );
72+ readWithParseException ("POINT (0.. 0)" );
73+ }
74+
6875 public void testBadCharsInType () throws IOException
6976 {
7077 readWithParseException ("POINTABC ( 0 0 )" );
@@ -74,7 +81,7 @@ public void testBadCharsInType() throws IOException
7481 readWithParseException ("MULTIPOINTABC (( 0 0 ), ( 0 0 ))" );
7582 readWithParseException ("MULTILINESTRINGABC (( 0 0, 1 1 ), ( 0 0, 1 1 ))" );
7683 readWithParseException ("MULTIPOLYGONABC ((( 0 0, 1 1, 2 2, 0 0 )), (( 0 0, 1 1, 2 2, 0 0 )))" );
77- readWithParseException ("GEOMETRYCOLLECTIONABC (POINT( 0 0 ), LINESTRING( 0 0, 1 1))" );
84+ readWithParseException ("GEOMETRYCOLLECTIONABC (POINT( 0 0 ), LINESTRING( 0 0, 1 1))" );
7885 }
7986
8087 public void testBadCharsInTypeZ () throws IOException
@@ -99,6 +106,63 @@ public void testBadCharsInTypeZM() throws IOException
99106 readWithParseException ("LINESTRINGABCZM ( 0 0 0 0, 1 1 1 1 )" );
100107 }
101108
109+ public void testBadType () throws IOException
110+ {
111+ readWithParseException ("POIN (0 0)" );
112+ readWithParseException ("POIN T(0 0)" );
113+ readWithParseException ("P OINT (0 0)" );
114+ readWithParseException ("POINtt (0 0)" );
115+ readWithParseException ("POINTzz (0 0)" );
116+ readWithParseException ("POINTabc (0 0)" );
117+ readWithParseException ("POINTxy (0 0)" );
118+ readWithParseException ("POINT XY (0 0)" );
119+ readWithParseException ("POINT XY EMPT" );
120+ readWithParseException ("POINT XY EMPT Y" );
121+ readWithParseException ("POINT XY EMPTYY" );
122+
123+ //-- not an error, since parser stops after correct parse
124+ //checkParseError("POINT EMPTY Z");
125+ }
126+
127+ public void testBadDimension () throws IOException
128+ {
129+ readWithParseException ("POINTZZ (0 0 0)" );
130+ readWithParseException ("POINT ZZ (0 0 0)" );
131+ readWithParseException ("POINT ZZM (0 0 0)" );
132+
133+ readWithParseException ("POINT Z M (0 0 0 0)" );
134+ readWithParseException ("POINTZ M (0 0 0 0)" );
135+ readWithParseException ("POINT MZ (0 0 0 0)" );
136+ readWithParseException ("POINTMZ (0 0 0 0)" );
137+ readWithParseException ("POINTZ ZM (0 0 0 0)" );
138+ readWithParseException ("POINT ZMc (0 0 0 0)" );
139+
140+ //-- not errors; perhaps should be?
141+ //checkParseErrorZ("POINTZ Z (0 0 0)");
142+ //checkParseErrorZM("POINTZM Z (0 0 0 0)");
143+ }
144+
145+ public void testMissingOrdinates () throws IOException
146+ {
147+ readWithParseException ("POINT (0)" );
148+ readWithParseException ("LINESTRING (0, 1 1)" );
149+ }
150+
151+ public void testMissingComponents () throws IOException
152+ {
153+ readWithParseException ("MULTILINESTRING (0 0)" );
154+ readWithParseException ("MULTILINESTRING ()" );
155+ readWithParseException ("GEOMETRYCOLLECTION ()" );
156+ readWithParseException ("GEOMETRYCOLLECTION" );
157+ }
158+
159+ public void testEmptyComponents () throws ParseException , IOException {
160+ readWithInvalidException ("POLYGON( EMPTY, (1 1,2 2,1 2,1 1))" );
161+
162+ //-- empty rings are valid
163+ //checkInvalidError("POLYGON( (1 1,2 2,1 2,1 1), EMPTY)");
164+ }
165+
102166 private void readWithParseException (String wkt )
103167 throws IOException
104168 {
@@ -112,5 +176,18 @@ private void readWithParseException(String wkt)
112176 }
113177 assertTrue (threwParseEx );
114178 }
179+
180+ private void readWithInvalidException (String wkt )
181+ throws IOException , ParseException
182+ {
183+ try {
184+ rdr .read (wkt );
185+ }
186+ catch (IllegalArgumentException ex ) {
187+ //System.out.println(ex.getMessage());
188+ return ;
189+ }
190+ fail ();
191+ }
115192}
116193
0 commit comments