TuttleOFX  1
wuline.tests.cpp
Go to the documentation of this file.
00001 #include <boost/test/included/unit_test.hpp>
00002 
00003 #include <wuline.hpp>
00004 
00005 using boost::unit_test::test_suite;
00006 using namespace boost::gil;
00007 
00008 //g++ wuline.tests.cpp -I /home/scott/project/boost_1_36_0 -I .
00009 
00010 struct test1
00011 {
00012         void operator()()
00013         {
00014                 int width = 200;
00015                 int height = 200;
00016                 unsigned char* buffer = new unsigned char[width * height * 3];
00017                 memset(buffer, 255, width * height * 3);        
00018                 rgb8_view_t view = interleaved_view(width,height,(rgb8_pixel_t*)buffer,width*3);
00019 
00020                 double phase = 0;
00021                 for (double theta = phase; theta < 360 + phase; theta += 10)
00022                 {
00023                         int x = (100.0*cos(theta*3.14/180.0)+100);
00024                         int y = (-100*sin(theta*3.14/180.0)+100);
00025                         wuline(view,rgb8_pixel_t(0,0,0),x,y,100,100);
00026                 }
00027                 
00028                 FILE* fd = fopen("wuline.ppm", "wb");
00029                 fprintf(fd, "P6\n# CREATOR: reportbase\n%d %d\n255\n", width, height);
00030                 fwrite(buffer, 1, width*height*3, fd);
00031                 fclose(fd);
00032                 delete [] buffer;
00033         }
00034 };
00035 
00036 test_suite* init_unit_test_suite( int argc, char** argv)
00037 {
00038         test_suite* test= BOOST_TEST_SUITE( "wuline tests" );
00039         test->add( BOOST_TEST_CASE(test1()), 0);
00040         return test;
00041 }