Initial import from SVN

This commit is contained in:
emeric
2014-03-09 10:58:52 +01:00
commit b6abce0c2f
440 changed files with 30862 additions and 0 deletions
+87
View File
@@ -0,0 +1,87 @@
#include <boost/foreach.hpp>
#include <boost/filesystem.hpp>
#include "database/DatabaseHandler.hpp"
#include "database/FileTypes.hpp"
int main(void)
{
try {
boost::filesystem::remove("test2.db");
// Set up the long living database session
DatabaseHandler database("test2.db");
Wt::Dbo::Transaction transaction(database.getSession());
std::cout << "Creating objects..." << std::endl;
assert( Path::getRoots(database.getSession()).empty() );
Path::pointer parentPath = database.getSession().add(new Path("/PARENT") );
assert( Path::getRoots(database.getSession()).size() == 1);
for (std::size_t i = 0; i < 5; ++i)
{
std::ostringstream oss; oss << "/PARENT/toto" << i << ".mp4";
Path::pointer childPath = database.getSession().add(new Path( oss.str()) );
{
std::ostringstream oss; oss << "/PARENT/toto" << i << "_dir";
Path::pointer childDirPath = database.getSession().add(new Path( oss.str()) );
for (std::size_t j = 0; j < 6; ++j) {
std::ostringstream oss2; oss2 << "/PARENT/toto" << i << "_dir/" << j << ".mp4";
Path::pointer childPath2 = database.getSession().add(new Path( oss2.str()) );
childDirPath.modify()->addChild( childPath2 );
}
childDirPath.modify()->addChild( childDirPath );
}
parentPath.modify()->addChild( childPath );
assert( childPath->getParent());
}
{
std::vector<Path::pointer> roots = Path::getRoots(database.getSession());
std::cout << "There are now " << roots.size() << " roots!" << std::endl;
BOOST_FOREACH(Path::pointer root, roots)
{
std::cout << "ROOT Path = " << root->getPath() << std::endl;
}
}
assert( !parentPath->getParent() );
std::cout << "PRINT objects..." << std::endl;
std::vector< Path::pointer > pathes = parentPath->getChilds();
BOOST_FOREACH(Path::pointer path, pathes)
{
std::cout << "Found a child: " << path->getPath() << std::endl;
std::cout << "Parent's = " << path->getParent()->getPath() << std::endl;
}
// make some empty root dirs
transaction.commit();
}
catch(std::exception& e)
{
std::cerr << "Caught exception " << e.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
+47
View File
@@ -0,0 +1,47 @@
#include <iostream>
#include <stdexcept>
#include <cstdlib>
#include <cassert>
#include "database/SqlQuery.hpp"
int main(void)
{
try {
SqlQuery query;
query.select().And( SelectStatement("artist.name")).And( SelectStatement("track.name"));
query.from().And( FromClause("artist") ).And( FromClause("track"));
query.where().And( WhereClause("artist.id = track.artist_id") );
std::cout << "Query = '" << query.get() << "'" << std::endl;
assert(query.get() == "SELECT artist.name,track.name FROM artist,track WHERE (artist.id = track.artist_id)");
{
WhereClause clause;
clause.Or(WhereClause("artist.name = ?").bind("Sepultura1"));
clause.Or(WhereClause("artist.name = ?").bind("Sepultura2"));
clause.Or(WhereClause("artist.name = ?")).bind("Sepultura3");
query.where().And(clause);
assert(query.get() == "SELECT artist.name,track.name FROM artist,track WHERE (artist.id = track.artist_id) AND ((artist.name = ?) OR (artist.name = ?) OR (artist.name = ?))");
assert(query.where().getBindArgs().size() == 3);
std::cout << "Query = '" << query.get() << "'" << std::endl;
}
}
catch(std::exception& e)
{
std::cerr << "Caught exception " << e.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
+42
View File
@@ -0,0 +1,42 @@
#include <iostream>
#include <stdexcept>
#include <cstdlib>
#include <boost/foreach.hpp>
#include "database/DatabaseHandler.hpp"
#include "database/AudioTypes.hpp"
int main(void)
{
try {
std::cout << "Starting test!" << std::endl;
// Set up the long living database session
DatabaseHandler database("test.db");
Wt::Dbo::Transaction transaction(database.getSession());
Wt::Dbo::collection< Track::pointer > tracks (Track::getAll( database.getSession() ));
std::cout << "Found " << tracks.size() << " tracks!" << std::endl;
BOOST_FOREACH(Track::pointer track, tracks ) {
assert( !track->getName().empty() );
assert( track->getArtist() );
assert( track->getRelease() );
assert( !track->getGenres().empty() );
assert( !track->getDuration().is_not_a_date_time() );
}
}
catch(std::exception& e)
{
std::cerr << "Caught exception " << e.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
+38
View File
@@ -0,0 +1,38 @@
TESTS = database-integrity sql-query database-basics
check_PROGRAMS = database-integrity sql-query database-basics
database_integrity_SOURCES = \
$(srcdir)/DatabaseIntegrity.cpp \
$(top_srcdir)/database/Artist.cpp \
$(top_srcdir)/database/Genre.cpp \
$(top_srcdir)/database/Release.cpp \
$(top_srcdir)/database/Track.cpp \
$(top_srcdir)/database/DatabaseHandler.cpp \
$(top_srcdir)/database/Path.cpp \
$(top_srcdir)/database/Video.cpp \
$(top_srcdir)/database/Checksum.cpp
database_integrity_CXXFLAGS=-std=c++11 -Wall -Wextra -I$(top_srcdir)
database_basics_SOURCES = \
$(srcdir)/CheckDatabaseBasics.cpp \
$(top_srcdir)/database/Artist.cpp \
$(top_srcdir)/database/Genre.cpp \
$(top_srcdir)/database/Release.cpp \
$(top_srcdir)/database/Track.cpp \
$(top_srcdir)/database/DatabaseHandler.cpp \
$(top_srcdir)/database/Path.cpp \
$(top_srcdir)/database/Video.cpp \
$(top_srcdir)/database/Checksum.cpp
database_basics_CXXFLAGS=-std=c++11 -Wall -Wextra -I$(top_srcdir)
sql_query_SOURCES = \
$(srcdir)/CheckSqlQuery.cpp \
$(top_srcdir)/database/SqlQuery.cpp
sql_query_CXXFLAGS=-std=c++11 -Wall -Wextra -I$(top_srcdir)
+1264
View File
File diff suppressed because it is too large Load Diff
Executable
BIN
View File
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
Starting test!
Cannot create tables: Sqlite3: create table "genre" (
"id" integer primary key autoincrement,
"version" integer not null,
"name" text not null
)
: table "genre" already exists
Found 7751 tracks!
database: ./DatabaseTest.cpp:26: int main(): Assertion `0' failed.
+4
View File
@@ -0,0 +1,4 @@
:test-result: FAIL
:global-test-result: FAIL
:recheck: yes
:copy-in-global-log: yes
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.