tests: cpp: Extended c++ test case to cover new/delete

Extended c++ test case to cover the zephyr implementation of new and
delete.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
This commit is contained in:
Jan Van Winkel 2019-11-14 00:26:41 +01:00 committed by David Leach
commit 1182956cd8
3 changed files with 23 additions and 2 deletions

View file

@ -2,3 +2,4 @@ CONFIG_CPLUSPLUS=y
CONFIG_NET_BUF=y
CONFIG_ZTEST=y
CONFIG_ZTEST_STACKSIZE=2048
CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=128

View file

@ -31,6 +31,14 @@
#include <ztest.h>
class foo_class {
public:
foo_class(int foo) : foo(foo) {}
int get_foo() const { return foo;}
private:
int foo;
};
struct foo {
int v1;
};
@ -49,7 +57,19 @@ static int test_init(struct device *dev)
SYS_INIT(test_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);
static void test_new_delete(void)
{
foo_class *test_foo = new foo_class(10);
zassert_equal(test_foo->get_foo(), 10, NULL);
delete test_foo;
}
void test_main(void)
{
/* Does nothing. This is a compile only test. */
ztest_test_suite(cpp_tests,
ztest_unit_test(test_new_delete)
);
ztest_run_test_suite(cpp_tests);
}

View file

@ -1,5 +1,5 @@
tests:
misc.app_dev.cpp:
arch_exclude: posix
build_only: true
platform_exclude: qemu_x86_coverage
tags: cpp