/* * Copyright (c) 2002 by Cliff Green. All rights reserved. Individual files * may be covered by other copyrights (as noted in the file itself). * * Redistribution and use in source and binary forms are permitted * provided that this entire copyright notice is duplicated in all such * copies. * * This software is provided "as is" and without any expressed or implied * warranties, including, without limitation, the implied warranties of * merchantibility and fitness for any particular purpose. */ //---------------------------------------------------------------------- // Source file: tstword.cpp // Written by: Cliff Green, 2002 // Compiler: Metrowerks CodeWarrior Pro 6, g++ 3.0.4 // History: // Modified: Mar. 5, 2002 // By: Cliff Green // Comments: Word class test application. //---------------------------------------------------------------------- // This commentheader supports documentation tools such as Doc++ and // Doxygen: http://www.doxygen.org/ //---------------------------------------------------------------------- /// Simple test harness for Word class (and related utility functions). /** * */ #include "word.h" #include int main(int argc, char* argv[]) { if (argc <= 1) { std::cout << "At least one command line argument must be entered." << std::endl; return 0; } // first create Word objects from each command line argument for (int i (1); i < argc; ++i) { Word w(argv[i]); std::cout << "\n\nArg[" << i << "], word: "; w.debugPrint(); std::cout << "Comparing with first word: "; Word* w1 (new Word(argv[1])); if (w == *w1) { std::cout << "Words are equal" << std::endl; } else { std::cout << "Words are not equal" << std::endl; } std::cout << "Soundexes " << (w.isSoundexSame(*w1) ? "are " : "are not ") << "the same" << std::endl; std::cout << "Word " << (w < *w1 ? "less than " : "not less than ") << "Word 1" << std::endl; std::cout << "Compare of word and word 1: " << w.compare(*w1) << std::endl; // ok, now let's test the copy ctor and copy assign op { Word newWord(w); std::cout << "Copy constructed word: " << newWord << std::endl; newWord = *w1; std::cout << "After assignment: " << newWord << std::endl; } delete w1; // end of block - if Word didn't have copy ctor or assigment, big // logic bug at this spot } return 0; }