[uClibc-cvs] CVS uClibc++/tests
CVS User gkajmowi
gkajmowi at codepoet.org
Thu Dec 23 16:06:50 UTC 2004
Update of /var/cvs/uClibc++/tests
In directory nail:/tmp/cvs-serv884/tests
Modified Files:
Makefile algotest.cpp excepttest.cpp io.cpp listtest.cpp
maptest.cpp newdel.cpp settest.cpp stringtest.cpp
Log Message:
Fix iterator issue in list, streambuf not meeting spec. Also now valarray is more (but not) complete.
Test suite is much better.
--- /var/cvs/uClibc++/tests/Makefile 2004/12/18 22:00:53 1.10
+++ /var/cvs/uClibc++/tests/Makefile 2004/12/23 16:06:46 1.11
@@ -5,16 +5,16 @@
CXXOFLAGS = -O0
-UCXX = ../bin/g++-uc
+ifeq ($(IMPORT_LIBSUP),y)
+ULIBS = -luClibc++ -lc
+else
+ULIBS = -luClibc++ -lc -lsupc++
+endif
+
+UCXX = g++ -nodefaultlibs -nostdinc++ -fno-builtin -I../include -L../src
-#UFLAGS = -nodefaultlibs -nostdinc++ -fno-builtin -L../src
UFLAGS = -L../src
-#ifeq ($(IMPORT_LIBSUP),y)
-#ULIBS = -luClibc++ -lc
-#else
-#ULIBS = -luClibc++ -lc -lsupc++
-#endif
SRCS =\
newdel.cpp \
@@ -127,9 +127,13 @@
rm -f $(ALLBIN)
clean: cleanobjs cleanbin
+ $(MAKE) -C testoutput clean
cleanall: cleanobjs cleanbin
+test: all
+ $(MAKE) -C testoutput test
+
newdel: $(EXOBJS)
$(UCXX) -o newdel newdel.o $(CXXFLAGS) $(UFLAGS) $(LIBS) $(ULIBS)
$(CXX) -o newdel-old newdel.o-old $(COFLAGS)
--- /var/cvs/uClibc++/tests/algotest.cpp 2004/09/26 19:18:25 1.6
+++ /var/cvs/uClibc++/tests/algotest.cpp 2004/12/23 16:06:46 1.7
@@ -43,43 +43,6 @@
++i;
}
- std::cout << "Checking set operations\n";
-
- b.clear();
- b.push_back(12.5);
- b.push_back(32.7);
- b.push_back(92.7);
-
- std::cout << "The following should be 1 : ";
- std::cout << std::includes(a.begin(), a.end(), b.begin(), b.end());
- std::cout << std::endl;
-
- b.clear();
- b.push_back(12.5);
- b.push_back(92.7);
- b.push_back(92.8);
-
- std::cout << "The following should be 0 : ";
- std::cout << std::includes(a.begin(), a.end(), b.begin(), b.end());
- std::cout << std::endl;
-
- b.clear();
- std::cout << "The following should be 1 : ";
- std::cout << std::includes(a.begin(), a.end(), b.begin(), b.end());
- std::cout << std::endl;
-
- b.push_back(12.5);
- std::cout << "The following should be 1 : ";
- std::cout << std::includes(a.begin(), a.end(), b.begin(), b.end());
- std::cout << std::endl;
-
- b.clear();
- b.push_back(1.0);
- std::cout << "The following should be 0 : ";
- std::cout << std::includes(a.begin(), a.end(), b.begin(), b.end());
- std::cout << std::endl;
-
-
std::cout << "Searching\n";
std::cout << "The following should be 1 : ";
std::cout << std::binary_search(a.begin(), a.end(), 32.7);
@@ -358,133 +321,6 @@
std::cout << std::endl;
- std::cout << "Set union\n";
- a.clear();
- a.push_back(10.8);
- a.push_back(12.5);
- a.push_back(32.7);
- a.push_back(52.9);
- a.push_back(72.3);
-
- b.clear();
- b.push_back(12.5);
- b.push_back(19.6);
- b.push_back(22.7);
- b.push_back(32.7);
- b.push_back(38.4);
- b.push_back(52.9);
- b.push_back(92.7);
-
- c.assign(20, 0.0);
-
- std::cout << "The following two lines should be identical:\n";
- std::cout << "10.8 12.5 19.6 22.7 32.7 38.4 52.9 72.3 92.7 " << std::endl;
-
- j = std::set_union(a.begin(), a.end(), b.begin(), b.end(), c.begin() );
- i = c.begin();
- while(i != j){
- std::cout << *i << " " ;
- ++i;
- }
- std::cout << std::endl;
-
-
- std::cout << "Set intersection\n";
- a.clear();
- a.push_back(10.8);
- a.push_back(12.5);
- a.push_back(32.7);
- a.push_back(52.9);
- a.push_back(72.3);
-
- b.clear();
- b.push_back(12.5);
- b.push_back(19.6);
- b.push_back(22.7);
- b.push_back(32.7);
- b.push_back(38.4);
- b.push_back(52.9);
- b.push_back(92.7);
-
- c.assign(20, 0.0);
-
- std::cout << "The following two lines should be identical:\n";
- std::cout << "12.5 32.7 52.9 " << std::endl;
-
- j = std::set_intersection(a.begin(), a.end(), b.begin(), b.end(), c.begin() );
- i = c.begin();
- while(i != j){
- std::cout << *i << " " ;
- ++i;
- }
- std::cout << std::endl;
-
-
-
- std::cout << "Set difference\n";
- a.clear();
- a.push_back(10.8);
- a.push_back(12.5);
- a.push_back(12.5);
- a.push_back(32.7);
- a.push_back(52.9);
- a.push_back(72.3);
-
- b.clear();
- b.push_back(12.5);
- b.push_back(19.6);
- b.push_back(22.7);
- b.push_back(32.7);
- b.push_back(38.4);
- b.push_back(52.9);
- b.push_back(92.7);
-
- c.assign(20, 0.0);
-
- std::cout << "The following two lines should be identical:\n";
- std::cout << "10.8 72.3 " << std::endl;
-
- j = std::set_difference(a.begin(), a.end(), b.begin(), b.end(), c.begin() );
- i = c.begin();
- while(i != j){
- std::cout << *i << " " ;
- ++i;
- }
- std::cout << std::endl;
-
-
- std::cout << "Set symmetric difference\n";
- a.clear();
- a.push_back(10.8);
- a.push_back(12.5);
- a.push_back(12.5);
- a.push_back(32.7);
- a.push_back(52.9);
- a.push_back(72.3);
-
- b.clear();
- b.push_back(12.5);
- b.push_back(19.6);
- b.push_back(22.7);
- b.push_back(32.7);
- b.push_back(38.4);
- b.push_back(52.9);
- b.push_back(92.7);
-
- c.assign(20, 0.0);
-
- std::cout << "The following two lines should be identical:\n";
- std::cout << "10.8 19.6 22.7 38.4 72.3 92.7 " << std::endl;
-
- j = std::set_symmetric_difference(a.begin(), a.end(), b.begin(), b.end(), c.begin() );
- i = c.begin();
- while(i != j){
- std::cout << *i << " " ;
- ++i;
- }
- std::cout << std::endl;
-
-
std::cout << "Permutation test\n";
a.clear();
--- /var/cvs/uClibc++/tests/excepttest.cpp 2004/08/20 16:17:08 1.1
+++ /var/cvs/uClibc++/tests/excepttest.cpp 2004/12/23 16:06:46 1.2
@@ -23,7 +23,7 @@
}
- printf("Testing inheriting excepetion handler\n");
+ printf("Testing inheriting exception handler\n");
try{
printf("Throwing length_error\n");
throw std::length_error("Length error test text");
--- /var/cvs/uClibc++/tests/io.cpp 2004/09/01 16:39:31 1.4
+++ /var/cvs/uClibc++/tests/io.cpp 2004/12/23 16:06:46 1.5
@@ -24,7 +24,9 @@
float i = 0;
long double j = 0;
- std::cout << "Address of i: " << &i << std::endl;
+ void * p = (void *)12345678;
+
+ std::cout << "Pointer: " << p << std::endl;
std::cout << "Please enter two floats:" << std::flush;
std::cin >> i >> j;
--- /var/cvs/uClibc++/tests/listtest.cpp 2004/09/17 02:47:52 1.4
+++ /var/cvs/uClibc++/tests/listtest.cpp 2004/12/23 16:06:46 1.5
@@ -56,7 +56,7 @@
i = temp.begin();
++i;
i = temp.erase(i);
- std::cout << "First element in list: " << *i << std::endl;
+ std::cout << "Second element in list: " << *i << std::endl;
for(j = temp.begin(); j!=temp.end(); j++){
std::cout << "j: " << *j << std::endl;
}
@@ -67,7 +67,8 @@
i--;
i--;
i = temp.erase(i,temp.end());
- std::cout << "First element in list: " << *i << std::endl;
+ --i;
+ std::cout << "Last element in list: " << *i << std::endl;
for(j = temp.begin(); j!=temp.end(); j++){
std::cout << "j: " << *j << std::endl;
}
--- /var/cvs/uClibc++/tests/maptest.cpp 2004/09/17 02:47:52 1.4
+++ /var/cvs/uClibc++/tests/maptest.cpp 2004/12/23 16:06:46 1.5
@@ -31,7 +31,7 @@
test["a"] = 1;
- std::cout << "Elements: " << std::endl;
+ std::cout << "Elements:" << std::endl;
std::cout << "test[\"b\"] = " << test["b"] << std::endl;
std::cout << "test[\"a\"] = " << test["a"] << std::endl;
std::cout << "test[\"k\"] = " << test["k"] << std::endl;
@@ -58,7 +58,6 @@
std::cout << "Number of elements: " << test.size() << std::endl;
std::cout << "Container empty? " << test.empty() << std::endl;
- std::cout << "Max size: " << test.max_size() << std::endl;
std::pair<std::string, double> q;
--- /var/cvs/uClibc++/tests/newdel.cpp 2004/09/01 16:39:31 1.2
+++ /var/cvs/uClibc++/tests/newdel.cpp 2004/12/23 16:06:46 1.3
@@ -1,10 +1,47 @@
#include <new>
+#include <cstdio>
struct test{
int a;
float b;
};
+class base {
+protected:
+ int a;
+
+public:
+ base() : a(0){
+ printf("Executing default base class constructor\n");
+ }
+
+ virtual ~base(){
+ printf("Executing base class destructor\n");
+ }
+
+ virtual void print(){
+ printf("Base class print function with a=%i\n", a);
+ }
+
+};
+
+class sub : public base{
+protected:
+ float f;
+public:
+ sub() : f(0){
+ printf("Executing default sub class constructor\n");
+ }
+ virtual ~sub(){
+ printf("Executing sub class destructor\n");
+ }
+
+ virtual void print(){
+ printf("Sub class print function with a=%i and f=%f\n", a, f);
+ }
+
+};
+
int main(){
test * temp = new test;
@@ -16,5 +53,28 @@
delete [] temp;
temp = 0;
+ base * b = new base;
+ b->print();
+ delete b;
+ b=0;
+
+ b = new base[3];
+ for(int i = 0; i < 3; ++i){
+ b[i].print();
+ }
+ delete [] b;
+ b = 0;
+
+ b = new sub;
+ b->print();
+ delete b;
+ b = 0;
+
+ //We can only create one because we can't step through the array properly
+ b = new sub[1];
+ b[0].print();
+ delete [] b;
+ b = 0;
+
return 0;
}
--- /var/cvs/uClibc++/tests/settest.cpp 2004/09/08 14:27:08 1.2
+++ /var/cvs/uClibc++/tests/settest.cpp 2004/12/23 16:06:46 1.3
@@ -1,9 +1,15 @@
#include <iostream>
+#include <algorithm>
#include <set>
+#include <vector>
int main(){
std::cout << "Starting set test\n";
std::set<int> a;
+ std::vector<int> c;
+ std::vector<int>::iterator k, l;
+
+ c.clear();
if(a.empty() == false){
std::cout << "ERROR - set should be empty\n";
@@ -27,7 +33,7 @@
- std::set<int>::iterator i;
+ std::set<int>::iterator i, j;
std::cout << "Element list" << std::endl;
i = a.begin();
@@ -51,5 +57,181 @@
}
+ std::cout << "Set algorithms test" << std::endl;
+ std::cout << "Testing std::includes\n";
+
+ a.clear();
+ a.insert(12);
+ a.insert(32);
+ a.insert(85);
+ a.insert(25);
+ a.insert(63);
+ a.insert(92);
+
+ std::set<int> b(a);
+
+
+ b.clear();
+ b.insert(12);
+ b.insert(32);
+ b.insert(92);
+
+ std::cout << "The following should be 1 : ";
+ std::cout << std::includes(a.begin(), a.end(), b.begin(), b.end());
+ std::cout << std::endl;
+
+ b.clear();
+ b.insert(12);
+ b.insert(92);
+ b.insert(91);
+
+ std::cout << "The following should be 0 : ";
+ std::cout << std::includes(a.begin(), a.end(), b.begin(), b.end());
+ std::cout << std::endl;
+
+ b.clear();
+ std::cout << "The following should be 1 : ";
+ std::cout << std::includes(a.begin(), a.end(), b.begin(), b.end());
+ std::cout << std::endl;
+
+ b.insert(12);
+ std::cout << "The following should be 1 : ";
+ std::cout << std::includes(a.begin(), a.end(), b.begin(), b.end());
+ std::cout << std::endl;
+
+
+ b.clear();
+ b.insert(1);
+ std::cout << "The following should be 0 : ";
+ std::cout << std::includes(a.begin(), a.end(), b.begin(), b.end());
+ std::cout << std::endl;
+
+
+ std::cout << "Set union\n";
+ a.clear();
+ a.insert(10);
+ a.insert(12);
+ a.insert(32);
+ a.insert(52);
+ a.insert(72);
+
+ b.clear();
+ b.insert(12);
+ b.insert(19);
+ b.insert(22);
+ b.insert(32);
+ b.insert(38);
+ b.insert(52);
+ b.insert(92);
+
+ c.assign(20, 0.0);
+
+ std::cout << "The following two lines should be identical:\n";
+ std::cout << "10 12 19 22 32 38 52 72 92 " << std::endl;
+
+ l = std::set_union(a.begin(), a.end(), b.begin(), b.end(), c.begin() );
+ k = c.begin();
+ while(k != l){
+ std::cout << *k << " " ;
+ ++k;
+ }
+ std::cout << std::endl;
+
+
+ std::cout << "Set intersection\n";
+ a.clear();
+ a.insert(10);
+ a.insert(12);
+ a.insert(32);
+ a.insert(52);
+ a.insert(72);
+
+ b.clear();
+ b.insert(12);
+ b.insert(19);
+ b.insert(22);
+ b.insert(32);
+ b.insert(38);
+ b.insert(52);
+ b.insert(92);
+
+ c.assign(20, 0.0);
+ std::cout << "Size of c: " << c.size() << std::endl;
+
+ std::cout << "The following two lines should be identical:\n";
+ std::cout << "12 32 52 " << std::endl;
+
+ l = std::set_intersection(a.begin(), a.end(), b.begin(), b.end(), c.begin() );
+ k = c.begin();
+ while(k != l){
+ std::cout << *k << " " ;
+ ++k;
+ }
+ std::cout << std::endl;
+
+
+
+ std::cout << "Set difference\n";
+ a.clear();
+ a.insert(10);
+ a.insert(12);
+ a.insert(32);
+ a.insert(52);
+ a.insert(72);
+
+ b.clear();
+ b.insert(12);
+ b.insert(19);
+ b.insert(22);
+ b.insert(32);
+ b.insert(38);
+ b.insert(52);
+ b.insert(92);
+
+ c.assign(20, 0.0);
+
+ std::cout << "The following two lines should be identical:\n";
+ std::cout << "10 72 " << std::endl;
+
+ l = std::set_difference(a.begin(), a.end(), b.begin(), b.end(), c.begin() );
+ k = c.begin();
+ while(k != l){
+ std::cout << *k << " " ;
+ ++k;
+ }
+ std::cout << std::endl;
+
+
+ std::cout << "Set symmetric difference\n";
+ a.clear();
+ a.insert(10);
+ a.insert(12);
+ a.insert(32);
+ a.insert(52);
+ a.insert(72);
+
+ b.clear();
+ b.insert(12);
+ b.insert(19);
+ b.insert(22);
+ b.insert(32);
+ b.insert(38);
+ b.insert(52);
+ b.insert(92);
+
+ c.assign(20, 0.0);
+
+ std::cout << "The following two lines should be identical:\n";
+ std::cout << "10 19 22 38 72 92 " << std::endl;
+
+ l = std::set_symmetric_difference(a.begin(), a.end(), b.begin(), b.end(), c.begin() );
+ k = c.begin();
+ while(k != l){
+ std::cout << *k << " " ;
+ ++k;
+ }
+ std::cout << std::endl;
+
+
return 0;
}
--- /var/cvs/uClibc++/tests/stringtest.cpp 2004/08/20 16:17:08 1.1
+++ /var/cvs/uClibc++/tests/stringtest.cpp 2004/12/23 16:06:46 1.2
@@ -100,7 +100,11 @@
std::cin >> a;
std::cout << std::endl << "You entered: " << a << std::endl;
-
+ std::cout << "Checking advanced string functions:\n";
+ std::cout << "Checking substr. The following two lines should be identical:\n";
+ a="This is the base string";
+ std::cout << "\"is th\"" << std::endl;
+ std::cout << "\"" << a.substr(5, 5) << "\"" << std::endl;
return 0;
}
More information about the uClibc-cvs
mailing list