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 "suggestionTest.h"
26
#include "core/suggestion.h"
30
CPPUNIT_TEST_SUITE_REGISTRATION( SuggestionTest );
32
void SuggestionTest::setUp()
34
sugg1Ptr = new Suggestion();
35
sugg2Ptr = new Suggestion( "test" );
36
sugg3Ptr = new Suggestion( "test", 0.5 );
37
sugg4Ptr = new Suggestion( "case", 0.7 );
38
sugg5Ptr = new Suggestion( "foo", 0.1 );
39
sugg6Ptr = new Suggestion( "bar", 0.3 );
40
sugg7Ptr = new Suggestion( "base", 0.7 );
41
sugg8Ptr = new Suggestion( "base", 0.7 );
44
void SuggestionTest::tearDown()
56
void SuggestionTest::testConstructor()
58
CPPUNIT_ASSERT( sugg1Ptr->getWord() == "" );
59
CPPUNIT_ASSERT( sugg1Ptr->getProbability() == 0.0 );
60
CPPUNIT_ASSERT( sugg2Ptr->getWord() == "test" );
61
CPPUNIT_ASSERT( sugg2Ptr->getProbability() == 0.0 );
62
CPPUNIT_ASSERT( sugg3Ptr->getWord() == "test" );
63
CPPUNIT_ASSERT( sugg3Ptr->getProbability() == 0.5 );
64
CPPUNIT_ASSERT( sugg4Ptr->getWord() == "case" );
65
CPPUNIT_ASSERT( sugg4Ptr->getProbability() == 0.7 );
68
void SuggestionTest::testOperatorEqual()
70
//CPPUNIT_ASSERT( *sugg2Ptr == *sugg3Ptr );
71
CPPUNIT_ASSERT( !( *sugg3Ptr == *sugg4Ptr ) );
72
CPPUNIT_ASSERT_EQUAL(*sugg7Ptr, *sugg8Ptr);
73
CPPUNIT_ASSERT_EQUAL(*sugg5Ptr, *sugg5Ptr);
76
void SuggestionTest::testOperatorNotEqual()
78
CPPUNIT_ASSERT(*sugg2Ptr != *sugg3Ptr);
79
CPPUNIT_ASSERT(*sugg3Ptr != *sugg4Ptr);
80
CPPUNIT_ASSERT(*sugg4Ptr != *sugg5Ptr);
81
CPPUNIT_ASSERT(*sugg5Ptr != *sugg6Ptr);
82
CPPUNIT_ASSERT(!(*sugg7Ptr != *sugg8Ptr));
83
CPPUNIT_ASSERT(!(*sugg5Ptr != *sugg5Ptr));
86
void SuggestionTest::testOperatorMinus()
88
CPPUNIT_ASSERT( *sugg1Ptr < *sugg2Ptr );
89
CPPUNIT_ASSERT( !( *sugg1Ptr < *sugg1Ptr ) );
90
CPPUNIT_ASSERT( *sugg2Ptr < *sugg3Ptr );
91
CPPUNIT_ASSERT( *sugg7Ptr < *sugg4Ptr );
92
CPPUNIT_ASSERT( !( *sugg4Ptr < *sugg3Ptr ) );
95
void SuggestionTest::testGetSetMethods()
97
CPPUNIT_ASSERT( sugg5Ptr->getWord() == "foo" );
98
CPPUNIT_ASSERT( sugg6Ptr->getWord() == "bar" );
99
CPPUNIT_ASSERT( sugg5Ptr->getProbability() == 0.1 );
100
CPPUNIT_ASSERT( sugg6Ptr->getProbability() == 0.3 );
102
sugg5Ptr->setWord( sugg6Ptr->getWord() );
103
CPPUNIT_ASSERT( sugg5Ptr->getWord() == sugg6Ptr->getWord() );
105
sugg5Ptr->setProbability( sugg6Ptr->getProbability() );
106
CPPUNIT_ASSERT( sugg5Ptr->getProbability() == sugg6Ptr->getProbability() );