[uClibc-cvs] CVS uClibc++/tests

CVS User gkajmowi gkajmowi at codepoet.org
Thu Jan 6 21:19:32 UTC 2005


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

Modified Files:
	listtest.cpp stringtest.cpp 
Log Message:
Fix of istream getline (only sets failbit if extracted 0 chars, not copied 0 chars)
Fix string::find so we can scan the last character in the string.

--- /var/cvs/uClibc++/tests/listtest.cpp	2005/01/06 18:03:06	1.6
+++ /var/cvs/uClibc++/tests/listtest.cpp	2005/01/06 21:19:30	1.7
@@ -3,12 +3,21 @@
 #include <vector>
 #include <string>
 
+class testClass{
+public:
+	void write(){
+		std::cout << "testClass::write()" << std::endl;
+	}
+};
+
 
 int main(){
 	std::string test;
 	std::list<double>temp(5, 12.0);
 	std::list<double> a;
 	std::list<double>::iterator i, j;
+	std::list<testClass *> testPointer;
+	std::list<testClass *>::iterator testPointerIterator;
 
 
 	int array1 [] = { 1, 2};
@@ -328,14 +337,30 @@
 	}
 	std::cout << std::endl;
 
-	i = a.begin();
-	while(i != a.end()){
+	i = a.end();
+	while(i != a.begin()){
+		--i;
 		std::cout << *i << " ";
-		++i;
 	}
 	std::cout << std::endl;
 
 
+	std::cout << "\nTesting lists with pointer parameters" << std::endl;
+
+	testPointer.clear();
+//	testPointer.push_back(new testClass());
+	testPointer.push_back(new testClass());
+
+	testPointerIterator = testPointer.begin();
+	while(testPointerIterator != testPointer.end()){
+		(*testPointerIterator)->write();
+		++testPointerIterator;
+	}
+//	delete testPointer.back();
+//	testPointer.pop_back();
+	delete testPointer.back();
+	testPointer.pop_back();
+
 
 	std::cout << "\nTesting sorting\n";
 
--- /var/cvs/uClibc++/tests/stringtest.cpp	2005/01/03 22:02:52	1.5
+++ /var/cvs/uClibc++/tests/stringtest.cpp	2005/01/06 21:19:30	1.6
@@ -107,6 +107,19 @@
 	std::cout << "\"" << a.substr(5, 5) << "\""  << std::endl;
 
 
+	std::cout << "\nChecking char constructor\n";
+	a = std::string(1, 'w');
+	b = "w";
+	std::cout << "The following two lines should be identical:\n";
+	std::cout << a << std::endl << b << std::endl;
+
+	std::cout << "\nChecking operator[]()\n";
+	std::cout << "The following two lines should be identical\n";
+	a = "abcdefg";
+	std::cout << "abcdefg\n";
+	std::cout << a[0] << a[1] << a[2] << a[3] << a[4] << a[5] << a[6] << std::endl;
+
+
 	std::cout << "\nChecking find on string \"" ;
 	a = "This is the string we are searching through";
 	std::cout << a << "\"\n";
@@ -121,11 +134,26 @@
 	std::cout << "Position of \"search\": ";
 	std::cout << a.find("search") << " - should be 26\n";
 
+	std::cout << "Position of \"through\": ";
+	std::cout << a.find("through") << " - should be 36\n";
+
+
 	std::cout << "Position of \"is\" starting at character 3: ";
 	std::cout << a.find("is", 3) << " - should be 5\n";
 
 	std::cout << "Position of \"q\": ";
 	std::cout << a.find("q") << " - should be " << a.npos << std::endl;
+	std::cout << "Making sure return value can be casted - ";
+	if( (long)a.find("q") >= 0){
+		std::cout << "error\n";
+	}else{
+		if((long)a.find("q") < 0){
+			std::cout << "OK\n";
+		}else{
+			std::cout << "error\n";
+		}
+	}
+	std::cout << std::endl;
 
 
 	std::cout << "\nChecking rfind on string \"";



More information about the uClibc-cvs mailing list