Skip to content

Commit

Permalink
More test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gershnik committed Aug 30, 2024
1 parent 4c18fbc commit 50ccce4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
8 changes: 8 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@

cmake_minimum_required(VERSION 3.16)

if (${CMAKE_SYSTEM_NAME} STREQUAL Android)

set(ANDROID_SDK_DIR ${CMAKE_ANDROID_NDK}/../..)
set(ADB ${ANDROID_SDK_DIR}/platform-tools/adb)
set(GRADLE_BUILD_PROS -Pandroid.sdk=${ANDROID_SDK_DIR})

endif()

add_subdirectory("../jnigen" ${CMAKE_CURRENT_BINARY_DIR}/jnigen)


Expand Down
11 changes: 2 additions & 9 deletions tests/src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ FetchContent_Declare(doctest

FetchContent_MakeAvailable(doctest)

if (${CMAKE_SYSTEM_NAME} STREQUAL Android)

set(ANDROID_SDK_DIR ${CMAKE_ANDROID_NDK}/../..)
set(ADB ${ANDROID_SDK_DIR}/platform-tools/adb)
set(ANDROID_TEST_DIR /data/local/tmp/smjni_test)
set(GRADLE_BUILD_PROS -Pandroid.sdk=${ANDROID_SDK_DIR})

endif()

add_custom_target(test-native ALL)

set (TEST_SUFFIXES
Expand Down Expand Up @@ -100,6 +91,8 @@ foreach(TEST_SUFFIX ${TEST_SUFFIXES})

if (${CMAKE_SYSTEM_NAME} STREQUAL Android)

set(ANDROID_TEST_DIR /data/local/tmp/smjni_test)

add_custom_target(test-native-${TEST_SUFFIX}
DEPENDS ${TEST_TARGET_NAME}
COMMAND ${ADB} shell mkdir -p ${ANDROID_TEST_DIR}
Expand Down
13 changes: 8 additions & 5 deletions tests/src/cpp/array_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <doctest.h>

#include <vector>
#include <iterator>

using namespace smjni;

Expand Down Expand Up @@ -118,11 +119,13 @@ TEST_CASE( "testObject" )
auto arr = java_array_create(env, java_runtime::object(), 5);
java_array_access<jobjectArray> acc(env, arr);
CHECK(acc.size() == 5);
local_java_ref<jobject> obj = acc.at(0);
CHECK(!obj);
acc[0] = java_string_create(env, "abc");
obj = acc.at(0);
CHECK(obj);
{
local_java_ref<jobject> obj = acc.at(0);
CHECK(!obj);
acc[0] = java_string_create(env, "abc");
obj = acc.at(0);
CHECK(obj);
}

std::vector<std::string> buf;
for(local_java_ref<jobject> obj: acc) {
Expand Down

0 comments on commit 50ccce4

Please sign in to comment.