forked from apache/mxnet
-
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.
Adding basic unit tests, bug fixes, and expanding some Java API class…
…es (apache#4) * Adding basic unit tests, bug fixes, and expanding some Java API classes * Moved pom skipTests change into core
- Loading branch information
1 parent
3861a90
commit ac380c8
Showing
6 changed files
with
189 additions
and
1 deletion.
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
40 changes: 40 additions & 0 deletions
40
scala-package/core/src/test/java/org/apache/mxnet/api/java/JavaContextTest.java
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,40 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.mxnet.javaapi; | ||
|
||
import org.junit.Test; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class JavaContextTest { | ||
|
||
@Test | ||
public void testCPU() { | ||
Context.cpu(); | ||
} | ||
|
||
@Test | ||
public void testDefault() { | ||
Context.defaultCtx(); | ||
} | ||
|
||
@Test | ||
public void testConstructor() { | ||
new Context("cpu", 0); | ||
} | ||
} |
121 changes: 121 additions & 0 deletions
121
scala-package/core/src/test/java/org/apache/mxnet/api/java/JavaShapeTest.java
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,121 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.mxnet.javaapi; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
import org.junit.Test; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
||
public class JavaShapeTest { | ||
@Test | ||
public void testArrayConstructor() | ||
{ | ||
new Shape(new int[] {3, 4, 5}); | ||
} | ||
|
||
@Test | ||
public void testListConstructor() | ||
{ | ||
ArrayList<Integer> arrList = new ArrayList<Integer>(); | ||
arrList.add(3); | ||
arrList.add(4); | ||
arrList.add(5); | ||
new Shape(arrList); | ||
} | ||
|
||
@Test | ||
public void testApply() | ||
{ | ||
Shape jS = new Shape(new int[] {3, 4, 5}); | ||
assertEquals(jS.apply(1), 4); | ||
} | ||
|
||
@Test | ||
public void testGet() | ||
{ | ||
Shape jS = new Shape(new int[] {3, 4, 5}); | ||
assertEquals(jS.get(1), 4); | ||
} | ||
|
||
@Test | ||
public void testSize() | ||
{ | ||
Shape jS = new Shape(new int[] {3, 4, 5}); | ||
assertEquals(jS.size(), 3); | ||
} | ||
|
||
@Test | ||
public void testLength() | ||
{ | ||
Shape jS = new Shape(new int[] {3, 4, 5}); | ||
assertEquals(jS.length(), 3); | ||
} | ||
|
||
@Test | ||
public void testDrop() | ||
{ | ||
Shape jS = new Shape(new int[] {3, 4, 5}); | ||
ArrayList<Integer> l = new ArrayList<Integer>(); | ||
l.add(4); | ||
l.add(5); | ||
assertTrue(jS.drop(1).toVector().equals(l)); | ||
} | ||
|
||
@Test | ||
public void testSlice() | ||
{ | ||
Shape jS = new Shape(new int[] {3, 4, 5}); | ||
ArrayList<Integer> l = new ArrayList<Integer>(); | ||
l.add(4); | ||
assertTrue(jS.slice(1,2).toVector().equals(l)); | ||
} | ||
|
||
@Test | ||
public void testProduct() | ||
{ | ||
Shape jS = new Shape(new int[] {3, 4, 5}); | ||
assertEquals(jS.product(), 60); | ||
} | ||
|
||
@Test | ||
public void testHead() | ||
{ | ||
Shape jS = new Shape(new int[] {3, 4, 5}); | ||
assertEquals(jS.head(), 3); | ||
} | ||
|
||
@Test | ||
public void testToArray() | ||
{ | ||
Shape jS = new Shape(new int[] {3, 4, 5}); | ||
assertTrue(Arrays.equals(jS.toArray(), new int[] {3,4,5})); | ||
} | ||
|
||
@Test | ||
public void testToVector() | ||
{ | ||
Shape jS = new Shape(new int[] {3, 4, 5}); | ||
ArrayList<Integer> l = new ArrayList<Integer>(); | ||
l.add(3); | ||
l.add(4); | ||
l.add(5); | ||
assertTrue(jS.toVector().equals(l)); | ||
} | ||
} |