t_point.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *                                                                             *
00003 *  Name   : test_point                                                        *
00004 *  Author : Chris Koeritz                                                     *
00005 *                                                                             *
00006 *  Purpose:                                                                   *
00007 *                                                                             *
00008 *    Tests out the point class.                                               *
00009 *                                                                             *
00010 *******************************************************************************
00011 * Copyright (c) 2002-$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/point.cpp>
00022 #include <opsystem/application_shell.h>
00023 #include <loggers/console_logger.h>
00024 #include <data_struct/static_memory_gremlin.h>
00025 
00026 using namespace geometric;
00027 
00028 class test_point : public application_shell
00029 {
00030 public:
00031   test_point() : application_shell(class_name()) {}
00032   IMPLEMENT_CLASS_NAME("test_point");
00033   virtual int execute();
00034 };
00035 
00036 int test_point::execute()
00037 {
00038   FUNCDEF("execute");
00039   {
00040     // first test just instantiates some things.
00041     point<double> fred(23, angle<double>(4));
00042     point<double> bob(399, angle<double>(2.3));
00043     double dist = bob.distance(fred);
00044 //LOG(istring("fred is ") + fred + " and bob is " + bob);
00045 //LOG(isprintf("distance between is ", dist));
00046     point<double> borg(fred - bob);
00047 //LOG(istring("borg is fred-bob, which is ") + borg);
00048     if (borg.magnitude() - dist > 0.001)
00049       deadly_error(class_name(), func, "difference is too large");
00050   }
00051 
00052   {
00053     istring pt1 = "12,38";
00054     point<double> to_scan;
00055     to_scan.from_text(pt1);
00056     if ( (to_scan.x() != 12) || (to_scan.y() != 38) )
00057       deadly_error(class_name(), "second test", "1st from_text failed");
00058     istring pt2 = "{14.3,16.2989}";
00059     to_scan.from_text(pt2);
00060     if ( (to_scan.x() != 14.3) || (to_scan.y() != 16.2989) )
00061       deadly_error(class_name(), "second test", "2nd from_text failed");
00062   }
00063 
00064   guards::alert_message("point:: works for all functions tested.");
00065 
00066   return 0;
00067 }
00068 
00069 HOOPLE_MAIN(test_point, )
00070 

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