mirror of https://github.com/rusefi/rusefi-1.git
unit tests in clang #2012
This commit is contained in:
parent
e5ef8de2ae
commit
8c5fe1bf23
|
@ -47,7 +47,7 @@ GTEST_API_ int main(int argc, char **argv) {
|
|||
printf("Success 20201203\r\n");
|
||||
printAllTriggers();
|
||||
if (focusOnTrigger != TT_UNUSED) {
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
|
|
@ -69,12 +69,12 @@ TEST(fuelControl, transitionIssue1592) {
|
|||
// Check that the action is correct - we don't care about the timing necessarily
|
||||
auto sched_open = engine->executor.getForUnitTest(0);
|
||||
ASSERT_EQ(sched_open->action.getArgument(), inj2);
|
||||
ASSERT_EQ(sched_open->action.getCallback(), &turnInjectionPinHigh);
|
||||
ASSERT_EQ(sched_open->action.getCallback(), (void(*)(void*))turnInjectionPinHigh);
|
||||
|
||||
auto sched_close = engine->executor.getForUnitTest(1);
|
||||
// Next action should be closing the same injector
|
||||
ASSERT_EQ(sched_close->action.getArgument(), inj2);
|
||||
ASSERT_EQ(sched_close->action.getCallback(), &turnInjectionPinLow);
|
||||
ASSERT_EQ(sched_close->action.getCallback(), (void(*)(void*))turnInjectionPinLow);
|
||||
}
|
||||
|
||||
// Run the engine for some revs
|
||||
|
|
|
@ -50,7 +50,7 @@ TEST(misc, cppPlainStructMemoryLayout) {
|
|||
memcpy(&destimationInt, &c, 4);
|
||||
ASSERT_EQ(540, destimationInt);
|
||||
|
||||
ASSERT_EQ(0, (int)&c.field0 - (int)&c);
|
||||
ASSERT_EQ((uintptr_t)&c.field0, (uintptr_t)&c);
|
||||
}
|
||||
|
||||
static int valueWePointAt;
|
||||
|
@ -58,13 +58,11 @@ static int valueWePointAt;
|
|||
TEST(misc, cppVirtualStructMemoryLayout) {
|
||||
TestChildWithVirtual c;
|
||||
|
||||
int * valuePointer = &valueWePointAt;
|
||||
int pointerSize = sizeof(valuePointer);
|
||||
int pointerSize = sizeof(int*);
|
||||
|
||||
|
||||
// '4' in case of 32 bit target
|
||||
// '8' in case of 64 bit target
|
||||
// this '8' is totally compiler and platform dependent
|
||||
int MAGIC_VTABLE_SIZE = pointerSize;
|
||||
|
||||
// validate field initializers just for fun
|
||||
|
@ -80,9 +78,9 @@ TEST(misc, cppVirtualStructMemoryLayout) {
|
|||
|
||||
// static_cast is smart to skip the vtable, we like static_cast
|
||||
TestParent *parent = static_cast<TestParent*>(&c);
|
||||
ASSERT_EQ(0, (int)&c.field0 - (int)parent);
|
||||
ASSERT_EQ((uintptr_t)&c.field0, (uintptr_t)parent);
|
||||
|
||||
ASSERT_EQ(MAGIC_VTABLE_SIZE, (int)&c.field0 - (int)&c);
|
||||
ASSERT_EQ(MAGIC_VTABLE_SIZE, (uintptr_t)&c.field0 - (uintptr_t)&c);
|
||||
|
||||
|
||||
}
|
||||
|
@ -96,5 +94,5 @@ TEST(misc, cppPlainExtraFieldsStructMemoryLayout) {
|
|||
// parent fields go first
|
||||
memcpy(&destimationInt, &c, 4);
|
||||
ASSERT_EQ(540, destimationInt);
|
||||
ASSERT_EQ(0, (int)&c.field0 - (int)&c);
|
||||
ASSERT_EQ(0, (uintptr_t)&c.field0 - (uintptr_t)&c);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
using ::testing::_;
|
||||
|
||||
static int testchip_readPad(void *data, brain_pin_e pin)
|
||||
static int testchip_readPad(void *data, unsigned int pin)
|
||||
{
|
||||
if (pin & 0x01)
|
||||
return 1;
|
||||
|
@ -19,7 +19,7 @@ static int testchip_readPad(void *data, brain_pin_e pin)
|
|||
|
||||
static int io_state = 0;
|
||||
|
||||
static int testchip_writePad(void *data, brain_pin_e pin, int value)
|
||||
static int testchip_writePad(void *data, unsigned int pin, int value)
|
||||
{
|
||||
if (value)
|
||||
io_state |= (1 << value);
|
||||
|
@ -39,7 +39,7 @@ static int testchip_init(void *data)
|
|||
}
|
||||
|
||||
static int calls_to_failed_chip = 0;
|
||||
static int testchip_failed_writePad(void *data, brain_pin_e pin, int value)
|
||||
static int testchip_failed_writePad(void *data, unsigned int pin, int value)
|
||||
{
|
||||
calls_to_failed_chip++;
|
||||
return 0;
|
||||
|
|
|
@ -13,7 +13,7 @@ TestParameters* TestParameters::put(string key, float value) {
|
|||
return this;
|
||||
}
|
||||
|
||||
float TestParameters::get(string key) const {
|
||||
float TestParameters::get(string key) {
|
||||
// WAT? 'contains' method only defined in C++20?!
|
||||
std::unordered_map<std::string, float>::const_iterator got = values.find(key);
|
||||
if (got == values.end())
|
||||
|
|
|
@ -14,6 +14,6 @@ class TestParameters {
|
|||
public:
|
||||
unordered_map<string, float> values;
|
||||
TestParameters* put(string key, float value);
|
||||
float get(string key) const;
|
||||
float get(string key);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue