summaryrefslogtreecommitdiffstats
path: root/tests/qmlauto/selftests/tst_compareObjects.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/qmlauto/selftests/tst_compareObjects.qml')
-rw-r--r--tests/qmlauto/selftests/tst_compareObjects.qml33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/qmlauto/selftests/tst_compareObjects.qml b/tests/qmlauto/selftests/tst_compareObjects.qml
new file mode 100644
index 0000000..84fe3fe
--- /dev/null
+++ b/tests/qmlauto/selftests/tst_compareObjects.qml
@@ -0,0 +1,33 @@
+import Qt 4.7
+import QtQuickTest 1.0
+
+TestCase {
+ name: "SelfTests_CompareObjects"
+
+ function test_qtest_internalCompareObjects() {
+ var testObj11 = {a: 1, b: "foo", c: true};
+ var testObj12 = {a: 1, b: "foo", c: true};
+ var testObj21 = {a: 1, b: "foo", c: true, d: testObj11};
+ var testObj22 = {a: 1, b: "foo", c: true, d: testObj11};
+ var testObj23 = {a: 1, b: "foo", c: true, d: testObj12};
+
+ compare(qtest_compareInternalObjects(testObj11, testObj11), true, "Object identity");
+ compare(qtest_compareInternalObjects(testObj11, testObj12), true, "Object equality");
+ compare(qtest_compareInternalObjects(testObj21, testObj21), true, "Nested object identity");
+ compare(qtest_compareInternalObjects(testObj21, testObj22), true, "Nested object equality");
+ compare(qtest_compareInternalObjects(testObj21, testObj23), true, "Deep nested object equality");
+ }
+
+ function test_qtest_internalCompareObjects_differentObjects() {
+ var testObj11 = {a: 1, b: "foo", c: true};
+ var testObj12 = {a: 2, b: "foo", c: true};
+ var testObj13 = {a: 1, b: "bar", c: true};
+ var testObj14 = {a: 1, b: "foo", c: false};
+
+ compare(qtest_compareInternalObjects(testObj11, testObj12), false, "Different number");
+ compare(qtest_compareInternalObjects(testObj11, testObj13), false, "Different string");
+ compare(qtest_compareInternalObjects(testObj11, testObj14), false, "Different boolean");
+ }
+
+
+}