32 namespace bfs = boost::filesystem;
38 TEST ( FstIo, basic_test ) {
39 fst::VectorFst<fst::StdArc> aux;
43 aux.SetFinal ( 1, fst::StdArc::Weight::One() );
44 aux.AddArc ( 0, fst::StdArc ( 10, 10, 0.5, 1 ) );
45 FstWrite ( aux,
"obliviate.fst.gz" );
46 boost::scoped_ptr< fst::VectorFst<fst::StdArc> > aux2
47 (fst::VectorFstRead<fst::StdArc> (
"obliviate.fst.gz" ) );
48 EXPECT_TRUE ( Equivalent ( aux, *aux2 ) );
49 bfs::remove ( bfs::path (
"obliviate.fst.gz" ) );
50 fst::ConstFst<fst::StdArc> caux ( aux );
51 FstWrite ( caux,
"const.obliviate.fst.gz" );
52 FstWrite ( caux,
"const.obliviate.txt" );
65 bfs::remove ( bfs::path (
"const.obliviate.fst.gz" ) );
69 while (
getline ( isz, t ) ) t2 += t +
"\n";
71 EXPECT_TRUE ( t2 ==
"0\t1\t10\t10\t0.5\n1\n" 72 || t2 ==
"0\t1\t10\t0.5\n1\t0\n" );
73 bfs::remove ( bfs::path (
"const.obliviate.txt" ) );
80 int main (
int argc,
char **argv ) {
81 ::testing::InitGoogleTest ( &argc, argv );
82 return RUN_ALL_TESTS();
Unit testing: google testing common header.
Contains convenience functions to write and read fsts.
Stream wrapper for pipe/text/compressed files.
iszfstream & getline(iszfstream &izs, std::string &line)
int main(int argc, char **argv)
test-specific classes and functions
Static variables for logger. Include only once from main file.
void FstWrite(const Fst< Arc > &fst, const std::string &filename, const std::string &txtname="txt")
Templated method that writes an fst either in binary or text format.
Wrapper stream class that reads pipes, text files or gzipped files.
Unit testing: google testing common header.
Static variable for custom_assert. Include only once from main file.