t_geometry.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *                                                                             *
00003 *  Name   : test_geometry                                                     *
00004 *  Author : Chris Koeritz                                                     *
00005 *                                                                             *
00006 *  Purpose:                                                                   *
00007 *                                                                             *
00008 *    Exercises some of the classes in the geometry library.                   *
00009 *                                                                             *
00010 *******************************************************************************
00011 * Copyright (c) 2001-$now By Author.  This program is free software; you can  *
00012 * redistribute it and/or modify it under the terms of the GNU General Public  *
00013 * License as published by the Free Software Foundation; either version 2 of   *
00014 * the License or (at your option) any later version.  This is online at:      *
00015 *     http://www.fsf.org/copyleft/gpl.html                                    *
00016 * Please send any updates to: fred@gruntose.com                               *
00017 \*****************************************************************************/
00018 
00019 #include <basis/guards.h>
00020 #include <basis/istring.h>
00021 #include <geometric/cartesian_objects.h>
00022 #include <geometric/circle.h>
00023 #include <geometric/ellipse.h>
00024 #include <geometric/line.cpp>
00025 #include <geometric/screen_rectangle.h>
00026 #include <geometric/rectangle.cpp>
00027 #include <geometric/warper.cpp>
00028 #include <geometric/triangle.h>
00029 #include <data_struct/static_memory_gremlin.h>
00030 
00031 HOOPLE_STARTUP_CODE;
00032 
00033 using namespace geometric;
00034 
00035 int main(int formal(argc), char *formal(argv)[])
00036 {
00037   // test constructors
00038   circle fred;
00039   ellipse tobias;
00040   line<double> slugmart;
00041   rectangle<double> burger;
00042   rectangle_warper<double> space_warp(burger, burger);
00043   triangle euclid;
00044 
00045   burger = cartesian_rectangle(23, 19, 82, 745);
00046   if (!burger.from_text(istring("84.0 290.0 10.0 912.0")))
00047     deadly_error("t_geometry", "cartesian from_text test", "returned failure");
00048   if (burger != cartesian_rectangle(84.0, 290.0, 10.0, 912.0))
00049     deadly_error("t_geometry", "cartesian from_text test", "didn't compare with expected value");
00050 
00051   screen_rectangle xingu(23, 19, 82, 745);
00052   if (xingu != screen_rectangle(screen_point(23, 19), screen_point(82, 745)))
00053     deadly_error("t_geometry", "screen test", "construction disagreed with expectations");
00054   if (!xingu.from_text(istring("84 290 10 912")))
00055     deadly_error("t_geometry", "screen from_text test", "returned failure");
00056   if (xingu != screen_rectangle(84, 290, 10, 912))
00057     deadly_error("t_geometry", "screen from_text test", "didn't compare with expected value");
00058 
00059   screen_rectangle guiness(-223, 19, 82, -745);
00060   if (guiness != screen_rectangle(screen_point(-223, 19), screen_point(82, -745)))
00061     deadly_error("t_geometry", "screen test", "construction disagreed with expectations");
00062   if (!guiness.from_text(istring("-84 290 -10 912")))
00063     deadly_error("t_geometry", "screen from_text test", "returned failure");
00064   if (guiness != screen_rectangle(-84, 290, -10, 912))
00065     deadly_error("t_geometry", "screen from_text test", "didn't compare with expected value");
00066 
00067 guards::alert_message(istring(istring::SPRINTF, "the string form is %s.", guiness.text_form().s()).s());
00068 
00069   // test non-mainstream constructors
00070   // test non-mainstream constructors
00071 
00072   // test operators
00073 
00074   // test conversions
00075 
00076   // test class specific functions
00077 
00078   // test other things?
00079 
00080   guards::alert_message("geometric:: works for those functions tested.");
00081 
00082   return 0;
00083 }
00084 

Generated on Fri Nov 28 04:29:38 2008 for HOOPLE Libraries by  doxygen 1.5.1