File tree 1 file changed +18
-3
lines changed
megamek/unittests/megamek/ai/neuralnetwork
1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -163,7 +163,7 @@ private static Collection<TestValue> loadTestValues() {
163
163
*/
164
164
private static MovementClassification getMovementClassificationFromSplitLine (String [] values ) {
165
165
// The last value in the line is the classification
166
- return MovementClassification .fromValue (Integer . parseInt (values [values .length -1 ]));
166
+ return MovementClassification .fromValue (parseInt (values [values .length -1 ]));
167
167
}
168
168
169
169
/**
@@ -175,9 +175,24 @@ private static float[] getInputsFromSplitLine(String[] values) {
175
175
// The last value in the line is the classification, so we don't want it in the input value
176
176
float [] entry = new float [values .length -1 ];
177
177
for (int i = 0 ; i < values .length -1 ; i ++) {
178
- entry [i ] = Float . parseFloat (values [i ]);
178
+ entry [i ] = parseFloat (values [i ]);
179
179
}
180
180
return entry ;
181
181
}
182
- // endregion TestSetup
182
+
183
+ private static float parseFloat (String value ) {
184
+ try {
185
+ return Float .parseFloat (value );
186
+ } catch (NumberFormatException e ) {
187
+ throw new IllegalArgumentException ("Invalid float value: " + value + " Possibly invalid test file" , e );
188
+ }
189
+ }
190
+
191
+ private static int parseInt (String value ) {
192
+ try {
193
+ return Integer .parseInt (value );
194
+ } catch (NumberFormatException e ) {
195
+ throw new IllegalArgumentException ("Invalid int value: " + value + " Possibly invalid test file" , e );
196
+ }
197
+ }
183
198
}
You can’t perform that action at this time.
0 commit comments