summaryrefslogtreecommitdiffstats
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>2011-01-24 16:42:00 -0200
commit55daad72b2358614bd4ec69728887ba631f01a4c (patch)
tree8be18472e8b6ec5eba3cb099178c5544c506c4e4 /tests
parent63e2501545f8ef932414ae617f02fe73681e987c (diff)
downloadshiboken-55daad72b2358614bd4ec69728887ba631f01a4c.tar.gz
shiboken-55daad72b2358614bd4ec69728887ba631f01a4c.tar.xz
shiboken-55daad72b2358614bd4ec69728887ba631f01a4c.zip
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 9c97c2e3..a0c13ef5 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 c81209c2..abeade93 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 00000000..eb319f03
--- /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()