Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: blinky_max32630fthr
main.cpp
00001 #include "greentea-client/test_env.h" 00002 00003 #define PATTERN_CHECK_VALUE 0xF0F0ADAD 00004 00005 class Test { 00006 00007 private: 00008 const char* name; 00009 const int pattern; 00010 00011 public: 00012 Test(const char* _name, bool print_message=true) : name(_name), pattern(PATTERN_CHECK_VALUE) { 00013 if (print_message) { 00014 print("init"); 00015 } 00016 } 00017 00018 void print(const char *message) { 00019 printf("%s::%s\n", name, message); 00020 } 00021 00022 bool check_init(void) { 00023 bool result = (pattern == PATTERN_CHECK_VALUE); 00024 print(result ? "check_init: OK" : "check_init: ERROR"); 00025 return result; 00026 } 00027 00028 void stack_test(void) { 00029 print("stack_test"); 00030 Test t("Stack"); 00031 t.hello(); 00032 } 00033 00034 void hello(void) { 00035 print("hello"); 00036 } 00037 00038 ~Test() { 00039 print("destroy"); 00040 } 00041 }; 00042 00043 /* Check C++ startup initialisation */ 00044 Test s("Static", false); 00045 00046 /* EXPECTED OUTPUT: 00047 ******************* 00048 Static::init 00049 Static::stack_test 00050 Stack::init 00051 Stack::hello 00052 Stack::destroy 00053 Static::check_init: OK 00054 Heap::init 00055 Heap::hello 00056 Heap::destroy 00057 *******************/ 00058 int main (void) { 00059 GREENTEA_SETUP(10, "default_auto"); 00060 00061 bool result = true; 00062 for (;;) 00063 { 00064 s.print("init"); 00065 // Global stack object simple test 00066 s.stack_test(); 00067 if (s.check_init() == false) 00068 { 00069 result = false; 00070 break; 00071 } 00072 00073 // Heap test object simple test 00074 Test *m = new Test("Heap"); 00075 m->hello(); 00076 00077 if (m->check_init() == false) 00078 { 00079 result = false; 00080 } 00081 delete m; 00082 break; 00083 } 00084 00085 GREENTEA_TESTSUITE_RESULT(result); 00086 }
Generated on Tue Jul 12 2022 14:21:14 by
1.7.2