forked from opencog/cogutil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rankingUTest.cxxtest
45 lines (39 loc) · 1.42 KB
/
rankingUTest.cxxtest
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
/** rankUTest.cxxtest ---
*
* Copyright (C) 2012 Nil Geisweiller
*
* Author: Nil Geisweiller <nilg@desktop>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License v3 as
* published by the Free Software Foundation and including the exceptions
* at http://opencog.org/wiki/Licenses
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program; if not, write to:
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <opencog/util/ranking.h>
using namespace opencog;
using namespace std;
class rankingUTest : public CxxTest::TestSuite
{
public:
rankingUTest() {
// logger().setPrintToStdoutFlag(true);
// logger().setLevel(Logger::FINE);
}
void test_ranking() {
Counter<string, float> c(vector<string>({"a", "a", "a", "b", "b", "c"}));
Counter<string, float> expected_rank = { {"a", 2}, {"b", 4.5}, {"c", 6} };
Counter<string, float> c_rank = ranking(c);
cout << endl << c_rank << endl;
TS_ASSERT_EQUALS(c_rank, expected_rank);
}
};