From 5edd0a2889377199b35e34ef7ad0e548d0755272 Mon Sep 17 00:00:00 2001
From: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
Date: Wed, 10 Jun 2020 15:19:07 -0300
Subject: [PATCH] Unit test for argument with default value

---
 .../shiboken2/tests/libsample/CMakeLists.txt  |  1 +
 .../shiboken2/tests/libsample/moderncpp.cpp   | 46 +++++++++++++++++
 sources/shiboken2/tests/libsample/moderncpp.h | 50 +++++++++++++++++++
 .../tests/samplebinding/CMakeLists.txt        |  2 +
 .../shiboken2/tests/samplebinding/global.h    |  1 +
 .../tests/samplebinding/typesystem_sample.xml |  5 ++
 6 files changed, 105 insertions(+)
 create mode 100644 sources/shiboken2/tests/libsample/moderncpp.cpp
 create mode 100644 sources/shiboken2/tests/libsample/moderncpp.h

diff --git a/sources/shiboken2/tests/libsample/CMakeLists.txt b/sources/shiboken2/tests/libsample/CMakeLists.txt
index ae13cd9f..d14f3601 100644
--- a/sources/shiboken2/tests/libsample/CMakeLists.txt
+++ b/sources/shiboken2/tests/libsample/CMakeLists.txt
@@ -16,6 +16,7 @@ handle.cpp
 implicitconv.cpp
 injectcode.cpp
 listuser.cpp
+moderncpp.cpp
 modifications.cpp
 mapuser.cpp
 modified_constructor.cpp
diff --git a/sources/shiboken2/tests/libsample/moderncpp.cpp b/sources/shiboken2/tests/libsample/moderncpp.cpp
new file mode 100644
index 00000000..c21b2146
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/moderncpp.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of Qt for Python.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "moderncpp.h"
+
+namespace ModernCpp
+{
+
+MyClass::MyClass(IntValues value)
+{
+}
+
+MyClass::MyClass(int value)
+{
+}
+
+MyClass::~MyClass()
+{
+}
+
+}
diff --git a/sources/shiboken2/tests/libsample/moderncpp.h b/sources/shiboken2/tests/libsample/moderncpp.h
new file mode 100644
index 00000000..d3f66bdc
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/moderncpp.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of Qt for Python.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#pragma once
+
+namespace ModernCpp
+{
+    enum IntValues
+    {
+        One = 1,
+        Two = 2,
+        Three = 3
+    };
+    
+    class MyClass
+    {
+    public:
+        // use new initializator
+        MyClass(IntValues value = {});
+        MyClass(int value = {});
+        virtual ~MyClass();
+
+        virtual void vfunc() = 0;
+    };
+}
diff --git a/sources/shiboken2/tests/samplebinding/CMakeLists.txt b/sources/shiboken2/tests/samplebinding/CMakeLists.txt
index b65068dc..af511ff0 100644
--- a/sources/shiboken2/tests/samplebinding/CMakeLists.txt
+++ b/sources/shiboken2/tests/samplebinding/CMakeLists.txt
@@ -43,6 +43,8 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/intwrapper_wrapper.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/sample/injectcode_wrapper.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/sample/listuser_wrapper.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/sample/mapuser_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/moderncpp_myclass_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/moderncpp_wrapper.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/sample/mderived1_wrapper.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/sample/mderived2_wrapper.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/sample/mderived3_wrapper.cpp
diff --git a/sources/shiboken2/tests/samplebinding/global.h b/sources/shiboken2/tests/samplebinding/global.h
index f4e20b74..8742d385 100644
--- a/sources/shiboken2/tests/samplebinding/global.h
+++ b/sources/shiboken2/tests/samplebinding/global.h
@@ -48,6 +48,7 @@
 #include "listuser.h"
 #include "mapuser.h"
 #include "modelindex.h"
+#include "moderncpp.h"
 #include "modifications.h"
 #include "modified_constructor.h"
 #include "multiple_derived.h"
diff --git a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
index 32df8fd7..5bd31666 100644
--- a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
+++ b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
@@ -2445,6 +2445,11 @@
 
     <value-type name="ToBeRenamedValue" target-lang-name="RenamedValue"/>
     <value-type name="RenamedUser"/>
+    
+    <namespace-type name="ModernCpp">
+        <enum-type name="IntValues"/>
+        <object-type name="MyClass"/>
+    </namespace-type>
 
     <suppress-warning text="horribly broken type '__off64_t'" />
     <suppress-warning text="enum '__codecvt_result' does not have a type entry or is not an enum" />
-- 
2.25.1

