Newer
Older
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
#include <boost/test/unit_test.hpp>
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <libwccl/ops/constant.h>
#include <libwccl/variables.h>
#include <libwccl/values/bool.h>
#include <libwccl/sentencecontext.h>
using namespace Wccl;
BOOST_AUTO_TEST_SUITE(constant)
struct BoolFix
{
BoolFix()
: sc(boost::make_shared<Corpus2::Sentence>()),
tagset(),
true_value(true),
false_value(false),
true_constant(true_value),
false_constant(false_value)
{
}
SentenceContext sc;
Corpus2::Tagset tagset;
Bool true_value;
Bool false_value;
Constant<Bool> true_constant;
Constant<Bool> false_constant;
};
BOOST_FIXTURE_TEST_CASE(bool_apply, BoolFix)
{
BOOST_CHECK_EQUAL(true, true_value.get_value());
BOOST_CHECK_EQUAL(true, true_constant.apply(sc)->get_value());
BOOST_CHECK_EQUAL(false, false_value.get_value());
BOOST_CHECK_EQUAL(false, false_constant.apply(sc)->get_value());
}
BOOST_FIXTURE_TEST_CASE(bool_to_string, BoolFix)
{
BOOST_CHECK_EQUAL("true", true_value.to_string(tagset));
BOOST_CHECK_EQUAL(true_value.to_string(tagset), true_constant.to_string(tagset));
BOOST_CHECK_EQUAL("false", false_value.to_string(tagset));
BOOST_CHECK_EQUAL(false_value.to_string(tagset), false_constant.to_string(tagset));
}
BOOST_FIXTURE_TEST_CASE(bool_to_raw_string, BoolFix)
{
BOOST_CHECK_EQUAL("true", true_value.to_raw_string());
BOOST_CHECK_EQUAL(true_value.to_raw_string(), true_constant.to_raw_string());
BOOST_CHECK_EQUAL("false", false_value.to_raw_string());
BOOST_CHECK_EQUAL(false_value.to_raw_string(), false_constant.to_raw_string());
}
BOOST_FIXTURE_TEST_CASE(bool_value_preserved, BoolFix)
{
boost::shared_ptr<Bool> v = true_constant.apply(sc);
v->set_value(false);
BOOST_CHECK_EQUAL(true, true_constant.apply(sc)->get_value());
v = false_constant.apply(sc);
v->set_value(true);
BOOST_CHECK_EQUAL(false, false_constant.apply(sc)->get_value());
}
BOOST_AUTO_TEST_SUITE_END()