本文整理汇总了C++中TEST2函数的典型用法代码示例。如果您正苦于以下问题:C++ TEST2函数的具体用法?C++ TEST2怎么用?C++ TEST2使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TEST2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetResolvedDllInfo_OOMTestL
void GetResolvedDllInfo_OOMTestL()
{
TInt processHandlesS = 0;
TInt threadHandlesS = 0;
TInt processHandlesE = 0;
TInt threadHandlesE = 0;
RThread().HandleCount(processHandlesS, threadHandlesS);
CEComServer* ecomServer = CEComServer::NewLC();
TClientRequest clientReq;
RArray<TUid> extendedInterfaces;
CleanupClosePushL(extendedInterfaces);
RImplInfoArray* implInfoArray = ecomServer->ListImplementationsL(KCExampleInterfaceUid,extendedInterfaces,clientReq);
CleanupStack::PopAndDestroy(&extendedInterfaces);
TEST(implInfoArray->Count() > 0);
for(TInt count=1;;++count)
{
// Setting Heap failure for OOM test
__UHEAP_SETFAIL(RHeap::EDeterministic, count);
__UHEAP_MARK;
TEntry dllInfo;
TUid dtorIdKey;
TClientRequest clntRq;
CImplementationInformation* info = (*implInfoArray)[0];
TRAPD(err, ecomServer->GetResolvedDllInfoL(info->ImplementationUid(),
dllInfo, dtorIdKey, clntRq));
if(err == KErrNoMemory)
{
__UHEAP_MARKEND;
}
else if(err == KErrNone)
{
__UHEAP_MARKEND;
RDebug::Print(_L("The test succeeded at heap failure rate=%d.\n"), count);
break;
}
else
{
__UHEAP_MARKEND;
TEST2(err, KErrNone);
}
__UHEAP_RESET;
}
__UHEAP_RESET;
//implInfoArray should be deleted! The caller takes the ownership.
if (implInfoArray!=NULL)
{
implInfoArray->Close();
delete implInfoArray;
}
CleanupStack::PopAndDestroy(ecomServer);
RThread().HandleCount(processHandlesE, threadHandlesE);
TEST(processHandlesS == processHandlesE);
TEST(threadHandlesS == threadHandlesE);
}
示例2: bi_substr
CELL *
bi_substr(CELL * sp)
{
int n_args, len;
register int i, n;
STRING *sval; /* substr(sval->str, i, n) */
n_args = sp->type;
sp -= n_args;
if (sp->type != C_STRING)
cast1_to_s(sp);
/* don't use < C_STRING shortcut */
sval = string(sp);
if ((len = (int) sval->len) == 0) /* substr on null string */
{
if (n_args == 3) {
cell_destroy(sp + 2);
}
cell_destroy(sp + 1);
return sp;
}
if (n_args == 2) {
n = MAX__INT;
if (sp[1].type != C_DOUBLE)
cast1_to_d(sp + 1);
} else {
if (TEST2(sp + 1) != TWO_DOUBLES)
cast2_to_d(sp + 1);
n = d_to_i(sp[2].dval);
}
i = d_to_i(sp[1].dval) - 1; /* i now indexes into string */
/*
* Workaround in case someone's written a script that does substr(0,last-1)
* by transforming it into substr(1,last).
*/
if (i < 0) {
n -= i + 1;
i = 0;
}
if (n > len - i) {
n = len - i;
}
if (n <= 0) /* the null string */
{
sp->ptr = (PTR) & null_str;
null_str.ref_cnt++;
} else { /* got something */
sp->ptr = (PTR) new_STRING0((size_t) n);
memcpy(string(sp)->str, sval->str + i, (size_t) n);
}
free_STRING(sval);
return sp;
}
示例3: original
/**
@SYMTestCaseID SYSLIB-SQL-UT-4058
@SYMTestCaseDesc Background compaction - configuration test.
The test creates a database with a background compaction mode.
The test reopens the database and verifies that the compaction mode is persistent and is still background.
Then the test reopens the database using different compaction mode in the configuration string and
verifies that the original (background) compaction mode cannot be changed when the database is opened.
@SYMTestPriority Medium
@SYMTestActions Background compaction - configuration test.
@SYMTestExpectedResults Test must not fail
@SYMREQ REQ10274
*/
void CompactConfigTest3L()
{
//Create a test database with "background" compaction mode
_LIT8(KConfigStr1, "encoding=utf-8;compaction=background");
TInt err = TheDb.Create(KTestDbName1, &KConfigStr1);
TEST2(err, KErrNone);
//Check the vacuum mode. The SQLite vacuum mode should be "incremental"
TSqlScalarFullSelectQuery scalarQuery(TheDb);
TInt compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum"));
TEST2(compact, KIncrementalVacuum);
TheDb.Close();
//Close and open the database again. The SQLite vacuum mode should be "incremental".
err = TheDb.Open(KTestDbName1);
TEST2(err, KErrNone);
scalarQuery.SetDatabase(TheDb);
compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum"));
TEST2(compact, KIncrementalVacuum);
TheDb.Close();
//Close and open the database again with a config string with "manual" compaction mode.
//The SQLite vacuum mode should stay unchanged.
_LIT8(KConfigStr2, "compaction=manual");
err = TheDb.Open(KTestDbName1, &KConfigStr2);
TEST2(err, KErrNone);
scalarQuery.SetDatabase(TheDb);
compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum"));
TEST2(compact, KIncrementalVacuum);
TheDb.Close();
//Delete database
err = RSqlDatabase::Delete(KTestDbName1);
TEST2(err, KErrNone);
}
示例4: use
/**
@SYMTestCaseID SYSLIB-SQLITE3-UT-4021
@SYMTestCaseDesc SQLite library multi-select performance test.
The test selects 100 records and stores
the execution time for later use (comparison and printing).
The IDs of the selected records are exactly the same as the IDs of the selected
records, used by SYSLIB-SQLITE3-UT-4013 test case.
The results of this test case will be compared against the results of
the SYSLIB-SQLITE3-UT-4013 test case - "SQL server multi-select performance test".
@SYMTestPriority High
@SYMTestActions SQLite library multi-select performance test.
@SYMTestExpectedResults Test must not fail
@SYMREQ REQ8782
*/
void SqliteMultiSelectTest(TPerfTestMode aPerfTestMode, const char aSelectSql[], int aSelectRecIds[], int aSelectRecCnt)
{
int err;
const char* tail = 0;
sqlite3_stmt* stmt = 0;
int recCnt = 0;
unsigned int fc;
TEST(aPerfTestMode > EPerfTestSqlMode && aPerfTestMode < EPerfTestModeCnt);
TEST(!TheDb2);
err = sqlite3_open(TestDbName(), &TheDb2);
TEST2(err, SQLITE_OK);
ExecSqliteConfig(aPerfTestMode);
FormatSqlStmt(TheSqlBuf2, aSelectSql, aSelectRecIds, aSelectRecCnt);
err = sqlite3_prepare(TheDb2, TheSqlBuf2, -1, &stmt, &tail);
TEST2(err, SQLITE_OK);
fc = FastCounterValue();
while((err = sqlite3_step(stmt)) == SQLITE_ROW)
{
__int64 i64;
double d;
const unsigned short* t;
const unsigned char* b;
i64 = sqlite3_column_int64(stmt, 0);
UNUSED_VAR(i64);
d = sqlite3_column_double(stmt, 1);
UNUSED_VAR(d);
t = (const unsigned short*)sqlite3_column_text16(stmt, 2);
UNUSED_VAR(t);
b = (const unsigned char*)sqlite3_column_blob(stmt, 3);
UNUSED_VAR(b);
++recCnt;
}
StorePerfTestResult(aPerfTestMode, EPerfTestMultiSelect, FastCounterValue() - fc);
TEST2(err, SQLITE_DONE);
TEST2(recCnt, aSelectRecCnt);
sqlite3_finalize(stmt);
sqlite3_close(TheDb2);
TheDb2 = 0;
}
示例5: CompactConfigTest8L
/**
@SYMTestCaseID SYSLIB-SQL-UT-4063
@SYMTestCaseDesc Compaction configuration test - attached database.
The test creates a database with an auto compaction mode.
Then the test attaches the same database.
The test verifies that the compaction mode of the main and the attached database is the same - auto.
@SYMTestPriority Medium
@SYMTestActions Compaction configuration test - attached database.
@SYMTestExpectedResults Test must not fail
@SYMREQ REQ10273
REQ10274
REQ10400
*/
void CompactConfigTest8L()
{
//Create a test database with "auto" compaction mode
_LIT8(KConfigStr1, "; ;; ; compaction = auto; ");
TInt err = TheDb.Create(KTestDbName1, &KConfigStr1);
TEST2(err, KErrNone);
//Attach a database
err = TheDb.Attach(KTestDbName1, _L("db2"));
TEST2(err, KErrNone);
//Check compact for both main and attached database
TSqlScalarFullSelectQuery scalarQuery(TheDb);
TInt compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum"));
TEST2(compact, KAutoVacuum);
compact = scalarQuery.SelectIntL(_L("PRAGMA db2.auto_vacuum"));
TEST2(compact, KAutoVacuum);
//Detach
err = TheDb.Detach(_L("db2"));
TEST2(err, KErrNone);
//Check compact again
compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum"));
TEST2(compact, KAutoVacuum);
//
TheDb.Close();
err = RSqlDatabase::Delete(KTestDbName1);
TEST2(err, KErrNone);
}
示例6: E32Main
GLDEF_C TInt E32Main()
{
__UHEAP_MARK;
TheTest.Printf(_L("\n"));
TheTest.Title();
TheTest.Start(_L("Ecom Ssa Tests"));
TEST2(TheFs.Connect(), KErrNone);
// get clean-up stack
CTrapCleanup* cleanup = CTrapCleanup::New();
TRAPD(err, ::KillEComServerL());
TEST2(err, KErrNone);
EnableEcomTestBehaviour(TheTest, TheFs);
SetupFiles(); //Add plugins to C: drive
TRAP(err,DoTestsL());
TEST2(err, KErrNone);
CleanupFiles(); //Cleanup after test. Remove the plugins from C: drive
DisableEcomTestBehaviour(TheTest, TheFs);
ResetSsa(TheTest, TheFs);
//Make sure that following tests start a fresh version of EComServer
TRAP(err, ::KillEComServerL());
TheTest.End();
TheTest.Close();
//delete scheduler;
delete cleanup;
TheFs.Close();
__UHEAP_MARKEND;
User::Heap().Check();
return KErrNone;
}
示例7: VerifyFileContent
static void VerifyFileContent(const TDesC8& aPattern, TInt64 aFilePos)
{
__ASSERT_DEBUG(aFilePos >= 0, User::Invariant());
TheBuf.Zero();
RFile64 file;
TInt err = file.Open(TheFs, KTestFile, EFileShareReadersOrWriters);
TEST2(err, KErrNone);
err = file.Read(aFilePos, TheBuf, aPattern.Length());
TEST2(err, KErrNone);
file.Close();
err = TheBuf.Compare(aPattern);
TEST2(err, 0);
}
示例8: operator
virtual void operator()()
{
RFileBuf64 fbuf(8192);
RFs fs;
TInt err = fs.Connect();
TEST2(err, KErrNone);
fbuf.Open(fs, KNullDesC, EFileRead);//panic here - invalid file name
fs.Close();
}
示例9: TestLogNotifyExtended2L
/**
@SYMTestCaseID SYSLIB-LOGENG-CT-4012
@SYMTestCaseDesc Tests Message schema validation for the ELogNotifyExtended message.
@SYMTestPriority High
@SYMTestActions Sends a message to the test server to test the validation of messages
against the message schema. The message contains an invalid descriptor.
@SYMTestExpectedResults The server should panic the client with KErrBadDescriptor
@SYMDEF INC114113
*/
void TestLogNotifyExtended2L()
{
RClientMessageTestSession session;
TInt err = session.Connect();
TEST2(err, KErrNone);
CleanupClosePushL(session);
_LIT8(KDes8,"Des8");
TPckgBuf<TInt> int0(0);
err = session.TestLogNotifyExtended(int0, 0, -1, KDes8);
TEST2(err, KErrNone);
CleanupStack::PopAndDestroy(&session);
}
示例10: TestCliServDataParam3L
/**
@SYMTestCaseID SYSLIB-LOGENG-LEGACY-T_LOGSERVIPC-0002
@SYMTestCaseDesc Tests Message schema validation for the messages accepting
TLogClientServerData parameters.
@SYMTestPriority High
@SYMTestActions Sends messages to the test server to test the validation of messages
against the message schema. The messages contain either valid or invalid
parameters.
@SYMTestExpectedResults The server should validate the message and handle bad messages appropriately
@SYMDEF INC114113
*/
void TestCliServDataParam3L()
{
RClientMessageTestSession session;
TInt err = session.Connect();
TEST2(err, KErrNone);
CleanupClosePushL(session);
TBuf8<sizeof(TLogClientServerData) + 1> buf;
buf.FillZ();
err = session.TestCliServDataParam(ELogOperationInitiate,buf);
TEST2(err, KErrArgument);
CleanupStack::PopAndDestroy(&session);
}
示例11: CreateTestDb
static void CreateTestDb()
{
int err;
err = sqlite3_open(TheTestDbName, &TheDb);
TEST2(err, SQLITE_OK);
TEST(TheDb != 0);
err = sqlite3_exec(TheDb, "CREATE TABLE A(F1 INTEGER, F2 BIGINT, F3 REAL, F4 TEXT, F5 BLOB)", &exec_callback, 0, 0);
TEST2(err, SQLITE_OK);
err = sqlite3_exec(TheDb, "INSERT INTO A VALUES(1, 1234567891234, 56.12, 'TEXT', x'313233343536')", &exec_callback, 0, 0);
TEST2(err, SQLITE_OK);
err = sqlite3_close(TheDb);
TEST2(err, SQLITE_OK);
TheDb = 0;
}
示例12: DEF057265
//DEF057265 - Panics when uninstalling a java midlet while it is running.
//The test will run one thread. Inside the thread's function the test will create
//DBMS session and reserve some disk space. Then the test will panic the thread
//(without freeing the reserved disk space).
//If DBMS server panics in _DEBUG mode - the defect is not fixed.
void DEF057265()
{
_LIT(KSessThreadName,"SessThrd");
RThread sessThread;
TEST2(sessThread.Create(KSessThreadName, &ThreadFunc, 0x2000, 0, 0), KErrNone);
TRequestStatus sessThreadStatus;
sessThread.Logon(sessThreadStatus);
TEST2(sessThreadStatus.Int(), KRequestPending);
sessThread.Resume();
User::WaitForRequest(sessThreadStatus);
TEST2(sessThread.ExitType(), EExitPanic);
User::SetJustInTime(EFalse); // disable debugger panic handling
sessThread.Close();//This Close() operation will force DBMS server to close
//created in ThreadFunc() DBMS session.
}
示例13: ListImplementationsL
/**
@SYMTestCaseID SYSLIB-ECOM-CT-3714
@SYMTestCaseDesc Tests CEComServer::ListImplementationsL with customer resolver.
@SYMTestPriority High
@SYMTestActions Calls ListImplementationsL(TUid,TUid,const RExtendedInterfacesArray&,const TClientRequest&)
with customer resolver.
@SYMTestExpectedResults No OOM errors.
@SYMDEF DEF111196
*/
void ListImplementations_OOMTest1L()
{
TInt processHandlesS = 0;
TInt threadHandlesS = 0;
TInt processHandlesE = 0;
TInt threadHandlesE = 0;
RThread().HandleCount(processHandlesS, threadHandlesS);
for(TInt count=1;;++count)
{
CEComServer* ecomServer = CEComServer::NewLC();
// Setting Heap failure for OOM test
__UHEAP_SETFAIL(RHeap::EDeterministic, count);
__UHEAP_MARK;
TUid resolverUid = {0x10009DD0};
TClientRequest clientReq;
RArray<TUid> extendedInterfaces;
CleanupClosePushL(extendedInterfaces);
RImplInfoArray* ifArray=NULL;
TRAPD(err, ifArray = ecomServer->ListImplementationsL(KCExampleInterfaceUid,resolverUid,extendedInterfaces,clientReq));
CleanupStack::PopAndDestroy(&extendedInterfaces);
if (ifArray!=NULL)
{
ifArray->Close();
delete ifArray;
}
if(err == KErrNoMemory)
{
CleanupStack::PopAndDestroy(ecomServer);
__UHEAP_MARKEND;
}
else if(err == KErrNone)
{
CleanupStack::PopAndDestroy(ecomServer);
__UHEAP_MARKEND;
//implInfoArray should not be deleted! The caller does not take the ownership.
RDebug::Print(_L("The test succeeded at heap failure rate=%d.\n"), count);
break;
}
else
{
CleanupStack::PopAndDestroy(ecomServer);
__UHEAP_MARKEND;
TEST2(err, KErrNone);
}
__UHEAP_RESET;
}
__UHEAP_RESET;
//CleanupStack::PopAndDestroy(ecomServer);
RThread().HandleCount(processHandlesE, threadHandlesE);
TEST(processHandlesS == processHandlesE);
TEST(threadHandlesS == threadHandlesE);
}
示例14: TestRefCountCFeatureDiscoveryL
/**
@SYMTestCaseID PDS-EFM-UT-4113
@SYMTestCaseDesc Unit test for client reference counting.
@SYMTestPriority High
@SYMTestActions Create CFeatureDiscovery object and check the client reference count
Connect using RFeatureControl and check the client reference count
Delete the CFeatureDiscovery object and check the client reference count
Close RFeatureControl and check the client reference count
@SYMTestExpectedResults Test must not fail
@SYMDEF DEF144262
*/
void TestRefCountCFeatureDiscoveryL()
{
RFeatureControl featCtrl;
CleanupClosePushL(featCtrl);
CFeatureDiscovery* featDisc = CFeatureDiscovery::NewLC();
TEST2 (GetClientCount(), 1); // Client count should be 1 at this point
featCtrl.Connect();
TEST2 (GetClientCount(), 2); // Client count should be 2 at this point
// Both should return same result
TEST2 (featDisc->IsSupported(KDummyFeatUid), featCtrl.FeatureSupported(KDummyFeatUid)==KFeatureSupported);
CleanupStack::PopAndDestroy(featDisc);
TEST2 (GetClientCount(), 1); // Client count should be 1 at this point
CleanupStack::PopAndDestroy(&featCtrl);
TEST2 (GetClientCount(), 0); // Client count should be 0 at this point
}
示例15: LoadSecurityPolicyTest
/**
@SYMTestCaseID SYSLIB-SQL-UT-3510
@SYMTestCaseDesc Test for DEF109100: SQL, code coverage for TSqlDbSysSettings is low.
The test has 3 sub-cases, where the test attempts to open
a secure shared database with:
- missing default policy in the security policy table;
- invalid database object type in the security policy table;
- 2 default policies in the security policy table;
@SYMTestPriority High
@SYMTestActions Test for DEF109100: SQL, code coverage for TSqlDbSysSettings is low.
@SYMTestExpectedResults Test must not fail
@SYMDEF DEF109100
*/
void LoadSecurityPolicyTest()
{
//Case 1: missing default policy.
RSqlDatabase db;
TInt err = db.Open(KDb6);
TEST2(err, KErrGeneral);
db.Close();
//Case 2: invalid database object type.
err = db.Open(KDb7);
TEST2(err, KErrGeneral);
db.Close();
//Case 3: 2 default policies.
err = db.Open(KDb8);
TEST2(err, KErrGeneral);
db.Close();
}