[uClibc-cvs] CVS update of uClibc++ (README tests/algotest.cpp tests/hello.cpp tests/hello.o-old tests/mmaptest.cpp)

Garrett Kajmowicz gkajmowi at codepoet.org
Thu Sep 9 18:42:53 UTC 2004


    Date: Thursday, September 9, 2004 @ 12:42:53
  Author: gkajmowi
    Path: /var/cvs/uClibc++

   Added: README (1.1) tests/algotest.cpp (1.1) tests/mmaptest.cpp (1.1)
 Removed: tests/hello.cpp (1.1) tests/hello.o-old (1.3)

Syncing cvs code to current developement level (0.1.4-pre)


Index: uClibc++/README
diff -u /dev/null uClibc++/README:1.1
--- /dev/null	Thu Sep  9 12:42:53 2004
+++ uClibc++/README	Thu Sep  9 12:42:52 2004
@@ -0,0 +1,6 @@
+A few notes:
+
+-	If you are looking to statically compile an application, you must compile it
+	without the use of either rtti or exceptions.  The library should be compiled
+	likewise.  Since the application will be statically compiled, you may run a 
+	dynamic library with exception support.
Index: uClibc++/tests/algotest.cpp
diff -u /dev/null uClibc++/tests/algotest.cpp:1.1
--- /dev/null	Thu Sep  9 12:42:53 2004
+++ uClibc++/tests/algotest.cpp	Thu Sep  9 12:42:52 2004
@@ -0,0 +1,196 @@
+#include <iostream>
+#include <algorithm>
+#include <functional>
+#include <vector>
+
+
+template <class T> class less_than : public std::unary_function <T, bool>{
+	T arg;
+public:
+	explicit less_than(const T & x) : arg(x) {  }
+	bool operator()(const T& x) const { return x < arg; }
+};
+
+
+int main(){
+	std::cout << "Begining algorithm test" << std::endl;
+
+	std::vector<double> a, b;
+
+	std::vector<double>::iterator i, j;
+	a.push_back(12.5);
+	a.push_back(32.7);
+	a.push_back(85.3);
+	a.push_back(25.8);
+	a.push_back(63.8);
+	a.push_back(92.7);
+
+	std::cout << "Starting element list:\n";
+
+	i = a.begin();
+	while(i != a.end()){
+		std::cout << *i << std::endl;
+		++i;
+	}
+
+	std::sort<std::vector<double>::iterator>(a.begin(), a.end());
+
+	std::cout << "Sorted elements:\n";
+
+	i = a.begin();
+	while(i != a.end()){
+		std::cout << *i << std::endl;
+		++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);
+	std::cout << std::endl;
+
+	std::cout << "The following should be 0 : ";
+	std::cout << std::binary_search(a.begin(), a.end(), 99.9);
+	std::cout << std::endl;
+
+	std::cout << "The following should be 0 : ";
+	std::cout << std::binary_search(a.begin(), a.end(), 1.0);
+	std::cout << std::endl;
+
+	std::cout << "The following should be 0 : ";
+	std::cout << std::binary_search(a.begin(), a.end(), 27.7);
+	std::cout << std::endl;
+
+	std::cout << "The following should be 0 : ";
+	std::cout << std::binary_search(a.begin(), a.end(), -26);
+	std::cout << std::endl;
+
+	std::cout << "The following should be 1 : ";
+	std::cout << std::binary_search(a.begin(), a.end(), 12.5);
+	std::cout << std::endl;
+
+	std::cout << "Bounds checks\n";
+	std::cout << "The following should read 32.7 : ";
+	std::cout << *(std::lower_bound(a.begin(), a.end(), 32.7));
+	std::cout << std::endl;
+
+	std::cout << "The following should read 32.7 : ";
+	std::cout << *(std::lower_bound(a.begin(), a.end(), 27.5));
+	std::cout << std::endl;
+
+	b.clear();
+	b.push_back(2);
+	b.push_back(3);
+	b.push_back(3);
+	b.push_back(3);
+	b.push_back(4);
+	b.push_back(7);
+	b.push_back(8);
+	b.push_back(9);
+
+	std::cout << "The following should read 3 : ";
+	std::cout << *(std::lower_bound(b.begin(), b.end(), 3));
+	std::cout << std::endl;
+
+	std::cout << "The following two lines should be identical:\n";
+	std::cout << "3 3 3 4 7 8 9 \n";
+	i = std::lower_bound(b.begin(), b.end(), 3);
+	while( i != b.end()){
+		std::cout << *i << " ";
+		++i;
+	}
+	std::cout << std::endl;
+
+
+	std::cout << "The following should read 32.7 : ";
+	std::cout << *(std::upper_bound(a.begin(), a.end(), 27.5));
+	std::cout << std::endl;
+
+	std::cout << "The following should read 2 : ";
+	std::cout << *(std::lower_bound(b.begin(), b.end(), 1));
+	std::cout << std::endl;
+
+	std::cout << "The following two lines should be identical:\n";
+	std::cout << "4 7 8 9 \n";
+	i = std::upper_bound(b.begin(), b.end(), 3);
+	while( i != b.end()){
+		std::cout << *i << " ";
+		++i;
+	}
+	std::cout << std::endl;
+
+
+	std::cout << "Partition Tests\n";
+	b.clear();
+	b.push_back(12.5);
+	b.push_back(32.7);
+	b.push_back(10.8);
+	b.push_back(92.7);
+	b.push_back(12.5);
+	b.push_back(22.7);
+	b.push_back(38.4);
+	b.push_back(52.9);
+	b.push_back(72.3);
+	b.push_back(19.6);
+
+
+	std::cout << "The following two lines should be identical:\n";
+	std::cout << "32.7 92.7 22.7 38.4 52.9 72.3" << std::endl;
+	i = std::stable_partition(b.begin(), b.end(), less_than<double>(20) );
+	j = i;
+	while(j != b.end()){
+		std::cout << *j << " ";
+		++j;
+	}
+	std::cout << std::endl;
+
+	std::cout << "The following two lines should be identical:\n";
+	std::cout << "12.5 10.8 12.5 19.6" << std::endl;
+	j = b.begin();
+	while(j != i){
+		std::cout << *j << " ";
+		++j;
+	}
+	std::cout << std::endl;
+
+
+
+	return 0;
+}
+
Index: uClibc++/tests/hello.cpp
diff -u uClibc++/tests/hello.cpp:1.1 uClibc++/tests/hello.cpp:removed
--- uClibc++/tests/hello.cpp:1.1	Thu Jul 22 12:10:07 2004
+++ uClibc++/tests/hello.cpp	Thu Sep  9 12:42:53 2004
@@ -1,6 +0,0 @@
-#include <iostream>
-
-int main(){
-	std::cout << "Hello, world!\n";
-	return 0;
-}
Index: uClibc++/tests/hello.o-old
<<Binary file>>
Index: uClibc++/tests/mmaptest.cpp
diff -u /dev/null uClibc++/tests/mmaptest.cpp:1.1
--- /dev/null	Thu Sep  9 12:42:53 2004
+++ uClibc++/tests/mmaptest.cpp	Thu Sep  9 12:42:53 2004
@@ -0,0 +1,106 @@
+#include <map>
+#include <iostream>
+
+
+int main(){
+	std::multimap<std::string, double> test;
+	std::multimap<std::string, double>::iterator i, j;
+	std::multimap<std::string, double>::const_iterator k;
+
+	std::cout << "Start of multimap test" << std::endl;
+
+	std::cout << "Adding a few elements..." << std::endl;
+
+
+	std::pair<std::string, double> a;
+	std::pair<std::string, double> b;
+	std::pair<std::map<std::string, double>::iterator, bool> c;
+
+	a.first="a";
+	a.second=1;
+	test.insert(a);
+
+	a.first="c";
+	a.second=3;
+	test.insert(a);
+
+	a.first="c";
+	a.second=3.1;
+	test.insert(a);
+
+	a.first="d";
+	a.second=4;
+	test.insert(a);
+
+	a.first="g";
+	a.second=7;
+	test.insert(a);
+
+	i = test.begin();
+	while(i != test.end()){
+		std::cout << "Element " << i->first << ": " << i->second << std::endl;
+		++i;
+	}
+
+	std::cout << "Checking locations\n";
+
+	i = test.find("c");
+	std::cout << "Element c: " << i->first << ": " << i->second << std::endl;
+
+	i = test.find("d");
+	std::cout << "Element d: " << i->first << ": " << i->second << std::endl;
+
+
+	a.first="c";
+	a.second=3.14;
+	i=test.begin();
+	++i;
+	++i;
+
+	test.insert(i, a);
+
+	std::cout << "Testing positioned inserting\n";
+
+	i = test.begin();
+	while(i != test.end()){
+		std::cout << "Element " << i->first << ": " << i->second << std::endl;
+		++i;
+	}
+
+	std::cout << "Count of \"c\" elements: " << test.count("c") << std::endl;
+	std::cout << "Count of \"d\" elements: " << test.count("d") << std::endl;
+	std::cout << "Count of \"q\" elements: " << test.count("q") << std::endl;
+
+
+	i = test.lower_bound("c");
+	std::cout << "lower bound for c: " << i->first << ": " << i->second << std::endl;
+	i = test.upper_bound("c");
+	std::cout << "upper bound for c: " << i->first << ": " << i->second << std::endl;
+
+	std::cout << "Erasing all \"c\" elements\n";
+	test.erase("c");
+
+	i = test.begin();
+	while(i != test.end()){
+		std::cout << "Element " << i->first << ": " << i->second << std::endl;
+		++i;
+	}
+
+	std::cout << "Inserting \"c\": 3.7\n";
+
+	a.first = "c";
+	a.second=3.7;
+	test.insert(a);
+
+	i = test.begin();
+	while(i != test.end()){
+		std::cout << "Element " << i->first << ": " << i->second << std::endl;
+		++i;
+	}
+
+
+	
+	return 0;
+}
+
+



More information about the uClibc-cvs mailing list