2012-03-18 00:58:40 +04:00
|
|
|
#include "Reference.h"
|
|
|
|
|
|
|
|
#define BOOST_TEST_MODULE MertReference
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
|
2012-07-01 00:39:10 +04:00
|
|
|
using namespace MosesTuning;
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
BOOST_AUTO_TEST_CASE(refernece_count)
|
|
|
|
{
|
2012-03-18 00:58:40 +04:00
|
|
|
Reference ref;
|
|
|
|
BOOST_CHECK(ref.get_counts() != NULL);
|
|
|
|
}
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
BOOST_AUTO_TEST_CASE(refernece_length_iterator)
|
|
|
|
{
|
2012-03-18 00:58:40 +04:00
|
|
|
Reference ref;
|
|
|
|
ref.push_back(4);
|
|
|
|
ref.push_back(2);
|
|
|
|
BOOST_REQUIRE(ref.num_references() == 2);
|
|
|
|
|
|
|
|
Reference::iterator it = ref.begin();
|
|
|
|
BOOST_CHECK_EQUAL(*it, 4);
|
|
|
|
++it;
|
|
|
|
BOOST_CHECK_EQUAL(*it, 2);
|
|
|
|
++it;
|
|
|
|
BOOST_CHECK(it == ref.end());
|
|
|
|
}
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
BOOST_AUTO_TEST_CASE(refernece_length_average)
|
|
|
|
{
|
2012-03-18 00:58:40 +04:00
|
|
|
{
|
|
|
|
Reference ref;
|
|
|
|
ref.push_back(4);
|
|
|
|
ref.push_back(1);
|
|
|
|
BOOST_CHECK_EQUAL(2, ref.CalcAverage());
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Reference ref;
|
|
|
|
ref.push_back(4);
|
|
|
|
ref.push_back(3);
|
|
|
|
BOOST_CHECK_EQUAL(3, ref.CalcAverage());
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Reference ref;
|
|
|
|
ref.push_back(4);
|
|
|
|
ref.push_back(3);
|
|
|
|
ref.push_back(4);
|
|
|
|
ref.push_back(5);
|
|
|
|
BOOST_CHECK_EQUAL(4, ref.CalcAverage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
BOOST_AUTO_TEST_CASE(refernece_length_closest)
|
|
|
|
{
|
2012-03-18 00:58:40 +04:00
|
|
|
{
|
|
|
|
Reference ref;
|
|
|
|
ref.push_back(4);
|
|
|
|
ref.push_back(1);
|
|
|
|
BOOST_REQUIRE(ref.num_references() == 2);
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(1, ref.CalcClosest(2));
|
|
|
|
BOOST_CHECK_EQUAL(1, ref.CalcClosest(1));
|
|
|
|
BOOST_CHECK_EQUAL(4, ref.CalcClosest(3));
|
|
|
|
BOOST_CHECK_EQUAL(4, ref.CalcClosest(4));
|
|
|
|
BOOST_CHECK_EQUAL(4, ref.CalcClosest(5));
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Reference ref;
|
|
|
|
ref.push_back(4);
|
|
|
|
ref.push_back(3);
|
|
|
|
BOOST_REQUIRE(ref.num_references() == 2);
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(3, ref.CalcClosest(1));
|
|
|
|
BOOST_CHECK_EQUAL(3, ref.CalcClosest(2));
|
|
|
|
BOOST_CHECK_EQUAL(3, ref.CalcClosest(3));
|
|
|
|
BOOST_CHECK_EQUAL(4, ref.CalcClosest(4));
|
|
|
|
BOOST_CHECK_EQUAL(4, ref.CalcClosest(5));
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Reference ref;
|
|
|
|
ref.push_back(4);
|
|
|
|
ref.push_back(3);
|
|
|
|
ref.push_back(4);
|
|
|
|
ref.push_back(5);
|
|
|
|
BOOST_REQUIRE(ref.num_references() == 4);
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(3, ref.CalcClosest(1));
|
|
|
|
BOOST_CHECK_EQUAL(3, ref.CalcClosest(2));
|
|
|
|
BOOST_CHECK_EQUAL(3, ref.CalcClosest(3));
|
|
|
|
BOOST_CHECK_EQUAL(4, ref.CalcClosest(4));
|
|
|
|
BOOST_CHECK_EQUAL(5, ref.CalcClosest(5));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
BOOST_AUTO_TEST_CASE(refernece_length_shortest)
|
|
|
|
{
|
2012-03-18 00:58:40 +04:00
|
|
|
{
|
|
|
|
Reference ref;
|
|
|
|
ref.push_back(4);
|
|
|
|
ref.push_back(1);
|
|
|
|
BOOST_CHECK_EQUAL(1, ref.CalcShortest());
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Reference ref;
|
|
|
|
ref.push_back(4);
|
|
|
|
ref.push_back(3);
|
|
|
|
BOOST_CHECK_EQUAL(3, ref.CalcShortest());
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Reference ref;
|
|
|
|
ref.push_back(4);
|
|
|
|
ref.push_back(3);
|
|
|
|
ref.push_back(4);
|
|
|
|
ref.push_back(5);
|
|
|
|
BOOST_CHECK_EQUAL(3, ref.CalcShortest());
|
|
|
|
}
|
|
|
|
}
|