// file: $isip/class/pr/LanguageModelJSGF/lmjsgf_02.cc // version: $Id: lmjsgf_02.cc 10549 2006-04-11 18:52:44Z suh $ // ISIP include files // #include "LanguageModelJSGF.h" // method: diagnose // // arguments: // Integral::DEBUG level: (input) debug level for diagnostics // // return: a bool8 value indicating status // bool8 LanguageModelJSGF::diagnose(Integral::DEBUG level_a) { //--------------------------------------------------------------------------- // // 0. preliminaries // //--------------------------------------------------------------------------- // output the class name // if (level_a > Integral::NONE) { SysString output(L"diagnosing class "); output.concat(CLASS_NAME); output.concat(L": "); Console::put(output); Console::increaseIndention(); } //-------------------------------------------------------------------------- // // 1. required public methods // //-------------------------------------------------------------------------- // set indention // if (level_a > Integral::NONE) { Console::put(L"testing required public methods...\n"); Console::increaseIndention(); } // test constructor // LanguageModelJSGF lmjsgf; // test debug methods // if (level_a > Integral::BRIEF) { Console::put(L"testing debug method..."); } // load grammar file // Filename model_file_a; model_file_a.assign(L"diagnose_grammar_jsgf.sof"); Sof lm_jsgf_file; lm_jsgf_file.open(model_file_a, File::READ_ONLY); // test read methods // if (level_a > Integral::BRIEF) { Console::put(L"testing read method..."); } if(!lmjsgf.read(lm_jsgf_file,0)){ return Error::handle(name(), L"read", Error::TEST, __FILE__, __LINE__); } lm_jsgf_file.close(); LanguageModelJSGF lmjsgf2; // test assign method // if(!(lmjsgf2.assign(lmjsgf))) { return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__); } if (level_a > Integral::BRIEF) { Console::put(L"testing assign method..."); } // test eq method // if(!lmjsgf2.eq(lmjsgf)) { return Error::handle(name(), L"eq", Error::TEST, __FILE__, __LINE__); } if (level_a > Integral::BRIEF) { Console::put(L"testing eq method..."); } // test clear method // if(!lmjsgf2.clear()) { return Error::handle(name(), L"clear", Error::TEST, __FILE__, __LINE__); } if (level_a > Integral::BRIEF) { Console::put(L"testing clear method..."); } // reset indention // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //-------------------------------------------------------------------------- // // 2. class-specific public methods: // //-------------------------------------------------------------------------- // set indention // if (level_a > Integral::NONE) { Console::put(L"testing class specific public methods...\n"); Console::increaseIndention(); } lmjsgf2.setJSGFGrammars(lmjsgf.getJSGFGrammars()); lmjsgf2.clear(); lmjsgf2.setABNFRuleModel(lmjsgf.getABNFRuleModel()); lmjsgf2.clear(); lmjsgf2.setRuleModel(lmjsgf.getRuleModel()); // test write methods // Sof lm_jsgf_file2; Filename model_file_a2(L"diagnose_grammar_jsgf_output.sof"); lm_jsgf_file2.open(model_file_a2, File::WRITE_ONLY); if(!lmjsgf2.write(lm_jsgf_file2,0)) { return Error::handle(name(), L"write", Error::TEST, __FILE__, __LINE__); } if (level_a > Integral::BRIEF) { Console::put(L"testing write method..."); } lm_jsgf_file2.close(); // reduce indention // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //-------------------------------------------------------------------------- // // 3. Clean up. // //-------------------------------------------------------------------------- // reset indention // if (level_a > Integral::NONE) { Console::decreaseIndention(); } if (level_a > Integral::NONE) { SysString output(L"diagnostics passed for class "); output.concat(name()); output.concat(L"\n"); Console::put(output); } // indicate success // return true; }