Added the same two trivial tests to the C++ version.

Next up, unification of it with the C version via the Power Of Crazy C Macros.

Change-Id: I29b55a07462f2e58fd4eabc4aef3b13e99ed076e
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_JniCTest.c b/tests/tests/jni/libjnitest/android_jni_cts_JniCTest.c
index ac82ecf..86e169b 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_JniCTest.c
+++ b/tests/tests/jni/libjnitest/android_jni_cts_JniCTest.c
@@ -23,6 +23,11 @@
 #include <jni.h>
 #include <JNIHelp.h>
 
+
+/*
+ * The tests.
+ */
+
 // Test GetVersion().
 static char *test_GetVersion(JNIEnv *env) {
     // Android implementations should all be at version 1.6.
@@ -47,6 +52,11 @@
     return NULL;
 }
 
+
+/*
+ * Plumbing.
+ */
+
 // private static native String runTest();
 static jstring JniCTest_runAllTests(JNIEnv *env, jclass clazz) {
     char *result = runJniTests(env,
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_JniCppTest.cpp b/tests/tests/jni/libjnitest/android_jni_cts_JniCppTest.cpp
index e3a7730..1049ede 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_JniCppTest.cpp
+++ b/tests/tests/jni/libjnitest/android_jni_cts_JniCppTest.cpp
@@ -18,13 +18,59 @@
  * Native implementation for the JniCppTest class.
  */
 
-#include <stdlib.h>
+#include "helper.h"
+
 #include <jni.h>
 #include <JNIHelp.h>
 
+
+/*
+ * The tests.
+ */
+
+// Test GetVersion().
+static char *test_GetVersion(JNIEnv *env) {
+    // Android implementations should all be at version 1.6.
+    jint version = env->GetVersion();
+
+    if (version != JNI_VERSION_1_6) {
+        return failure("Expected JNI_VERSION_1_6 but got 0x%x", version);
+    }
+
+    return NULL;
+}
+
+// Test DefineClass().
+static char *test_DefineClass(JNIEnv *env) {
+    // Android implementations should always return NULL.
+    jclass clazz = env->DefineClass("foo", NULL, NULL, 0);
+
+    if (clazz != NULL) {
+        return failure("Expected NULL but got %p", clazz);
+    }
+
+    return NULL;
+}
+
+
+/*
+ * Plumbing.
+ */
+
 // private static native String runTest();
 static jstring JniCppTest_runAllTests(JNIEnv *env, jclass clazz) {
-    // TODO: Actual tests go here.
+    char *result = runJniTests(env,
+            JNI_TEST(GetVersion),
+            JNI_TEST(DefineClass),
+            NULL);
+
+    // TODO: Add more tests, above.
+
+    if (result != NULL) {
+        jstring s = env->NewStringUTF(result);
+        free(result);
+        return s;
+    }
 
     return NULL;
 }
diff --git a/tests/tests/jni/libjnitest/helper.h b/tests/tests/jni/libjnitest/helper.h
index 381d5f3..bb2ceee 100644
--- a/tests/tests/jni/libjnitest/helper.h
+++ b/tests/tests/jni/libjnitest/helper.h
@@ -19,6 +19,10 @@
 
 #include <jni.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /** A JNI test function */
 typedef char *JniTestFunction(JNIEnv *env);
 
@@ -49,4 +53,8 @@
  */
 char *runJniTests(JNIEnv *env, ...);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif // HELPER_H