Commit 193af69a authored by hjk's avatar hjk
Browse files

debugger: add a manual test for QSharedDataPointer

parent 01284f21
...@@ -500,9 +500,46 @@ void testQSet() ...@@ -500,9 +500,46 @@ void testQSet()
//hash.insert(ptr); //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() void testQSharedPointer()
{ {
Employee e1(1, "Herbert");
Employee e2 = e1;
} }
void stringRefTest(const QString &refstring) void stringRefTest(const QString &refstring)
...@@ -1050,6 +1087,7 @@ int main(int argc, char *argv[]) ...@@ -1050,6 +1087,7 @@ int main(int argc, char *argv[])
testQMultiMap(); testQMultiMap();
testQString(); testQString();
testQSet(); testQSet();
testQSharedPointer();
testQStringList(); testQStringList();
testStruct(); testStruct();
//testThreads(); //testThreads();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment