diff options
author | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2016-08-17 22:34:04 +0300 |
---|---|---|
committer | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2016-08-17 22:34:04 +0300 |
commit | f024cd02a588e5f205298e11ea5e7be6c8247b80 (patch) | |
tree | 963cd5247faac1d8d7c218f4e93e3aa028a3788a /test | |
parent | 01dcbd53bf65cffc403ef5cf179c0d2ffa049b6e (diff) |
Added kernel test for kernel_section_handle. Compiles, but untested (tomorrow!).
Diffstat (limited to 'test')
3 files changed, 59 insertions, 15 deletions
diff --git a/test/tests/file_handle_create_close/runner.cpp b/test/tests/file_handle_create_close/runner.cpp index 9ed5525e..5ec1b6cc 100644 --- a/test/tests/file_handle_create_close/runner.cpp +++ b/test/tests/file_handle_create_close/runner.cpp @@ -76,21 +76,8 @@ template <class U> inline void file_handle_create_close_creation(U &&f) // Have the permuter permute callable f with all the permutations, returning outcomes auto results = permuter(std::forward<U>(f)); - static_assert(permuter.permutation_results_type_is_constant_sized, "Results type returned should be a std::array due to the constant sized input"); - static_assert(results.size() > 0, "Results type returned should be a std::array due to the constant sized input"); - std::vector<std::function<void()>> checks; - - // Check each of the results, calling the failure/pass callables supplied. We don't do - // this inside the kernel or permuter as it messes with fuzzing/sanitising. - // - // Note that we accumulate failures into the checks vector for later processing - bool all_passed = permuter.check(results, pretty_print_failure(permuter, [&checks](const auto &result, const auto &shouldbe) { checks.push_back([&] { BOOST_CHECK(result == shouldbe); }); }), pretty_print_success(permuter)); - BOOST_CHECK(all_passed); - - // The pretty printing gets messed up by the unit test output, so defer telling it - // about failures until now - for(auto &i : checks) - i(); + // Check these permutation results, pretty printing the outcomes and also informing Boost.Test via BOOST_CHECK(). + check_results_with_boost_test(permuter, results); } BOOST_KERNELTEST_TEST_KERNEL(integration, afio, file_handle_create_close, file_handle, "Tests that afio::file_handle's creation parameter works as expected", file_handle_create_close_creation(file_handle_create_close::test_kernel_file_handle)) diff --git a/test/tests/section_handle_create_close/kernel_section_handle.cpp.hpp b/test/tests/section_handle_create_close/kernel_section_handle.cpp.hpp new file mode 100644 index 00000000..3bf8c91b --- /dev/null +++ b/test/tests/section_handle_create_close/kernel_section_handle.cpp.hpp @@ -0,0 +1,17 @@ +/* Test kernel for section_handle create and close +(C) 2016 Niall Douglas http://www.nedprod.com/ +File Created: August 2016 +*/ + +#include "../../test_kernel_decl.hpp" + +namespace section_handle_create_close +{ + BOOST_AFIO_TEST_KERNEL_DECL boost::outcome::result<boost::afio::section_handle> test_kernel_section_handle(boost::afio::file_handle &backing, boost::afio::section_handle::extent_type maximum_size, boost::afio::section_handle::flag m) + { + auto h = boost::afio::section_handle::section(backing, maximum_size, m); + if(h) + h.get().close(); + return h; + } +} diff --git a/test/tests/section_handle_create_close/runner.cpp b/test/tests/section_handle_create_close/runner.cpp new file mode 100644 index 00000000..dd9bfb33 --- /dev/null +++ b/test/tests/section_handle_create_close/runner.cpp @@ -0,0 +1,40 @@ +/* Integration test kernel for section_handle create and close +(C) 2016 Niall Douglas http://www.nedprod.com/ +File Created: Aug 2016 +*/ + +#include "../kerneltest/include/boost/kerneltest.hpp" +#include "kernel_section_handle.cpp.hpp" + +template <class U> inline void section_handle_create_close_(U &&f) +{ + using namespace BOOST_KERNELTEST_V1_NAMESPACE; + using namespace BOOST_AFIO_V2_NAMESPACE; + + // Create a temporary file and put some text into it + auto temph = file_handle::file("tempfile", file_handle::mode::write, file_handle::creation::if_needed).get(); + temph.write(0, "niall is not here", 17).get(); + auto boundf = [&](auto... pars) { return f(temph, pars...); }; + + // clang-format off + static const auto permuter(mt_permute_parameters< + result<void>, + parameters< + typename section_handle::extent_type, + typename section_handle::flag + >, + precondition::filesystem_setup_parameters + >( + { + // Does the mode parameter have the expected side effects? + { make_ready_result<void>(), { 1, section_handle::flag::read }, { "_" } }, + }, + precondition::filesystem_setup() + )); + // clang-format on + + auto results = permuter(boundf); + check_results_with_boost_test(permuter, results); +} + +BOOST_KERNELTEST_TEST_KERNEL(integration, afio, section_handle_create_close, section_handle, "Tests that afio::section_handle's creation parameters work as expected", section_handle_create_close_(section_handle_create_close::test_kernel_section_handle)) |