t_set.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *                                                                             *
00003 *  Name   : test_set                                                          *
00004 *  Author : Chris Koeritz                                                     *
00005 *                                                                             *
00006 *******************************************************************************
00007 * Copyright (c) 1995-$now By Author.  This program is free software; you can  *
00008 * redistribute it and/or modify it under the terms of the GNU General Public  *
00009 * License as published by the Free Software Foundation; either version 2 of   *
00010 * the License or (at your option) any later version.  This is online at:      *
00011 *     http://www.fsf.org/copyleft/gpl.html                                    *
00012 * Please send any updates to: fred@gruntose.com                               *
00013 \*****************************************************************************/
00014 
00015 #include <basis/guards.h>
00016 #include <basis/set.cpp>
00017 #include <opsystem/application_base.h>
00018 #include <loggers/console_logger.h>
00019 #include <data_struct/static_memory_gremlin.h>
00020 
00021 using namespace basis;
00022 
00023 #define DIE(how) \
00024   deadly_error("test_set", "bad outcome", how)
00025 
00026 class set_tester : public application_base
00027 {
00028 public:
00029   virtual int execute();
00030 
00031   IMPLEMENT_CLASS_NAME("set_tester");
00032 };
00033 
00034 int set_tester::execute()
00035 {
00036   int_set fred;
00037   if (!fred.empty()) DIE("first empty check");
00038   if (!fred.add(23)) DIE("fred 1st add");
00039   if (!fred.add(90123)) DIE("fred 2nd add");
00040   if (fred.add(23)) DIE("fred 3rd add");
00041   if (fred.add(90123)) DIE("fred 4th add");
00042   if (fred.empty()) DIE("second empty check");
00043   if (!fred.non_empty()) DIE("non_empty check");
00044 
00045   int_set gen;
00046   if (!gen.add(13)) DIE("gen 1st add");
00047   if (!gen.add(23)) DIE("gen 2nd add");
00048   if (!gen.add(8012)) DIE("gen 3rd add");
00049 
00050   int_set intersect(gen.intersection(fred));
00051   if (intersect.elements() != 1) DIE("intersection elements error");
00052   if (!intersect.member(23)) DIE("element not present error");
00053 
00054   int_set uni(gen.set_union(fred));
00055   if (uni.elements() != 4) DIE("union elements error");
00056   if (!uni.member(23)
00057       || !uni.member(90123)
00058       || !uni.member(13)
00059       || !uni.member(8012) )
00060     DIE("element not present error");
00061 
00062   guards::alert_message("set:: works for those functions tested.");
00063   return 0;
00064 }
00065 
00066 HOOPLE_MAIN(set_tester, )
00067 

Generated on Fri Nov 21 04:30:05 2008 for HOOPLE Libraries by  doxygen 1.5.1