Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Examples  

test-word.C

The following program tests the Word class.

// $Id: test-word.C,v 1.1.1.1 2002/03/24 12:37:03 dvermeir Exp $
#include <fstream>
#include <list>
#include "word.h"

int
main() {
static const string ifn("test-word.C");
static const string ofn("test-word.words");
list<Word>      words;
{
ifstream ifs(ifn.c_str());
ofstream ofs(ofn.c_str());

Word    w;
while (ifs>>w) {
  words.push_back(w);
  ofs << w.str() << endl;
  }
}

{
ifstream ifs(ofn.c_str());
Word    w;
for (list<Word>::const_iterator i=words.begin(); (ifs>>w) ; ++i) 
  if (*i!=w) {
    cerr << w.str() << " not found, expected " << i->str() << endl;
    return 1;
    }
}
return 0;
}

textindexer-0.2 [27 March, 2002]