From 9c36c576742fbd42b9ba2250946aaa442c1908d0 Mon Sep 17 00:00:00 2001 From: "Andreas Fankhauser hiddenalpha.ch" <23085769+hiddenalpha@users.noreply.github.com> Date: Sat, 23 Nov 2024 18:56:24 +0100 Subject: [PATCH] Cleanup --- src/main/cpp/windows/jssc.cpp | 2 +- src/test/java/jssc/SerialNativeInterfaceTest.java | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/cpp/windows/jssc.cpp b/src/main/cpp/windows/jssc.cpp index 9c68d1a0d..71d53ec0e 100644 --- a/src/main/cpp/windows/jssc.cpp +++ b/src/main/cpp/windows/jssc.cpp @@ -290,7 +290,7 @@ JNIEXPORT jbyteArray JNICALL Java_jssc_SerialNativeInterface_readBytes } returnArray = env->NewByteArray(byteCount); - if( returnArray == NULL ){ goto Finally; } + if( returnArray == NULL ) goto Finally; lpBuffer = (jbyte *)malloc(byteCount * sizeof(jbyte)); if(lpBuffer == NULL){ diff --git a/src/test/java/jssc/SerialNativeInterfaceTest.java b/src/test/java/jssc/SerialNativeInterfaceTest.java index 492d4bc44..07dafde67 100644 --- a/src/test/java/jssc/SerialNativeInterfaceTest.java +++ b/src/test/java/jssc/SerialNativeInterfaceTest.java @@ -5,7 +5,6 @@ import org.junit.Before; import org.junit.Test; -import static java.lang.Integer.MAX_VALUE; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.nullValue; @@ -96,7 +95,7 @@ public void throwsNpeIfPassedBufferIsNull() throws Exception { } @Test - public void throwsIaeIfCountNegative() throws Exception { + public void throwsIaeIfCountNegative() { SerialNativeInterface testTarget = new SerialNativeInterface(); byte[] ret; try{ @@ -115,13 +114,13 @@ public void throwsIaeIfCountNegative() throws Exception { +" test run will just happily wait infinitely for those 2GiB to arrive" +" at the stdin fd. Feel free to remove this test if you think it" +" doesn't make sense to have it here.") - public void throwsOOMExIfRequestTooLarge() throws Exception { + public void throwsOOMExIfRequestTooLarge() { SerialNativeInterface testTarget = new SerialNativeInterface(); try{ - byte[] ret = testTarget.readBytes(0, MAX_VALUE); + byte[] ret = testTarget.readBytes(0, Integer.MAX_VALUE); fail("Where's the exception?"); }catch( OutOfMemoryError ex ){ - assertTrue(ex.getMessage().contains(String.valueOf(MAX_VALUE))); + assertTrue(ex.getMessage().contains(String.valueOf(Integer.MAX_VALUE))); } }