2
/******************************************************
3
* Presage, an extensible predictive text entry system
4
* ---------------------------------------------------
6
* Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2 of the License, or
11
(at your option) any later version.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License along
19
with this program; if not, write to the Free Software Foundation, Inc.,
20
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25
#include "nGramTest.h"
27
CPPUNIT_TEST_SUITE_REGISTRATION( NgramTest );
29
void NgramTest::setUp()
31
unigramFoo = new Ngram(1);
32
unigramFoo->setNgram(0, "foo");
33
unigramBar = new Ngram(1);
34
unigramBar->setNgram(0, "bar");
36
bigramFooBar = new Ngram(2);
37
bigramFooBar->setNgram(0, "foo");
38
bigramFooBar->setNgram(1, "bar");
39
bigramBarFoo = new Ngram(2);
40
bigramBarFoo->setNgram(0, "bar");
41
bigramBarFoo->setNgram(1, "foo");
43
trigramFooBarFoobar = new Ngram(3);
44
trigramFooBarFoobar->setNgram(0, "foo");
45
trigramFooBarFoobar->setNgram(1, "bar");
46
trigramFooBarFoobar->setNgram(2, "foobar");
47
trigramBarFooBarfoo = new Ngram(3);
48
trigramBarFooBarfoo->setNgram(0, "bar");
49
trigramBarFooBarfoo->setNgram(1, "foo");
50
trigramBarFooBarfoo->setNgram(2, "barfoo");
53
void NgramTest::tearDown()
61
delete trigramFooBarFoobar;
62
delete trigramBarFooBarfoo;
65
void NgramTest::testConstructor()
68
void NgramTest::testLessOperator()
70
CPPUNIT_ASSERT( *unigramBar < *unigramFoo );
71
CPPUNIT_ASSERT( *bigramBarFoo < *bigramFooBar );
72
CPPUNIT_ASSERT( *trigramBarFooBarfoo < *trigramFooBarFoobar );
75
void NgramTest::testToString()
77
CPPUNIT_ASSERT( "<foo> " == unigramFoo->toString() );
78
CPPUNIT_ASSERT( "<bar> " == unigramBar->toString() );
79
CPPUNIT_ASSERT( "<foo> <bar> " == bigramFooBar->toString() );
80
CPPUNIT_ASSERT( "<bar> <foo> " == bigramBarFoo->toString() );
81
CPPUNIT_ASSERT( "<foo> <bar> <foobar> " == trigramFooBarFoobar->toString() );
82
CPPUNIT_ASSERT( "<bar> <foo> <barfoo> " == trigramBarFooBarfoo->toString() );