|
Boost-Commit : |
From: chintanraoh_at_[hidden]
Date: 2008-06-06 13:50:22
Author: chintanraoh
Date: 2008-06-06 13:50:22 EDT (Fri, 06 Jun 2008)
New Revision: 46199
URL: http://svn.boost.org/trac/boost/changeset/46199
Log:
added test of erase(iterator)
Text files modified:
sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/test_trie_string.cpp | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
Modified: sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/test_trie_string.cpp
==============================================================================
--- sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/test_trie_string.cpp (original)
+++ sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/test_trie_string.cpp 2008-06-06 13:50:22 EDT (Fri, 06 Jun 2008)
@@ -62,7 +62,7 @@
//testing copy contructor
template <class T>
-void test_copy(const T &tr)
+void test_copy(T tr)
{
BOOST_CHECK( tr.find("hello")!=tr.end() );
BOOST_CHECK( *tr.find("hello")==1 );
@@ -231,12 +231,15 @@
{
T tr;
typename T::iterator it;
+ typename T::const_iterator cit;
tr.insert(make_pair("hello",1));
it=tr.find("hello");
tr.erase(it);
BOOST_CHECK(tr.find("hello")==tr.end());
+ //it=cit; //TODO:MAKE THIS NOT COMPILE
+ cit=it; //should compile properly
//"" 3<"hel" 4<"hellish" 7<"hello" 1<"wor" 5<"world" 2<"worry" 6
tr=test_insert<T>();
@@ -245,6 +248,7 @@
tr.erase(it);
BOOST_CHECK(tr.find("hello")==tr.end());
+
it=tr.find("wor");
BOOST_CHECK(it!=tr.end());
tr.erase(it);
@@ -274,9 +278,31 @@
BOOST_CHECK(it!=tr.end());
tr.erase(it);
BOOST_CHECK(tr.find("")==tr.end());
+
BOOST_CHECK( tr.empty() );
}
+template<class T>
+void test_erase_range(T tr)
+{
+ typename T::iterator it;
+ std::cout<<"test erase"<<std::endl;
+
+// "" 3<"hel" 4<"hellish" 7<"hello" 1<"wor" 5<"world" 2<"worry" 6
+// tr.erase(tr.begin(),tr.end());
+ it=tr.begin();
+ std::cout<<"grrr..."<<*it<<std::endl;
+ ++it;
+ std::cout<<"grrrr..."<<*it<<std::endl;
+ ++it;
+ std::cout<<"grrr..."<<*it<<std::endl;
+ ++it;
+ std::cout<<"grrr..."<<*it<<std::endl;
+
+ tr.erase(tr.begin(),it);
+ //BOOST_CHECK( tr.empty() );
+}
+
int test_main(int,char **)
{
typedef trie<std::string,int,trie_array_node,string_traits> trie_type;
@@ -288,8 +314,10 @@
test_bound(tr);
test_erase(tr);
test_iteration(tr);
-
test_erase_iterator<trie_type>();
+
+ //test_erase_range(tr);
+
return 0;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk