[apriltag] Clean up apriltag JNI (#4823)

This commit is contained in:
Thad House
2022-12-19 21:06:36 -08:00
committed by GitHub
parent 8b74ab389d
commit 17ceebfff4
5 changed files with 88 additions and 94 deletions

View File

@@ -4,13 +4,24 @@
package edu.wpi.first.apriltag.jni;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
public class JNITest {
@Test
void jniLinkTest() {
// Test to verify that the JNI test link works correctly.
void validCreationTest() {
var detector = AprilTagJNI.aprilTagCreate("tag16h5", 2.0, 0.0, 1, false, false);
assertTrue(detector >= 0);
AprilTagJNI.aprilTagDestroy(detector);
}
@Test
void invalidCreationTest() {
var detector = AprilTagJNI.aprilTagCreate("badtag", 2.0, 0.0, 1, false, false);
assertEquals(detector, -1);
// Still call destroy to ensure passing a bad destroy value doesn't break
AprilTagJNI.aprilTagDestroy(detector);
}
}