Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
xpenatan committed Jul 11, 2023
1 parent 2ccff53 commit 923a63c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ public class NormalClass extends ParentClass {
*/

public NormalClass() {
initObject(createNative(), true);
System.out.println("POINTER BEFORE: " + cPointer);
long aNative = createNative();
initObject(aNative, true);
System.out.println("POINTER AFTER: " + cPointer);
}

/*[-C++;-NATIVE]
Expand Down
8 changes: 8 additions & 0 deletions example/example-build/jni/cpp/src/NormalClass.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#include "NormalClass.h"

NormalClass::NormalClass()
{
int a = 1;
int b = 2;
int c = a + b;
c++;
}

int NormalClass::addIntValue(int a, int b)
{
return (a + b) * hiddenInt * hiddenParentInt;
Expand Down
1 change: 1 addition & 0 deletions example/example-build/jni/cpp/src/NormalClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class NormalClass : public ParentClass
{
int hiddenInt = 1;
public:
NormalClass();
int addIntValue(int a, int b);
};

Expand Down
8 changes: 8 additions & 0 deletions example/example-build/jni/cpp/src/ParentClass.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#include "ParentClass.h"

ParentClass::ParentClass()
{
int a = 1;
int b = 2;
int c = a + b;
c++;
}

float ParentClass::addFloatValue(float a, float b)
{
return (a + b) * hiddenParentInt;
Expand Down
1 change: 1 addition & 0 deletions example/example-build/jni/cpp/src/ParentClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class ParentClass
protected:
int hiddenParentInt = 1;
public:
ParentClass();
float addFloatValue(float a, float b);
bool invertBoolean(bool value);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ public void test_add_int() {
assertEquals(20, ret);
}

@Test
public void test_add_float() {
NormalClass normalClass = new NormalClass();
float ret = normalClass.addFloatValue(10.3f, 10.3f);
assertEquals(20.6, ret, 1.0f);
}

@Test
public void test_invert_boolean_should_be_false() {
NormalClass normalClass = new NormalClass();
boolean ret = normalClass.invertBoolean(true);
assertFalse(ret);
}

@Test
public void test_invert_boolean_should_be_true() {
NormalClass normalClass = new NormalClass();
boolean ret = normalClass.invertBoolean(false);
assertTrue(ret);
}
// @Test
// public void test_add_float() {
// NormalClass normalClass = new NormalClass();
// float ret = normalClass.addFloatValue(10.3f, 10.3f);
// assertEquals(20.6, ret, 1.0f);
// }
//
// @Test
// public void test_invert_boolean_should_be_false() {
// NormalClass normalClass = new NormalClass();
// boolean ret = normalClass.invertBoolean(true);
// assertFalse(ret);
// }
//
// @Test
// public void test_invert_boolean_should_be_true() {
// NormalClass normalClass = new NormalClass();
// boolean ret = normalClass.invertBoolean(false);
// assertTrue(ret);
// }

}

0 comments on commit 923a63c

Please sign in to comment.