aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-01-24 15:19:40 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:12:55 -0300
commit70a863eb2da935505ffa325c1772b13f4a80bded (patch)
tree6e8b5bfb18d0e951d047b04ec2be29cd1bf09758 /tests
parent9d36585f19bf858db10bee4c8b1933ed81301a98 (diff)
Fix bug#633 - "bool of null QDate (possibly other empty QString/null QObj types?) returns True for empty instance; probably should be False"
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/libsample/pen.h10
-rw-r--r--tests/samplebinding/CMakeLists.txt2
-rw-r--r--tests/samplebinding/nonzero_test.py38
3 files changed, 46 insertions, 4 deletions
diff --git a/tests/libsample/pen.h b/tests/libsample/pen.h
index 9c97c2e36..a0c13ef50 100644
--- a/tests/libsample/pen.h
+++ b/tests/libsample/pen.h
@@ -29,9 +29,13 @@
class LIBSAMPLE_API Color
{
public:
- Color() {}
- Color(SampleNamespace::InValue arg) {}
- Color(unsigned int arg) {}
+ Color() : m_null(true) {}
+ Color(SampleNamespace::InValue arg) : m_null(false) {}
+ Color(unsigned int arg) : m_null(false) {}
+
+ bool isNull() const { return m_null; }
+private:
+ bool m_null;
};
class LIBSAMPLE_API Pen
diff --git a/tests/samplebinding/CMakeLists.txt b/tests/samplebinding/CMakeLists.txt
index c81209c21..abeade93f 100644
--- a/tests/samplebinding/CMakeLists.txt
+++ b/tests/samplebinding/CMakeLists.txt
@@ -88,7 +88,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/valueandvirtual_wrapper.cpp
)
add_custom_command(OUTPUT ${sample_SRC}
-COMMAND ${GENERATORRUNNER_BINARY} --generatorSet=${generators_BINARY_DIR}/shiboken_generator${CMAKE_RELEASE_POSTFIX}${CMAKE_DEBUG_POSTFIX} --enable-parent-ctor-heuristic
+COMMAND ${GENERATORRUNNER_BINARY} --generatorSet=${generators_BINARY_DIR}/shiboken_generator${CMAKE_RELEASE_POSTFIX}${CMAKE_DEBUG_POSTFIX} --enable-parent-ctor-heuristic --use-isnull-as-nb_nonzero
${CMAKE_CURRENT_SOURCE_DIR}/global.h
--include-paths=${libsample_SOURCE_DIR}
--typesystem-paths=${CMAKE_CURRENT_SOURCE_DIR}
diff --git a/tests/samplebinding/nonzero_test.py b/tests/samplebinding/nonzero_test.py
new file mode 100644
index 000000000..eb319f030
--- /dev/null
+++ b/tests/samplebinding/nonzero_test.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# This file is part of the Shiboken Python Bindings Generator project.
+#
+# Copyright (C) 2011 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
+
+import unittest
+from sample import *
+
+class TestNonZeroOperator(unittest.TestCase):
+ def testIt(self):
+ c = Color()
+ self.assertFalse(c)
+ c = Color(2)
+ self.assertTrue(c)
+
+if __name__ == "__main__":
+ unittest.main()