testdriver.cc
来自「CxxTester是一个用于C++代码的通用测试框。它支持测试库系统、有一套方法」· CC 代码 · 共 47 行
CC
47 行
#include "CxxTester.h"//----------------------------------------------------------------------//// startup for linux // startup for windows ////----------------------------------------------------------------------//int main(int argc, char** argv) // BOOL CxxMain::InitInstance() { // { return cxxloop(argc,argv); // return cxxloop();} // }//----------------------------------------------------------------------//// usage of global variables for storage of values across testcases ////----------------------------------------------------------------------//cxxcall(allocate){ int size = DIN["size"]; int idx = DIN["storeindex"]; if(size > 0) { char *ptr = new char[size]; // the 0x prefix forces hex output // brackets forces global storage DOUT["(0xaddress)"][idx] = (int)ptr; }}//----------------------------------------------------------------------//// the testscript uses global (address) to recover the memory pointer ////----------------------------------------------------------------------//cxxcall(deallocate){ int val = DIN["pointer"]; char* ptr = (char*)val; DOUT["0xdeleteptr"] = (int)ptr; // 0xheader forces hex output if(ptr != 0) { delete[] ptr; int idx = DIN["freeindex"]; DOUT["(0xaddress)"][idx] = 0; // to avoid multiple delete }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?