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

test-stringpool.C

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

int
main() {
try {
  static const string ifn("stringpool.C");
  
  ifstream ifs(ifn.c_str());

  set<string>   words;
  StringPool    pool;
  
  Word  w;
  while (ifs>>w) 
    words.insert(*pool[w.str()]);

  set<string>::iterator i = words.begin();
  StringPool::iterator j = pool.begin();
  if (words.size() != pool.size() )
    throw runtime_error("Sizes are different");
  for ( ; i!= words.end() && j != words.end(); ++i, ++j)
    if (*i != **j )
      throw runtime_error(*i + " != " + **j);
  }
catch (exception& e) {
  cerr << e.what() << endl;
  return 1;
  }
return 0;
}

textindexer-0.2 [27 March, 2002]