|
Boost-Commit : |
From: chintanraoh_at_[hidden]
Date: 2008-05-31 10:12:03
Author: chintanraoh
Date: 2008-05-31 10:12:02 EDT (Sat, 31 May 2008)
New Revision: 45974
URL: http://svn.boost.org/trac/boost/changeset/45974
Log:
contains a half done trie class and a simple test case file
Added:
sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/test.cpp (contents, props changed)
Removed:
sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/test_nothing.cpp
sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/test_nothing_n.cpp
Text files modified:
sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/Jamfile | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
Modified: sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/Jamfile
==============================================================================
--- sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/Jamfile (original)
+++ sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/Jamfile 2008-05-31 10:12:02 EDT (Sat, 31 May 2008)
@@ -12,5 +12,4 @@
<define>BOOST_ALL_NO_LIB=1
;
-run test_nothing.cpp ;
-run test_nothing_n.cpp ;
+run test.cpp ;
Added: sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/test.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/test.cpp 2008-05-31 10:12:02 EDT (Sat, 31 May 2008)
@@ -0,0 +1,79 @@
+#include<boost/dsearch/key_traits.hpp>
+#include<boost/dsearch/trie_array_node.hpp>
+#include<boost/dsearch/trie.hpp>
+#include<boost/dsearch/node_cursor.hpp>
+#include<assert.h>
+#include<string>
+#include<memory>
+#include<iostream>
+
+using namespace boost::dsearch;
+
+template<class T>
+void test_trie()
+{
+ T tr;
+ typename T::cursor c;
+ std::string str="hello";
+ tr.insert( std::make_pair(str,1) );
+ tr.insert( std::make_pair("he",2) );
+
+ assert( tr["hello"]==1 );
+ assert( !tr.find("hell") );
+ assert( !tr.find("helli") );
+ assert(tr.find("he"));
+ tr.erase("he");
+ assert( !tr.find("he") );
+ assert( tr.find("hello") );
+ tr.erase("hello");
+ assert( !tr.find("hello") );
+ c=tr.root();
+ tr.insert( std::make_pair("he",2) );
+ tr.insert( std::make_pair("hello",3) );
+ assert( (*c).find('h')!=(*c).end() );
+ assert( (*c).find('e')==(*c).end() );
+ assert( (*c.begin()).find('e')!=(*c).end() ) ;
+ assert( c.begin().begin()->find('l')!=(*c).end() ) ;
+
+ tr.insert( std::make_pair("it",3) );
+ c=tr.root().begin();
+ c++;
+ tr.clear();
+// tr.clear();
+ //assert(c->find('h')!=c.begin()->end());
+ //assert(c.begin()->find('e')!=c.begin()->end());
+}
+
+
+
+int main(void)
+{
+ typedef trie<std::string,int,trie_array_node,string_traits> trie_type;
+ test_trie<trie_type>();
+ return 0;
+}
+
+#if 0
+int main2(void)
+{
+/* trie<std::string,int,trie_array_node,string_traits> a;
+ a.empty();
+ a.insert(std::make_pair("hello",1));
+ a.erase("hello");
+ a.find("hello");
+ a["hello"]=10;*/
+ return 0;
+}
+
+int main3(void)
+{
+ /*trie_cursor<trie_array_node<int,int,string_traits> > c;
+ c++;
+ c--;
+ c.begin();
+ c.end();
+ *c;
+ c.empty();*/
+ return 0;
+}
+#endif
Deleted: sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/test_nothing.cpp
==============================================================================
--- sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/test_nothing.cpp 2008-05-31 10:12:02 EDT (Sat, 31 May 2008)
+++ (empty file)
@@ -1,20 +0,0 @@
-// Copyright 2008 Chintan Rao H.
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-
-#include <boost/dsearch.hpp>
-
-#include <boost/test/included/test_exec_monitor.hpp>
-
-int test_main(int, char* [])
-{
- boost::dsearch::dsearch<int> object;
- int x = 0;
- BOOST_CHECK_EQUAL(object.get_nothing_count(),0);
- object.nothing(x);
- BOOST_CHECK_EQUAL(object.get_nothing_count(),1);
-
- return 0;
-};
Deleted: sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/test_nothing_n.cpp
==============================================================================
--- sandbox/SOC/2008/digital_searching/dsearch/libs/dsearch/test/test_nothing_n.cpp 2008-05-31 10:12:02 EDT (Sat, 31 May 2008)
+++ (empty file)
@@ -1,21 +0,0 @@
-// Copyright 2008 Chintan Rao H.
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-
-#include <boost/dsearch.hpp>
-
-#include <boost/test/included/test_exec_monitor.hpp>
-
-int test_main(int, char* [])
-{
- boost::dsearch::dsearch<int> object;
- int x = 0;
- BOOST_CHECK_EQUAL(object.get_call_count(),0);
- object.nothing(x,4);
- BOOST_CHECK_EQUAL(object.get_call_count(),1);
- BOOST_CHECK_EQUAL(object.get_nothing_count(),4);
-
- 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