⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testdriver.cc

📁 CxxTester是一个用于C++代码的通用测试框。它支持测试库系统、有一套方法的对象文件、甚至单行C++源(即所有用C++接口的东西)。解释程序的前端使你能够在不需要重新编译代码的情况下修改和扩大测
💻 CC
字号:
#include "CxxTester.h"//----------------------------------------------------------------------//// startup for linux                // startup for windows              ////----------------------------------------------------------------------//int main(int argc, char** argv)     //  BOOL CxxMain::InitInstance() {                                   //  {    return cxxloop(argc,argv);      //      return cxxloop();}                                   //  }//----------------------------------------------------------------------//// text output and graphic output can be mixed in every way             //// the graphic output of this test explains the DrawPoint method        ////----------------------------------------------------------------------//cxxcall(DrawPoint){    DOUT["StartDrawPoint"] = "reached";    SetForeground(255,0,0);    int x	  = DIN["x"];    int y	  = DIN["y"];    DrawPoint(x,y);    //    // additional visual explanation    //    SetForeground(200,200,200);    DrawMediumString(x,y,"(x,y)");    DOUT["EndDrawPoint"] = "reached";}//----------------------------------------------------------------------//// the graphic output of this test explains the DrawLine method         ////----------------------------------------------------------------------//cxxcall(DrawLine){    DOUT["StartDrawLine"] = "reached";    SetForeground(255,0,0);    int xs = DIN["xs"];    int ys = DIN["ys"];    int xe = DIN["xe"];    int ye = DIN["ye"];    DrawLine(xs,ys,xe,ye);    //    // additional visual explanation    //    SetForeground(200,200,200);    DrawMediumString(xs-25,ys-5,"(xs,ys)");    DrawMediumString(xe-25,ye+15,"(xe,ye)");    SetForeground(100,100,100);    DrawRect(xs,ys,xe,ye);    DOUT["EndDrawLine"] = "reached";}//----------------------------------------------------------------------//// the graphic output of this test explains the DrawRect method         ////----------------------------------------------------------------------//cxxcall(DrawRect){    DOUT["StartDrawRect"] = "reached";    SetForeground(255,0,0);    int xs = DIN["xs"];    int ys = DIN["ys"];    int xe = DIN["xe"];    int ye = DIN["ye"];    DrawRect(xs,ys,xe,ye);    //    // additional visual explanation    //    SetForeground(200,200,200);    DrawMediumString(xs-25,ys-5,"(xs,ys)");    DrawMediumString(xe-25,ye+15,"(xe,ye)");    DOUT["EndDrawRect"] = "reached";}//----------------------------------------------------------------------//// the graphic output of this test explains the FillRect method         ////----------------------------------------------------------------------//cxxcall(FillRect){    DOUT["StartFillRect"] = "reached";    SetForeground(255,0,0);    int xs = DIN["xs"];    int ys = DIN["ys"];    int xe = DIN["xe"];    int ye = DIN["ye"];    FillRect(xs,ys,xe,ye);    //    // additional visual explanation    //    SetForeground(200,200,200);    DrawMediumString(xs-25,ys-5,"(xs,ys)");    DrawMediumString(xe-25,ye+15,"(xe,ye)");    DOUT["EndFillRect"] = "reached";}//----------------------------------------------------------------------//// the graphic output of this test explains the DrawArc method          ////----------------------------------------------------------------------//cxxcall(DrawArc){	DOUT["StartDrawArc"] = "reached";    SetForeground(255,0,0);    int xs	  = DIN["xs"];    int ys	  = DIN["ys"];    int xe	  = DIN["xe"];    int ye	  = DIN["ye"];    int angle = DIN["angle"];    int span  = DIN["span"];    DrawArc(xs,ys,xe,ye,angle,span);    //    // additional visual explanation    //    if(angle == 0) angle=1;    SetForeground(200,200,200);    DrawMediumString(xs-25,ys-5,"(xs,ys)");    DrawMediumString(xe+5,ye+5,"(xe,ye)");    DrawMediumString(xe-55,(ys+ye)/2-10,"angle"),    SetForeground(100,100,100);    int hlp;    if(xs > xe)    {        hlp = xs;        xs  = xe;        xe  = hlp;    }    if(ys > ye)    {        hlp = ys;        ys  = ye;        ye  = hlp;    }    DrawRect(xs-1,ys-1,xe+1,ye+1);    DrawArc(xs,ys,xe,ye,0,angle);    DrawLine(xs,(ys+ye)/2,xe,(ys+ye)/2);    DrawLine((xs+xe)/2,ys,(xs+xe)/2,ye);    DOUT["EndDrawArc"] = "reached";}//----------------------------------------------------------------------//// the graphic output of this test explains the FillArc method          ////----------------------------------------------------------------------//cxxcall(FillArc){    DOUT["StartFillArc"] = "reached";    SetForeground(255,0,0);    int xs	  = DIN["xs"];    int ys	  = DIN["ys"];    int xe	  = DIN["xe"];    int ye	  = DIN["ye"];    int angle = DIN["angle"];    int span  = DIN["span"];    FillArc(xs,ys,xe,ye,angle,span);    //    // additional visual explanation    //    if(angle == 0) angle=1;    SetForeground(50,50,50);    FillArc(xs,ys,xe,ye,0,angle);    SetForeground(200,200,200);    DrawMediumString(xs-25,ys-5,"(xs,ys)");    DrawMediumString(xe+5,ye+5,"(xe,ye)");    DrawMediumString(xe-55,(ys+ye)/2-10,"angle"),    SetForeground(100,100,100);    DrawRect(xs-1,ys-1,xe+1,ye+1);    DrawLine(xs,(ys+ye)/2,xe,(ys+ye)/2);    DrawLine((xs+xe)/2,ys,(xs+xe)/2,ye);    DOUT["EndFillArc"] = "reached";}//----------------------------------------------------------------------//// the graphic output of this test explains the DrawPolygon method      ////----------------------------------------------------------------------//cxxcall(DrawPolygon){    DOUT["StartDrawPolygon"] = "reached";    SetForeground(255,0,0);    int i = 0;    int xlist[100];    int ylist[100];    int nr = DIN["nr"];    while(DIN["xlist"][i].getType() == DS_INT)    {        xlist[i] = DIN["xlist"][i];        ylist[i] = DIN["ylist"][i];        i++;    }    if(i != nr)    {        DOUT["listLength"] = nr = i;    }    DrawPolygon(nr,xlist,ylist);    //    // additional visual explanation    //    SetForeground(200,200,200);    for(i = 0; i < nr; i++)    {        char str[100];        sprintf(str,"x[%d] y[%d]",i,i);        DrawPoint(xlist[i],ylist[i]);        DrawTinyString(xlist[i]+1,ylist[i]-1,str);    }    DOUT["EndDrawPolygon"] = "reached";}//----------------------------------------------------------------------//// the graphic output of this test explains the FillPolygon method      ////----------------------------------------------------------------------//cxxcall(FillPolygon){    DOUT["StartFillPolygon"] = "reached";    SetForeground(255,0,0);    int i = 0;    int xlist[100];    int ylist[100];    int nr = DIN["nr"];    while(DIN["xlist"][i].getType() == DS_INT)    {        xlist[i] = DIN["xlist"][i];        ylist[i] = DIN["ylist"][i];        i++;    }    if(i != nr)    {        DOUT["listLength"] = nr = i;    }    FillPolygon(nr,xlist,ylist);    //    // additional visual explanation    //    SetForeground(200,200,200);    for(i = 0; i < nr; i++)    {        char str[100];        sprintf(str,"x[%d] y[%d]",i,i);        DrawPoint(xlist[i],ylist[i]);        DrawTinyString(xlist[i]+1,ylist[i]-1,str);    }    DOUT["EndFillPolygon"] = "reached";}//----------------------------------------------------------------------//// the graphic output of this test explains the DrawXXXString methods   ////----------------------------------------------------------------------//cxxcall(DrawString){    DOUT["StartDrawString"] = "reached";    SetForeground(255,0,0);    int x     = DIN["x"];    int y     = DIN["y"];    char* fnt = DIN["font"];    char* str = DIN["str"];    if(!strcmp(fnt,"tiny"))    {        DrawTinyString(x,y,str);    }    if(!strcmp(fnt,"medium"))    {        DrawMediumString(x,y,str);    }    if(!strcmp(fnt,"large"))    {        DrawLargeString(x,y,str);    }    //    // additional visual explanation    //    SetForeground(200,200,200);    DrawPoint(x,y);    DOUT["EndDrawString"] = "reached";}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -