1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
#include "M6Lib.h"
#include <iostream>
#include <boost/test/unit_test.hpp>
#include <boost/filesystem/operations.hpp>
//#include <boost/timer/timer.hpp>
#include "M6Databank.h"
#include "M6Lexicon.h"
#include "M6Document.h"
#include "M6Iterator.h"
using namespace std;
namespace fs = boost::filesystem;
//BOOST_AUTO_TEST_CASE(test_databank_0)
//{
// cout << "testing pdbfinder" << endl;
//
// M6Databank databank("./test/pdbfinder.m6", eReadOnly);
// databank.Validate();
//}
BOOST_AUTO_TEST_CASE(test_databank_1)
{
cout << "testing pdbfinder" << endl;
// boost::timer::auto_cpu_timer t;
//M6Databank databank("./test/pdbfinder.m6", eReadWrite);
//databank.RecalculateDocumentWeights();
}
// test of building a databank with a IDL index
BOOST_AUTO_TEST_CASE(test_databank_2)
{
cout << "testing IDL 1" << endl;
if (fs::exists("./test/test-idl.m6"))
fs::remove_all("./test/test-idl.m6");
M6Databank databank("./test/test-idl.m6", eReadWrite);
M6Lexicon lexicon;
databank.StartBatchImport(lexicon);
string text("eerste aap noot mies, boom roos vis. vuur & water");
M6InputDocument* doc = new M6InputDocument(databank, text);
for (int i = 0; i < 100; ++i)
doc->Index("text", eM6TextData, false, text.c_str(), text.length());
doc->Tokenize(lexicon, 0);
doc->Compress();
databank.Store(doc);
text = "tweede document aap noot mies, boom roos vis. vuur & water.";
doc = new M6InputDocument(databank, text);
for (int i = 0; i < 100; ++i)
doc->Index("text", eM6TextData, false, text.c_str(), text.length());
doc->Tokenize(lexicon, 0);
doc->Compress();
databank.Store(doc);
databank.CommitBatchImport();
}
// test of building a databank with a IDL index
BOOST_AUTO_TEST_CASE(test_databank_3)
{
cout << "testing IDL 2" << endl;
M6Databank databank("./test/test-idl.m6", eReadOnly);
M6Iterator* iter = databank.FindString("text", "aap noot mies");
BOOST_CHECK(iter != nullptr);
uint32 docNr;
float rank;
BOOST_CHECK_EQUAL(iter->Next(docNr, rank), true);
BOOST_CHECK_EQUAL(docNr, 1);
BOOST_CHECK_EQUAL(iter->Next(docNr, rank), true);
BOOST_CHECK_EQUAL(docNr, 2);
BOOST_CHECK_EQUAL(iter->Next(docNr, rank), false);
delete iter;
iter = databank.FindString("text", "vuur & water");
BOOST_CHECK(iter != nullptr);
BOOST_CHECK_EQUAL(iter->Next(docNr, rank), true);
BOOST_CHECK_EQUAL(docNr, 1);
BOOST_CHECK_EQUAL(iter->Next(docNr, rank), true);
BOOST_CHECK_EQUAL(docNr, 2);
BOOST_CHECK_EQUAL(iter->Next(docNr, rank), false);
delete iter;
}
|