Skip to content

Commit

Permalink
Clone tests from implementation into a legacy directory.
Browse files Browse the repository at this point in the history
In a follow up CL all of these tests will be the only tests run on C++17 GitHub actions.

Without these tests there would be no test coverage for C++17 after the project migrates to C++20 syntax.

Also drive by cleanup of clang-tidy failures.

#42

PiperOrigin-RevId: 712664206
  • Loading branch information
jwhpryor authored and copybara-github committed Jan 6, 2025
1 parent 657d76a commit 2048800
Show file tree
Hide file tree
Showing 36 changed files with 4,773 additions and 49 deletions.
2 changes: 1 addition & 1 deletion implementation/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ cc_test(
deps = [
"//:jni_bind",
"//:jni_test",
"//metaprogramming:concatenate",
"//metaprogramming:type_to_type_map",
"@googletest//:gtest_main",
],
)
Expand Down
3 changes: 0 additions & 3 deletions implementation/array_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

#include <type_traits>

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "jni_bind.h"
#include "jni_test.h"

namespace {

Expand Down
4 changes: 2 additions & 2 deletions implementation/array_type_conversion_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <type_traits>

#include "jni_bind.h"

namespace {
Expand Down
46 changes: 19 additions & 27 deletions implementation/array_view_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/
#include <algorithm>
#include <array>

#include <gmock/gmock.h>
#include <gtest/gtest.h>
Expand Down Expand Up @@ -50,51 +51,43 @@ TEST_F(JniTest, ArrayView_CallsLengthProperly) {
TEST_F(JniTest, ArrayView_GetsAndReleaseArrayBuffer) {
EXPECT_CALL(*env_, GetBooleanArrayElements(Eq(Fake<jbooleanArray>()), _))
.WillOnce(::testing::Return(Fake<jboolean*>()));
EXPECT_CALL(*env_, ReleaseBooleanArrayElements(
Eq(Fake<jbooleanArray>()),
Eq(Fake<jboolean*>()), 0));
EXPECT_CALL(*env_, ReleaseBooleanArrayElements(Eq(Fake<jbooleanArray>()),
Eq(Fake<jboolean*>()), 0));

EXPECT_CALL(*env_, GetByteArrayElements(Eq(Fake<jbyteArray>()), _))
.WillOnce(::testing::Return(Fake<jbyte*>()));
EXPECT_CALL(*env_,
ReleaseByteArrayElements(Eq(Fake<jbyteArray>()),
Eq(Fake<jbyte*>()), 0));
EXPECT_CALL(*env_, ReleaseByteArrayElements(Eq(Fake<jbyteArray>()),
Eq(Fake<jbyte*>()), 0));

EXPECT_CALL(*env_, GetCharArrayElements(Eq(Fake<jcharArray>()), _))
.WillOnce(::testing::Return(Fake<jchar*>()));
EXPECT_CALL(*env_,
ReleaseCharArrayElements(Eq(Fake<jcharArray>()),
Eq(Fake<jchar*>()), 0));
EXPECT_CALL(*env_, ReleaseCharArrayElements(Eq(Fake<jcharArray>()),
Eq(Fake<jchar*>()), 0));

EXPECT_CALL(*env_, GetShortArrayElements(Eq(Fake<jshortArray>()), _))
.WillOnce(::testing::Return(Fake<jshort*>()));
EXPECT_CALL(
*env_, ReleaseShortArrayElements(Eq(Fake<jshortArray>()),
Eq(Fake<jshort*>()), 0));
EXPECT_CALL(*env_, ReleaseShortArrayElements(Eq(Fake<jshortArray>()),
Eq(Fake<jshort*>()), 0));

EXPECT_CALL(*env_, GetIntArrayElements(Eq(Fake<jintArray>()), _))
.WillOnce(::testing::Return(Fake<jint*>()));
EXPECT_CALL(*env_,
ReleaseIntArrayElements(Eq(Fake<jintArray>()),
Eq(Fake<jint*>()), 0));
EXPECT_CALL(*env_, ReleaseIntArrayElements(Eq(Fake<jintArray>()),
Eq(Fake<jint*>()), 0));

EXPECT_CALL(*env_, GetLongArrayElements(Eq(Fake<jlongArray>()), _))
.WillOnce(::testing::Return(Fake<jlong*>()));
EXPECT_CALL(*env_,
ReleaseLongArrayElements(Eq(Fake<jlongArray>()),
Eq(Fake<jlong*>()), 0));
EXPECT_CALL(*env_, ReleaseLongArrayElements(Eq(Fake<jlongArray>()),
Eq(Fake<jlong*>()), 0));

EXPECT_CALL(*env_, GetFloatArrayElements(Eq(Fake<jfloatArray>()), _))
.WillOnce(::testing::Return(Fake<jfloat*>()));
EXPECT_CALL(
*env_, ReleaseFloatArrayElements(Eq(Fake<jfloatArray>()),
Eq(Fake<jfloat*>()), 0));
EXPECT_CALL(*env_, ReleaseFloatArrayElements(Eq(Fake<jfloatArray>()),
Eq(Fake<jfloat*>()), 0));

EXPECT_CALL(*env_, GetDoubleArrayElements(Eq(Fake<jdoubleArray>()), _))
.WillOnce(::testing::Return(Fake<jdouble*>()));
EXPECT_CALL(*env_, ReleaseDoubleArrayElements(
Eq(Fake<jdoubleArray>()),
Eq(Fake<jdouble*>()), 0));
EXPECT_CALL(*env_, ReleaseDoubleArrayElements(Eq(Fake<jdoubleArray>()),
Eq(Fake<jdouble*>()), 0));

LocalArray<jboolean> boolean_array{AdoptLocal{}, Fake<jbooleanArray>()};
LocalArray<jbyte> byte_array{AdoptLocal{}, Fake<jbyteArray>()};
Expand All @@ -118,9 +111,8 @@ TEST_F(JniTest, ArrayView_GetsAndReleaseArrayBuffer) {
TEST_F(JniTest, LocalArrayView_AllowsCTAD) {
EXPECT_CALL(*env_, GetBooleanArrayElements(Eq(Fake<jbooleanArray>()), _))
.WillOnce(::testing::Return(Fake<jboolean*>()));
EXPECT_CALL(*env_, ReleaseBooleanArrayElements(
Eq(Fake<jbooleanArray>()),
Eq(Fake<jboolean*>()), 0));
EXPECT_CALL(*env_, ReleaseBooleanArrayElements(Eq(Fake<jbooleanArray>()),
Eq(Fake<jboolean*>()), 0));

LocalArray<jboolean> boolean_array{AdoptLocal{}, Fake<jbooleanArray>()};
ArrayView ctad_array_view{boolean_array.Pin()};
Expand Down
1 change: 0 additions & 1 deletion implementation/class_loader_ref_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <optional>
#include <utility>

#include <gmock/gmock.h>
Expand Down
2 changes: 0 additions & 2 deletions implementation/class_loader_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#include "jni_bind.h"
#include "jni_test.h"

namespace {

Expand Down
1 change: 0 additions & 1 deletion implementation/class_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "jni_bind.h"
#include "jni_test.h"
Expand Down
1 change: 1 addition & 0 deletions implementation/constructor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "jni_bind.h"
#include "jni_test.h"
Expand Down
2 changes: 1 addition & 1 deletion implementation/field_ref_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include <optional>
#include <utility>

#include <gmock/gmock.h>
#include <gtest/gtest.h>
Expand Down
2 changes: 1 addition & 1 deletion implementation/global_object_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <optional>
#include <tuple>
#include <utility>

#include <gmock/gmock.h>
Expand Down
2 changes: 0 additions & 2 deletions implementation/id_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

#include <string_view>

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "jni_bind.h"

namespace {
Expand Down
2 changes: 0 additions & 2 deletions implementation/jni_type_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
#include <type_traits>

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "jni_bind.h"

namespace {
Expand Down
6 changes: 0 additions & 6 deletions implementation/jvm_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@
* limitations under the License.
*/

#include <thread>

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "implementation/jni_helper/jni_env.h"
#include "implementation/jni_helper/jni_helper.h"
#include "jni_bind.h"
#include "jni_test.h"

namespace {

Expand Down
Loading

0 comments on commit 2048800

Please sign in to comment.