@needs_dlfcn
def test_dylink_dynamic_cast(self):
    self.dylink_test(header='\n      class Base {\n      public:\n          virtual void printName();\n      };\n\n      class Derived : public Base {\n      public:\n          void printName();\n      };\n    ', main='\n      #include "header.h"\n      #include <iostream>\n\n      using namespace std;\n\n      int main() {\n        cout << "starting main" << endl;\n\n        Base *base = new Base();\n        Base *derived = new Derived();\n        base->printName();\n        derived->printName();\n\n        if (dynamic_cast<Derived*>(derived)) {\n          cout << "OK" << endl;\n        } else {\n          cout << "KO" << endl;\n        }\n\n        return 0;\n      }\n    ', side='\n      #include "header.h"\n      #include <iostream>\n\n      using namespace std;\n\n      void Base::printName() {\n          cout << "Base" << endl;\n      }\n\n      void Derived::printName() {\n          cout << "Derived" << endl;\n      }\n    ', expected=['starting main\nBase\nDerived\nOK'])
@needs_dlfcn
def test_dylink_dynamic_cast(self):
    self.dylink_test(header='\n      class Base {\n      public:\n          virtual void printName();\n      };\n\n      class Derived : public Base {\n      public:\n          void printName();\n      };\n    ', main='\n      #include "header.h"\n      #include <iostream>\n\n      using namespace std;\n\n      int main() {\n        cout << "starting main" << endl;\n\n        Base *base = new Base();\n        Base *derived = new Derived();\n        base->printName();\n        derived->printName();\n\n        if (dynamic_cast<Derived*>(derived)) {\n          cout << "OK" << endl;\n        } else {\n          cout << "KO" << endl;\n        }\n\n        return 0;\n      }\n    ', side='\n      #include "header.h"\n      #include <iostream>\n\n      using namespace std;\n\n      void Base::printName() {\n          cout << "Base" << endl;\n      }\n\n      void Derived::printName() {\n          cout << "Derived" << endl;\n      }\n    ', expected=['starting main\nBase\nDerived\nOK'])