JNI for test coverage #3965
This commit is contained in:
parent
72b85e3a32
commit
e9625b3cd8
|
@ -5,6 +5,9 @@ import org.junit.Test;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
import static com.rusefi.config.generated.Fields.TS_FILE_VERSION;
|
||||||
|
import static com.rusefi.shared.FileUtil.littleEndianWrap;
|
||||||
|
import static junit.framework.Assert.assertEquals;
|
||||||
import static junit.framework.Assert.assertTrue;
|
import static junit.framework.Assert.assertTrue;
|
||||||
|
|
||||||
public class JniUnitTest {
|
public class JniUnitTest {
|
||||||
|
@ -21,8 +24,8 @@ public class JniUnitTest {
|
||||||
byte[] outputs = engineLogic.getOutputs();
|
byte[] outputs = engineLogic.getOutputs();
|
||||||
|
|
||||||
Sensor sensor = Sensor.FIRMWARE_VERSION;
|
Sensor sensor = Sensor.FIRMWARE_VERSION;
|
||||||
ByteBuffer bb = ByteBuffer.wrap(outputs, sensor.getOffset(), 4);
|
ByteBuffer bb = littleEndianWrap(outputs, sensor.getOffset(), 4);
|
||||||
double value = sensor.getValueForChannel(bb);
|
double value = sensor.getValueForChannel(bb);
|
||||||
System.out.println(value);
|
assertEquals(TS_FILE_VERSION, (int)value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "com_rusefi_native__EngineLogic.h"
|
#include "com_rusefi_native__EngineLogic.h"
|
||||||
#include "auto_generated_sensor.h"
|
#include "auto_generated_sensor.h"
|
||||||
|
#include "tunerstudio.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -64,6 +65,7 @@ JNIEXPORT jbyteArray JNICALL Java_com_rusefi_native_1_EngineLogic_getOutputs(JNI
|
||||||
jbyteArray retVal = env->NewByteArray(sizeof(TunerStudioOutputChannels));
|
jbyteArray retVal = env->NewByteArray(sizeof(TunerStudioOutputChannels));
|
||||||
jbyte *buf = env->GetByteArrayElements(retVal, NULL);
|
jbyte *buf = env->GetByteArrayElements(retVal, NULL);
|
||||||
EngineTestHelper* eth = getEth();
|
EngineTestHelper* eth = getEth();
|
||||||
|
updateTunerStudioState();
|
||||||
memcpy(buf, (const void*)ð->engine.outputChannels, sizeof(TunerStudioOutputChannels));
|
memcpy(buf, (const void*)ð->engine.outputChannels, sizeof(TunerStudioOutputChannels));
|
||||||
env->ReleaseByteArrayElements(retVal, buf, 0);
|
env->ReleaseByteArrayElements(retVal, buf, 0);
|
||||||
|
|
||||||
|
|
|
@ -497,7 +497,7 @@ TEST(misc, testMenuTree) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int getRusEfiVersion(void) {
|
int getRusEfiVersion(void) {
|
||||||
return 776655;
|
return TS_FILE_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(util, PeakDetect) {
|
TEST(util, PeakDetect) {
|
||||||
|
|
Loading…
Reference in New Issue