/*
 * Test program for the class FileName
 *
 * $Date$
 * $Revision$
 *
 */

#ifdef NDEBUG
#undef NDEBUG
#endif /* NDEBUG */

#include "WImage/FileName.hh"
#include "WImage/miscdefs.h"
#include <cassert>
#include <cstring>
#include <iostream>

#if !(defined __WATCOMC__ && __WATCOMC__ < 1230)
using namespace std;
#endif

int
main (void)
{
  cout << "Testing class FileName...\n";

  FileName *name = NEW (FileName ("/usr/src/x.c"));
  cout << name->dir () << name->base () << name->ext () << endl;
  assert (strcmp (name->dir (), "/usr/src/") == 0);
  assert (strcmp (name->base (), "x") == 0);
  assert (strcmp (name->ext (), ".c") == 0);
  cout << (int)name->guess () << endl;
  assert (name->guess () == fn_unknown);
  assert (name->dos () == false);
  name->toext (".pgM");
  assert (name->guess () == fn_pgm);
  name->toext (".RAW");
  assert (name->guess () == fn_raw);
#ifdef PFI
  name->toext (".PfI");
  assert (name->guess () == fn_pfi);
#endif
  DELETE (name);
  
  name = NEW (FileName ("e:\\usr\\src/x.c"));
  cout << name->dir () << name->base () << name->ext () << endl;
  assert (strcmp (name->dir (), "e:\\usr\\src/") == 0);
  assert (strcmp (name->base (), "x") == 0);
  assert (strcmp (name->ext (), ".c") == 0);
  assert (name->guess () == fn_unknown);
  assert (name->dos () == true);
  name->toext (".");
  cout << name->dir () << name->base () << name->ext () << endl;
  assert (name->guess () == fn_unknown);
  name->toext ("");
  cout << name->dir () << name->base () << name->ext () << endl;
  assert (name->guess () == fn_unknown);
  DELETE (name);

  cout << "Test of class FileName completed successfully.\n";
  return 0;
}
