diff options
-rw-r--r-- | tests/libsample/virtualmethods.cpp | 2 | ||||
-rw-r--r-- | tests/libsample/virtualmethods.h | 13 | ||||
-rw-r--r-- | tests/samplebinding/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/samplebinding/typesystem_sample.xml | 2 | ||||
-rwxr-xr-x | tests/samplebinding/virtualdtor_test.py | 47 |
5 files changed, 65 insertions, 0 deletions
diff --git a/tests/libsample/virtualmethods.cpp b/tests/libsample/virtualmethods.cpp index 979d1d8f0..e2e6a2374 100644 --- a/tests/libsample/virtualmethods.cpp +++ b/tests/libsample/virtualmethods.cpp @@ -35,6 +35,8 @@ #include <string.h> #include "virtualmethods.h" +int VirtualDtor::dtor_called = 0; + double VirtualMethods::virtualMethod0(Point pt, int val, Complex cpx, bool b) { diff --git a/tests/libsample/virtualmethods.h b/tests/libsample/virtualmethods.h index 45d8ae71e..cd504d90f 100644 --- a/tests/libsample/virtualmethods.h +++ b/tests/libsample/virtualmethods.h @@ -86,5 +86,18 @@ public: }; +class VirtualDtor +{ +public: + VirtualDtor() {} + virtual ~VirtualDtor() { VirtualDtor::dtor_called++; } + + static int dtorCalled() { return dtor_called; } + +private: + static int dtor_called; +}; + + #endif // VIRTUALMETHODS_H diff --git a/tests/samplebinding/CMakeLists.txt b/tests/samplebinding/CMakeLists.txt index 9ba100523..f5789259c 100644 --- a/tests/samplebinding/CMakeLists.txt +++ b/tests/samplebinding/CMakeLists.txt @@ -35,6 +35,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/simplefile_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/sample/size_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/sample/str_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/sample/time_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/sample/virtualdtor_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/sample/virtualmethods_wrapper.cpp ) diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml index f24441edf..796f5f3cc 100644 --- a/tests/samplebinding/typesystem_sample.xml +++ b/tests/samplebinding/typesystem_sample.xml @@ -417,6 +417,8 @@ </modify-function> </value-type> + <value-type name="VirtualDtor"/> + <value-type name="InjectCode"> <!-- Various tests for inject codes. diff --git a/tests/samplebinding/virtualdtor_test.py b/tests/samplebinding/virtualdtor_test.py new file mode 100755 index 000000000..19d7176f2 --- /dev/null +++ b/tests/samplebinding/virtualdtor_test.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# This file is part of the Shiboken Python Bindings Generator project. +# +# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +# +# Contact: PySide team <contact@pyside.org> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# version 2.1 as published by the Free Software Foundation. Please +# review the following information to ensure the GNU Lesser General +# Public License version 2.1 requirements will be met: +# http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +# # +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +# 02110-1301 USA + +'''Test cases for virtual destructor.''' + +import sys +import unittest + +from sample import VirtualDtor + +class VirtualDtorTest(unittest.TestCase): + '''Test case for virtual destructor.''' + + def testVirtualDtor(self): + '''Original virtual destructor is being called.''' + dtor_called = VirtualDtor.dtorCalled() + for i in range(1, 10): + vd = VirtualDtor() + del vd + self.assertEqual(VirtualDtor.dtorCalled(), dtor_called + i) + +if __name__ == '__main__': + unittest.main() + |