aboutsummaryrefslogtreecommitdiffstats
path: root/_test/meowpp.cpp
diff options
context:
space:
mode:
Diffstat (limited to '_test/meowpp.cpp')
-rw-r--r--_test/meowpp.cpp92
1 files changed, 66 insertions, 26 deletions
diff --git a/_test/meowpp.cpp b/_test/meowpp.cpp
index e03edaa..805f459 100644
--- a/_test/meowpp.cpp
+++ b/_test/meowpp.cpp
@@ -1,32 +1,72 @@
-#include "dsa/KD_Tree.h"
-#include "Usage.h"
+#include "meowpp.h"
-bool testColors(){
-}
-bool testDisjointSet(){
-}
-bool testMergeableHeap(){
-}
+#include <string>
+#include <cstdlib>
+#include <ctime>
+
+////////////////////////////
+meow::Usage usg("meowpp"), usg2;
+int count = 0;
+TestFunctions tests;
+////////////////////////
int main(int argc, char** argv){
- Usage usg("meowpp"), usg2;
- usg .addOption('h', "Display this help document");
- usg2.addOption('t',
- "Test the i-th part of the meowpp and then quit",
- "<number>", "",
- false);
+ //srand(time(NULL));
+ usg.addOption('h', "Display this help document");
+ usg.addUsageBegin("<name> is a little test program to check whether"
+ "the data structures in the template is correct by"
+ "random generate lots of data to test");
+ usg.addUsageEnd ("zzzzzzzzzzzzzzz....");
+ usg.import(usg2);
- KD_Tree();
- KD_Tree(size_t _dimension);
- ~KD_Tree();
- //
- void insert(Keys const& key, Value value);
- void build();
- //
- Value query (Keys const& point, int k) const;
- Values rangeQuery(Keys const& point, int k) const;
- //
- void clear();
- void reset(size_t _dimension);
+ std::string err;
+ if(usg.setArguments(argc, argv, &err) == false){
+ printf("%s\n\n%s\n", err.c_str(), usg.getUsage().c_str());
+ return 1;
+ }else if(usg.hasOptionSetup('h')){
+ printf("%s", usg.getUsage().c_str());
+ return 0;
+ }else{
+ usg2.update(usg);
+ if(usg2.getOptionValuesCount('t') > 0){
+ for(int i = 0, I = usg2.getOptionValuesCount('t'); i < I; i++){
+ int id = atoi(usg2.getOptionValue('t', i).c_str());
+ TestFunction* f = (TestFunction*)tests.getImplement(id);
+ if(f->run() == false){
+ printf("error occure on %s\n", f->name().c_str());
+ return 1;
+ }else{
+ printf("%s success\n", f->name().c_str());
+ }
+ }
+ }else{
+ std::vector<int> ids = tests.getIdentifys();
+ while(true){
+ for(int i = 0, I = ids.size(); i < I; i++){
+ TestFunction* f = (TestFunction*)tests.getImplement(i);
+ printf(" %d) %s\n", ids[i], f->name().c_str());
+ }
+ printf("please select(EOF to quit): ");
+ int id;
+ if(!~scanf("%d", &id)){
+ break;
+ }
+ printf("\n");
+ TestFunction* f = (TestFunction*)tests.getImplement(id);
+ if(f == NULL){
+ printf("Bad value!\n\n");
+ continue;
+ }
+ if(f->run() == false){
+ printf("error occure on %s\n\n", f->name().c_str());
+ return 1;
+ }else{
+ printf("%s success\n\n", f->name().c_str());
+ }
+ }
+ printf("\n");
+ }
+ return 0;
+ }
return 0;
}