From f816e926716583f31e6701c44a3fabde877c3be8 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 25 Aug 2019 17:38:08 -0400 Subject: [PATCH] unit_tests are failing under 32 bit mingw-w64 fix #905 --- unit_tests/main.cpp | 2 +- unit_tests/tests/test_cpp_memory_layout.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index 7ff879a540..62b6707033 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -47,7 +47,7 @@ GTEST_API_ int main(int argc, char **argv) { // printTriggerDebug = true; // resizeMap(); - printf("Success 20190824\r\n"); + printf("Success 20190825\r\n"); printAllTriggers(); // printConvertedTable(); testing::InitGoogleTest(&argc, argv); diff --git a/unit_tests/tests/test_cpp_memory_layout.cpp b/unit_tests/tests/test_cpp_memory_layout.cpp index 73eef2494c..5bed449f4d 100644 --- a/unit_tests/tests/test_cpp_memory_layout.cpp +++ b/unit_tests/tests/test_cpp_memory_layout.cpp @@ -53,11 +53,19 @@ TEST(misc, cppPlainStructMemoryLayout) { ASSERT_EQ(0, (int)&c.field0 - (int)&c); } +static int valueWePointAt; + TEST(misc, cppVirtualStructMemoryLayout) { TestChildWithVirtual c; + int * valuePointer = &valueWePointAt; + int pointerSize = sizeof(valuePointer); + + + // '4' in case of 32 bit target + // '8' in case of 64 bit target // this '8' is totally compiler and platform dependent -#define MAGIC_VTABLE_SIZE 8 + int MAGIC_VTABLE_SIZE = pointerSize; // validate field initializers just for fun ASSERT_EQ(540, c.field0);