[uClibc-cvs] CVS uClibc++/tests

CVS User gkajmowi gkajmowi at codepoet.org
Fri Sep 17 02:47:53 UTC 2004


Update of /var/cvs/uClibc++/tests
In directory nail:/tmp/cvs-serv30023/tests

Modified Files:
	Makefile algotest.cpp dequetest.cpp listtest.cpp maptest.cpp 
Added Files:
	stacktest.cpp 
Log Message:
-Added code for all algorithms
-Fixed map/set code to prevent infinite loops.  Oops.
-Fixed list code to prevent most memory leaks.  1 still remains, but unknown location
-stlport v 1.00 test suite now compiles, links and runs.  Some issues remain
-Fix deque constructor using the wrong end_pointer value
-Added erase capability to vector
-Changed multimap::find to point to first matching element instead of any matching element
-Added more tests to test suite based upon problems from stlport test suite

--- /var/cvs/uClibc++/tests/Makefile	2004/09/08 14:27:08	1.6
+++ /var/cvs/uClibc++/tests/Makefile	2004/09/17 02:47:52	1.7
@@ -23,7 +23,8 @@
 	settest.cpp \
 	numerictest.cpp \
 	bitsettest.cpp \
-	algotest.cpp
+	algotest.cpp \
+	stacktest.cpp
 
 
 EXOBJS	=\
@@ -39,7 +40,8 @@
 	newdel.o \
 	numerictest.o \
 	bitsettest.o \
-	algotest.o
+	algotest.o \
+	stacktest.o
 
 ALLOBJS	=	$(EXOBJS) \
 		newdel.o-old \
@@ -54,7 +56,8 @@
 		settest.o-old \
 		numerictest.o-old \
 		bitsettest.o-old \
-		algotest.o-old
+		algotest.o-old \
+		stacktest.o-old
 
 ALLBIN	=	newdel newdel-old \
 		io io-old \
@@ -68,9 +71,11 @@
 		listtest listtest-old \
 		numerictest numerictest-old \
 		bitsettest bitsettest-old \
-		algotest algotest-old
+		algotest algotest-old \
+		stacktest stacktest-old
 
-ALLTGT	=	algotest \
+ALLTGT	=	stacktest \
+		algotest \
 		bitsettest \
 		sstreamtest \
 		numerictest \
@@ -165,6 +170,10 @@
 	$(CXX) -o algotest algotest.o $(CXXFLAGS) $(UFLAGS) $(ULIBS)
 	$(CXX) -o algotest-old algotest.o-old $(COFLAGS)
 
+stacktest: $(EXOBJS)
+	$(CXX) -o stacktest stacktest.o $(CXXFLAGS) $(UFLAGS) $(ULIBS)
+	$(CXX) -o stacktest-old stacktest.o-old $(COFLAGS)
+
 
 .cpp.o:
 	$(CXX) -c $(CXXFLAGS) -o $@ $<
--- /var/cvs/uClibc++/tests/algotest.cpp	2004/09/12 02:20:33	1.4
+++ /var/cvs/uClibc++/tests/algotest.cpp	2004/09/17 02:47:52	1.5
@@ -485,5 +485,46 @@
 	std::cout << std::endl;
 
 
+	std::cout << "Permutation test\n";
+
+	a.clear();
+	a.push_back(1);
+	a.push_back(2);
+	a.push_back(3);
+	a.push_back(4);
+
+	i = a.begin();
+	while(i != a.end() ){
+		std::cout << *i << " " ;
+		++i;
+	}
+	std::cout << std::endl;
+
+
+	for(int x = 0; x < 24; ++x){
+		std::next_permutation(a.begin(), a.end());
+		i = a.begin();
+		while(i != a.end() ){
+			std::cout << *i << " " ;
+			++i;
+		}
+		std::cout << std::endl;
+
+	}
+
+	std::cout << "Previous permutation:\n";
+
+	for(int x = 0; x < 24; ++x){
+		std::prev_permutation(a.begin(), a.end());
+		i = a.begin();
+		while(i != a.end() ){
+			std::cout << *i << " " ;
+			++i;
+		}
+		std::cout << std::endl;
+
+	}
+
+
 	return 0;
 }
--- /var/cvs/uClibc++/tests/dequetest.cpp	2004/08/20 16:17:08	1.1
+++ /var/cvs/uClibc++/tests/dequetest.cpp	2004/09/17 02:47:52	1.2
@@ -63,8 +63,10 @@
 	std::cout << "Copy constructor:" << std::endl;
 
 	std::deque<double> test2(test);
