Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2125)

Unified Diff: android/jni_array_unittest.cc

Issue 2045303002: Update to Chromium //base at Chromium commit 3e81715e6d3a4324362635aea46ce1f1a163cca1. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/domokit/base@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android/jni_array.cc ('k') | android/jni_generator/golden_sample_for_tests_jni.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android/jni_array_unittest.cc
diff --git a/android/jni_array_unittest.cc b/android/jni_array_unittest.cc
index 7cb896ce9034fd159e044fdcb8a6f7ee7c2159df..58b244322a6c21ed7cb74ecb6caf733ddbfe32a4 100644
--- a/android/jni_array_unittest.cc
+++ b/android/jni_array_unittest.cc
@@ -112,6 +112,61 @@ TEST(JniArray, JavaIntArrayToIntVector) {
}
}
+TEST(JniArray, JavaLongArrayToInt64Vector) {
+ const int64 kInt64s[] = {0LL, 1LL, -1LL};
+ const size_t kLen = arraysize(kInt64s);
+
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jlongArray> jlongs(env, env->NewLongArray(kLen));
+ ASSERT_TRUE(jlongs.obj());
+
+ for (size_t i = 0; i < kLen; ++i) {
+ jlong j = static_cast<jlong>(kInt64s[i]);
+ env->SetLongArrayRegion(jlongs.obj(), i, 1, &j);
+ ASSERT_FALSE(HasException(env));
+ }
+
+ std::vector<int64> int64s;
+ JavaLongArrayToInt64Vector(env, jlongs.obj(), &int64s);
+
+ ASSERT_EQ(static_cast<jsize>(int64s.size()),
+ env->GetArrayLength(jlongs.obj()));
+
+ jlong value;
+ for (size_t i = 0; i < kLen; ++i) {
+ env->GetLongArrayRegion(jlongs.obj(), i, 1, &value);
+ ASSERT_EQ(int64s[i], value);
+ ASSERT_EQ(kInt64s[i], int64s[i]);
+ }
+}
+
+TEST(JniArray, JavaLongArrayToLongVector) {
+ const int64 kInt64s[] = {0LL, 1LL, -1LL};
+ const size_t kLen = arraysize(kInt64s);
+
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jlongArray> jlongs(env, env->NewLongArray(kLen));
+ ASSERT_TRUE(jlongs.obj());
+
+ for (size_t i = 0; i < kLen; ++i) {
+ jlong j = static_cast<jlong>(kInt64s[i]);
+ env->SetLongArrayRegion(jlongs.obj(), i, 1, &j);
+ ASSERT_FALSE(HasException(env));
+ }
+
+ std::vector<jlong> jlongs_vector;
+ JavaLongArrayToLongVector(env, jlongs.obj(), &jlongs_vector);
+
+ ASSERT_EQ(static_cast<jsize>(jlongs_vector.size()),
+ env->GetArrayLength(jlongs.obj()));
+
+ jlong value;
+ for (size_t i = 0; i < kLen; ++i) {
+ env->GetLongArrayRegion(jlongs.obj(), i, 1, &value);
+ ASSERT_EQ(jlongs_vector[i], value);
+ }
+}
+
TEST(JniArray, JavaFloatArrayToFloatVector) {
const float kFloats[] = {0.0, 0.5, -0.5};
const size_t kLen = arraysize(kFloats);
« no previous file with comments | « android/jni_array.cc ('k') | android/jni_generator/golden_sample_for_tests_jni.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698