diff options
| -rw-r--r-- | example/simple_example/example.cpp | 19 | ||||
| -rw-r--r-- | include/ocl/tproc/rope.hpp | 2 | ||||
| -rw-r--r-- | test/rope_test/crope.pred.test.cpp | 33 | ||||
| -rw-r--r-- | test/rope_test/crope.test.cpp | 10 |
4 files changed, 39 insertions, 25 deletions
diff --git a/example/simple_example/example.cpp b/example/simple_example/example.cpp index 5209494..445c92b 100644 --- a/example/simple_example/example.cpp +++ b/example/simple_example/example.cpp @@ -7,16 +7,19 @@ #include <ocl/tproc/rope.hpp> +#ifndef STANDALONE +using namespace ocl; +#else +using namespace boost; +#endif + int main() { - auto rope = ocl::tproc::crope("The Quick Brown Fox Jumps Over The Lazy Dog"); - - auto new_elem = new ocl::tproc::crope(", and Jumps again."); - auto res = rope.concat(new_elem); + auto rope = tproc::crope("The Quick Brown Fox Jumps Over The Lazy Dog"); - ocl::io::println((++rope)->data()); - ocl::io::println(rope.data()); + std::unique_ptr<tproc::crope> new_elem(new tproc::crope(", and Jumps again.")); + std::unique_ptr<tproc::crope> res(rope.concat(new_elem.get())); - delete new_elem; - delete res; + io::println((++rope)->data()); + io::println(rope.data()); } diff --git a/include/ocl/tproc/rope.hpp b/include/ocl/tproc/rope.hpp index 9573734..2a02f05 100644 --- a/include/ocl/tproc/rope.hpp +++ b/include/ocl/tproc/rope.hpp @@ -25,7 +25,7 @@ namespace ocl::tproc::rope using iterator_ptr = It*; - It* operator()(It* rbegin, It* rend) + iterator_ptr operator()(iterator_ptr rbegin, iterator_ptr rend) { for (auto rbeg{rbegin}; rbeg != rend; ++rbeg) { diff --git a/test/rope_test/crope.pred.test.cpp b/test/rope_test/crope.pred.test.cpp index 63670e0..afbc9c5 100644 --- a/test/rope_test/crope.pred.test.cpp +++ b/test/rope_test/crope.pred.test.cpp @@ -6,14 +6,21 @@ */ #include <ocl/tproc/rope.hpp> +#include <memory> #define BOOST_TEST_MODULE crope_pred #include <boost/test/included/unit_test.hpp> +#ifndef STANDALONE +using namespace ocl; +#else +using namespace boost; +#endif + BOOST_AUTO_TEST_CASE(rope_should_succeed_in_find_pred) { - auto rope = ocl::tproc::crope("Exact Sentence"); - auto it = ocl::tproc::rope::exact_pred<ocl::tproc::crope>{"Exact Sentence"}(rope.cbegin(), rope.cend()); + auto rope = tproc::crope("Exact Sentence"); + auto it = tproc::rope::exact_pred<tproc::crope>{"Exact Sentence"}(rope.cbegin(), rope.cend()); BOOST_TEST(it != rope.cend()); @@ -22,7 +29,7 @@ BOOST_AUTO_TEST_CASE(rope_should_succeed_in_find_pred) BOOST_AUTO_TEST_CASE(rope_should_succeed_in_at) { - auto rope = ocl::tproc::crope("Exact Sentence"); + auto rope = tproc::crope("Exact Sentence"); auto it = std::move(rope.substr(rope.at("Exact"), rope.size())); ocl::io::println(it.data()); @@ -30,24 +37,22 @@ BOOST_AUTO_TEST_CASE(rope_should_succeed_in_at) BOOST_AUTO_TEST_CASE(rope_should_succeed_in_starts_with) { - auto rope = ocl::tproc::crope("The Quick Brown Fox Jumps Over The Lazy Dog"); + auto rope = tproc::crope("The Quick Brown Fox Jumps Over The Lazy Dog"); + // find the leaf with the starting value 'foo' - auto it = ocl::tproc::rope::starts_with_pred<ocl::tproc::crope>{"The Quick"}(rope.cbegin(), rope.cend()); + auto it = tproc::rope::starts_with_pred<tproc::crope>{"The Quick"}(rope.cbegin(), rope.cend()); BOOST_TEST(it != rope.cend()); - auto it_end = ocl::tproc::rope::ends_with_pred<ocl::tproc::crope>{"Lazy Dog"}(rope.cbegin(), rope.cend()); + auto it_end = tproc::rope::ends_with_pred<tproc::crope>{"Lazy Dog"}(rope.cbegin(), rope.cend()); BOOST_TEST(it_end != rope.cend()); - ocl::io::println(it_end->data()); - ocl::io::println(it->data()); - - auto new_elem = new ocl::tproc::crope(", and Jumps again."); - auto ret_elem = rope.concat(new_elem); + io::println(it_end->data()); + io::println(it->data()); - ocl::io::println(ret_elem->data()); + std::unique_ptr<tproc::crope> new_elem(new tproc::crope(", and Jumps again.")); + std::unique_ptr<tproc::crope> ret_elem(rope.concat(new_elem.get())); - delete new_elem; - delete ret_elem; + io::println(ret_elem->data()); } diff --git a/test/rope_test/crope.test.cpp b/test/rope_test/crope.test.cpp index 4fe1a87..9275bef 100644 --- a/test/rope_test/crope.test.cpp +++ b/test/rope_test/crope.test.cpp @@ -10,14 +10,20 @@ #define BOOST_TEST_MODULE crope #include <boost/test/included/unit_test.hpp> +#ifndef STANDALONE +using namespace ocl; +#else +using namespace boost; +#endif + BOOST_AUTO_TEST_CASE(allocator_should_succeed_in_empty) { - auto rope = ocl::tproc::crope(""); + auto rope = tproc::crope(""); BOOST_TEST(rope.empty() == true); } BOOST_AUTO_TEST_CASE(allocator_should_not_succeed_in_empty) { - auto rope = ocl::tproc::crope("foobar"); + auto rope = tproc::crope("foobar"); BOOST_TEST(rope.empty() == false); } |
