Skip to content

Commit 6d87d57

Browse files
committed
fixed typos
1 parent 39d8530 commit 6d87d57

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

jbbp/src/test/java/com/igormaznitsa/jbbp/compiler/conversion/JBBPToJavaConverterReadWriteTest.java

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
import static com.igormaznitsa.jbbp.TestUtils.getField;
2121
import static com.igormaznitsa.jbbp.TestUtils.getFieldThroughGetters;
2222
import static com.igormaznitsa.jbbp.TestUtils.wavInt2Str;
23+
import static java.util.Objects.requireNonNull;
2324
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
2425
import static org.junit.jupiter.api.Assertions.assertEquals;
2526
import static org.junit.jupiter.api.Assertions.assertFalse;
27+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
2628
import static org.junit.jupiter.api.Assertions.assertNull;
2729
import static org.junit.jupiter.api.Assertions.assertThrows;
28-
import static org.junit.jupiter.api.Assertions.assertTrue;
2930
import static org.junit.jupiter.api.Assertions.fail;
3031

3132
import com.igormaznitsa.jbbp.JBBPCustomFieldTypeProcessor;
@@ -45,7 +46,6 @@
4546
import com.igormaznitsa.jbbp.utils.ReflectUtils;
4647
import java.io.ByteArrayInputStream;
4748
import java.io.ByteArrayOutputStream;
48-
import java.io.IOException;
4949
import java.io.InputStream;
5050
import java.util.HashMap;
5151
import java.util.Map;
@@ -58,8 +58,8 @@
5858
public class JBBPToJavaConverterReadWriteTest extends AbstractJBBPToJavaConverterTest {
5959

6060
private byte[] loadResource(final String name) throws Exception {
61-
try (final InputStream result = this.getClass().getClassLoader()
62-
.getResourceAsStream("com/igormaznitsa/jbbp/it/" + name)) {
61+
try (final InputStream result = requireNonNull(this.getClass().getClassLoader()
62+
.getResourceAsStream("com/igormaznitsa/jbbp/it/" + name))) {
6363
return IOUtils.toByteArray(result);
6464
}
6565
}
@@ -111,7 +111,7 @@ public void testReadWrite_ExtendsSuperClassAndUseItsFields() throws Exception {
111111
final ClassLoader classLoader = saveAndCompile(new JavaClassContent(fullClassName, text));
112112

113113
final Object instance = ReflectUtils.newInstance(classLoader.loadClass(fullClassName));
114-
assertTrue(instance instanceof TestSuperclass);
114+
assertInstanceOf(TestSuperclass.class, instance);
115115

116116
final byte[] etalon = new byte[] {
117117
0,
@@ -206,7 +206,7 @@ public void testReadWrite_BooleanArrayWholeStream() throws Exception {
206206
}
207207

208208
@Test
209-
public void testReadWite_ByteArrayWholeStream() throws Exception {
209+
public void testReadWrite_ByteArrayWholeStream() throws Exception {
210210
final Object instance = compileAndMakeInstance("byte [_] byteArray;");
211211
assertNull(getField(instance, "bytearray", byte[].class), "by default must be null");
212212

@@ -219,7 +219,7 @@ public void testReadWite_ByteArrayWholeStream() throws Exception {
219219
}
220220

221221
@Test
222-
public void testReadWite_Float_SingleValue() throws Exception {
222+
public void testReadWrite_Float_SingleValue() throws Exception {
223223
final Object instance = compileAndMakeInstance("floatj value;");
224224
final byte[] etalon = new byte[] {1, 2, 3, 4};
225225

@@ -231,7 +231,7 @@ public void testReadWite_Float_SingleValue() throws Exception {
231231
}
232232

233233
@Test
234-
public void testReadWite_FloatArrayWholeStream() throws Exception {
234+
public void testReadWrite_FloatArrayWholeStream() throws Exception {
235235
final Object instance = compileAndMakeInstance("floatj [_] floatArray;");
236236
assertNull(getField(instance, "floatarray", float[].class), "by default must be null");
237237

@@ -245,7 +245,7 @@ public void testReadWite_FloatArrayWholeStream() throws Exception {
245245
}
246246

247247
@Test
248-
public void testReadWite_String_SingleValue() throws Exception {
248+
public void testReadWrite_String_SingleValue() throws Exception {
249249
final Object instance = compileAndMakeInstance("stringj value;");
250250
final byte[] etalon = new byte[] {3, 65, 66, 67};
251251

@@ -256,7 +256,7 @@ public void testReadWite_String_SingleValue() throws Exception {
256256
}
257257

258258
@Test
259-
public void testReadWite_Val_CalculatedLength() throws Exception {
259+
public void testReadWrite_Val_CalculatedLength() throws Exception {
260260
final Object instance =
261261
compileAndMakeInstance("ubyte a; ubyte b; val:(a-b) c; val:(c+8) d; byte [d] data;");
262262
final byte[] etalon = new byte[] {2, 8, 33, 44};
@@ -268,7 +268,7 @@ public void testReadWite_Val_CalculatedLength() throws Exception {
268268
}
269269

270270
@Test
271-
public void testReadWite_Bit_SingleValueWhichLengthCalclatedThrouhExpression() throws Exception {
271+
public void testReadWrite_Bit_SingleValueWhichLengthCalclatedThrouhExpression() throws Exception {
272272
final Object instance = compileAndMakeInstance("ubyte a; ubyte b; bit:(a+b) c;");
273273
final byte[] etalon = new byte[] {1, 2, (byte) 0xB4};
274274

@@ -279,7 +279,7 @@ public void testReadWite_Bit_SingleValueWhichLengthCalclatedThrouhExpression() t
279279
}
280280

281281
@Test
282-
public void testReadWite_StringArrayWholeStream() throws Exception {
282+
public void testReadWrite_StringArrayWholeStream() throws Exception {
283283
final Object instance = compileAndMakeInstance("stringj [_] strArray;");
284284
assertNull(getField(instance, "strarray", String[].class), "by default must be null");
285285

@@ -293,7 +293,7 @@ public void testReadWite_StringArrayWholeStream() throws Exception {
293293
}
294294

295295
@Test
296-
public void testReadWite_Double_SingleValue() throws Exception {
296+
public void testReadWrite_Double_SingleValue() throws Exception {
297297
final Object instance = compileAndMakeInstance("doublej value;");
298298
final byte[] etalon = new byte[] {1, 2, 3, 4, 5, 6, 7, 8};
299299

@@ -305,7 +305,7 @@ public void testReadWite_Double_SingleValue() throws Exception {
305305
}
306306

307307
@Test
308-
public void testReadWite_UInt_SingleValue() throws Exception {
308+
public void testReadWrite_UInt_SingleValue() throws Exception {
309309
final Object instance = compileAndMakeInstance("uint value;");
310310
final byte[] etalon = new byte[] {(byte) 0xFF, 2, 3, 4};
311311

@@ -316,7 +316,7 @@ public void testReadWite_UInt_SingleValue() throws Exception {
316316
}
317317

318318
@Test
319-
public void testReadWite_DoubleArrayWholeStream() throws Exception {
319+
public void testReadWrite_DoubleArrayWholeStream() throws Exception {
320320
final Object instance = compileAndMakeInstance("doublej [_] doubleArray;");
321321
assertNull(getField(instance, "doublearray", double[].class), "by default must be null");
322322

@@ -333,7 +333,7 @@ public void testReadWite_DoubleArrayWholeStream() throws Exception {
333333
}
334334

335335
@Test
336-
public void testReadWite_UIntArrayWholeStream() throws Exception {
336+
public void testReadWrite_UIntArrayWholeStream() throws Exception {
337337
final Object instance = compileAndMakeInstance("uint [_] uintArray;");
338338
assertNull(getField(instance, "uintarray", long[].class), "by default must be null");
339339

@@ -349,7 +349,7 @@ public void testReadWite_UIntArrayWholeStream() throws Exception {
349349
}
350350

351351
@Test
352-
public void testReadWite_BitArrayWholeStream() throws Exception {
352+
public void testReadWrite_BitArrayWholeStream() throws Exception {
353353
final Object instance = compileAndMakeInstance("bit [_] bitArray;");
354354
assertNull(getField(instance, "bitarray", byte[].class), "by default must be null");
355355

@@ -363,7 +363,7 @@ public void testReadWite_BitArrayWholeStream() throws Exception {
363363
}
364364

365365
@Test
366-
public void testReadWite_FloatFieldAsCounter() throws Exception {
366+
public void testReadWrite_FloatFieldAsCounter() throws Exception {
367367
final Object instance = compileAndMakeInstance("floatj len; byte [len] data;");
368368
assertNull(getField(instance, "data", byte[].class), "by default must be null");
369369

@@ -377,7 +377,7 @@ public void testReadWite_FloatFieldAsCounter() throws Exception {
377377
}
378378

379379
@Test
380-
public void testReadWite_FloatFieldAsCounter_Expression() throws Exception {
380+
public void testReadWrite_FloatFieldAsCounter_Expression() throws Exception {
381381
final Object instance = compileAndMakeInstance("floatj len; byte [len/2] data;");
382382
assertNull(getField(instance, "data", byte[].class), "by default must be null");
383383

@@ -391,7 +391,7 @@ public void testReadWite_FloatFieldAsCounter_Expression() throws Exception {
391391
}
392392

393393
@Test
394-
public void testReadWite_DoubleFloatFieldAsCounter() throws Exception {
394+
public void testReadWrite_DoubleFloatFieldAsCounter() throws Exception {
395395
final Object instance = compileAndMakeInstance("doublej len; byte [len] data;");
396396
assertNull(getField(instance, "data", byte[].class), "by default must be null");
397397

@@ -406,7 +406,7 @@ public void testReadWite_DoubleFloatFieldAsCounter() throws Exception {
406406
}
407407

408408
@Test
409-
public void testReadWite_DoubleFloatFieldAsCounter_Expression() throws Exception {
409+
public void testReadWrite_DoubleFloatFieldAsCounter_Expression() throws Exception {
410410
final Object instance = compileAndMakeInstance("doublej len; byte [len/2] data;");
411411
assertNull(getField(instance, "data", byte[].class), "by default must be null");
412412

@@ -447,7 +447,7 @@ public void testReadWriteWithOptionallyIgnoredStructureArray() throws Exception
447447
}
448448

449449
@Test
450-
public void testReadWite_PNG() throws Exception {
450+
public void testReadWrite_PNG() throws Exception {
451451
final Object instance = compileAndMakeInstance("long header;"
452452
+ "// chunks\n"
453453
+ "chunk [_]{"
@@ -478,7 +478,7 @@ public void testReadWite_PNG() throws Exception {
478478
}
479479

480480
@Test
481-
public void testReadWite_WAV() throws Exception {
481+
public void testReadWrite_WAV() throws Exception {
482482
final Object instance = compileAndMakeInstance("<int ChunkID;"
483483
+ "<int ChunkSize;"
484484
+ "<int Format;"
@@ -723,8 +723,7 @@ public JBBPAbstractField readCustomFieldType(JBBPBitInputStream in, JBBPBitOrder
723723
JBBPFieldTypeParameterContainer customTypeFieldInfo,
724724
JBBPNamedFieldInfo fieldName, int extraData,
725725
boolean readWholeStream, int arrayLength,
726-
JBBPArraySizeLimiter arraySizeLimiter)
727-
throws IOException {
726+
JBBPArraySizeLimiter arraySizeLimiter) {
728727
fail("Must not be called");
729728
return null;
730729
}
@@ -736,7 +735,6 @@ public JBBPAbstractField readCustomFieldType(JBBPBitInputStream in, JBBPBitOrder
736735
+ "import com.igormaznitsa.jbbp.compiler.tokenizer.*;\n"
737736
+ "import java.io.IOException;\n"
738737
+ "import java.util.*;\n"
739-
+ ""
740738
+ "public class CustomFieldParser extends " + PACKAGE_NAME + '.' + CLASS_NAME + "{"
741739
+
742740
" private int readThree(JBBPBitInputStream in, JBBPByteOrder byteOrder) throws IOException {"
@@ -837,7 +835,6 @@ public void testReadWrite_VarFields() throws Exception {
837835
+ "import com.igormaznitsa.jbbp.compiler.tokenizer.*;\n"
838836
+ "import java.io.IOException;\n"
839837
+ "import java.util.*;\n"
840-
+ ""
841838
+ "public class VarFieldParser extends " + PACKAGE_NAME + '.' + CLASS_NAME + "{"
842839
+
843840
" private int readThree(JBBPBitInputStream in, JBBPByteOrder byteOrder) throws IOException {"

0 commit comments

Comments
 (0)