int main() { std::vector <Kernel::Point_3> points; points.reserve(GRID_SIZE*GRID_SIZE*GRID_SIZE); for (int i=0;i<GRID_SIZE;++i) for (int j=0;j<GRID_SIZE;++j) for (int k=0;k<GRID_SIZE;++k) points.push_back(Kernel::Point_3(i,j,k)); DT3 dt3(points.begin(),points.end()); std::stringstream buffer; buffer << dt3; //~ std::ofstream out ("test_dt_deterministic_3.in"); //~ out << dt3; //reading the result from a file std::ifstream file ("test_dt_deterministic_3.in"); std::string original,computed; if (file) { while (file && file >> original ){ buffer >> computed; if ( original!=computed ){ std::cout <<"Error: triangulations are differents"<< std::endl; std::cout << "|" << original <<"| vs |"<< computed << "|"<< std::endl; return EXIT_FAILURE; } } } std::cout <<"Triangulations are identical"<< std::endl; return 0; }
void testMyDateTimeStore() { __int64 tmp; fielddefs* fds = fielddefs::create(); fielddef f; memset(&f, 0, sizeof(fielddef)); f.len = 8; f.pos = 0; //timestamp f.type = ft_mytimestamp; f.decimals = 6; field fd((unsigned char* )&tmp, f, fds); myTimeStamp dt(f.decimals, true); dt = "2010-10-10 00:00:00.123456"; fd = dt.i64; BOOST_CHECK_MESSAGE(fd.i64() == dt.i64, "ft_mytimestamp7 value = " << fd.i64()); //Legacy format myTimeStamp dtl(f.decimals, false); dtl = "2010-10-10 00:00:00"; fd = dtl.i64; BOOST_CHECK_MESSAGE(fd.i64() == dtl.i64, "ft_mytimestamp legacy value = " << fd.i64()); f.decimals = 4; f.len = 7; myTimeStamp dt2(f.decimals, true); dt2 = "2010-10-10 00:00:12.9988"; fd = dt2.i64; BOOST_CHECK_MESSAGE(fd.i64() == dt2.i64, "ft_mytimestamp6 value = " << fd.i64()); f.decimals = 2; f.len = 6; myTimeStamp dt3(f.decimals, true); dt3 = "2010-10-10 00:00:12.23"; fd = dt3.i64; BOOST_CHECK_MESSAGE(fd.i64() == dt3.i64, "ft_mytimestamp5 value = " << fd.i64()); f.decimals = 0; f.len = 5; myTimeStamp dt4(f.decimals, true); dt4 = "2010-10-10 00:00:12"; fd = dt4.i64; BOOST_CHECK_MESSAGE(fd.i64() == dt4.i64, "ft_mytimestamp4 value = " << fd.i64()); //datetime f.decimals = 6; f.len = 8; f.type = ft_mydatetime; myDateTime dt5(f.decimals, true); dt5 = "2015-10-10 00:00:12.445566"; fd = dt5.i64; BOOST_CHECK_MESSAGE(fd.i64() == dt5.i64, "ft_mydatetime8 value = " << fd.i64()); //Legacy format myDateTime dt5l(f.decimals, true); dt5l = "2015-10-10 00:00:12"; fd = dt5l.i64; BOOST_CHECK_MESSAGE(fd.i64() == dt5l.i64, "ft_mydatetime Legacy value = " << fd.i64()); f.decimals = 4; f.len = 7; myDateTime dt6(f.decimals, true); dt6 = "2015-10-10 00:00:12.7788"; fd = dt6.i64; BOOST_CHECK_MESSAGE(fd.i64() == dt6.i64, "ft_mydatetime7 value = " << fd.i64()); f.decimals = 2; f.len = 6; myDateTime dt7(f.decimals, true); dt7 = "2015-10-10 00:00:12.00"; fd = dt7.i64; BOOST_CHECK_MESSAGE(fd.i64() == dt7.i64, "ft_mydatetime6 value = " << fd.i64()); f.decimals = 0; f.len = 5; myDateTime dt71(f.decimals, true); dt71 = "2015-10-10 00:00:12"; fd = dt71.i64; BOOST_CHECK_MESSAGE(fd.i64() == dt71.i64, "ft_mydatetime5 value = " << fd.i64()); //mariadb datetime f.setOptions(FIELD_OPTION_MARIADB); f.decimals = 6; f.len = 8; f.type = ft_mydatetime; maDateTime dta(f.decimals, true); dta = "2015-10-10 00:00:12.445566"; fd = dta.i64; BOOST_CHECK_MESSAGE(fd.i64() == dta.i64, "ft_mydatetime8 maridb value = " << fd.i64()); f.decimals = 4; f.len = 7; maDateTime dta1(f.decimals, true); dta1 = "2015-10-10 00:00:12.7788"; fd = dta1.i64; BOOST_CHECK_MESSAGE(fd.i64() == dta1.i64, "ft_mydatetime7 maridb value = " << fd.i64()); f.decimals = 2; f.len = 6; maDateTime dta2(f.decimals, true); dta2 = "2015-10-10 00:00:12.00"; fd = dta2.i64; BOOST_CHECK_MESSAGE(fd.i64() == dta2.i64, "ft_mydatetime6 maridb value = " << fd.i64()); f.decimals = 0; f.len = 5; maDateTime dta20(f.decimals, true); dta20 = "2015-10-10 00:00:12"; fd = dta20.i64; BOOST_CHECK_MESSAGE(fd.i64() == dta20.i64, "ft_mydatetime6 maridb value = " << fd.i64()); // mariadb time f.decimals = 6; f.len = 6; f.type = ft_mytime; maTime dtma1(f.decimals, true); dtma1 = "00:00:12.123456"; fd = dtma1.i64; BOOST_CHECK_MESSAGE(fd.i64() == dtma1.i64, "ft_mytime6 maridb value = " << fd.i64()); f.decimals = 4; f.len = 5; maTime dtma2(f.decimals, true); dtma2 = "00:00:12.1234"; fd = dtma2.i64; BOOST_CHECK_MESSAGE(fd.i64() == dtma2.i64, "ft_mytime5 maridb value = " << fd.i64()); f.decimals = 2; f.len = 4; maTime dta3(f.decimals, true); dta3 = "00:00:12.12"; fd = dta3.i64; BOOST_CHECK_MESSAGE(fd.i64() == dta3.i64, "ft_mytime4 maridb value = " << fd.i64()); f.decimals = 0; f.len = 3; maTime dta4(f.decimals, true); dta4 = "00:00:12"; fd = dta4.i64; BOOST_CHECK_MESSAGE(fd.i64() == dta4.i64, "ft_mytime3 maridb value = " << fd.i64()); maTime dta5(f.decimals, false); dta5 = "00:00:12"; fd = dta5.i64; BOOST_CHECK_MESSAGE(fd.i64() == dta5.i64, "ft_mytime Legacy maridb value = " << fd.i64()); // MySQl time f.setOptions(0); f.decimals = 6; f.len = 6; f.type = ft_mytime; myTime dt10(f.decimals, true); dt10 = "00:00:12.123456"; fd = dt10.i64; BOOST_CHECK_MESSAGE(fd.i64() == dt10.i64, "ft_mytime6 value = " << fd.i64()); f.decimals = 4; f.len = 5; myTime dt11(f.decimals, true); dt11 = "00:00:12.1234"; fd = dt11.i64; BOOST_CHECK_MESSAGE(fd.i64() == dt11.i64, "ft_mytime5 value = " << fd.i64()); f.decimals = 2; f.len = 4; myTime dt12(f.decimals, true); dt12 = "00:00:12.12"; fd = dt12.i64; BOOST_CHECK_MESSAGE(fd.i64() == dt12.i64, "ft_mytime4 value = " << fd.i64()); f.decimals = 0; f.len = 3; myTime dt13(f.decimals, true); dt13 = "00:00:12"; fd = dt13.i64; BOOST_CHECK_MESSAGE(fd.i64() == dt13.i64, "ft_mytime3 value = " << fd.i64()); myTime dt13l(f.decimals, false); dt13l = "00:00:12"; fd = dt13l.i64; BOOST_CHECK_MESSAGE(fd.i64() == dt13l.i64, "ft_mytime Legacy value = " << fd.i64()); //print f.type = ft_mydatetime; f.decimals = 6; f.len = 8; fd = _T("2015-10-01 20:50:36.002000"); BOOST_CHECK_MESSAGE(fd.c_str() == _tstring(_T("2015-10-01 20:50:36.002000")) , "ft_mydatetime string8 = " << fd.c_str()); f.decimals = 4; f.len = 7; fd = _T("2015-10-01 20:50:36.002000"); BOOST_CHECK_MESSAGE(fd.c_str() == _tstring(_T("2015-10-01 20:50:36.0020")) , "ft_mydatetime string7 = " << fd.c_str()); f.decimals = 2; f.len = 6; fd = _T("2015-10-01 20:50:36.052000"); BOOST_CHECK_MESSAGE(fd.c_str() == _tstring(_T("2015-10-01 20:50:36.05")) , "ft_mydatetime string6 = " << fd.c_str()); f.decimals = 0; f.len = 5; fd = _T("2015-10-01 20:50:36.002000"); BOOST_CHECK_MESSAGE(fd.c_str() == _tstring(_T("2015-10-01 20:50:36")) , "ft_mydatetime string5 = " << fd.c_str()); f.type = ft_mytimestamp; f.decimals = 6; f.len = 7; fd = _T("2015-10-01 20:50:36.052001"); BOOST_CHECK_MESSAGE(fd.c_str() == _tstring(_T("2015-10-01 20:50:36.052001")) , "ft_mytimestamp string7 = " << fd.c_str()); f.decimals = 4; f.len = 6; fd = _T("2015-10-01 20:50:36.052001"); BOOST_CHECK_MESSAGE(fd.c_str() == _tstring(_T("2015-10-01 20:50:36.0520")) , "ft_mytimestamp string6 = " << fd.c_str()); f.decimals = 2; f.len = 5; fd = _T("2015-10-01 20:50:36.052000"); BOOST_CHECK_MESSAGE(fd.c_str() == _tstring(_T("2015-10-01 20:50:36.05")) , "ft_mytimestamp string5 = " << fd.c_str()); f.decimals = 0; f.len = 4; fd = _T("2015-10-01 20:50:36.952000"); BOOST_CHECK_MESSAGE(fd.c_str() == _tstring(_T("2015-10-01 20:50:36")) , "ft_mytimestamp string4 = " << fd.c_str()); fds->release(); }
void create_point_test() { // create point with specified parameterization { piecewise_curve_type pc; point_creator_type pt_creator(4); data_type dt0(3), dt1(2), dt2(3), dt3(2), t0(-1), dt; point_type p0, ptemp; // set the point p0 << 1, 2, 3; pt_creator.set_point(p0); // set the times pt_creator.set_t0(t0); pt_creator.set_segment_dt(dt0, 0); pt_creator.set_segment_dt(dt1, 1); pt_creator.set_segment_dt(dt2, 2); pt_creator.set_segment_dt(dt3, 3); // test point setting ptemp=pt_creator.get_point(); TEST_ASSERT(p0==ptemp); // test time step settings TEST_ASSERT(pt_creator.get_t0()==t0); dt=pt_creator.get_segment_dt(0); TEST_ASSERT(dt==dt0); dt=pt_creator.get_segment_dt(1); TEST_ASSERT(dt==dt1); dt=pt_creator.get_segment_dt(2); TEST_ASSERT(dt==dt2); dt=pt_creator.get_segment_dt(3); TEST_ASSERT(dt==dt3); // create the polygon TEST_ASSERT(pt_creator.create(pc)); } // create point with default parameterization { piecewise_curve_type pc; point_creator_type pt_creator(4); data_type dt; point_type p0, ptemp; // set the corners p0 << 1, 0, 0; pt_creator.set_point(p0); // test corner settings ptemp=pt_creator.get_point(); TEST_ASSERT(p0==ptemp); // test time step settings TEST_ASSERT(pt_creator.get_t0()==0); dt=pt_creator.get_segment_dt(0); TEST_ASSERT(dt==1); dt=pt_creator.get_segment_dt(1); TEST_ASSERT(dt==1); dt=pt_creator.get_segment_dt(2); TEST_ASSERT(dt==1); dt=pt_creator.get_segment_dt(3); TEST_ASSERT(dt==1); // create the polygon TEST_ASSERT(pt_creator.create(pc)); } }