forked from kivy/pyjnius
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kivy#111 from abrasive/multidim
Add support for multidimensional arrays
- Loading branch information
Showing
5 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.jnius; | ||
|
||
public class MultipleDimensions { | ||
public static boolean methodParamsMatrixI(int[][] x) { | ||
if (x.length != 3 || x[0].length != 3) | ||
return false; | ||
return (x[0][0] == 1 && x[0][1] == 2 && x[1][2] == 6); | ||
} | ||
public static int[][] methodReturnMatrixI() { | ||
int[][] matrix = {{1,2,3}, | ||
{4,5,6}, | ||
{7,8,9}}; | ||
return matrix; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import unittest | ||
from jnius.reflect import autoclass | ||
|
||
class MultipleDimensionsTest(unittest.TestCase): | ||
|
||
def test_multiple_dimensions(self): | ||
MultipleDims = autoclass('org.jnius.MultipleDimensions') | ||
matrix = [[1, 2, 3], | ||
[4, 5, 6], | ||
[7, 8, 9]] | ||
self.assertEquals(MultipleDims.methodParamsMatrixI(matrix), True) | ||
self.assertEquals(MultipleDims.methodReturnMatrixI(), matrix) |