summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2016-12-23 12:01:05 +0100
committerUlf Hermann <ulf.hermann@qt.io>2017-01-03 15:23:56 +0000
commitec66083cc2af3dbac0d770a32fb27d93c0470dcd (patch)
tree246ab3b0a183e0696ac7ad8c6536f1a852db8fcf /tests
parent01e3d73acea6e05d10b055cfffc41345eaab7806 (diff)
Add test for overwriting elfmaps
A newer elfmap takes precedence over an older one, independent of the insertion order. Change-Id: Id2756f63d73b437a1b6ab3979b86f02def6f1521 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/elfmap/tst_elfmap.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/elfmap/tst_elfmap.cpp b/tests/auto/elfmap/tst_elfmap.cpp
index 3da7eea..e65a5f7 100644
--- a/tests/auto/elfmap/tst_elfmap.cpp
+++ b/tests/auto/elfmap/tst_elfmap.cpp
@@ -67,6 +67,42 @@ private slots:
QCOMPARE(map.findElf(110, 0), map.constEnd());
QCOMPARE(map.findElf(105, 1), second);
}
+
+ void testOverwrite()
+ {
+ QFETCH(bool, reversed);
+
+ PerfElfMap map;
+ if (!reversed) {
+ QVERIFY(!map.registerElf(100, 20, 0, {}));
+ QVERIFY(map.registerElf(100, 20, 1, {}));
+ } else {
+ QVERIFY(!map.registerElf(100, 20, 1, {}));
+ QVERIFY(map.registerElf(100, 20, 0, {}));
+ }
+
+ auto first = map.findElf(105, 0);
+ QCOMPARE(first.key(), 100ull);
+ QCOMPARE(first->length, 20ull);
+ QCOMPARE(first->timeAdded, 0ull);
+ QCOMPARE(first->timeOverwritten, 1ull);
+
+ auto second = map.findElf(105, 1);
+ QCOMPARE(second.key(), 100ull);
+ QCOMPARE(second->length, 20ull);
+ QCOMPARE(second->timeAdded, 1ull);
+ QCOMPARE(second->timeOverwritten, std::numeric_limits<quint64>::max());
+
+ QCOMPARE(map.findElf(105, 2), second);
+ }
+
+ void testOverwrite_data()
+ {
+ QTest::addColumn<bool>("reversed");
+
+ QTest::newRow("normal") << false;
+ QTest::newRow("reversed") << true;
+ }
};
QTEST_MAIN(TestElfMap)