-	for(i = test2.begin(); i !=test2.end(); ++i){
+	i = test2.begin();
+	while(i !=test2.end()){
 		std::cout << *i << std::endl;
+		++i;
 	}
 
 
--- /var/cvs/uClibc++/tests/listtest.cpp	2004/09/12 02:20:33	1.3
+++ /var/cvs/uClibc++/tests/listtest.cpp	2004/09/17 02:47:52	1.4
@@ -10,6 +10,16 @@
 	std::list<double> a;
 	std::list<double>::iterator i, j;
 
+
+	int array1 [] = { 1, 2};
+	int array2 [] = { 3, 4};
+
+	std::list<int> list_int_1( array1, array1 + 2);
+	std::list<int> list_int_2( array2, array2 + 2);
+	std::list<int>::iterator list_iter_1;
+	std::list<int>::iterator list_iter_2;
+
+
 	test = "Begining of list test";
 
 	std::cout << test << std::endl;
@@ -19,7 +29,7 @@
 
 
 
-	std::cout << "List insert test\n";
+	std::cout << "\nList insert test\n";
 	i = temp.begin();
 	i++;
 	++i;
@@ -30,7 +40,7 @@
 	}
 
 
-	std::cout << "List multi-insert test\n";
+	std::cout << "\nList multi-insert test\n";
 	i = temp.end();
 	--i;
 	i--;
@@ -56,14 +66,14 @@
 	i--;
 	i--;
 	i--;
-	temp.erase(i,temp.end());
+	i = temp.erase(i,temp.end());
 	std::cout << "First element in list: " << *i << std::endl;
 	for(j = temp.begin(); j!=temp.end(); j++){
 		std::cout << "j: " << *j << std::endl;
 	}
 
 
-	std::cout << "Testing reverse\n";
+	std::cout << "\nTesting reverse\n";
 	temp.clear();
 	temp.push_back(12.8);
 	temp.push_back(22.4);
@@ -91,7 +101,7 @@
 	}
 	std::cout << std::endl;
 
-	std::cout << "Testing splice" << std::endl;
+	std::cout << "\nTesting splice" << std::endl;
 
 	temp.clear();
 	temp.push_back(12.8);
@@ -264,8 +274,40 @@
 	std::cout << std::endl;
 
 
+	std::cout << "The following two lines should be identical\n";
+	std::cout << "1 2 3 4 \n";
+
+	list_iter_1 = list_int_1.begin();
+	while(list_iter_1 != list_int_1.end()){
+		std::cout << *list_iter_1 << " ";
+		++list_iter_1;
+	}
+	list_iter_1 = list_int_2.begin();
+	while(list_iter_1 != list_int_2.end()){
+		std::cout << *list_iter_1 << " ";
+		++list_iter_1;
+	}
+	std::cout << std::endl;
+
+	list_iter_1 = list_int_1.begin();
+	list_iter_1++;
+
+
+	std::cout << "The following two lines should be identical\n";
+	std::cout << "1 3 4 2 \n";
+	
+	list_int_1.splice(list_iter_1, list_int_2, list_int_2.begin(), list_int_2.end());
+
+	list_iter_1 = list_int_1.begin();
+	while(list_iter_1 != list_int_1.end()){
+		std::cout << *list_iter_1 << " ";
+		++list_iter_1;
+	}
+	std::cout << std::endl;
+	
+
 
-	std::cout << "Testing sorting\n";
+	std::cout << "\nTesting sorting\n";
 
 	temp.clear();
 	temp.push_back(12.8);
@@ -289,7 +331,7 @@
 
 
 
-	std::cout << "Testing merging\n";
+	std::cout << "\nTesting merging\n";
 
 	temp.clear();
 	temp.push_back(12.8);
@@ -316,7 +358,7 @@
 	
 
 
-	std::cout << "Testing remove\n";
+	std::cout << "\nTesting remove\n";
 
 	temp.clear();
 	temp.push_back(12.8);
@@ -340,7 +382,7 @@
 
 
 
-	std::cout << "Testing unique\n";
+	std::cout << "\nTesting unique\n";
 
 	temp.clear();
 	temp.push_back(11.7);
--- /var/cvs/uClibc++/tests/maptest.cpp	2004/09/08 14:27:08	1.3
+++ /var/cvs/uClibc++/tests/maptest.cpp	2004/09/17 02:47:52	1.4
@@ -2,6 +2,15 @@
 #include <iostream>
 
 
+struct Int {
+	Int(int x = 0) : val(x) { };
+	int val;
+};
+
+std::ostream& operator<<(std::ostream& s, Int x)
+  { return s << x.val; }
+
+
 int main(){
 	std::map<std::string, double> test;
 	std::map<std::string, double>::iterator i, j;
@@ -108,6 +117,21 @@
 
 
 	std::cout << "This should read 11: " << test.equal_range("k").first->second << std::endl;
+
+
+
+	typedef std::map<char, Int, std::less<char> > maptype;
+
+	maptype map_char_myClass;
+	// Store mappings between roman numerals and decimals.
+	map_char_myClass['l'] = 50;
+	map_char_myClass['x'] = 20; // Deliberate mistake.
+	map_char_myClass['v'] = 5;
+	map_char_myClass['i'] = 1;
+	std::cout << "map_char_myClass['x'] = " << map_char_myClass['x'] << std::endl;
+	map_char_myClass['x'] = 10; // Correct mistake.
+	std::cout << "map_char_myClass['x'] = " << map_char_myClass['x'] << std::endl;
+	std::cout << "map_char_myClass['z'] = " << map_char_myClass['z'] << std::endl; // Note default value is added.
 	
 
 



More information about the uClibc-cvs mailing list