From 2aafdb8520b302f01e57c677ec694db58527dddd Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 6 Jan 2026 19:41:27 +0100 Subject: chore: testing and example cleanup work. Signed-off-by: Amlal El Mahrouss --- example/simple_example/example.cpp | 19 +++++++++++-------- include/ocl/tproc/rope.hpp | 2 +- test/rope_test/crope.pred.test.cpp | 33 +++++++++++++++++++-------------- 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 +#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 new_elem(new tproc::crope(", and Jumps again.")); + std::unique_ptr 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 +#include #define BOOST_TEST_MODULE crope_pred #include +#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{"Exact Sentence"}(rope.cbegin(), rope.cend()); + auto rope = tproc::crope("Exact Sentence"); + auto it = tproc::rope::exact_pred{"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{"The Quick"}(rope.cbegin(), rope.cend()); + auto it = tproc::rope::starts_with_pred{"The Quick"}(rope.cbegin(), rope.cend()); BOOST_TEST(it != rope.cend()); - auto it_end = ocl::tproc::rope::ends_with_pred{"Lazy Dog"}(rope.cbegin(), rope.cend()); + auto it_end = tproc::rope::ends_with_pred{"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 new_elem(new tproc::crope(", and Jumps again.")); + std::unique_ptr 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 +#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); } -- cgit v1.2.3