@@ -109,6 +109,12 @@ public TestPointerType() { }
109109 int fillFloatBuffer (float [] buf , int len , float value );
110110 int fillDoubleBuffer (double [] buf , int len , double value );
111111
112+ // boolean[] maps to jboolean* (always 8-bit), boolean mapping is 32-bit by default; use byte
113+ int fillInt8Buffer (boolean [] buf , int len , byte value );
114+
115+ // char[] maps to jchar* (always 16-bit), char maps to wchar_t (can be 32-bit); use short
116+ int fillInt16Buffer (char [] buf , int len , short value );
117+
112118 // Nonexistent functions
113119 boolean returnBooleanArgument (Object arg );
114120
@@ -507,6 +513,20 @@ public void testReadStructureByReferenceArrayArgumentMemory() {
507513 }
508514 }
509515
516+ public void testBooleanArrayArgument () {
517+ boolean [] buf = new boolean [1024 ];
518+ assertEquals ("Wrong return value" , buf .length ,
519+ lib .fillInt8Buffer (buf , buf .length , (byte )1 ));
520+ for (int i =0 ;i < buf .length ;i ++) {
521+ assertTrue ("Bad value at index " + i , buf [i ]);
522+ }
523+ assertEquals ("Wrong return value" , buf .length ,
524+ lib .fillInt8Buffer (buf , buf .length , (byte )0 ));
525+ for (int i =0 ;i < buf .length ;i ++) {
526+ assertFalse ("Bad value at index " + i , buf [i ]);
527+ }
528+ }
529+
510530 public void testByteArrayArgument () {
511531 byte [] buf = new byte [1024 ];
512532 final byte MAGIC = (byte )0xED ;
@@ -517,6 +537,16 @@ public void testByteArrayArgument() {
517537 }
518538 }
519539
540+ public void testCharArrayArgument () {
541+ char [] buf = new char [1024 ];
542+ final char MAGIC = '\uFEFF' ;
543+ assertEquals ("Wrong return value" , buf .length ,
544+ lib .fillInt16Buffer (buf , buf .length , (short )MAGIC ));
545+ for (int i =0 ;i < buf .length ;i ++) {
546+ assertEquals ("Bad value at index " + i , MAGIC , buf [i ]);
547+ }
548+ }
549+
520550 public void testShortArrayArgument () {
521551 short [] buf = new short [1024 ];
522552 final short MAGIC = (short )0xABED ;
0 commit comments