X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftests%2FCXXTest.cc;fp=src%2Ftests%2FCXXTest.cc;h=21b3972a1773cda531b522c518acd2d73bd72bb6;hb=3eb15f58ca0911489d7d9bdc0ac2c575d27a68d8;hp=0000000000000000000000000000000000000000;hpb=a6ee28ca37621098ed040e6d1c4ae103934c3e97;p=nestedvm.git diff --git a/src/tests/CXXTest.cc b/src/tests/CXXTest.cc new file mode 100644 index 0000000..21b3972 --- /dev/null +++ b/src/tests/CXXTest.cc @@ -0,0 +1,54 @@ +#include + +using namespace std; + +class Test { +public: + Test(); + ~Test(); + void sayhi(); +}; + +class Exn { +public: + Exn() { } +}; + + +Test test; + +int main(int argc,char *argv[]) { + printf("Name: %p\n",typeid(const char*).name()); + printf("Name: %s\n",typeid(const char*).name()); + printf("Is pointer: %d\n",typeid(const char*).__is_pointer_p ()); + printf("Name: %p\n",typeid(int).name()); + printf("Name: %s\n",typeid(int).name()); + printf("Is pointer: %d\n",typeid(int).__is_pointer_p ()); + + try { + test.sayhi(); + } catch(char *e) { + printf("sayhi threw: %s\n",e); + } catch(const char *e) { + printf("sayhi threw: const char *:%s\n",e); + } catch(int n) { + printf("sayhi threw: %d\n",n); + } + return 0; +} + +Test::Test() { + cout << "Test's constructor" << endl; +} + +Test::~Test() { + cout << "Test's destructor" << endl; +} + +void Test::sayhi() { + static char exn[] = "Non-const!"; + cout << "Hello, World from Test" << endl; + cout << "Now throwing an exception" << endl; + throw "Hello, Exception Handling!"; + //throw exn; +}