void CTest::x_TestPathes() { CNcbiDiag p1( CDiagCompileInfo("somewhere/cpp/src/corelib/file.cpp", 0, NCBI_CURRENT_FUNCTION) ); CNcbiDiag p2( CDiagCompileInfo("somewhere/include/corelib/file.cpp", 0, NCBI_CURRENT_FUNCTION) ); CNcbiDiag p3( CDiagCompileInfo("somewhere/cpp/src/corelib/int/file.cpp", 0, NCBI_CURRENT_FUNCTION) ); CNcbiDiag p4( CDiagCompileInfo("somewhere/include/corelib/int/file.cpp", 0, NCBI_CURRENT_FUNCTION) ); CNcbiDiag p5( CDiagCompileInfo("somewhere/foo/corelib/file.cpp", 0, NCBI_CURRENT_FUNCTION) ); m_Diags.push_back(&p1); m_Diags.push_back(&p2); m_Diags.push_back(&p3); m_Diags.push_back(&p4); m_Diags.push_back(&p5); NcbiCout << "Testing file paths" << NcbiEndl; { int expects[] = { 1, 1, 1, 1, 0 }; x_TestString( "/corelib", expects ); } { int expects[] = { 1, 1, 0, 0, 0 }; x_TestString( "/corelib/", expects ); } { int expects[] = { 0, 0, 1, 1, 0 }; x_TestString( "/corelib/int", expects ); } m_Diags.clear(); }
CInvalidChoiceSelection::CInvalidChoiceSelection( size_t currentIndex, size_t mustBeIndex, const char* const names[], size_t namesCount, EDiagSev severity) : CSerialException(CDiagCompileInfo("unknown", 0), 0, (CSerialException::EErrCode) CException::eInvalid,"") { x_Init(CDiagCompileInfo("unknown", 0), string("Invalid choice selection: ")+ GetName(currentIndex, names, namesCount)+". " "Expected: "+ GetName(mustBeIndex, names, namesCount),0, severity); x_InitErrCode((CException::EErrCode)(CInvalidChoiceSelection::eFail)); }
string CException::ReportAll(TDiagPostFlags flags) const { // invert the order stack<const CException*> pile; const CException* pex; for (pex = this; pex; pex = pex->GetPredecessor()) { pile.push(pex); } CNcbiOstrstream os; os << "NCBI C++ Exception:" << '\n'; for (; !pile.empty(); pile.pop()) { //indentation os << " "; os << pile.top()->ReportThis(flags) << '\n'; } if (sm_BkgrEnabled && !m_InReporter) { m_InReporter = true; CExceptionReporter::ReportDefault(CDiagCompileInfo(0, 0, NCBI_CURRENT_FUNCTION), "(background reporting)", *this, eDPF_Trace); m_InReporter = false; } return CNcbiOstrstreamToString(os); }
void CTest::x_TestErrCode() { NcbiCout << "Testing ErrCodes\n"; CNcbiDiag p1( CDiagCompileInfo("", 0, NCBI_CURRENT_FUNCTION) ); p1.SetErrorCode(-6,-10); m_Diags.push_back(&p1); CNcbiDiag p2( CDiagCompileInfo("", 0, NCBI_CURRENT_FUNCTION) ); p2.SetErrorCode(-6,10); m_Diags.push_back(&p2); CNcbiDiag p3( CDiagCompileInfo("", 0, NCBI_CURRENT_FUNCTION) ); p3.SetErrorCode(20,1); m_Diags.push_back(&p3); CNcbiDiag p4( CDiagCompileInfo("", 0, NCBI_CURRENT_FUNCTION) ); p4.SetErrorCode(21,1); m_Diags.push_back(&p4); CNcbiDiag p5( CDiagCompileInfo("", 0, NCBI_CURRENT_FUNCTION) ); p5.SetErrorCode(31,21); m_Diags.push_back(&p5); CNcbiDiag p6( CDiagCompileInfo("", 0, NCBI_CURRENT_FUNCTION) ); p6.SetErrorCode(40,1); m_Diags.push_back(&p6); { int expects[] = { 1, 1, 1, 0, 0, 1 }; x_TestString("(-10--5,20,30-40.) !(31.1-100)",expects); } { int expects[] = { 1, 0, 0, 1, 1, 0 }; x_TestString("!(-10--5,20,30-40.1-20)",expects); } { int expects[] = { 1, 0, 0, 1, 1, 0 }; x_TestString("!(20.) !(30-40.1-20) !(-6.1-100)",expects); } m_Diags.clear(); }