diff options
Diffstat (limited to 'utils')
-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 | |||
35 | 35 | ||
36 | 36 | ||
37 | struct { | 37 | struct { |
38 | const char* first; | 38 | const char* name; // dataset name |
39 | const char* second; | 39 | const char* first; // first comparison value |
40 | const int expected; | 40 | const char* second; // second comparison value |
41 | const int expected; // expected result | ||
41 | } const compdata[] = | 42 | } const compdata[] = |
42 | { | 43 | { |
43 | { "1.2.3", "1.2.3 ", 0 }, | 44 | { "trailing-whitespace", "1.2.3", "1.2.3 ", 0 }, |
44 | { "1.2.3", " 1.2.3", 0 }, | 45 | { "identical", "1.2.3", "1.2.3", 0 }, |
45 | { "1.2.3", "1.2.4", 1 }, | 46 | { "leading-whitespace", "1.2.3", " 1.2.3", 0 }, |
46 | { "1.2.3", "1.3.0", 1 }, | 47 | { "last-digit-greater", "1.2.3", "1.2.4", 1 }, |
47 | { "1.2.3", "2.0.0", 1 }, | 48 | { "last-digit-less", "1.2.3", "1.3.0", 1 }, |
48 | { "10.22.33", "10.22.33", 0 }, | 49 | { "all-digits-differ", "1.2.3", "2.0.0", 1 }, |
49 | { "10.22.33", "10.23.0", 1 }, | 50 | { "multidigit-numbers-identical", "10.22.33", "10.22.33", 0 }, |
50 | { "10.22.33", "11.0.0", 1 }, | 51 | { "multidigit-last-differs", "10.22.33", "10.23.0", 1 }, |
51 | { "1.2.3", "1.2.3.1", 1 }, | 52 | { "multidigit-next-to-last-differs", "10.22.33", "11.0.0", 1 }, |
52 | { "1.2.3", "1.2.3-1", 1 }, | 53 | { "last-additional-digit-with-dot", "1.2.3", "1.2.3.1", 1 }, |
53 | { "1.2.3-1", "1.2.3.1", 1 }, | 54 | { "last-additional-digit-with-hyphen", "1.2.3", "1.2.3-1", 1 }, |
54 | { "1.2.3-10", "1.2.3.0", 1 }, | 55 | { "first-additional-digit-with-hyphen", "1.2.3-1", "1.2.3.1", 1 }, |
55 | { "1.2.3-1", "1.2.3.10", 1 }, | 56 | { "first-additional-multidigit-with-hyphen", "1.2.3-10", "1.2.3.0", 1 }, |
56 | { "1.2.3-1", "1.2.3a", 1 }, | 57 | { "first-additional-with-hyphen-last-dot", "1.2.3-1", "1.2.3.10", 1 }, |
57 | { "1.2.3", "1.2.3a", 1 }, | 58 | { "first-additional-hyphen-last-charsuffix", "1.2.3-1", "1.2.3a", 1 }, |
58 | { "1.2.3a", "1.2.3b", 1 }, | 59 | { "last-with-char-suffix", "1.2.3", "1.2.3a", 1 }, |
59 | { "1.2.3", "1.2.3b", 1 }, | 60 | { "first-and-last-with-char-suffix", "1.2.3a", "1.2.3b", 1 }, |
60 | { "1.2.3.0", "2.0.0", 1 }, | 61 | { "last-with-char-suffix", "1.2.3", "1.2.3b", 1 }, |
61 | { "1.2.3b", "2.0.0", 1 }, | 62 | { "greater-has-less-digits", "1.2.3.0", "2.0.0", 1 }, |
62 | { "1.2.3", "2.0.0.1", 1 }, | 63 | { "less-has-char-suffix-greater-has-less-digits", "1.2.3b", "2.0.0", 1 }, |
63 | { "test-1.2.3", "test-1.2.3.tar.gz", 0 }, | 64 | { "greater-has-more-digits", "1.2.3", "2.0.0.1", 1 }, |
64 | { "1.2.3", "test-1.2.3.tar.bz2", 0 }, | 65 | { "identidal-with-differing-prefix-suffix", "test-1.2.3", "test-1.2.3.tar.gz", 0 }, |
65 | { "test-1.2.3.tar.gz", "test-1.2.3.tar.bz2", 0 }, | 66 | { "identical-with-filename", "1.2.3", "test-1.2.3.tar.bz2", 0 }, |
66 | { "test-1.2.3.tar.gz", "program-1.2.3.1.tar.bz2", 1 }, | 67 | { "identical-with-different-filesuffixes", "test-1.2.3.tar.gz", "test-1.2.3.tar.bz2", 0 }, |
67 | { "program-1.2.3.zip", "program-1.2.3a.zip", 1 }, | 68 | { "identical-with-different-filenames", "test-1.2.3.tar.gz", "program-1.2.3.1.tar.bz2", 1 }, |
68 | { "program-1.2.3.tar.bz2", "2.0.0", 1 }, | 69 | { "last-additional-char-suffix-with-filename", "program-1.2.3.zip", "program-1.2.3a.zip", 1 }, |
69 | { "prog-1.2-64bit.tar.bz2", "prog-1.2.3.tar.bz2", 1 }, | 70 | { "less-has-filename", "program-1.2.3.tar.bz2", "2.0.0", 1 }, |
70 | { "prog-1.2-64bit.tar.bz2", "prog-1.2-64bit.tar.bz2", 0 }, | 71 | { "filename-64bit-vs-additional-number", "prog-1.2-64bit.tar.bz2", "prog-1.2.3.tar.bz2", 1 }, |
71 | { "prog-1.2-64bit.tar.bz2", "prog-1.2.3-64bit.tar.bz2", 1 }, | 72 | { "filename-64bit-identical", "prog-1.2-64bit.tar.bz2", "prog-1.2-64bit.tar.bz2", 0 }, |
72 | { "prog-1.2a-64bit.tar.bz2","prog-1.2b-64bit.tar.bz2", 1 }, | 73 | { "filename-64bit-additional-number", "prog-1.2-64bit.tar.bz2", "prog-1.2.3-64bit.tar.bz2", 1 }, |
73 | { "prog-1.2-64bit.tar.bz2", "prog-1.2.3a-64bit.tar.bz2", 1 }, | 74 | { "filename-64bit-different-char-suffixes", "prog-1.2a-64bit.tar.bz2","prog-1.2b-64bit.tar.bz2", 1 }, |
74 | { "prog-1.2a-64bit.tar.bz2","prog-1.2.3-64bit.tar.bz2", 1 }, | 75 | { "filename-64bit-extra-number-and-char-suffix", "prog-1.2-64bit.tar.bz2", "prog-1.2.3a-64bit.tar.bz2", 1 }, |
76 | { "filename-64bit-char-suffix-vs-extra-number", "prog-1.2a-64bit.tar.bz2","prog-1.2.3-64bit.tar.bz2", 1 }, | ||
75 | }; | 77 | }; |
76 | 78 | ||
77 | struct { | 79 | struct { |
78 | const char* input; | 80 | const char* name; // dataset name |
79 | const QString expected; | 81 | const char* input; // input string |
82 | const QString expected; // output string | ||
80 | } const trimdata[] = | 83 | } const trimdata[] = |
81 | { | 84 | { |
82 | { "prog-1.2-64bit.tar.bz2", "1.2" }, | 85 | { "full-filename-with-64bit", "prog-1.2-64bit.tar.bz2", "1.2" }, |
83 | { "prog-1.2.tar.bz2", "1.2" }, | 86 | { "full-filename", "prog-1.2.tar.bz2", "1.2" }, |
84 | { "1.2.3", "1.2.3" }, | 87 | { "version-only", "1.2.3", "1.2.3" }, |
85 | { " 1.2.3", "1.2.3" }, | 88 | { "version-with-leading-whitespace", " 1.2.3", "1.2.3" }, |
86 | { "1.2.3 ", "1.2.3" }, | 89 | { "version-with-trailing-whitespace", "1.2.3 ", "1.2.3" }, |
87 | { "10.22.33", "10.22.33" }, | 90 | { "multidigit-version", "10.22.33", "10.22.33" }, |
88 | { "test-1.2.3", "1.2.3" }, | 91 | { "name-version", "test-1.2.3", "1.2.3" }, |
89 | { "1.2.3", "1.2.3" }, | 92 | { "name-version-suffix", "test-1.2.3.tar.gz", "1.2.3" }, |
90 | { "test-1.2.3.tar.gz", "1.2.3" }, | 93 | { "name-version-increment-suffix", "prog-1.2a.tar.bz2", "1.2a" }, |
91 | { "prog-1.2-64bit.tar.bz2", "1.2" }, | 94 | { "name-version-increment-64bit", "prog-1.2a-64bit.tar.bz2","1.2a" }, |
92 | { "prog-1.2a.tar.bz2", "1.2a" }, | ||
93 | { "prog-1.2a-64bit.tar.bz2","1.2a" }, | ||
94 | }; | 95 | }; |
95 | 96 | ||
96 | 97 | ||
@@ -100,7 +101,8 @@ void TestVersionCompare::testCompare_data() | |||
100 | QTest::addColumn<QString>("second"); | 101 | QTest::addColumn<QString>("second"); |
101 | QTest::addColumn<int>("expected"); | 102 | QTest::addColumn<int>("expected"); |
102 | for(size_t i = 0; i < sizeof(compdata) / sizeof(compdata[0]); i++) { | 103 | for(size_t i = 0; i < sizeof(compdata) / sizeof(compdata[0]); i++) { |
103 | QTest::newRow("") << compdata[i].first << compdata[i].second << compdata[i].expected; | 104 | QTest::newRow(compdata[i].name) |
105 | << compdata[i].first << compdata[i].second << compdata[i].expected; | ||
104 | } | 106 | } |
105 | } | 107 | } |
106 | 108 | ||
@@ -123,7 +125,8 @@ void TestVersionCompare::testTrim_data() | |||
123 | QTest::addColumn<QString>("input"); | 125 | QTest::addColumn<QString>("input"); |
124 | QTest::addColumn<QString>("expected"); | 126 | QTest::addColumn<QString>("expected"); |
125 | for(size_t i = 0; i < sizeof(trimdata) / sizeof(trimdata[0]); i++) { | 127 | for(size_t i = 0; i < sizeof(trimdata) / sizeof(trimdata[0]); i++) { |
126 | QTest::newRow("") << trimdata[i].input << trimdata[i].expected; | 128 | QTest::newRow(trimdata[i].name) |
129 | << trimdata[i].input << trimdata[i].expected; | ||
127 | } | 130 | } |
128 | } | 131 | } |
129 | 132 | ||
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); | |||
82 | Q_DECLARE_METATYPE(PlayerBuildInfo::DeviceInfo); | 82 | Q_DECLARE_METATYPE(PlayerBuildInfo::DeviceInfo); |
83 | 83 | ||
84 | struct { | 84 | struct { |
85 | QString target; | 85 | const char* target; |
86 | PlayerBuildInfo::BuildInfo item; | 86 | PlayerBuildInfo::BuildInfo item; |
87 | PlayerBuildInfo::BuildType type; | 87 | PlayerBuildInfo::BuildType type; |
88 | QString expected; | 88 | const char* expected; |
89 | } testdataBuild[] = | 89 | } testdataBuild[] = |
90 | { | 90 | { |
91 | // release builds | 91 | // release builds |
@@ -132,9 +132,9 @@ struct { | |||
132 | }; | 132 | }; |
133 | 133 | ||
134 | struct { | 134 | struct { |
135 | QString target; | 135 | const char* target; |
136 | PlayerBuildInfo::DeviceInfo item; | 136 | PlayerBuildInfo::DeviceInfo item; |
137 | QString expected; | 137 | const char* expected; |
138 | } testdataPlayer[] = | 138 | } testdataPlayer[] = |
139 | { | 139 | { |
140 | { "archosfmrecorder", PlayerBuildInfo::BuildStatus, "3" }, | 140 | { "archosfmrecorder", PlayerBuildInfo::BuildStatus, "3" }, |
@@ -166,8 +166,13 @@ void TestPlayerBuildInfo::testBuildInfo_data() | |||
166 | QTest::addColumn<PlayerBuildInfo::BuildType>("type"); | 166 | QTest::addColumn<PlayerBuildInfo::BuildType>("type"); |
167 | QTest::addColumn<QString>("expected"); | 167 | QTest::addColumn<QString>("expected"); |
168 | for (size_t i = 0; i < sizeof(testdataBuild) / sizeof(testdataBuild[0]); i++) | 168 | for (size_t i = 0; i < sizeof(testdataBuild) / sizeof(testdataBuild[0]); i++) |
169 | QTest::newRow("") << testdataBuild[i].target << testdataBuild[i].item | 169 | { |
170 | << testdataBuild[i].type << testdataBuild[i].expected; | 170 | char tag[30]; |
171 | snprintf(tag, sizeof(tag), "%s-%i-%i", | ||
172 | testdataBuild[i].target, testdataBuild[i].item, testdataBuild[i].type); | ||
173 | QTest::newRow(tag) << testdataBuild[i].target << testdataBuild[i].item | ||
174 | << testdataBuild[i].type << testdataBuild[i].expected; | ||
175 | } | ||
171 | } | 176 | } |
172 | 177 | ||
173 | 178 | ||
@@ -204,8 +209,13 @@ void TestPlayerBuildInfo::testPlayerInfo_data() | |||
204 | QTest::addColumn<PlayerBuildInfo::DeviceInfo>("item"); | 209 | QTest::addColumn<PlayerBuildInfo::DeviceInfo>("item"); |
205 | QTest::addColumn<QString>("expected"); | 210 | QTest::addColumn<QString>("expected"); |
206 | for (size_t i = 0; i < sizeof(testdataPlayer) / sizeof(testdataPlayer[0]); i++) | 211 | for (size_t i = 0; i < sizeof(testdataPlayer) / sizeof(testdataPlayer[0]); i++) |
207 | QTest::newRow("") << testdataPlayer[i].target << testdataPlayer[i].item | 212 | { |
208 | << testdataPlayer[i].expected; | 213 | char tag[30]; |
214 | snprintf(tag, sizeof(tag), "%s-%i", | ||
215 | testdataPlayer[i].target, testdataPlayer[i].item); | ||
216 | QTest::newRow(tag) << testdataPlayer[i].target << testdataPlayer[i].item | ||
217 | << testdataPlayer[i].expected; | ||
218 | } | ||
209 | } | 219 | } |
210 | 220 | ||
211 | void TestPlayerBuildInfo::testPlayerInfo() | 221 | void TestPlayerBuildInfo::testPlayerInfo() |