Showing the changes to test/cpp_interface_test.cpp (1 of 2 files). Show all
Unified · Split
| @@ -1,5 +1,6 @@ | |||
| 1 | #include <gtest/gtest.h> | 1 | #include <gtest/gtest.h> |
| 2 | #include "codec_api.h" | 2 | #include "codec_api.h" |
| 3 | #include <stddef.h> | ||
| 3 | 4 | ||
| 4 | static void CheckFunctionOrder(int expect, int actual, const char* name) { | 5 | static void CheckFunctionOrder(int expect, int actual, const char* name) { |
| 5 | EXPECT_EQ(expect, actual) << "Wrong function order: " << name; | 6 | EXPECT_EQ(expect, actual) << "Wrong function order: " << name; |
| @@ -8,6 +9,9 @@ static void CheckFunctionOrder(int expect, int actual, const char* name) { · 2 unmodified lines | |||
| 8 | typedef void(*CheckFunc)(int, int, const char*); | 9 | typedef void(*CheckFunc)(int, int, const char*); |
| 9 | extern "C" void CheckEncoderInterface(ISVCEncoder* p, CheckFunc); | 10 | extern "C" void CheckEncoderInterface(ISVCEncoder* p, CheckFunc); |
| 10 | extern "C" void CheckDecoderInterface(ISVCDecoder* p, CheckFunc); | 11 | extern "C" void CheckDecoderInterface(ISVCDecoder* p, CheckFunc); |
| 12 | extern "C" size_t GetBoolSize(void); | ||
| 13 | extern "C" size_t GetBoolOffset(void); | ||
| 14 | extern "C" size_t GetBoolStructSize(void); | ||
| 11 | 15 | ||
| 12 | // Store the 'this' pointer to verify 'this' is received as expected from C code. | 16 | // Store the 'this' pointer to verify 'this' is received as expected from C code. |
| 13 | static void* gThis; | 17 | static void* gThis; |
| @@ -114,3 +118,14 @@ TEST(ISVCDecoderTest, CheckFunctionOrder) { · 100 unmodified lines | |||
| 114 | CheckDecoderInterface(p, CheckFunctionOrder); | 118 | CheckDecoderInterface(p, CheckFunctionOrder); |
| 115 | delete p; | 119 | delete p; |
| 116 | } | 120 | } |
| 121 | |||
| 122 | struct bool_test_struct { | ||
| 123 | char c; | ||
| 124 | bool b; | ||
| 125 | }; | ||
| 126 | |||
| 127 | TEST(ISVCDecoderEncoderTest, CheckCAbi) { | ||
| 128 | EXPECT_EQ(sizeof(bool), GetBoolSize()) << "Wrong size of bool type"; | ||
| 129 | EXPECT_EQ(offsetof(bool_test_struct, b), GetBoolOffset()) << "Wrong alignment of bool in a struct"; | ||
| 130 | EXPECT_EQ(sizeof(bool_test_struct), GetBoolStructSize()) << "Wrong size of struct with a bool"; | ||
| 131 | } | ||