Commit f7dd4035 authored by Lukas Appelhans's avatar Lukas Appelhans

Make tests compile again, add two new testcases to versiontests and fix the...

Make tests compile again, add two new testcases to versiontests and fix the one version reported by Luca which didn't work...
Basically this adds support for chars inside version strings
parent 12cd8df9
......@@ -150,8 +150,23 @@ int compare_versions(QString const& a, QString const& b)
QStringList::iterator i2 = v2.begin();
for (; i1 < v1.end() && i2 < v2.end() ; i1++, i2++) {
int p1 = i1->toInt();
int p2 = i2->toInt();
bool conversion1, conversion2;
int p1 = i1->toInt(&conversion1);
int p2 = i2->toInt(&conversion2);
//Basically we have something that are not only strings
if (!conversion1 || !conversion2) {
for (int i = 0; i != i1->length(); ++i) {
if (i2->length() > i && i1->at(i) != i2->at(i))
return i1[i].toAscii() > i2[i].toAscii() ? 1 : -1;
p1 = i1->mid(i + 1).toInt(&conversion1);
p2 = i2->mid(i + 1).toInt(&conversion2);
if (conversion1 && conversion2)
break;
}
}
if (p1 > p2) {
return 1;
......
......@@ -10,7 +10,7 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "^[Dd]ebug[Ff]ull$")
add_executable(akabei_test ${akabei_test_SRCS} ${akabei_test_MOC_SRCS})
target_link_libraries(akabei_test ${QT_QTTEST_LIBRARY} akabeicore)
target_link_libraries(akabei_test ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} akabeicore)
add_test(akabei akabei_test)
......@@ -23,7 +23,7 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "^[Dd]ebug[Ff]ull$")
add_executable(akabei_hook_test ${akabei_hook_test_SRCS} ${akabei_hook_test_MOC_SRCS})
target_link_libraries(akabei_hook_test ${QT_QTTEST_LIBRARY} akabeicore)
target_link_libraries(akabei_hook_test ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} akabeicore)
add_test(akabei_hook_test akabei_hook_test)
......@@ -36,7 +36,7 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "^[Dd]ebug[Ff]ull$")
add_executable(akabei_group_test ${akabei_group_test_SRCS} ${akabei_group_test_MOC_SRCS})
target_link_libraries(akabei_group_test ${QT_QTTEST_LIBRARY} akabeicore)
target_link_libraries(akabei_group_test ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} akabeicore)
add_test(akabei_group_test akabei_group_test)
......@@ -49,7 +49,7 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "^[Dd]ebug[Ff]ull$")
add_executable(akabei_error_test ${akabei_error_test_SRCS} ${akabei_error_test_MOC_SRCS})
target_link_libraries(akabei_error_test ${QT_QTTEST_LIBRARY} akabeicore)
target_link_libraries(akabei_error_test ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} akabeicore)
add_test(akabei_error_test akabei_error_test)
......@@ -62,7 +62,7 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "^[Dd]ebug[Ff]ull$")
add_executable(akabei_md5sum_test ${akabei_md5sum_test_SRCS} ${akabei_md5sum_test_MOC_SRCS})
target_link_libraries(akabei_md5sum_test ${QT_QTTEST_LIBRARY} akabeicore)
target_link_libraries(akabei_md5sum_test ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} akabeicore)
add_test(akabei_md5sum_test akabei_md5sum_test)
......@@ -75,7 +75,7 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "^[Dd]ebug[Ff]ull$")
add_executable(akabei_sqlite_test ${akabei_sqlite_test_SRCS} ${akabei_sqlite_test_MOC_SRCS})
target_link_libraries(akabei_sqlite_test ${QT_QTTEST_LIBRARY} akabeicore)
target_link_libraries(akabei_sqlite_test ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} akabeicore)
add_test(akabei_sqlite_test akabei_sqlite_test)
......@@ -88,14 +88,14 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "^[Dd]ebug[Ff]ull$")
add_executable(akabei_archive_handler_test ${akabei_archive_handler_test_SRCS} ${akabei_archive_handler_test_MOC_SRCS})
target_link_libraries(akabei_archive_handler_test ${QT_QTTEST_LIBRARY} akabeicore)
target_link_libraries(akabei_archive_handler_test ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} akabeicore)
add_test(akabei_archive_handler_test akabei_archive_handler_test)
#Version test
set(akabei_version_test_SRCS akabeiversiontest.cpp)
qt4_wrap_cpp(akabei_version_test_MOC_SRCS akabeiversiontest.h)
add_executable(akabei_version_test ${akabei_version_test_SRCS} ${akabei_version_test_MOC_SRCS})
target_link_libraries(akabei_version_test ${QT_QTTEST_LIBRARY} akabeicore)
target_link_libraries(akabei_version_test ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} akabeicore)
add_test(akabei_version_test akabei_version_test)
#PolKitArchiveHandler test
......@@ -107,7 +107,7 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "^[Dd]ebug[Ff]ull$")
add_executable(akabei_polkit_archive_handler_test ${akabei_polkit_archive_handler_test_SRCS} ${akabei_polkit_archive_handler_test_MOC_SRCS})
target_link_libraries(akabei_polkit_archive_handler_test ${QT_QTTEST_LIBRARY} akabeicore)
target_link_libraries(akabei_polkit_archive_handler_test ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} akabeicore)
add_test(akabei_polkit_archive_handler_test akabei_polkit_archive_handler_test)
#PolKitSQLiteConnection test
......@@ -119,7 +119,7 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "^[Dd]ebug[Ff]ull$")
add_executable(akabei_polkit_sqliteconnection_test ${akabei_polkit_sqliteconnection_test_SRCS} ${akabei_polkit_sqliteconnection_test_MOC_SRCS})
target_link_libraries(akabei_polkit_sqliteconnection_test ${QT_QTTEST_LIBRARY} akabeicore)
target_link_libraries(akabei_polkit_sqliteconnection_test ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} akabeicore)
add_test(akabei_polkit_sqliteconnection_test akabei_polkit_sqliteconnection_test)
#Permissions test
......@@ -131,7 +131,7 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "^[Dd]ebug[Ff]ull$")
add_executable(akabei_permissions_test ${akabei_permissions_test_SRCS} ${akabei_permissions_test_MOC_SRCS})
target_link_libraries(akabei_permissions_test ${QT_QTTEST_LIBRARY} akabeicore)
target_link_libraries(akabei_permissions_test ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} akabeicore)
add_test(akabei_permissions_test akabei_permissions_test)
......
......@@ -33,6 +33,8 @@ void AkabeiVersionTest::test_data()
QTest::newRow("SameMajorMinorMaybePkgrelease") << "2.88-1" << "2.88" << 0 << 0 << false << false;
QTest::newRow("MajorMinorMaybeReleasePkgrelease") << "1.1.10-1" << "2.0-3" << 0 << 0 << true << false;
QTest::newRow("MajorMinorMaybeReleaseMaybePkgrelease") << "1.1.10-1" << "2.0" << 0 << 0 << true << false;
QTest::newRow("MajorMinorReleasePatchWithChars") << "3.1.2.p10-1" << "3.1.2.p5-2" << 0 << 0 << false << true;
QTest::newRow("MajorMinorReleasePatchWithChars") << "3.1.2.p-1" << "3.1.2.f-2" << 0 << 0 << false << true;
QTest::newRow("MajorMinorReleasePkgrelease") << "1.1.3-2" << "1.1.3-7" << 0 << 0 << true << false;
QTest::newRow("MajorMinorReleaseMaybePkgrelease") << "1.1.3" << "1.1.2-5" << 0 << 0 << false << true;
QTest::newRow("Date") << "20110711" << "20110710" << 0 << 0 << false << true;
......
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