Skip to content

Commit c7f1811

Browse files
committed
Added a test for 2D arrays
1 parent 6f361eb commit c7f1811

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

tests/java/src/test/java/OneTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,16 @@ public void testCharArray() throws IOException {
244244
oos.close();
245245
}
246246

247+
@Test
248+
public void test2DArray() throws IOException {
249+
int[][] array = new int[][] {
250+
new int[] {1, 2, 3},
251+
new int[] {4, 5, 6},
252+
};
253+
oos.writeObject(array);
254+
oos.close();
255+
}
256+
247257
@Test
248258
public void testJapan() throws IOException {
249259
String stateOfJapan = "日本国";

tests/test2DArray.ser

85 Bytes
Binary file not shown.

tests/test_v1.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,17 @@ def test_char_array(self):
359359
)
360360
self._try_marshalling(jobj, pobj)
361361

362+
def test_2d_array(self):
363+
"""
364+
Tests the handling of a 2D array
365+
"""
366+
jobj = self.read_file("test2DArray.ser")
367+
pobj = javaobj.loads(jobj)
368+
_logger.debug(pobj)
369+
self.assertEqual(
370+
pobj, [[1, 2, 3], [4, 5, 6],],
371+
)
372+
362373
def test_enums(self):
363374
"""
364375
Tests the handling of "enum" types

tests/test_v2.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
sys.path.insert(0, os.path.abspath(os.path.dirname(os.getcwd())))
4545

4646
import javaobj.v2 as javaobj
47+
4748
# Local
4849
from javaobj.utils import bytes_char, java_data_fd
4950

@@ -452,6 +453,17 @@ def test_char_array(self):
452453
],
453454
)
454455

456+
def test_2d_array(self):
457+
"""
458+
Tests the handling of a 2D array
459+
"""
460+
jobj = self.read_file("test2DArray.ser")
461+
pobj = javaobj.loads(jobj)
462+
_logger.debug(pobj)
463+
self.assertEqual(
464+
pobj, [[1, 2, 3], [4, 5, 6],],
465+
)
466+
455467
def test_enums(self):
456468
"""
457469
Tests the handling of "enum" types
@@ -596,7 +608,8 @@ def test_writeObject(self):
596608

597609
self.assertEqual(isinstance(pobj, CustomWriterInstance), True)
598610
self.assertEqual(
599-
isinstance(pobj.field_data["custom_obj"], RandomChildInstance), True
611+
isinstance(pobj.field_data["custom_obj"], RandomChildInstance),
612+
True,
600613
)
601614

602615
parent_data = pobj.field_data

0 commit comments

Comments
 (0)