mirror of https://github.com/ArduPilot/ardupilot
35 lines
779 B
C++
35 lines
779 B
C++
|
#include <AP_gtest.h>
|
||
|
|
||
|
int hal = 0;
|
||
|
|
||
|
class DummyDummy {
|
||
|
public:
|
||
|
double d = 42.0;
|
||
|
uint8_t count = 1;
|
||
|
};
|
||
|
|
||
|
TEST(AP_Common, TEST_CPP)
|
||
|
{
|
||
|
DummyDummy * test_new = new DummyDummy[0];
|
||
|
EXPECT_FALSE(test_new == nullptr);
|
||
|
EXPECT_TRUE(sizeof(test_new) == 8);
|
||
|
EXPECT_EQ(test_new->count, 0);
|
||
|
EXPECT_FLOAT_EQ(test_new->d, 0);
|
||
|
|
||
|
DummyDummy * test_d = (DummyDummy*) ::operator new (0);
|
||
|
EXPECT_FALSE(test_d == nullptr);
|
||
|
EXPECT_TRUE(sizeof(test_d) == 8);
|
||
|
EXPECT_EQ(test_d->count, 0);
|
||
|
EXPECT_FLOAT_EQ(test_d->d, 0);
|
||
|
|
||
|
DummyDummy * test_d2 = new DummyDummy;
|
||
|
EXPECT_TRUE(sizeof(test_d2) == 8);
|
||
|
EXPECT_EQ(test_d2->count, 1);
|
||
|
EXPECT_FLOAT_EQ(test_d2->d, 42.0);
|
||
|
|
||
|
delete[] test_new;
|
||
|
delete test_d;
|
||
|
delete test_d2;
|
||
|
}
|
||
|
|
||
|
AP_GTEST_MAIN()
|