Cambridge SMT System
address.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 #ifndef GMAINTEST
23 #include "main.custom_assert.hpp"
24 #include "main.logger.hpp"
25 #endif
26 
27 #include "registrypo.hpp"
28 #include "addresshandler.hpp"
29 
34 TEST ( patternaddress, test1 ) {
35  ucam::util::IntegerPatternAddress ipa ( "lm/?.lm.gz", "?" );
36  std::string aux = ipa.get ( 3 );
37  EXPECT_EQ ( aux, "lm/3.lm.gz" );
38  aux = ipa ( 3 );
39  EXPECT_EQ ( aux, "lm/3.lm.gz" );
40  aux = ipa();
41  EXPECT_EQ ( aux, "lm/?.lm.gz" );
42 }
43 
47 TEST ( patternaddress, test2 ) {
48  ucam::util::IntegerPatternAddress ipa ( "expecto.fst", "?" );
49  std::string aux = ipa.get ( 3 );
50  EXPECT_EQ ( aux, "expecto.fst" );
51  aux = ipa ( 3 );
52  EXPECT_EQ ( aux, "expecto.fst" );
53  aux = ipa();
54  EXPECT_EQ ( aux, "expecto.fst" );
55 }
56 
61 TEST ( patternaddress, test3 ) {
62  ucam::util::IntegerPatternAddress ipa ( "", "?" );
63  std::string aux = ipa.get ( 3 );
64  EXPECT_EQ ( aux, "" );
65  aux = ipa ( 3 );
66  EXPECT_EQ ( aux, "" );
67  aux = ipa();
68  EXPECT_EQ ( aux, "" );
69 }
70 
71 #ifndef GMAINTEST
72 
78 int main ( int argc, char **argv ) {
79  ::testing::InitGoogleTest ( &argc, argv );
80  return RUN_ALL_TESTS();
81 }
82 #endif
Handles simple wildcard expansion for strings.
class that expands a wildcard into its actual value. This is useful e.g. for filenames ranging severa...
int main(int argc, char **argv)
main function. If compiled individualy, will kickoff any tests in this file.
Static variables for logger. Include only once from main file.
Contains wrapper class RegistryPO, which uses boost::program_options to parse parameters, and provides methods to access them.
TEST(patternaddress, test1)
Tests wildcard expansion with an integer.
const std::string get(T idx)
Expands string and returns.
Unit testing: google testing common header.
Static variable for custom_assert. Include only once from main file.