Cambridge SMT System
wordmapper.gtest.cpp
Go to the documentation of this file.
1
// Licensed under the Apache License, Version 2.0 (the "License");
2
// you may not use these files except in compliance with the License.
3
// You may obtain a copy of the License at
4
//
5
// http://www.apache.org/licenses/LICENSE-2.0
6
//
7
// Unless required by applicable law or agreed to in writing, software
8
// distributed under the License is distributed on an "AS IS" BASIS,
9
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
// See the License for the specific language governing permissions and
11
// limitations under the License.
12
13
// Copyright 2012 - Gonzalo Iglesias, AdriĆ de Gispert, William Byrne
14
21
#include <
googletesting.h
>
22
23
#ifndef GMAINTEST
24
#include "
main.custom_assert.hpp
"
25
#include "
main.logger.hpp
"
26
#endif
27
28
#include "
wordmapper.hpp
"
29
31
TEST
( wordmapper , basic_test ) {
32
std::stringstream ss;
33
ss <<
"hey\t0\n"
;
34
ss <<
"ho\t1\n"
;
35
ss <<
"silver\t2\n"
;
36
uu::iszfstream
x ( ss );
37
uu::WordMapper
wm ( x,
true
);
38
std::string mapped;
39
wm (
"0 1 2"
, &mapped );
40
EXPECT_EQ ( mapped,
"hey ho silver"
);
41
wm (
""
, &mapped );
42
EXPECT_EQ ( mapped,
""
);
43
wm (
"hey ho silver"
, &mapped,
true
);
44
EXPECT_EQ ( mapped,
"0 1 2"
);
45
wm (
""
, &mapped,
true
);
46
EXPECT_EQ ( mapped,
""
);
47
}
48
49
#ifndef GMAINTEST
50
51
int
main
(
int
argc,
char
**argv ) {
52
::testing::InitGoogleTest ( &argc, argv );
53
return
RUN_ALL_TESTS();
54
}
55
#endif
TEST
TEST(wordmapper, basic_test)
Basic test over WordMapper class.
Definition:
wordmapper.gtest.cpp:31
main.logger.hpp
Static variables for logger. Include only once from main file.
ucam::util::WordMapper
Loads efficiently a wordmap file and provides methods to map word-to-integer or integer-to-word. To avoid memory footprint issues, hashing the wordmap entries is avoided.
Definition:
wordmapper.hpp:63
wordmapper.hpp
class WordMapper
main
int main(int argc, char **argv)
Definition:
wordmapper.gtest.cpp:51
ucam::util::iszfstream
Wrapper stream class that reads pipes, text files or gzipped files.
Definition:
szfstream.hpp:34
googletesting.h
Unit testing: google testing common header.
main.custom_assert.hpp
Static variable for custom_assert. Include only once from main file.
ucam-smt
cpp
tests
wordmapper.gtest.cpp
Generated on Wed May 25 2016 10:26:01 for Cambridge SMT System by
1.8.11