From e6a786de1f49d9386d4c2c9f00b11a1fa0b08ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20Pl=C3=B6se?= Date: Sat, 15 Dec 2018 07:27:04 +0100 Subject: [PATCH 1/5] boolean bug fixed genherix, but not X86 and AARCH??? --- .../jnr/ffi/provider/jffi/NumberUtil.java | 30 ++++++++++--- src/test/java/jnr/ffi/NumberTest.java | 45 +++++++++++++++++++ 2 files changed, 69 insertions(+), 6 deletions(-) diff --git a/src/main/java/jnr/ffi/provider/jffi/NumberUtil.java b/src/main/java/jnr/ffi/provider/jffi/NumberUtil.java index 3ca02c51c..9f19ab118 100644 --- a/src/main/java/jnr/ffi/provider/jffi/NumberUtil.java +++ b/src/main/java/jnr/ffi/provider/jffi/NumberUtil.java @@ -20,6 +20,7 @@ import jnr.ffi.NativeType; import jnr.ffi.provider.SigType; +import org.objectweb.asm.Label; public final class NumberUtil { private NumberUtil() {} @@ -143,7 +144,29 @@ public static void widen(SkinnyMethodAdapter mv, Class from, Class to, NativeTyp public static void narrow(SkinnyMethodAdapter mv, Class from, Class to) { if (!from.equals(to)) { - if (byte.class == to || short.class == to || char.class == to || int.class == to || boolean.class == to) { + if (boolean.class == to) { + Label label_0 = new Label(); + Label label_1 = new Label(); + if (long.class == from) { + mv.lconst_0(); + mv.lcmp(); + mv.ifeq(label_0); + mv.iconst_1(); + mv.go_to(label_1); + mv.label(label_0); + mv.iconst_0(); + mv.label(label_1); + } else { +// mv.iconst_0(); + mv.ifeq(label_0); + mv.iconst_1(); + mv.go_to(label_1); + mv.label(label_0); + mv.iconst_0(); + mv.label(label_1); + } + + } else if (byte.class == to || short.class == to || char.class == to || int.class == to) { if (long.class == from) { mv.l2i(); } @@ -156,11 +179,6 @@ public static void narrow(SkinnyMethodAdapter mv, Class from, Class to) { } else if (char.class == to) { mv.i2c(); - - } else if (boolean.class == to) { - // Ensure only 0x0 and 0x1 values are used for boolean - mv.iconst_1(); - mv.iand(); } } } diff --git a/src/test/java/jnr/ffi/NumberTest.java b/src/test/java/jnr/ffi/NumberTest.java index 10f1c506f..8a65ba2db 100644 --- a/src/test/java/jnr/ffi/NumberTest.java +++ b/src/test/java/jnr/ffi/NumberTest.java @@ -70,6 +70,7 @@ public static interface TestLib { public static interface TestBoolean { public boolean ret_int32_t(int l); + public boolean ret_int64_t(long l); } static TestBoolean testboolean; @@ -356,5 +357,49 @@ public long n(long i1, long i2) { assertEquals(true, testboolean.ret_int32_t(-1)); assertEquals(true, testboolean.ret_int32_t(1)); assertEquals(true, testboolean.ret_int32_t(2)); + + assertEquals(true, testboolean.ret_int64_t(0x00000001)); + assertEquals(true, testboolean.ret_int64_t(0x00000010)); + assertEquals(true, testboolean.ret_int64_t(0x00000100)); + assertEquals(true, testboolean.ret_int64_t(0x00001000)); + assertEquals(true, testboolean.ret_int64_t(0x00010000)); + assertEquals(true, testboolean.ret_int64_t(0x00100000)); + assertEquals(true, testboolean.ret_int64_t(0x01000000)); + assertEquals(true, testboolean.ret_int32_t(0x10000000)); + + assertEquals(true, testboolean.ret_int32_t(0x20000000)); + + assertEquals(true, testboolean.ret_int32_t(0x04000000)); + assertEquals(true, testboolean.ret_int32_t(0x40000000)); + } + + @Test public void testBooleanFromLong() throws Exception { + assertEquals(false, testboolean.ret_int64_t(0)); + assertEquals(true, testboolean.ret_int64_t(-1)); + assertEquals(true, testboolean.ret_int64_t(1)); + assertEquals(true, testboolean.ret_int64_t(2)); + + assertEquals(true, testboolean.ret_int64_t(0x0000000000000001L)); + assertEquals(true, testboolean.ret_int64_t(0x0000000000000010L)); + assertEquals(true, testboolean.ret_int64_t(0x0000000000000100L)); + assertEquals(true, testboolean.ret_int64_t(0x0000000000001000L)); + assertEquals(true, testboolean.ret_int64_t(0x0000000000010000L)); + assertEquals(true, testboolean.ret_int64_t(0x0000000000100000L)); + assertEquals(true, testboolean.ret_int64_t(0x0000000001000000L)); + assertEquals(true, testboolean.ret_int64_t(0x0000000010000000L)); + assertEquals(true, testboolean.ret_int64_t(0x0000000100000000L)); + assertEquals(true, testboolean.ret_int64_t(0x0000001000000000L)); + assertEquals(true, testboolean.ret_int64_t(0x0000010000000000L)); + assertEquals(true, testboolean.ret_int64_t(0x0000100000000000L)); + assertEquals(true, testboolean.ret_int64_t(0x0001000000000000L)); + assertEquals(true, testboolean.ret_int64_t(0x0010000000000000L)); + assertEquals(true, testboolean.ret_int64_t(0x0100000000000000L)); + assertEquals(true, testboolean.ret_int64_t(0x1000000000000000L)); + + assertEquals(true, testboolean.ret_int64_t(0x2000000000000000L)); + + assertEquals(true, testboolean.ret_int64_t(0x0400000000000000L)); + assertEquals(true, testboolean.ret_int64_t(0x4000000000000000L)); } + } From 56f76be2e592901821e01f17d9395ff4f150d0da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20Pl=C3=B6se?= Date: Sat, 15 Dec 2018 12:44:10 +0100 Subject: [PATCH 2/5] enhanced boolean tests to byte and short maybe float and double ?? --- src/test/java/jnr/ffi/NumberTest.java | 82 +++++++++++++++------------ 1 file changed, 47 insertions(+), 35 deletions(-) diff --git a/src/test/java/jnr/ffi/NumberTest.java b/src/test/java/jnr/ffi/NumberTest.java index 8a65ba2db..a2c4d6ea1 100644 --- a/src/test/java/jnr/ffi/NumberTest.java +++ b/src/test/java/jnr/ffi/NumberTest.java @@ -69,8 +69,14 @@ public static interface TestLib { public static interface TestBoolean { + public boolean ret_int8_t(byte l); + public boolean ret_uint8_t(byte l); + public boolean ret_int16_t(short l); + public boolean ret_uint16_t(short l); public boolean ret_int32_t(int l); + public boolean ret_uint32_t(int l); public boolean ret_int64_t(long l); + public boolean ret_uint64_t(long l); } static TestBoolean testboolean; @@ -357,20 +363,41 @@ public long n(long i1, long i2) { assertEquals(true, testboolean.ret_int32_t(-1)); assertEquals(true, testboolean.ret_int32_t(1)); assertEquals(true, testboolean.ret_int32_t(2)); - - assertEquals(true, testboolean.ret_int64_t(0x00000001)); - assertEquals(true, testboolean.ret_int64_t(0x00000010)); - assertEquals(true, testboolean.ret_int64_t(0x00000100)); - assertEquals(true, testboolean.ret_int64_t(0x00001000)); - assertEquals(true, testboolean.ret_int64_t(0x00010000)); - assertEquals(true, testboolean.ret_int64_t(0x00100000)); - assertEquals(true, testboolean.ret_int64_t(0x01000000)); - assertEquals(true, testboolean.ret_int32_t(0x10000000)); - - assertEquals(true, testboolean.ret_int32_t(0x20000000)); - - assertEquals(true, testboolean.ret_int32_t(0x04000000)); - assertEquals(true, testboolean.ret_int32_t(0x40000000)); + + int value = 0x00000001; + for (int i = 0; i < 32; i++) { + assertTrue(String.format("Must evaluate to true: 0x%04x", value), testboolean.ret_int32_t(value)); + assertTrue(String.format("Must evaluate to true: 0x%04x", value), testboolean.ret_uint32_t(value)); + value <<= 1; + } + } + + @Test public void testBooleanFromByte() throws Exception { + assertEquals(false, testboolean.ret_int32_t(0)); + assertEquals(true, testboolean.ret_int32_t(-1)); + assertEquals(true, testboolean.ret_int32_t(1)); + assertEquals(true, testboolean.ret_int32_t(2)); + + byte value = 0x01; + for (int i = 0; i < 8; i++) { + assertTrue(String.format("Must evaluate to true: 0x%02x", value), testboolean.ret_int8_t((byte)value)); + assertTrue(String.format("Must evaluate to true: 0x%02x", value), testboolean.ret_uint8_t((byte)value)); + value <<= 1; + } + } + + @Test public void testBooleanFromShort() throws Exception { + assertEquals(false, testboolean.ret_int32_t(0)); + assertEquals(true, testboolean.ret_int32_t(-1)); + assertEquals(true, testboolean.ret_int32_t(1)); + assertEquals(true, testboolean.ret_int32_t(2)); + + short value = 0x0001; + for (int i = 0; i < 16; i++) { + assertTrue(String.format("Must evaluate to true: 0x%04x", value), testboolean.ret_int16_t(value)); + assertTrue(String.format("Must evaluate to true: 0x%04x", value), testboolean.ret_uint16_t(value)); + value <<= 1; + } } @Test public void testBooleanFromLong() throws Exception { @@ -379,27 +406,12 @@ public long n(long i1, long i2) { assertEquals(true, testboolean.ret_int64_t(1)); assertEquals(true, testboolean.ret_int64_t(2)); - assertEquals(true, testboolean.ret_int64_t(0x0000000000000001L)); - assertEquals(true, testboolean.ret_int64_t(0x0000000000000010L)); - assertEquals(true, testboolean.ret_int64_t(0x0000000000000100L)); - assertEquals(true, testboolean.ret_int64_t(0x0000000000001000L)); - assertEquals(true, testboolean.ret_int64_t(0x0000000000010000L)); - assertEquals(true, testboolean.ret_int64_t(0x0000000000100000L)); - assertEquals(true, testboolean.ret_int64_t(0x0000000001000000L)); - assertEquals(true, testboolean.ret_int64_t(0x0000000010000000L)); - assertEquals(true, testboolean.ret_int64_t(0x0000000100000000L)); - assertEquals(true, testboolean.ret_int64_t(0x0000001000000000L)); - assertEquals(true, testboolean.ret_int64_t(0x0000010000000000L)); - assertEquals(true, testboolean.ret_int64_t(0x0000100000000000L)); - assertEquals(true, testboolean.ret_int64_t(0x0001000000000000L)); - assertEquals(true, testboolean.ret_int64_t(0x0010000000000000L)); - assertEquals(true, testboolean.ret_int64_t(0x0100000000000000L)); - assertEquals(true, testboolean.ret_int64_t(0x1000000000000000L)); - - assertEquals(true, testboolean.ret_int64_t(0x2000000000000000L)); - - assertEquals(true, testboolean.ret_int64_t(0x0400000000000000L)); - assertEquals(true, testboolean.ret_int64_t(0x4000000000000000L)); + long value = 0x0000000000000001; + for (int i = 0; i < 32; i++) { + assertTrue(String.format("Must evaluate to true: 0x%016x", value), testboolean.ret_int64_t(value)); + assertTrue(String.format("Must evaluate to true: 0x%016x", value), testboolean.ret_uint64_t(value)); + value <<= 1; + } } } From 6781e6f4426e57806466fde01443dff79e21cb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20Pl=C3=B6se?= Date: Sat, 15 Dec 2018 14:12:33 +0100 Subject: [PATCH 3/5] fix native lib bug jffi ver 1.2.17 lib was 1.2.6 bumped both to 1.2.18 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 28a9d7010..209289028 100644 --- a/pom.xml +++ b/pom.xml @@ -61,13 +61,13 @@ com.github.jnr jffi - 1.2.17 + 1.2.18 compile com.github.jnr jffi - 1.2.16 + 1.2.18 runtime native @@ -169,7 +169,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.4.2 + 3.0.0-M2 From 946d940997846d0bc571d6c1ce90bc96eca05c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20Pl=C3=B6se?= Date: Sat, 15 Dec 2018 15:19:16 +0100 Subject: [PATCH 4/5] boolean fix for x86_64 --- src/main/java/jnr/ffi/Struct.java | 6 +-- src/main/java/jnr/ffi/StructLayout.java | 23 ++++++++- .../jnr/ffi/provider/jffi/NumberUtil.java | 47 +++++++++---------- .../ffi/provider/jffi/X86MethodGenerator.java | 4 +- 4 files changed, 49 insertions(+), 31 deletions(-) diff --git a/src/main/java/jnr/ffi/Struct.java b/src/main/java/jnr/ffi/Struct.java index 38f0d3354..04cfe9ae0 100755 --- a/src/main/java/jnr/ffi/Struct.java +++ b/src/main/java/jnr/ffi/Struct.java @@ -783,7 +783,7 @@ public Boolean() { } public final boolean get() { - return (getMemory().getByte(offset()) & 0x1) != 0; + return getMemory().getByte(offset()) != 0; } public final void set(boolean value) { @@ -800,7 +800,7 @@ public WBOOL() { } public final boolean get() { - return (getMemory().getInt(offset()) & 0x1) != 0; + return getMemory().getInt(offset()) != 0; } public final void set(boolean value) { @@ -814,7 +814,7 @@ public BOOL16() { } public final boolean get() { - return (getMemory().getShort(offset()) & 0x1) != 0; + return getMemory().getShort(offset()) != 0; } public final void set(boolean value) { diff --git a/src/main/java/jnr/ffi/StructLayout.java b/src/main/java/jnr/ffi/StructLayout.java index a1b32cf0b..1dbe5329e 100644 --- a/src/main/java/jnr/ffi/StructLayout.java +++ b/src/main/java/jnr/ffi/StructLayout.java @@ -312,7 +312,7 @@ protected Boolean(Offset offset) { } public final boolean get(jnr.ffi.Pointer ptr) { - return (ptr.getByte(offset()) & 0x1) != 0; + return ptr.getByte(offset()) != 0; } public final void set(jnr.ffi.Pointer ptr, boolean value) { @@ -333,7 +333,7 @@ protected WBOOL(Offset offset) { } public final boolean get(jnr.ffi.Pointer ptr) { - return (ptr.getInt(offset()) & 0x1) != 0; + return ptr.getInt(offset()) != 0; } public final void set(jnr.ffi.Pointer ptr, boolean value) { @@ -341,6 +341,25 @@ public final void set(jnr.ffi.Pointer ptr, boolean value) { } } + public final class BOOL16 extends AbstractBoolean { + protected BOOL16() { + super(NativeType.SSHORT); + } + + protected BOOL16(Offset offset) { + super(NativeType.SSHORT, offset); + } + + public final boolean get(jnr.ffi.Pointer ptr) { + return ptr.getShort(offset()) != 0; + } + + public final void set(jnr.ffi.Pointer ptr, boolean value) { + ptr.putShort(offset(), (short) (value ? 1 : 0)); + } + } + + /** * Base class for all Number structure fields. */ diff --git a/src/main/java/jnr/ffi/provider/jffi/NumberUtil.java b/src/main/java/jnr/ffi/provider/jffi/NumberUtil.java index 9f19ab118..d300192ce 100644 --- a/src/main/java/jnr/ffi/provider/jffi/NumberUtil.java +++ b/src/main/java/jnr/ffi/provider/jffi/NumberUtil.java @@ -144,29 +144,7 @@ public static void widen(SkinnyMethodAdapter mv, Class from, Class to, NativeTyp public static void narrow(SkinnyMethodAdapter mv, Class from, Class to) { if (!from.equals(to)) { - if (boolean.class == to) { - Label label_0 = new Label(); - Label label_1 = new Label(); - if (long.class == from) { - mv.lconst_0(); - mv.lcmp(); - mv.ifeq(label_0); - mv.iconst_1(); - mv.go_to(label_1); - mv.label(label_0); - mv.iconst_0(); - mv.label(label_1); - } else { -// mv.iconst_0(); - mv.ifeq(label_0); - mv.iconst_1(); - mv.go_to(label_1); - mv.label(label_0); - mv.iconst_0(); - mv.label(label_1); - } - - } else if (byte.class == to || short.class == to || char.class == to || int.class == to) { + if (byte.class == to || short.class == to || char.class == to || int.class == to) { if (long.class == from) { mv.l2i(); } @@ -180,7 +158,28 @@ public static void narrow(SkinnyMethodAdapter mv, Class from, Class to) { } else if (char.class == to) { mv.i2c(); } - } + } else if (boolean.class == to) { + Label label_false_branch = new Label(); + Label label_end = new Label(); + if (long.class == from) { + mv.lconst_0(); + mv.lcmp(); + mv.ifeq(label_false_branch); + mv.iconst_1(); + mv.go_to(label_end); + mv.label(label_false_branch); + mv.iconst_0(); + mv.label(label_end); + } else { +// mv.iconst_0(); + mv.ifeq(label_false_branch); + mv.iconst_1(); + mv.go_to(label_end); + mv.label(label_false_branch); + mv.iconst_0(); + mv.label(label_end); + } + } } } diff --git a/src/main/java/jnr/ffi/provider/jffi/X86MethodGenerator.java b/src/main/java/jnr/ffi/provider/jffi/X86MethodGenerator.java index d75416730..429eb9996 100644 --- a/src/main/java/jnr/ffi/provider/jffi/X86MethodGenerator.java +++ b/src/main/java/jnr/ffi/provider/jffi/X86MethodGenerator.java @@ -106,8 +106,8 @@ public void generate(AsmBuilder builder, String functionName, Function function, } Class nativeReturnType; - wrapperNeeded |= resultType.getFromNativeConverter() != null || !resultType.effectiveJavaType().isPrimitive(); - if (resultType.effectiveJavaType().isPrimitive()) { + wrapperNeeded |= resultType.getFromNativeConverter() != null || !resultType.effectiveJavaType().isPrimitive() || boolean.class.equals(resultType.effectiveJavaType()); + if (resultType.effectiveJavaType().isPrimitive() && !boolean.class.equals(resultType.effectiveJavaType())) { nativeReturnType = resultType.effectiveJavaType(); } else { nativeReturnType = getNativeClass(resultType.getNativeType()); From adf08937b26d2eb59db7faee9edbc3a44e9d84d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20Pl=C3=B6se?= Date: Sat, 15 Dec 2018 15:27:06 +0100 Subject: [PATCH 5/5] enhaned testcase now test the boxing of Boolean --- src/test/java/jnr/ffi/NumberTest.java | 77 +++++++++++++++++---------- 1 file changed, 50 insertions(+), 27 deletions(-) diff --git a/src/test/java/jnr/ffi/NumberTest.java b/src/test/java/jnr/ffi/NumberTest.java index a2c4d6ea1..2b217bf87 100644 --- a/src/test/java/jnr/ffi/NumberTest.java +++ b/src/test/java/jnr/ffi/NumberTest.java @@ -67,7 +67,21 @@ public static interface TestLib { } static TestLib testlib; - public static interface TestBoolean { + + public static interface Test_Boolean { + + public Boolean ret_int8_t(byte l); + public Boolean ret_uint8_t(byte l); + public Boolean ret_int16_t(short l); + public Boolean ret_uint16_t(short l); + public Boolean ret_int32_t(int l); + public Boolean ret_uint32_t(int l); + public Boolean ret_int64_t(long l); + public Boolean ret_uint64_t(long l); + } + static Test_Boolean test_Boolean; + + public static interface Test_boolean { public boolean ret_int8_t(byte l); public boolean ret_uint8_t(byte l); @@ -78,12 +92,13 @@ public static interface TestBoolean { public boolean ret_int64_t(long l); public boolean ret_uint64_t(long l); } - static TestBoolean testboolean; + static Test_boolean test_boolean; @BeforeClass public static void setUpClass() throws Exception { testlib = TstUtil.loadTestLib(TestLib.class); - testboolean = TstUtil.loadTestLib(TestBoolean.class); + test_boolean = TstUtil.loadTestLib(Test_boolean.class); + test_Boolean = TstUtil.loadTestLib(Test_Boolean.class); } @AfterClass @@ -359,57 +374,65 @@ public long n(long i1, long i2) { } @Test public void testBooleanFromInt() throws Exception { - assertEquals(false, testboolean.ret_int32_t(0)); - assertEquals(true, testboolean.ret_int32_t(-1)); - assertEquals(true, testboolean.ret_int32_t(1)); - assertEquals(true, testboolean.ret_int32_t(2)); + assertEquals(false, test_boolean.ret_int32_t(0)); + assertEquals(true, test_boolean.ret_int32_t(-1)); + assertEquals(true, test_boolean.ret_int32_t(1)); + assertEquals(true, test_boolean.ret_int32_t(2)); int value = 0x00000001; for (int i = 0; i < 32; i++) { - assertTrue(String.format("Must evaluate to true: 0x%04x", value), testboolean.ret_int32_t(value)); - assertTrue(String.format("Must evaluate to true: 0x%04x", value), testboolean.ret_uint32_t(value)); + assertTrue(String.format("Must evaluate to true: 0x%04x", value), test_boolean.ret_int32_t(value)); + assertTrue(String.format("Must evaluate to true: 0x%04x", value), test_boolean.ret_uint32_t(value)); + assertTrue(String.format("Must evaluate to true: 0x%04x", value), test_Boolean.ret_int32_t(value)); + assertTrue(String.format("Must evaluate to true: 0x%04x", value), test_Boolean.ret_uint32_t(value)); value <<= 1; } } @Test public void testBooleanFromByte() throws Exception { - assertEquals(false, testboolean.ret_int32_t(0)); - assertEquals(true, testboolean.ret_int32_t(-1)); - assertEquals(true, testboolean.ret_int32_t(1)); - assertEquals(true, testboolean.ret_int32_t(2)); + assertEquals(false, test_boolean.ret_int32_t(0)); + assertEquals(true, test_boolean.ret_int32_t(-1)); + assertEquals(true, test_boolean.ret_int32_t(1)); + assertEquals(true, test_boolean.ret_int32_t(2)); byte value = 0x01; for (int i = 0; i < 8; i++) { - assertTrue(String.format("Must evaluate to true: 0x%02x", value), testboolean.ret_int8_t((byte)value)); - assertTrue(String.format("Must evaluate to true: 0x%02x", value), testboolean.ret_uint8_t((byte)value)); + assertTrue(String.format("Must evaluate to true: 0x%02x", value), test_boolean.ret_int8_t((byte)value)); + assertTrue(String.format("Must evaluate to true: 0x%02x", value), test_boolean.ret_uint8_t((byte)value)); + assertTrue(String.format("Must evaluate to true: 0x%02x", value), test_Boolean.ret_int8_t((byte)value)); + assertTrue(String.format("Must evaluate to true: 0x%02x", value), test_Boolean.ret_uint8_t((byte)value)); value <<= 1; } } @Test public void testBooleanFromShort() throws Exception { - assertEquals(false, testboolean.ret_int32_t(0)); - assertEquals(true, testboolean.ret_int32_t(-1)); - assertEquals(true, testboolean.ret_int32_t(1)); - assertEquals(true, testboolean.ret_int32_t(2)); + assertEquals(false, test_boolean.ret_int32_t(0)); + assertEquals(true, test_boolean.ret_int32_t(-1)); + assertEquals(true, test_boolean.ret_int32_t(1)); + assertEquals(true, test_boolean.ret_int32_t(2)); short value = 0x0001; for (int i = 0; i < 16; i++) { - assertTrue(String.format("Must evaluate to true: 0x%04x", value), testboolean.ret_int16_t(value)); - assertTrue(String.format("Must evaluate to true: 0x%04x", value), testboolean.ret_uint16_t(value)); + assertTrue(String.format("Must evaluate to true: 0x%04x", value), test_boolean.ret_int16_t(value)); + assertTrue(String.format("Must evaluate to true: 0x%04x", value), test_boolean.ret_uint16_t(value)); + assertTrue(String.format("Must evaluate to true: 0x%04x", value), test_Boolean.ret_int16_t(value)); + assertTrue(String.format("Must evaluate to true: 0x%04x", value), test_Boolean.ret_uint16_t(value)); value <<= 1; } } @Test public void testBooleanFromLong() throws Exception { - assertEquals(false, testboolean.ret_int64_t(0)); - assertEquals(true, testboolean.ret_int64_t(-1)); - assertEquals(true, testboolean.ret_int64_t(1)); - assertEquals(true, testboolean.ret_int64_t(2)); + assertEquals(false, test_boolean.ret_int64_t(0)); + assertEquals(true, test_boolean.ret_int64_t(-1)); + assertEquals(true, test_boolean.ret_int64_t(1)); + assertEquals(true, test_boolean.ret_int64_t(2)); long value = 0x0000000000000001; for (int i = 0; i < 32; i++) { - assertTrue(String.format("Must evaluate to true: 0x%016x", value), testboolean.ret_int64_t(value)); - assertTrue(String.format("Must evaluate to true: 0x%016x", value), testboolean.ret_uint64_t(value)); + assertTrue(String.format("Must evaluate to true: 0x%016x", value), test_boolean.ret_int64_t(value)); + assertTrue(String.format("Must evaluate to true: 0x%016x", value), test_boolean.ret_uint64_t(value)); + assertTrue(String.format("Must evaluate to true: 0x%016x", value), test_Boolean.ret_int64_t(value)); + assertTrue(String.format("Must evaluate to true: 0x%016x", value), test_Boolean.ret_uint64_t(value)); value <<= 1; } }