00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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
00041 point<double> fred(23, angle<double>(4));
00042 point<double> bob(399, angle<double>(2.3));
00043 double dist = bob.distance(fred);
00044
00045
00046 point<double> borg(fred - bob);
00047
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