00001
00002
00003
00004
00005
00006
00007 #ifndef testTableDataSourceCSV_h
00008 #define testTableDataSourceCSV_h
00009
00010 #define BOOST_TEST_MODULE MediaTableTestSuite
00011 #include "boost/test/unit_test.hpp"
00012
00013 #include "testTableDataSource.h"
00014
00015 #include "../TableDataSourceCSV.h"
00016 #include "../TableColumn.h"
00017
00018 #include "../TableDataView.h"
00019
00020 typedef Impala::Application::MediaTable::TableDataSource TableDataSource;
00021 typedef Impala::Application::MediaTable::TableDataSourceCSV TableDataSourceCSV;
00022 typedef Impala::Application::MediaTable::TableDataView TableDataView;
00023
00024 BOOST_AUTO_TEST_SUITE( TableDataSourceCSVTests )
00025
00026 struct TableDataSourceCSVFixture {
00027 TableDataSourceCSVFixture(std::string filename = "data.csv")
00028 {
00029 std::ifstream is(filename.c_str());
00030
00031 BOOST_REQUIRE(is.good());
00032 is.close();
00033
00034 src = new TableDataSourceCSV(filename);
00035 }
00036
00037 TableDataSource* src;
00038 };
00039
00040 BOOST_FIXTURE_TEST_CASE (TableDataSourceCSVTest, TableDataSourceCSVFixture) {
00041 BOOST_REQUIRE(src);
00042
00043 BOOST_CHECK_GT(src->GetTotalRows(), 0);
00044
00045 TableDataSourceTests::IsValidTableDataSourceTest(src);
00046
00047 for(int col=0; col < src->GetColumns(true, true).size(); col++) {
00048 BOOST_CHECK_GT(src->GetColumns(true, true)[col]->GetName().length(), 0);
00049 }
00050 for(int row=0; row < src->GetTotalRows(); row++) {
00051 for(int col=0; col < src->GetColumns(true, true).size(); col++) {
00052 if(src->GetColumns(true, true)[col]->GetType() == TableDataSource::TYPE_INT)
00053 BOOST_CHECK_GE(src->GetIntDataByID(src->GetColumns(true, true)[col]->GetName(), row), 0);
00054 }
00055 }
00056
00057 BOOST_CHECK_EQUAL(src->GetColumns(true, true).size(), 29);
00058 BOOST_CHECK_EQUAL(src->GetTotalRows(), 18371);
00059
00060
00061 }
00062
00063 BOOST_FIXTURE_TEST_CASE (TableDataSourceCSVViewTest, TableDataSourceCSVFixture) {
00064 BOOST_REQUIRE(src);
00065 TableDataView* view = new TableDataView(src);
00066 BOOST_REQUIRE(view);
00067
00068 BOOST_CHECK_EQUAL(view->GetColumns(true, true).size(), 29);
00069 BOOST_CHECK_EQUAL(view->GetTotalRows(), 18371);
00070
00071 }
00072
00073 BOOST_AUTO_TEST_SUITE_END()
00074
00075 #endif // testTableDataSourceCSV_h