📄 tlogtofile.cpp
字号:
// TLOGTOFILE.CPP//// Copyright (c) 1999-2000 PanSoftware Ltd. All rights reserved.//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License version 2 as// published by the Free Software Foundation.#include "logtofile.h"#include "tlogtofile.h"GLDEF_D RTest gTest(_L("LogToFile test code"));////////////////////////////////////////////////////////////////////////////////// Tests ...////////////////////////////////////////////////////////////////////////////////LOCAL_C void Test1()//// First test - briefly exercise all methods// { gTest.Next(_L("Briefly test all methods")); TInt test = 1; WriteLogF(_L("TestLogFile"),_L8("Starting Test\n")); WriteLogF(_L("TestLogFile"),_L8("Test %d\n"), test); WriteLogF(_L("TestLogFile"),_L8("Test End")); }LOCAL_C void Test2()//// Low memory testing// {#ifndef _DEBUG gTest.Next(_L("No low memory tests in release builds"));#else gTest.Next(_L("Low memory tests")); TInt count=0; TInt ret=KErrNoMemory; while(ret==KErrNoMemory) { gTest.Printf(_L("Starting Test: Fail at %d allocations\n"),count); __UHEAP_FAILNEXT(count); __UHEAP_MARK; TRAP(ret,/*Do Test*/ ; ); __UHEAP_MARKEND; count++; } __UHEAP_RESET;#endif }////////////////////////////////////////////////////////////////////////////////// Other functions ...////////////////////////////////////////////////////////////////////////////////LOCAL_C void InitGlobals()//// Initialise any global variables// {}LOCAL_C void DestroyGlobals()//// Close all global variables// {}LOCAL_C void RunTestsL()//// Run all the tests// { InitGlobals(); Test1(); Test2(); DestroyGlobals(); }////////////////////////////////////////////////////////////////////////////////// E32Main////////////////////////////////////////////////////////////////////////////////EXPORT_C TInt E32Main()//// Main// { CTrapCleanup* cleanup = CTrapCleanup::New(); CActiveScheduler* theActiveScheduler = new CActiveScheduler(); CActiveScheduler::Install(theActiveScheduler); __UHEAP_MARK; gTest.Title(); gTest.Start(_L("Starting Tests ...")); TRAPD(err,RunTestsL()); if(err!=KErrNone) gTest.Printf(_L("ERROR: Leave %d\n"),err); gTest.Printf(_L("Test Complete. Press any key ...\n")); gTest.Getch(); gTest.End(); gTest.Close(); WriteLogDeallocTls(); __UHEAP_MARKEND; delete cleanup; delete theActiveScheduler; return KErrNone; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -