summaryrefslogtreecommitdiff
path: root/utils/dict_test.cc
blob: dac65de106bab8d28a90749ee2d222c017735fc0 (plain)
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
#include "dict.h"

#include "fdict.h"

#include <iostream>
#define BOOST_TEST_MODULE CrpTest
#include <boost/test/unit_test.hpp>
#include <boost/test/floating_point_comparison.hpp>
#include <cassert>

using namespace std;

BOOST_AUTO_TEST_CASE(Convert) {
  Dict d;
  WordID a = d.Convert("foo");
  WordID b = d.Convert("bar");
  std::string x = "foo";
  WordID c = d.Convert(x);
  assert(a != b);
  BOOST_CHECK_EQUAL(a, c);
  BOOST_CHECK_EQUAL(d.Convert(a), "foo");
  BOOST_CHECK_EQUAL(d.Convert(b), "bar");
}

BOOST_AUTO_TEST_CASE(FDictTest) {
  int fid = FD::Convert("First");
  assert(fid > 0);
  BOOST_CHECK_EQUAL(FD::Convert(fid), "First");
  string x = FD::Escape("=");
  cerr << x << endl;
  assert(x != "=");
  x = FD::Escape(";");
  cerr << x << endl;
  assert(x != ";");
}