diff options
Diffstat (limited to 'src/svnqt/cache/test')
-rw-r--r-- | src/svnqt/cache/test/CMakeLists.txt | 19 | ||||
-rw-r--r-- | src/svnqt/cache/test/sqlite.cpp | 111 | ||||
-rw-r--r-- | src/svnqt/cache/test/testconfig.h.in | 8 |
3 files changed, 138 insertions, 0 deletions
diff --git a/src/svnqt/cache/test/CMakeLists.txt b/src/svnqt/cache/test/CMakeLists.txt new file mode 100644 index 0000000..ecc6130 --- /dev/null +++ b/src/svnqt/cache/test/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) + +MACRO(BUILD_TEST tname) + SET(${tname}-src ${tname}.cpp) + IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${tname}.h) + SET(${tname}-src ${${tname}-src} ${tname}.h) + ENDIF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${tname}.h) + ADD_EXECUTABLE(${tname} ${${tname}-src}) + TARGET_LINK_LIBRARIES(${tname} ${svnqt-name} ${QT_LIBRARIES}) + ADD_TEST(${tname} ${CMAKE_CURRENT_BINARY_DIR}/${tname}) +ENDMACRO(BUILD_TEST) + +IF (BUILD_TESTS) + CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/testconfig.h.in + ${CMAKE_CURRENT_BINARY_DIR}/testconfig.h + ) + BUILD_TEST(sqlite) +ENDIF(BUILD_TESTS) diff --git a/src/svnqt/cache/test/sqlite.cpp b/src/svnqt/cache/test/sqlite.cpp new file mode 100644 index 0000000..4f14b2d --- /dev/null +++ b/src/svnqt/cache/test/sqlite.cpp @@ -0,0 +1,111 @@ +#include <qsql.h> +#include <qsqldatabase.h> +#include <qstringlist.h> +#include <iostream> +#include <qapplication.h> +#include <qtextstream.h> + +#include "svnqt/client.hpp" +#include "svnqt/svnqttypes.hpp" +#include "svnqt/log_entry.hpp" + +#include "svnqt/cache/LogCache.hpp" +#include "svnqt/cache/ReposLog.hpp" +#include "svnqt/cache/test/testconfig.h" +#include "svnqt/cache/DatabaseException.hpp" + +#if QT_VERSION < 0x040000 +#else +#include <QSqlQuery> +#include <QSqlError> +#endif + +int main(int argc,char**argv) +{ + QApplication app(argc,argv); + + svn::ContextP m_CurrentContext; + svn::Client* m_Svnclient; + m_Svnclient=svn::Client::getobject(0,0); + m_CurrentContext = new svn::Context(); + + m_Svnclient->setContext(m_CurrentContext); + + QStringList list; + QStringList::Iterator it; + // goes into "self" of logcache + new svn::cache::LogCache(TESTDBPATH); + list = QSqlDatabase::drivers(); + it = list.begin(); + while( it != list.end() ) { + std::cout << (*it).TOUTF8().data() << std::endl; + ++it; + } + svn::cache::ReposLog rl(m_Svnclient,"http://www.alwins-world.de/repos/kdesvn"); + QDataBase db = rl.Database(); +#if QT_VERSION < 0x040000 + if (!db) { +#else + if (!db.isValid()) { +#endif + std::cerr << "No database object."<<std::endl; + exit(-1); + } +#if QT_VERSION < 0x040000 + list = db->tables(); +#else + list = db.tables(); +#endif + it = list.begin(); + while( it != list.end() ) { + std::cout << ( *it ).TOUTF8().data() << std::endl; + ++it; + } + svn::LogEntriesMap lm; + try { + rl.simpleLog(lm,100,svn::Revision::HEAD); + } + catch (const svn::cache::DatabaseException&cl) + { + std::cerr << cl.msg().TOUTF8().data() <<std::endl; + } + catch (const svn::Exception&ce) + { + std::cerr << "Exception: " << ce.msg().TOUTF8().data() <<std::endl; + } + svn::LogEntriesMap::ConstIterator lit = lm.begin(); + std::cout<<"Count: "<<lm.count()<<std::endl; + + svn::Revision r("{2006-09-27}"); + std::cout << r.toString().TOUTF8().data() << " -> " << rl.date2numberRev(r).toString().TOUTF8().data()<<std::endl; + r = svn::Revision::HEAD; + std::cout << rl.date2numberRev(r).toString().TOUTF8().data()<<std::endl; + try { + rl.insertLogEntry(lm[100]); + } + catch (const svn::cache::DatabaseException&cl) + { + std::cerr << cl.msg().TOUTF8().data() << std::endl; + } + QSqlQuery q("insert into logentries(revision,date,author,message) values ('100','1122591406','alwin','copy and moving works now in basic form')",db); + q.exec(); + std::cerr << "\n" << q.lastError().text().TOUTF8().data()<<std::endl; + +#if QT_VERSION < 0x040000 +#else + db=QSqlDatabase(); +#endif + try { + rl.log("/trunk/src/svnqt",1,1000,svn::Revision::UNDEFINED,lm,false,-1); + } + catch (const svn::cache::DatabaseException&cl) + { + std::cerr << cl.msg().TOUTF8().data() <<std::endl; + } + catch (const svn::Exception&ce) + { + std::cerr << "Exception: " << ce.msg().TOUTF8().data() <<std::endl; + } + std::cout<<"Count: "<<lm.count()<<std::endl; + return 0; +} diff --git a/src/svnqt/cache/test/testconfig.h.in b/src/svnqt/cache/test/testconfig.h.in new file mode 100644 index 0000000..865ac6e --- /dev/null +++ b/src/svnqt/cache/test/testconfig.h.in @@ -0,0 +1,8 @@ +#ifndef __TEST_CONFIG_H +#define __TEST_CONFIG_H + +#define TESTREPOPATH "@CMAKE_CURRENT_BINARY_DIR@/repo" +#define TESTCOPATH "@CMAKE_CURRENT_BINARY_DIR@/co" +#define TESTDBPATH "@CMAKE_CURRENT_BINARY_DIR@/db" + +#endif |