📄 coretest.cpp
字号:
} { NcbiCerr << "Test CRef on CObjectInt on heap:" << NcbiEndl; CRef<CObjectInt> objRef(new CObjectInt()); assert(objRef->CanBeDeleted()); } { NcbiCerr << "Test CObject in stack:" << NcbiEndl; CObject stackObj; assert(!stackObj.CanBeDeleted()); } { NcbiCerr << "Test CObject on heap:" << NcbiEndl; CObject* heapObj = new CObject(); assert(heapObj->CanBeDeleted()); } { NcbiCerr << "Test static CObject:" << NcbiEndl; static CObject staticObj; assert(!staticObj.CanBeDeleted()); } { NcbiCerr << "Test CRef on CObject on heap:" << NcbiEndl; CRef<CObject> objRef(new CObject()); assert(objRef->CanBeDeleted()); } SetDiagTrace(eDT_Default);}/////////////////////////////////// Test application//class CTestApplication : public CNcbiApplication{public: virtual ~CTestApplication(void); virtual int Run(void);};int CTestApplication::Run(void){ TestStartup(); TestDiag(); TestDiag_ErrCodeInfo(); TestException(); TestException_AuxTrace(); TestIostream(); TestRegistry(); TestThrowTrace(); TestHeapStack(); NcbiCout << NcbiEndl << "CORETEST execution completed successfully!" << NcbiEndl << NcbiEndl << NcbiEndl; return 0;}CTestApplication::~CTestApplication(){ SetDiagStream(0); assert( IsDiagStream(0) ); assert( !IsDiagStream(&NcbiCout) );} /////////////////////////////////// APPLICATION OBJECT// and// MAIN//// Note that if the application's object ("theTestApplication") was defined// inside the scope of function "main()", then its destructor could be// called *before* destructors of other statically allocated objects// defined in other modules.// It would cause a premature closure of diag. stream, and disallow the// destructors of other projects to refer to this application object:// - the singleton method CNcbiApplication::Instance() would return NULL, and// - if there is a "raw"(direct) pointer to "theTestApplication" then it// might cause a real trouble.static CTestApplication theTestApplication;int main(int argc, const char* argv[] /*, const char* envp[]*/){ // Post error message ERR_POST("This message goes to the default diag.stream, CERR"); // Execute main application function return theTestApplication.AppMain(argc, argv, 0 /*envp*/, eDS_ToMemory);}/* * =========================================================================== * $Log: coretest.cpp,v $ * Revision 1000.1 2004/06/01 19:09:37 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.90 * * Revision 1.90 2004/05/14 13:59:51 gorelenk * Added include of ncbi_pch.hpp * * Revision 1.89 2003/10/06 16:59:37 ivanov * Use macro _TROUBLE instead assert(0) * * Revision 1.88 2003/04/25 20:54:40 lavr * Add test for IgnoreDiagDieLevel() operations * * Revision 1.87 2003/02/24 19:56:51 gouriano * use template-based exceptions instead of errno and parse exceptions * * Revision 1.86 2002/08/28 17:06:18 vasilche * Added code for checking heap detection * * Revision 1.85 2002/08/16 15:02:32 ivanov * Added test for class CDiagAutoPrefix * * Revision 1.84 2002/08/01 18:52:27 ivanov * Added test for output verbose messages for error codes * * Revision 1.83 2002/07/15 18:53:36 gouriano * renamed CNcbiException to CException * * Revision 1.82 2002/07/15 18:17:25 gouriano * renamed CNcbiException and its descendents * * Revision 1.81 2002/07/11 14:18:28 gouriano * exceptions replaced by CNcbiException-type ones * * Revision 1.80 2002/04/16 18:49:06 ivanov * Centralize threatment of assert() in tests. * Added #include <test/test_assert.h>. CVS log moved to end of file. * * Revision 1.79 2001/10/15 19:48:24 vakatov * Use two #if's instead of "#if ... && ..." as KAI cannot handle #if x == y * * Revision 1.78 2001/09/05 18:47:12 ucko * Work around WorkShop 5.3 type-equivalence bug. * * Revision 1.77 2001/07/30 14:42:27 lavr * eDiag_Trace and eDiag_Fatal always print as much as possible * * Revision 1.76 2001/07/25 19:14:14 lavr * Added test for date/time stamp in message logging * * Revision 1.75 2001/06/22 21:46:15 ivanov * Added test for read/write the registry file with comments * * Revision 1.74 2001/06/13 23:19:39 vakatov * Revamped previous revision (prefix and error codes) * * Revision 1.73 2001/06/13 20:50:00 ivanov * Added test for stack post prefix messages and ErrCode manipulator. * * Revision 1.72 2001/03/26 20:59:57 vakatov * String-related tests moved to "test_ncbistr.cpp" (by A.Grichenko) * * Revision 1.71 2001/01/30 00:40:28 vakatov * Do not use arg "envp[]" in main() -- as it is not working on MAC * * Revision 1.70 2000/12/11 20:42:52 vakatov * + NStr::PrintableString() * * Revision 1.69 2000/10/24 21:51:23 vakatov * [DEBUG] By default, do not print file name and line into the diagnostics * * Revision 1.68 2000/10/24 19:54:48 vakatov * Diagnostics to go to CERR by default (was -- disabled by default) * * Revision 1.67 2000/10/11 21:03:50 vakatov * Cleanup to avoid 64-bit to 32-bit values truncation, etc. * (reported by Forte6 Patch 109490-01) * * Revision 1.66 2000/08/03 20:21:35 golikov * Added predicate PCase for AStrEquiv * PNocase, PCase goes through NStr::Compare now * * Revision 1.65 2000/06/26 20:56:35 vakatov * TestDiag() -- using user-istalled message posting handler * * Revision 1.64 2000/06/23 19:57:19 vakatov * TestDiag() -- added tests for the switching diag.handlers * * Revision 1.63 2000/06/11 01:47:34 vakatov * IsDiagSet(0) to return TRUE if the diag stream is unset * * Revision 1.62 2000/06/09 21:22:49 vakatov * Added test for IsDiagStream() * * Revision 1.61 2000/05/24 20:57:13 vasilche * Use new macro _DEBUG_ARG to avoid warning about unused argument. * * Revision 1.60 2000/04/19 18:36:44 vakatov * Test NStr::Compare() for non-zero "pos" * * Revision 1.59 2000/04/17 04:16:25 vakatov * Added tests for NStr::Compare() and NStr::ToLower/ToUpper() * * Revision 1.58 2000/04/04 22:34:32 vakatov * Checks for the NStr:: for "long", and for the debug tracing * * Revision 1.57 2000/02/18 16:54:10 vakatov * + eDiag_Critical * * Revision 1.56 2000/01/20 17:55:48 vakatov * Fixes to follow the "CNcbiApplication" change. * * Revision 1.55 1999/11/29 17:49:12 golikov * NStr::Replace tests modified obedience to Denis :) * * Revision 1.54 1999/11/26 18:45:30 golikov * NStr::Replace tests added * * Revision 1.53 1999/11/12 17:33:24 vakatov * To be more careful with _DEBUG to suit some ugly MSVC++ features * * Revision 1.52 1999/10/04 16:21:06 vasilche * Added full set of macros THROW*_TRACE * * Revision 1.51 1999/09/29 18:21:58 vakatov * + TestException_Features() -- to test how the thrown object is handled * * Revision 1.50 1999/09/02 21:54:42 vakatov * Tests for CNcbiRegistry:: allowed '-' and '.' in the section/entry name * * Revision 1.49 1999/08/30 16:00:45 vakatov * CNcbiRegistry:: Get()/Set() -- force the "name" and "section" to * consist of alphanumeric and '_' only; ignore leading and trailing * spaces * * Revision 1.48 1999/07/07 14:17:07 vakatov * CNcbiRegistry:: made the section and entry names be case-insensitive * * Revision 1.47 1999/07/06 15:26:37 vakatov * CNcbiRegistry:: * - allow multi-line values * - allow values starting and ending with space symbols * - introduced EFlags/TFlags for optional parameters in the class * member functions -- rather than former numerous boolean parameters * * Revision 1.46 1999/05/27 15:22:16 vakatov * Extended and fixed tests for the StringToXXX() functions * * Revision 1.45 1999/05/11 14:47:38 vakatov * Added missing <algorithm> header (for MSVC++) * * Revision 1.44 1999/05/11 02:53:52 vakatov * Moved CGI API from "corelib/" to "cgi/" * * Revision 1.43 1999/05/10 14:26:13 vakatov * Fixes to compile and link with the "egcs" C++ compiler under Linux * * Revision 1.42 1999/05/04 16:14:50 vasilche * Fixed problems with program environment. * Added class CNcbiEnvironment for cached access to C environment. * * Revision 1.41 1999/05/04 00:03:16 vakatov * Removed the redundant severity arg from macro ERR_POST() * * Revision 1.40 1999/05/03 20:32:31 vakatov * Use the (newly introduced) macro from <corelib/ncbidbg.h>: * RETHROW_TRACE, * THROW0_TRACE(exception_class), * THROW1_TRACE(exception_class, exception_arg), * THROW_TRACE(exception_class, exception_args) * instead of the former (now obsolete) macro _TRACE_THROW. * * Revision 1.39 1999/04/30 19:21:06 vakatov * Added more details and more control on the diagnostics * See #ERR_POST, EDiagPostFlag, and ***DiagPostFlag() * * Revision 1.38 1999/04/27 14:50:12 vasilche * Added FastCGI interface. * CNcbiContext renamed to CCgiContext. * * Revision 1.37 1999/04/14 20:12:52 vakatov * + <stdio.h>, <stdlib.h> * * Revision 1.36 1999/03/12 18:04:09 vakatov * Added ERR_POST macro to perform a plain "standard" error posting * * Revision 1.35 1999/01/21 16:18:04 sandomir * minor changes due to NStr namespace to contain string utility functions * * Revision 1.34 1999/01/12 17:10:16 sandomir * test restored * * Revision 1.33 1999/01/12 17:06:37 sandomir * GetLink changed * * Revision 1.32 1999/01/07 21:15:24 vakatov * Changed prototypes for URL_DecodeString() and URL_EncodeString() * * Revision 1.31 1999/01/07 20:06:06 vakatov * + URL_DecodeString() * + URL_EncodeString() * * Revision 1.30 1999/01/04 22:41:44 vakatov * Do not use so-called "hardware-exceptions" as these are not supported * (on the signal level) by UNIX * Do not "set_unexpected()" as it works differently on UNIX and MSVC++ * * Revision 1.29 1998/12/28 17:56:43 vakatov * New CVS and development tree structure for the NCBI C++ projects * * Revision 1.28 1998/12/15 15:43:24 vasilche * Added utilities to convert string <> int. * * Revision 1.27 1998/12/11 18:00:56 vasilche * Added cookies and output stream * * Revision 1.26 1998/12/10 22:59:49 vakatov * CNcbiRegistry:: API is ready(and by-and-large tested) * * Revision 1.25 1998/12/10 18:05:40 vakatov * CNcbiReg:: Just passed a draft test. * * Revision 1.24 1998/12/10 17:36:56 sandomir * ncbires.cpp added * * Revision 1.23 1998/12/09 19:38:53 vakatov * Started with TestRegistry(). Freeze in the "compilable" state. * * Revision 1.22 1998/12/07 23:48:03 vakatov * Changes in the usage of CCgiApplication class * * Revision 1.21 1998/12/03 21:24:23 sandomir * NcbiApplication and CgiApplication updated * * Revision 1.20 1998/12/03 16:40:15 vakatov * Initial revision * Aux. function "Getline()" to read from "istream" to a "string" * Adopted standard I/O "string" <--> "istream" for old-fashioned streams * * Revision 1.19 1998/12/01 00:27:21 vakatov * Made CCgiRequest::ParseEntries() to read ISINDEX data, too. * Got rid of now redundant CCgiRequest::ParseIndexesAsEntries() * * Revision 1.18 1998/11/30 21:23:20 vakatov * CCgiRequest:: - by default, interprete ISINDEX data as regular FORM entries * + CCgiRequest::ParseIndexesAsEntries() * Allow FORM entry in format "name1&name2....." (no '=' necessary after name) * * Revision 1.17 1998/11/27 20:55:23 vakatov * CCgiRequest:: made the input stream arg. be optional(std.input by default) * * Revision 1.16 1998/11/27 19:46:06 vakatov * TestCgi() -- test the query string passed as a cmd.-line argument * * Revision 1.15 1998/11/27 15:55:07 vakatov * + TestCgi(USER STDIN) * * Revision 1.14 1998/11/26 00:29:55 vakatov * Finished NCBI CGI API; successfully tested on MSVC++ and SunPro C++ 5.0 * * Revision 1.13 1998/11/24 23:07:31 vakatov * Draft(almost untested) version of CCgiRequest API * * Revision 1.12 1998/11/24 21:31:34 vakatov * Updated with the ISINDEX-related code for CCgiRequest:: * TCgiEntries, ParseIndexes(), GetIndexes(), etc. * * Revision 1.11 1998/11/24 17:52:38 vakatov * + TestException_Aux() -- tests for CErrnoException:: and CErrnoException:: * + TestCgi_Request() -- tests for CCgiRequest::ParseEntries() * * Revision 1.10 1998/11/20 22:34:39 vakatov * Reset diag. stream to get rid of a mem.leak * * Revision 1.9 1998/11/19 23:41:14 vakatov * Tested version of "CCgiCookie::" and "CCgiCookies::" * * Revision 1.8 1998/11/13 00:18:08 vakatov * Added a test for the "unexpected" exception. * Turned off "hardware" exception tests for UNIX. * * Revision 1.7 1998/11/10 01:17:38 vakatov * Cleaned, adopted to the standard NCBI C++ framework and incorporated * the "hardware exceptions" code and tests(originally written by * V.Sandomirskiy). * Only tested for MSVC++ compiler yet -- to be continued for SunPro... * * Revision 1.6 1998/11/06 22:42:42 vakatov * Introduced BEGIN_, END_ and USING_ NCBI_SCOPE macros to put NCBI C++ * API to namespace "ncbi::" and to use it by default, respectively * Introduced THROWS_NONE and THROWS(x) macros for the exception * specifications * Other fixes and rearrangements throughout the most of "corelib" code * * Revision 1.5 1998/11/04 23:48:15 vakatov * Replaced <ncbidiag> by <ncbistd> * * ========================================================================== */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -