void CCmnStateTest::doTestTSsmStateConstructors() { INFO_PRINTF1(_L("Testing TSsmState default constructor")); TSsmState s0; TEST(s0.Int() == 0); TEST(s0.MainState() == 0); TEST(s0.SubState() == 0); INFO_PRINTF1(_L("Lower bound test for TSsmState constructor with two arguments")); TSsmState s1(1,1); TEST(s1.Int() == 0x00010001); TEST(s1.MainState() == 1); TEST(s1.SubState() == 1); INFO_PRINTF1(_L("Upper bound test for TSsmState constructor with two arguments")); TSsmState sF(0x00FF, 0xFFFF); TEST(sF.Int() == 0x00FFFFFF); TEST(sF.MainState() == 0x00FF); TEST(sF.SubState() == 0xFFFF); INFO_PRINTF1(_L("Testing TSsmState copy constructor")); const TSsmState KState(0x00FE, 0xBABE); TSsmState copy(KState); TEST(copy.Int() == KState.Int()); TEST(copy.MainState() == KState.MainState()); TEST(copy.SubState() == KState.SubState()); INFO_PRINTF1(_L("Testing TSsmState enum constructor")); TSsmState enum0(ESsmNormal, KSsmAnySubState); TEST(enum0.MainState() == 1); TEST(enum0.SubState() == 0xFFFF); }
int main() { srand(time(NULL)); const double xMin = -1, yMin = -1; const double xMax = 1, yMax = 1; { epswriter c("circle.eps", xMin, yMin, xMax, yMax); epswriter cF("circleF.eps", xMin, yMin, xMax, yMax); const double radius = 0.5; const double centerX = 0; const double centerY = 0; c.circle(centerX, centerY,radius,MyRand(), MyRand(), MyRand()); cF.filledCircle(centerX, centerY,radius,MyRand(), MyRand(), MyRand()); } { epswriter t("triangle.eps", xMin, yMin, xMax, yMax); epswriter tF("triangleFilled.eps", xMin, yMin, xMax, yMax); const double x1= 0 , y1=.5; const double x2=-.25, y2=-.25; const double x3= .25, y3=-.25; t.triangle(x1,y1,x2,y2,x3,y3,MyRand(),MyRand(),MyRand()); tF.filledTriangle(x1,y1,x2,y2,x3,y3,MyRand(),MyRand(),MyRand()); } { epswriter s("square.eps", xMin, yMin, xMax, yMax); epswriter sF("squareFilled.eps", xMin, yMin, xMax, yMax); const double leftDownX = -.5, leftDownY=-.5; const double rightUpX = .5, rightUpY = .5; s.square(leftDownX, leftDownY, rightUpX, rightUpY,MyRand(),MyRand(),MyRand()); sF.filledSquare(leftDownX, leftDownY, rightUpX, rightUpY,MyRand(),MyRand(),MyRand()); } { epswriter l("line.eps", xMin, yMin, xMax, yMax); epswriter ml("multiline.eps",xMin, yMin, xMax, yMax); const double lineWidth = .05; const double x0 = -1, y0=-1; const double xf = .5, yf=1.0; std::vector<double> x,y; x.push_back(.5);x.push_back(.7); x.push_back(.9); y.push_back(-.3);y.push_back(.4); y.push_back(0); l.line(x0,y0,xf,yf, lineWidth, MyRand(),MyRand(),MyRand()); ml.multiline(x,y, lineWidth, MyRand(),MyRand(),MyRand()); } { epswriter n("names.eps", xMin, yMin, xMax, yMax); const double x1= 0 , y1=.5; const double x2=-.25, y2=-.25; n.writeText(x1,y1,"Very nice name", 0.2, 0,0, 0); n.writeText(x2,y2,"Nice name indeed", 0.2, 0,0,0); } }
static void cmd_cp (char *args) { bool onepass; get_option (args, onepass); char *src, *dst; if (!get2args ("cp", args, src, dst)) return; csRef<iStringArray> fl (VFS->FindFiles (src)); size_t i; for (i = 0; i < fl->GetSize () ; i++) { char destname [VFS_MAX_PATH_LEN + 1]; src = (char *)fl->Get (i); if (fl->GetSize () > 1) { size_t dirlen = strlen (src); if (dirlen) dirlen--; while (dirlen && src [dirlen - 1] != VFS_PATH_SEPARATOR) dirlen--; strcpy (destname, dst); if (destname [0]) if (destname [strlen (destname) - 1] != VFS_PATH_SEPARATOR) strcat (destname, "/"); strcat (destname, src + dirlen); csPrintf ("%s -> %s\n", src, destname); dst = destname; } if (onepass) { csRef<iDataBuffer> data (VFS->ReadFile (src)); if (!data) { csPrintfErr ("cp: cannot read file \"%s\"\n", src); return; } if (!VFS->WriteFile (dst, **data, data->GetSize ())) csPrintfErr ("cp: error writing to file \"%s\"\n", dst); } else { csRef<iFile> dF (VFS->Open (dst, VFS_FILE_WRITE)); if (!dF) { csPrintfErr ("cp: cannot open destination file \"%s\"\n", dst); return; } csRef<iFile> sF (VFS->Open (src, VFS_FILE_READ)); if (!sF) { csPrintfErr ("cp: cannot open source file \"%s\"\n", src); return; } while (!sF->AtEOF ()) { char buff [123]; size_t len = sF->Read (buff, sizeof (buff)); if (dF->Write (buff, len) != len) { csPrintfErr ("cp: error writing to file \"%s\"\n", dst); break; } } } } }