From 193af69a38ad0af6da1af777904d5912433dfadc Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Fri, 17 Apr 2009 15:34:46 +0200
Subject: [PATCH] debugger: add a manual test for QSharedDataPointer

---
 tests/manual/gdbdebugger/simple/app.cpp | 38 +++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp
index 76b35c9ce77..9c5c007a4b9 100644
--- a/tests/manual/gdbdebugger/simple/app.cpp
+++ b/tests/manual/gdbdebugger/simple/app.cpp
@@ -500,9 +500,46 @@ void testQSet()
     //hash.insert(ptr);
 }
 
+class EmployeeData : public QSharedData
+{
+public:
+    EmployeeData() : id(-1) { name.clear(); }
+    EmployeeData(const EmployeeData &other)
+        : QSharedData(other), id(other.id), name(other.name) { }
+    ~EmployeeData() { }
+
+    int id;
+    QString name;
+};
+
+class Employee
+{
+public:
+    Employee() { d = new EmployeeData; }
+    Employee(int id, QString name) {
+        d = new EmployeeData;
+        setId(id);
+        setName(name);
+    }
+    Employee(const Employee &other)
+          : d (other.d)
+    {
+    }
+    void setId(int id) { d->id = id; }
+    void setName(QString name) { d->name = name; }
+
+    int id() const { return d->id; }
+    QString name() const { return d->name; }
+
+   private:
+     QSharedDataPointer<EmployeeData> d;
+ };
+
 
 void testQSharedPointer()
 {
+    Employee e1(1, "Herbert");
+    Employee e2 = e1;
 }
 
 void stringRefTest(const QString &refstring)
@@ -1050,6 +1087,7 @@ int main(int argc, char *argv[])
     testQMultiMap();
     testQString();
     testQSet();
+    testQSharedPointer();
     testQStringList();
     testStruct();
     //testThreads();
-- 
GitLab