Index: library/tests/rv_test.cpp
===================================================================
--- library/tests/rv_test.cpp (revision 386)
+++ library/tests/rv_test.cpp (revision 422)
@@ -1,58 +1,120 @@
-
+#include <string>
+#include <sstream>
 #include "../bdm/base/bdmbase.h"
 #include "../bdm/math/square_mat.h"
 #include "../bdm/math/chmat.h"
+#include "UnitTest++.h"
 
 using namespace bdm;
 
-//These lines are needed for use of cout and endl
-using std::cout;
-using std::endl;
+TEST(test_rv)
+{
+    RV a = RV("{a }", "3");
+    CHECK_EQUAL(1, a.length());
+    CHECK_EQUAL(3, a.size(0));
+    CHECK_EQUAL(std::string("a"), a.name(0));
 
-int main()
-{
-	RV a = RV ( "{a }","3");
-	RV b = RV ( "{b }","2");
-	RV c = RV ( "{c }");
-	RV ef = RV ("{e f }");
+    RV b = RV("{b }", "2");
+    CHECK_EQUAL(0, b.mint());
+
+    RV c = RV("{c }");
+    CHECK_EQUAL(1, c.length());
+    CHECK_EQUAL(1, c.size(0));
+
+    RV trv = RV("{e f }", "1 2", "3 4");
+    CHECK_EQUAL(2, trv.length());
+    CHECK_EQUAL(3, trv.mint());
+
+    // add a and b
+    RV ab = a;
+    bool added = ab.add(b);
+    CHECK(added);
+    CHECK_EQUAL(2, ab.length());
+    CHECK_EQUAL(3, ab.size(0));
+    CHECK_EQUAL(std::string("a"), ab.name(0));
+    CHECK_EQUAL(2, ab.size(1));
+    CHECK_EQUAL(std::string("b"), ab.name(1));
+
+    std::stringstream abss;
+    abss << ab;
+    CHECK_EQUAL(std::string("1(3)=a_{0}; 2(2)=b_{0}; "), abss.str());
+
+    // concat a, b and c
+    RV abc = concat(ab, c);
+    CHECK_EQUAL(3, abc.length());
+    std::stringstream abcss;
+    abcss << abc;
+    CHECK_EQUAL(std::string("1(3)=a_{0}; 2(2)=b_{0}; 3(1)=c_{0}; "), abcss.str());
+
+    // structure of a, b, c
+    str s = abc.tostr();
+    int exp_ids[] = { 1, 1, 1, 2, 2, 3 };
+    int exp_sz = sizeof(exp_ids) / sizeof(exp_ids[0]);
+    CHECK_EQUAL(exp_sz, s.ids.size());
+    CHECK_EQUAL(exp_sz, s.times.size());
+    for (int i = 0; i < exp_sz; ++i) {
+        CHECK_EQUAL(exp_ids[i], s.ids(i));
+        CHECK_EQUAL(0, s.times(i));
+    }
+
+    RV slice = abc(1, 2);
+    CHECK_EQUAL(1, slice.length());
+    CHECK_EQUAL(3, slice.size(0));
+    CHECK_EQUAL(std::string("a"), slice.name(0));
+
+    // find a in abc
+    ivec f = a.findself(abc);
+    CHECK_EQUAL(1, f.length());
+    CHECK_EQUAL(0, f(0));
+
+    // find abc in a
+    f = abc.findself(a);
+    int exp_indices[] = { 0, -1, -1 };
+    CHECK_EQUAL(3, f.length());
+    for (unsigned i = 0;
+	 i < sizeof(exp_indices) / sizeof(exp_indices[0]);
+	 ++i) {
+        CHECK_EQUAL(exp_indices[i], f(i));
+    }
+
+    // subtract b from abc
+    RV ac = abc.subt(b);
+    std::stringstream acss;
+    acss << ac;
+    CHECK_EQUAL(std::string("1(3)=a_{0}; 3(1)=c_{0}; "), acss.str());
+
+    // data index of ac in abc
+    ivec di = ac.dataind(abc);
+    int exp_di[] = { 0, 1, 2, 5 };
+    exp_sz = sizeof(exp_di) / sizeof(exp_di[0]);
+    CHECK_EQUAL(exp_sz, di.size());
+    for (int i = 0; i < exp_sz; ++i) {
+        CHECK_EQUAL(exp_di[i], di(i));
+    }
+
+    // Copy indices between ba and ab
+    RV ba = b;
+    ba.add(a);
 	
-	cout << "Add a and b"<<endl;
-	RV ab = a;
-	ab.add(b);
-	cout << ab <<endl;
-	
-	cout << "Concat a,b and c "<<endl;
-	RV abc = concat(ab,c);
-	cout << abc <<endl;
-	cout << "Structure of a,b,c "<<endl;
-	str s =abc.tostr();
-	cout << s.ids <<endl;
-	cout << s.times <<endl;
-		
-	cout << "Find a in abc "<<endl;
-	cout << a.findself(abc)<<endl;
-	cout << "Find abc in a "<<endl;
-	cout << abc.findself(a)<<endl;
-	
-	cout << "Subtract b from abc"<<endl;
-	RV ac = abc.subt(b);
-	cout << ac <<endl;
-	
-	cout << "Data index of ac in abc"<<endl;
-	cout << ac.dataind(abc) <<endl;
-	
-	cout<< "copy indeces between ba and ab" << endl;
-	RV ba = b;
-	ba.add(a);
-	
-	ivec ai;
-	ivec bi;
-	ba.dataind(ac,ai,bi);
-	cout << "ba(" << ai <<")=ac(" << bi <<")"<<endl;
-	
-	//Exit program:
-	
-	//getchar();
-	return 0;
+    ivec ai;
+    ivec bi;
+    ba.dataind(ac, ai, bi);
 
+    int exp_ai[] = { 2, 3, 4 };
+    exp_sz = sizeof(exp_ai) / sizeof(exp_ai[0]);
+    CHECK_EQUAL(exp_sz, ai.size());
+    for (unsigned i = 0;
+	 i < sizeof(exp_ai) / sizeof(exp_ai[0]);
+	 ++i) {
+        CHECK_EQUAL(exp_ai[i], ai(i));
+    }
+
+    int exp_bi[] = { 0, 1, 2 };
+    exp_sz = sizeof(exp_bi) / sizeof(exp_bi[0]);
+    CHECK_EQUAL(exp_sz, bi.size());
+    for (unsigned i = 0;
+	 i < sizeof(exp_bi) / sizeof(exp_bi[0]);
+	 ++i) {
+        CHECK_EQUAL(exp_bi[i], bi(i));
+    }
 }
Index: library/tests/CMakeLists.txt
===================================================================
--- library/tests/CMakeLists.txt (revision 419)
+++ library/tests/CMakeLists.txt (revision 422)
@@ -11,5 +11,4 @@
 
 # BASIC EXECS
-EXEC(rv_test)
 EXEC(datalink_test)
 EXEC(loggers_test)
@@ -42,5 +41,5 @@
 
 # using UnitTest++
-add_executable(testsuite testsuite.cpp test_user_info.cpp test_shared_ptr.cpp)
+add_executable(testsuite rv_test.cpp testsuite.cpp test_user_info.cpp test_shared_ptr.cpp)
 target_link_libraries(testsuite bdm itpp unittest)
 
