diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2021-12-28 17:47:59 +0100 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2021-12-28 17:57:04 +0100 |
commit | c055b5e9331d94b74026029176ef84283153ca7b (patch) | |
tree | 28c7068aec91ed4e7ccb8d702734aa25690ef595 | |
parent | 0c8f5391826b193c7f20b56b099b29d228f759df (diff) | |
download | rockbox-c055b5e933.tar.gz rockbox-c055b5e933.zip |
rbutil: Add data tags to data driven unit tests.
Make tests implemented as data driven tests show a sensible test data
tag value, so test can get identified more easily.
Change-Id: Ifeb42ed11ce9a8efc6491b2c3b9fe31802a67d33
-rw-r--r-- | utils/rbutilqt/test/test-compareversion.cpp | 105 | ||||
-rw-r--r-- | utils/rbutilqt/test/test-playerbuildinfo.cpp | 26 |
2 files changed, 72 insertions, 59 deletions
diff --git a/utils/rbutilqt/test/test-compareversion.cpp b/utils/rbutilqt/test/test-compareversion.cpp index 94d7697646..47155955eb 100644 --- a/utils/rbutilqt/test/test-compareversion.cpp +++ b/utils/rbutilqt/test/test-compareversion.cpp @@ -35,62 +35,63 @@ class TestVersionCompare : public QObject struct { - const char* first; - const char* second; - const int expected; + const char* name; // dataset name + const char* first; // first comparison value + const char* second; // second comparison value + const int expected; // expected result } const compdata[] = { - { "1.2.3", "1.2.3 ", 0 }, - { "1.2.3", " 1.2.3", 0 }, - { "1.2.3", "1.2.4", 1 }, - { "1.2.3", "1.3.0", 1 }, - { "1.2.3", "2.0.0", 1 }, - { "10.22.33", "10.22.33", 0 }, - { "10.22.33", "10.23.0", 1 }, - { "10.22.33", "11.0.0", 1 }, - { "1.2.3", "1.2.3.1", 1 }, - { "1.2.3", "1.2.3-1", 1 }, - { "1.2.3-1", "1.2.3.1", 1 }, - { "1.2.3-10", "1.2.3.0", 1 }, - { "1.2.3-1", "1.2.3.10", 1 }, - { "1.2.3-1", "1.2.3a", 1 }, - { "1.2.3", "1.2.3a", 1 }, - { "1.2.3a", "1.2.3b", 1 }, - { "1.2.3", "1.2.3b", 1 }, - { "1.2.3.0", "2.0.0", 1 }, - { "1.2.3b", "2.0.0", 1 }, - { "1.2.3", "2.0.0.1", 1 }, - { "test-1.2.3", "test-1.2.3.tar.gz", 0 }, - { "1.2.3", "test-1.2.3.tar.bz2", 0 }, - { "test-1.2.3.tar.gz", "test-1.2.3.tar.bz2", 0 }, - { "test-1.2.3.tar.gz", "program-1.2.3.1.tar.bz2", 1 }, - { "program-1.2.3.zip", "program-1.2.3a.zip", 1 }, - { "program-1.2.3.tar.bz2", "2.0.0", 1 }, - { "prog-1.2-64bit.tar.bz2", "prog-1.2.3.tar.bz2", 1 }, - { "prog-1.2-64bit.tar.bz2", "prog-1.2-64bit.tar.bz2", 0 }, - { "prog-1.2-64bit.tar.bz2", "prog-1.2.3-64bit.tar.bz2", 1 }, - { "prog-1.2a-64bit.tar.bz2","prog-1.2b-64bit.tar.bz2", 1 }, - { "prog-1.2-64bit.tar.bz2", "prog-1.2.3a-64bit.tar.bz2", 1 }, - { "prog-1.2a-64bit.tar.bz2","prog-1.2.3-64bit.tar.bz2", 1 }, + { "trailing-whitespace", "1.2.3", "1.2.3 ", 0 }, + { "identical", "1.2.3", "1.2.3", 0 }, + { "leading-whitespace", "1.2.3", " 1.2.3", 0 }, + { "last-digit-greater", "1.2.3", "1.2.4", 1 }, + { "last-digit-less", "1.2.3", "1.3.0", 1 }, + { "all-digits-differ", "1.2.3", "2.0.0", 1 }, + { "multidigit-numbers-identical", "10.22.33", "10.22.33", 0 }, + { "multidigit-last-differs", "10.22.33", "10.23.0", 1 }, + { "multidigit-next-to-last-differs", "10.22.33", "11.0.0", 1 }, + { "last-additional-digit-with-dot", "1.2.3", "1.2.3.1", 1 }, + { "last-additional-digit-with-hyphen", "1.2.3", "1.2.3-1", 1 }, + { "first-additional-digit-with-hyphen", "1.2.3-1", "1.2.3.1", 1 }, + { "first-additional-multidigit-with-hyphen", "1.2.3-10", "1.2.3.0", 1 }, + { "first-additional-with-hyphen-last-dot", "1.2.3-1", "1.2.3.10", 1 }, + { "first-additional-hyphen-last-charsuffix", "1.2.3-1", "1.2.3a", 1 }, + { "last-with-char-suffix", "1.2.3", "1.2.3a", 1 }, + { "first-and-last-with-char-suffix", "1.2.3a", "1.2.3b", 1 }, + { "last-with-char-suffix", "1.2.3", "1.2.3b", 1 }, + { "greater-has-less-digits", "1.2.3.0", "2.0.0", 1 }, + { "less-has-char-suffix-greater-has-less-digits", "1.2.3b", "2.0.0", 1 }, + { "greater-has-more-digits", "1.2.3", "2.0.0.1", 1 }, + { "identidal-with-differing-prefix-suffix", "test-1.2.3", "test-1.2.3.tar.gz", 0 }, + { "identical-with-filename", "1.2.3", "test-1.2.3.tar.bz2", 0 }, + { "identical-with-different-filesuffixes", "test-1.2.3.tar.gz", "test-1.2.3.tar.bz2", 0 }, + { "identical-with-different-filenames", "test-1.2.3.tar.gz", "program-1.2.3.1.tar.bz2", 1 }, + { "last-additional-char-suffix-with-filename", "program-1.2.3.zip", "program-1.2.3a.zip", 1 }, + { "less-has-filename", "program-1.2.3.tar.bz2", "2.0.0", 1 }, + { "filename-64bit-vs-additional-number", "prog-1.2-64bit.tar.bz2", "prog-1.2.3.tar.bz2", 1 }, + { "filename-64bit-identical", "prog-1.2-64bit.tar.bz2", "prog-1.2-64bit.tar.bz2", 0 }, + { "filename-64bit-additional-number", "prog-1.2-64bit.tar.bz2", "prog-1.2.3-64bit.tar.bz2", 1 }, + { "filename-64bit-different-char-suffixes", "prog-1.2a-64bit.tar.bz2","prog-1.2b-64bit.tar.bz2", 1 }, + { "filename-64bit-extra-number-and-char-suffix", "prog-1.2-64bit.tar.bz2", "prog-1.2.3a-64bit.tar.bz2", 1 }, + { "filename-64bit-char-suffix-vs-extra-number", "prog-1.2a-64bit.tar.bz2","prog-1.2.3-64bit.tar.bz2", 1 }, }; struct { - const char* input; - const QString expected; + const char* name; // dataset name + const char* input; // input string + const QString expected; // output string } const trimdata[] = { - { "prog-1.2-64bit.tar.bz2", "1.2" }, - { "prog-1.2.tar.bz2", "1.2" }, - { "1.2.3", "1.2.3" }, - { " 1.2.3", "1.2.3" }, - { "1.2.3 ", "1.2.3" }, - { "10.22.33", "10.22.33" }, - { "test-1.2.3", "1.2.3" }, - { "1.2.3", "1.2.3" }, - { "test-1.2.3.tar.gz", "1.2.3" }, - { "prog-1.2-64bit.tar.bz2", "1.2" }, - { "prog-1.2a.tar.bz2", "1.2a" }, - { "prog-1.2a-64bit.tar.bz2","1.2a" }, + { "full-filename-with-64bit", "prog-1.2-64bit.tar.bz2", "1.2" }, + { "full-filename", "prog-1.2.tar.bz2", "1.2" }, + { "version-only", "1.2.3", "1.2.3" }, + { "version-with-leading-whitespace", " 1.2.3", "1.2.3" }, + { "version-with-trailing-whitespace", "1.2.3 ", "1.2.3" }, + { "multidigit-version", "10.22.33", "10.22.33" }, + { "name-version", "test-1.2.3", "1.2.3" }, + { "name-version-suffix", "test-1.2.3.tar.gz", "1.2.3" }, + { "name-version-increment-suffix", "prog-1.2a.tar.bz2", "1.2a" }, + { "name-version-increment-64bit", "prog-1.2a-64bit.tar.bz2","1.2a" }, }; @@ -100,7 +101,8 @@ void TestVersionCompare::testCompare_data() QTest::addColumn<QString>("second"); QTest::addColumn<int>("expected"); for(size_t i = 0; i < sizeof(compdata) / sizeof(compdata[0]); i++) { - QTest::newRow("") << compdata[i].first << compdata[i].second << compdata[i].expected; + QTest::newRow(compdata[i].name) + << compdata[i].first << compdata[i].second << compdata[i].expected; } } @@ -123,7 +125,8 @@ void TestVersionCompare::testTrim_data() QTest::addColumn<QString>("input"); QTest::addColumn<QString>("expected"); for(size_t i = 0; i < sizeof(trimdata) / sizeof(trimdata[0]); i++) { - QTest::newRow("") << trimdata[i].input << trimdata[i].expected; + QTest::newRow(trimdata[i].name) + << trimdata[i].input << trimdata[i].expected; } } diff --git a/utils/rbutilqt/test/test-playerbuildinfo.cpp b/utils/rbutilqt/test/test-playerbuildinfo.cpp index a250e37979..4dd5773576 100644 --- a/utils/rbutilqt/test/test-playerbuildinfo.cpp +++ b/utils/rbutilqt/test/test-playerbuildinfo.cpp @@ -82,10 +82,10 @@ Q_DECLARE_METATYPE(PlayerBuildInfo::BuildType); Q_DECLARE_METATYPE(PlayerBuildInfo::DeviceInfo); struct { - QString target; + const char* target; PlayerBuildInfo::BuildInfo item; PlayerBuildInfo::BuildType type; - QString expected; + const char* expected; } testdataBuild[] = { // release builds @@ -132,9 +132,9 @@ struct { }; struct { - QString target; + const char* target; PlayerBuildInfo::DeviceInfo item; - QString expected; + const char* expected; } testdataPlayer[] = { { "archosfmrecorder", PlayerBuildInfo::BuildStatus, "3" }, @@ -166,8 +166,13 @@ void TestPlayerBuildInfo::testBuildInfo_data() QTest::addColumn<PlayerBuildInfo::BuildType>("type"); QTest::addColumn<QString>("expected"); for (size_t i = 0; i < sizeof(testdataBuild) / sizeof(testdataBuild[0]); i++) - QTest::newRow("") << testdataBuild[i].target << testdataBuild[i].item - << testdataBuild[i].type << testdataBuild[i].expected; + { + char tag[30]; + snprintf(tag, sizeof(tag), "%s-%i-%i", + testdataBuild[i].target, testdataBuild[i].item, testdataBuild[i].type); + QTest::newRow(tag) << testdataBuild[i].target << testdataBuild[i].item + << testdataBuild[i].type << testdataBuild[i].expected; + } } @@ -204,8 +209,13 @@ void TestPlayerBuildInfo::testPlayerInfo_data() QTest::addColumn<PlayerBuildInfo::DeviceInfo>("item"); QTest::addColumn<QString>("expected"); for (size_t i = 0; i < sizeof(testdataPlayer) / sizeof(testdataPlayer[0]); i++) - QTest::newRow("") << testdataPlayer[i].target << testdataPlayer[i].item - << testdataPlayer[i].expected; + { + char tag[30]; + snprintf(tag, sizeof(tag), "%s-%i", + testdataPlayer[i].target, testdataPlayer[i].item); + QTest::newRow(tag) << testdataPlayer[i].target << testdataPlayer[i].item + << testdataPlayer[i].expected; + } } void TestPlayerBuildInfo::testPlayerInfo() |