From 45ff1bba527834fbbec6cb1475f7b293a2b433f2 Mon Sep 17 00:00:00 2001 From: kmannthe Date: Sun, 30 Jan 2022 20:15:42 -0800 Subject: [PATCH] Remove a few spots that can be NULL in the unit tets Signed-off-by: Keith Mannthey --- .../com/intel/gkl/IntelGKLUtilsUnitTest.java | 2 -- .../gkl/compression/DeflaterUnitTest.java | 2 ++ .../gkl/compression/InflaterUnitTest.java | 4 ++- .../smithwaterman/SmithWatermanUnitTest.java | 31 ++++++++++--------- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/test/java/com/intel/gkl/IntelGKLUtilsUnitTest.java b/src/test/java/com/intel/gkl/IntelGKLUtilsUnitTest.java index 80726c95..9132a351 100644 --- a/src/test/java/com/intel/gkl/IntelGKLUtilsUnitTest.java +++ b/src/test/java/com/intel/gkl/IntelGKLUtilsUnitTest.java @@ -75,8 +75,6 @@ public void childThreadTest() { @Test(enabled = true) public void testInvalidInputsForPathToTestResource() { - IntelGKLUtils utils = new IntelGKLUtils(); - try { IntelGKLUtils.pathToTestResource(null); Assert.fail("NullPointerException expected."); diff --git a/src/test/java/com/intel/gkl/compression/DeflaterUnitTest.java b/src/test/java/com/intel/gkl/compression/DeflaterUnitTest.java index 02a72124..48bfd78b 100644 --- a/src/test/java/com/intel/gkl/compression/DeflaterUnitTest.java +++ b/src/test/java/com/intel/gkl/compression/DeflaterUnitTest.java @@ -180,6 +180,8 @@ public void deflateEmptyInputBufferTest() { byte[] outputBufferBad = new byte[LEN]; deflater.setInput(inputBuffer, 0, inputBuffer.length); int bytes = deflater.deflate(outputBufferBad, 0, outputBufferBad.length); + if (bytes != 0) + Assert.fail(); } catch (Exception e) { log.error(e.getMessage()); throw e; diff --git a/src/test/java/com/intel/gkl/compression/InflaterUnitTest.java b/src/test/java/com/intel/gkl/compression/InflaterUnitTest.java index 6e3c7066..a888a168 100644 --- a/src/test/java/com/intel/gkl/compression/InflaterUnitTest.java +++ b/src/test/java/com/intel/gkl/compression/InflaterUnitTest.java @@ -150,7 +150,9 @@ public void inflateEmptyInputBufferSetOverflowTest() throws DataFormatException, inflater.setInput(input, 0, input.length); int resultLength = inflater.inflate(result, 0 , 1024); - inflater.end(); + if (resultLength != 0) + Assert.fail(); + inflater.end(); } catch(RuntimeException dfe) { log.error(dfe.getMessage()); diff --git a/src/test/java/com/intel/gkl/smithwaterman/SmithWatermanUnitTest.java b/src/test/java/com/intel/gkl/smithwaterman/SmithWatermanUnitTest.java index 0287f4a8..0c545d48 100644 --- a/src/test/java/com/intel/gkl/smithwaterman/SmithWatermanUnitTest.java +++ b/src/test/java/com/intel/gkl/smithwaterman/SmithWatermanUnitTest.java @@ -49,7 +49,8 @@ public void inputDataTest() { altString = in.readLine(); } catch (IOException e) {System.err.println("Caught IOException: " + e.getMessage());} try { - smithWaterman.align(null, altString.getBytes("UTF-8"), SWparameters, SWstrategy); + if (altString != null) + smithWaterman.align(null, altString.getBytes("UTF-8"), SWparameters, SWstrategy); Assert.fail("NullPointerException expected."); } catch(NullPointerException e) {} @@ -231,27 +232,27 @@ public void simpleTest() { refString = in.readLine(); } catch (IOException e) {System.err.println("Caught IOException: " + e.getMessage());} - while(refString !=null) { + while(refString !=null) { - ref = refString.getBytes("UTF-8"); - try { - altString = in.readLine(); - } catch (IOException e) {System.err.println("Caught IOException: " + e.getMessage());} - alt = altString.getBytes("UTF-8"); - - //Get the results for one pair - SWNativeAlignerResult result = smithWaterman.align(refString.getBytes("UTF-8"), altString.getBytes("UTF-8"), SWparameters, SWstrategy); - - try { - refString = in.readLine(); - } catch (IOException e) {System.err.println("Caught IOException: " + e.getMessage());} + ref = refString.getBytes("UTF-8"); + try { + altString = in.readLine(); + } catch (IOException e) {System.err.println("Caught IOException: " + e.getMessage());} + if (altString !=null) { + alt = altString.getBytes("UTF-8"); + //Get the results for one pair + SWNativeAlignerResult result = smithWaterman.align(refString.getBytes("UTF-8"), altString.getBytes("UTF-8"), SWparameters, SWstrategy); + } + try { + refString = in.readLine(); + } catch (IOException e) {System.err.println("Caught IOException: " + e.getMessage());} } in.close(); input.close(); } catch (java.io.IOException e) { - e.printStackTrace(); + e.printStackTrace(); } smithWaterman.close(); }