aboutsummaryrefslogtreecommitdiffstats
path: root/_test
diff options
context:
space:
mode:
Diffstat (limited to '_test')
-rw-r--r--_test/meowpp.cpp32
-rw-r--r--_test/meowpp.h55
-rw-r--r--_test/meowpp_BinaryIndexTree.cpp2
-rw-r--r--_test/meowpp_Colors.cpp2
-rw-r--r--_test/meowpp_DisjointSet.cpp2
-rw-r--r--_test/meowpp_KD_Tree.cpp2
-rw-r--r--_test/meowpp_Matrix.cpp2
-rw-r--r--_test/meowpp_MergeableHeap.cpp2
-rw-r--r--_test/meowpp_SegmentTree.cpp2
-rw-r--r--_test/meowpp_SplayTree.cpp2
-rw-r--r--_test/meowpp_SplayTree_Range.cpp2
-rw-r--r--_test/meowpp_VP_Tree.cpp2
12 files changed, 48 insertions, 59 deletions
diff --git a/_test/meowpp.cpp b/_test/meowpp.cpp
index e45a4c1..c380098 100644
--- a/_test/meowpp.cpp
+++ b/_test/meowpp.cpp
@@ -1,5 +1,6 @@
#include "meowpp.h"
+#include <vector>
#include <string>
#include <cstdlib>
#include <ctime>
@@ -9,11 +10,19 @@
////////////////////////////
meow::Usage usg("meowpp"), usg2;
int count = 0;
-TestFunctions tests;
////////////////////////
int main(int argc, char** argv){
- //srand(time(NULL));
+ std::vector<std::string> ids(meow::ObjSelector<0>::lst());
+ usg2.addOption('t', "Select which subject to test",
+ "<number>", "",
+ false);
+ for(size_t i = 0; i < ids.size(); i++){
+ TestFunction* tmp = (TestFunction*)meow::ObjSelector<0>::get(ids[i]);
+ usg2.addOptionValueAccept('t', ids[i], tmp->name() + ", " + tmp->description());
+ delete tmp;
+ }
+
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"
@@ -32,21 +41,22 @@ int main(int argc, char** argv){
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);
+ std::string wh = usg2.getOptionValue('t', i);
+ TestFunction* f = (TestFunction*)meow::ObjSelector<0>::get(wh);
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());
}
+ delete f;
}
}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());
+ TestFunction* tmp = (TestFunction*)meow::ObjSelector<0>::get(ids[i]);
+ printf(" %s) %s\n", ids[i].c_str(), tmp->name().c_str());
+ delete tmp;
}
printf("please select(EOF to quit): ");
int id;
@@ -54,21 +64,21 @@ int main(int argc, char** argv){
break;
}
printf("\n");
- TestFunction* f = (TestFunction*)tests.getImplement(id);
+ TestFunction* f = (TestFunction*)meow::ObjSelector<0>::get(meow::stringPrintf("%d", 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());
+ printf("error occure on %s\n", f->name().c_str());
return 1;
}else{
- printf("%s success\n\n", f->name().c_str());
+ printf("%s success\n", f->name().c_str());
}
+ delete f;
}
printf("\n");
}
- return 0;
}
return 0;
}
diff --git a/_test/meowpp.h b/_test/meowpp.h
index 94ff3ec..8e6e181 100644
--- a/_test/meowpp.h
+++ b/_test/meowpp.h
@@ -5,51 +5,30 @@
#include "meowpp/geo/Vector3D.h"
#include "meowpp/Usage.h"
-#include "meowpp/oo/Register_Implement.h"
#include "meowpp/oo/Properties.h"
+#include "meowpp/oo/ObjBase.h"
+#include "meowpp/oo/ObjSelector.h"
-extern meow::Usage usg, usg2;
extern int count;
-//////////////////////////////////
-class TestFunctions: public meow::RegisterInterface<int>{
- public:
- TestFunctions(): RegisterInterface(){
- usg2.addOption('t',
- "Specify which part of the template to test",
- "name", "",
- false);
- }
- bool regImplement(meow::ImplementInterface<int>* imp,
- std::string const& str){
- usg2.addOptionValueAccept('t',
- meow::stringPrintf("%d", imp->identify()),
- str);
- return RegisterInterface::regImplement(imp);
- }
-};
-extern TestFunctions tests;
-////////////////////////
-class TestFunction: public meow::ImplementInterface<int>{
- private:
- std::string _name;
+
+class TestFunction: public meow::ObjBase{
public:
- TestFunction(std::string const& __name):
- ImplementInterface(count++), _name("testing code about " + __name){
- tests.regImplement(this, _name);
- }
- virtual ~TestFunction(){ }
+ virtual ~TestFunction(){ };
virtual bool run() = 0;
- std::string name() const{ return _name; }
+ virtual std::string name () const = 0;
+ virtual std::string description() const = 0;
};
-////////////////////////
-#define concat(a,b) a##b
-#define TEST(a) \
-class Test_##a: public TestFunction{ \
+#define TEST(__A,__B) \
+class Test##__A: public TestFunction{ \
public: \
- Test_##a(): TestFunction(#a){ } \
- bool run();\
-} __test_##a; bool Test_##a::run()
-
+ \
+ meow::ObjBase* create() const{ return new Test##__A(); } \
+ bool run(); \
+ std::string name() const{ return #__A; } \
+ std::string description() const{ return __B; } \
+}; \
+static meow::ObjSelector<0> _(meow::stringPrintf("%d", count++), new Test##__A()); \
+inline bool Test##__A::run()
#endif // __meowpp_h__
diff --git a/_test/meowpp_BinaryIndexTree.cpp b/_test/meowpp_BinaryIndexTree.cpp
index 3071839..0b81f10 100644
--- a/_test/meowpp_BinaryIndexTree.cpp
+++ b/_test/meowpp_BinaryIndexTree.cpp
@@ -19,7 +19,7 @@ inline int sum(int k){
static meow::BinaryIndexTree<int> bit;
-TEST(BinaryIndexTree){
+TEST(BinaryIndexTree, "Test with large data"){
size_t tMe = 0, tBi = 0, t0;
for(int z = 0; z < 10; z++){
meow::messagePrintf(1, "test %d", z);
diff --git a/_test/meowpp_Colors.cpp b/_test/meowpp_Colors.cpp
index ac740e0..3233cf6 100644
--- a/_test/meowpp_Colors.cpp
+++ b/_test/meowpp_Colors.cpp
@@ -6,7 +6,7 @@
#include "meowpp.h"
-TEST(Colors){
+TEST(Colors, "Transformations"){
meow::RGBf rgb, rgb2;
meow::YUVf yuv, yuv2;
meow::HSLf hsl, hsl2;
diff --git a/_test/meowpp_DisjointSet.cpp b/_test/meowpp_DisjointSet.cpp
index 484e146..41ca7d2 100644
--- a/_test/meowpp_DisjointSet.cpp
+++ b/_test/meowpp_DisjointSet.cpp
@@ -5,7 +5,7 @@
#include <vector>
-TEST(DisjointSet){
+TEST(DisjointSet, "..."){
int N = 10000000;
meow::DisjointSet dsj(N);
diff --git a/_test/meowpp_KD_Tree.cpp b/_test/meowpp_KD_Tree.cpp
index 6cb2e0c..25c18b0 100644
--- a/_test/meowpp_KD_Tree.cpp
+++ b/_test/meowpp_KD_Tree.cpp
@@ -116,7 +116,7 @@ struct Node{
bool operator<(Node const& n) const{ return (id < n.id); }
};
-TEST(KD_Tree){
+TEST(KD_Tree, "It is very slow"){
int t0, t1, t2;
diff --git a/_test/meowpp_Matrix.cpp b/_test/meowpp_Matrix.cpp
index dbcfcb1..6ef94b7 100644
--- a/_test/meowpp_Matrix.cpp
+++ b/_test/meowpp_Matrix.cpp
@@ -19,7 +19,7 @@ void print(Matrix<int> const& m){
}
}
-TEST(Matrix){
+TEST(Matrix, "Unfinished"){
Matrix<int> a(3, 4, 0);
Matrix<int> b(3, 4, 0);
Matrix<int> c(4, 5, 0);
diff --git a/_test/meowpp_MergeableHeap.cpp b/_test/meowpp_MergeableHeap.cpp
index 65fe2cc..78eed00 100644
--- a/_test/meowpp_MergeableHeap.cpp
+++ b/_test/meowpp_MergeableHeap.cpp
@@ -8,7 +8,7 @@
#include <cstdlib>
-TEST(MergeableHeap){
+TEST(MergeableHeap, "..."){
int N = 10;
std::vector<std::priority_queue<int> > nhp;
std::vector<meow::MergeableHeap<int> > mhp;
diff --git a/_test/meowpp_SegmentTree.cpp b/_test/meowpp_SegmentTree.cpp
index 05b1b51..f92f55f 100644
--- a/_test/meowpp_SegmentTree.cpp
+++ b/_test/meowpp_SegmentTree.cpp
@@ -80,7 +80,7 @@ void show(){
}
}
-TEST(SegmentTree){
+TEST(SegmentTree, "..."){
s_max.reset(N);
s_sum.reset(N);
s_max.override(0, N - 1, RangeMax(0));
diff --git a/_test/meowpp_SplayTree.cpp b/_test/meowpp_SplayTree.cpp
index 68ae58f..96c5807 100644
--- a/_test/meowpp_SplayTree.cpp
+++ b/_test/meowpp_SplayTree.cpp
@@ -312,7 +312,7 @@ static bool check(){
return true;
}
-TEST(SplayTree){
+TEST(SplayTree, "Seems buggy"){
detail_fg = false;
N = 5;
for(int i = 0; i < 10; i++){
diff --git a/_test/meowpp_SplayTree_Range.cpp b/_test/meowpp_SplayTree_Range.cpp
index 0233a49..7df650a 100644
--- a/_test/meowpp_SplayTree_Range.cpp
+++ b/_test/meowpp_SplayTree_Range.cpp
@@ -364,7 +364,7 @@ static bool check(){
return true;
}
-TEST(SplayTree_Range){
+TEST(SplayTree_Range, "..."){
detail_fg = false;
N = 5;
for(int i = 0; i < 10; i++){
diff --git a/_test/meowpp_VP_Tree.cpp b/_test/meowpp_VP_Tree.cpp
index c01db38..503cde6 100644
--- a/_test/meowpp_VP_Tree.cpp
+++ b/_test/meowpp_VP_Tree.cpp
@@ -110,7 +110,7 @@ static std::vector<MyVector> find(MyVector const& v, int k){
return ret;
}
-TEST(VP_Tree){
+TEST(VP_Tree, "A little bit slow"){
int t0, t1, t2;
meow::VP_Tree<MyVector, lnt> tree(D);