// Testing DviFile // This tests only a small subset of the things that could be tested here. #include #include #include #include #if HAVE_CSTD_INCLUDE #include #else #include #endif using STD::cerr; using STD::endl; using STD::fabs; // could do with boosting accuracy, but that would involve being // cleverer in convertUnits #define EQTOL(a,b) (fabs((a)/(b)-1)<2e-5) int testConvertFromScaledPoints(void) { struct { int testvalue; double expected; DviFile::DviUnits unit; const char* unitname; } testset[] = { { 12345, 12345, DviFile::unit_sp, "sp", }, { 65536, 1, DviFile::unit_pt, "pt", }, { 65536*12, 1, DviFile::unit_pc, "pc", }, { 65536*7227, 7200, DviFile::unit_bp, "bp", }, { 65536*7227, 100, DviFile::unit_in, "in", }, { 65536*7227, 2540, DviFile::unit_mm, "mm", }, { 65536*7227, 254, DviFile::unit_cm, "cm", }, { 65536*1238, 1157, DviFile::unit_dd, "dd", }, { 65536*1238*12, 1157, DviFile::unit_cc, "cc", }, }; int ntests = sizeof(testset)/sizeof(testset[0]); int nerrors = 0; for (int i=0; i(dvif->getEvent()); if (! p) { cerr << "Eeek! First event from DVI file is not DviFilePreamble" << endl; return 1; // JUMP OUT } int nerrors = 0; struct { double testvalue; // in points double expected_sp; double expected_px; } testset[] = { { 72.27, 65536*72.27, 110 }, }; int ntests = sizeof(testset)/sizeof(testset[0]); for (int i=0; i