diff --git a/.clang-format b/.clang-format index ca56dcd22..e528fd9df 100644 --- a/.clang-format +++ b/.clang-format @@ -83,7 +83,7 @@ NamespaceIndentation: All PointerAlignment: Left QualifierAlignment: Left ReferenceAlignment: Left -RemoveParentheses: MultipleParentheses +#RemoveParentheses: MultipleParentheses SeparateDefinitionBlocks: Always SpaceAfterTemplateKeyword: true SpaceBeforeParens: ControlStatements diff --git a/src/adiar/adiar.cpp b/src/adiar/adiar.cpp index 8bf9ae6a5..df9d3cafd 100644 --- a/src/adiar/adiar.cpp +++ b/src/adiar/adiar.cpp @@ -2,9 +2,9 @@ #include -#include #include #include +#include #include #include @@ -15,7 +15,8 @@ namespace adiar bool _adiar_initialized = false; bool _tpie_initialized = false; - void adiar_init(size_t memory_limit_bytes, std::string temp_dir) + void + adiar_init(size_t memory_limit_bytes, std::string temp_dir) { if (_adiar_initialized) { #ifndef NDEBUG @@ -28,8 +29,7 @@ namespace adiar } if (memory_limit_bytes < minimum_memory) { throw invalid_argument("Adiar requires at least " - + std::to_string(minimum_memory / 1024 / 1024) - + " MiB of memory"); + + std::to_string(minimum_memory / 1024 / 1024) + " MiB of memory"); } try { @@ -41,9 +41,7 @@ namespace adiar tpie::tempname::set_default_extension("adiar"); // - tmp directory - if (temp_dir != "") { - tpie::tempname::set_default_path(temp_dir); - } + if (temp_dir != "") { tpie::tempname::set_default_path(temp_dir); } // - memory limit and block size tpie::get_memory_manager().set_limit(memory_limit_bytes); @@ -57,7 +55,7 @@ namespace adiar // - all done, mark initialized _adiar_initialized = true; - } catch (const std::exception &e) { + } catch (const std::exception& e) { // LCOV_EXCL_START // Mark as not initialized. _adiar_initialized = false; @@ -72,12 +70,14 @@ namespace adiar } } - bool adiar_initialized() noexcept + bool + adiar_initialized() noexcept { return _adiar_initialized; } - void adiar_deinit() + void + adiar_deinit() { if (!_adiar_initialized) return; diff --git a/src/adiar/adiar.h b/src/adiar/adiar.h index 37a966684..d10b4aee8 100644 --- a/src/adiar/adiar.h +++ b/src/adiar/adiar.h @@ -25,8 +25,8 @@ //////////////////////////////////////////////////////////////////////////////// /// Decision Diagrams #include -#include #include +#include //////////////////////////////////////////////////////////////////////////////// /// Statistics @@ -75,12 +75,14 @@ namespace adiar /// \throws runtime_error If `adiar_init()` and then `adiar_deinit()` have /// been called previously. ////////////////////////////////////////////////////////////////////////////// - void adiar_init(size_t memory_limit_bytes, std::string temp_dir = ""); + void + adiar_init(size_t memory_limit_bytes, std::string temp_dir = ""); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether Adiar is initialized. ////////////////////////////////////////////////////////////////////////////// - bool adiar_initialized() noexcept; + bool + adiar_initialized() noexcept; ////////////////////////////////////////////////////////////////////////////// /// \brief Closes and cleans up everything by Adiar @@ -93,7 +95,8 @@ namespace adiar /// \throws runtime_error If compiled with *debug* and one of Adiar's objects /// have *not* been destructed. ////////////////////////////////////////////////////////////////////////////// - void adiar_deinit(); + void + adiar_deinit(); /// \} ////////////////////////////////////////////////////////////////////////////// diff --git a/src/adiar/bdd.h b/src/adiar/bdd.h index 513c7e726..cd493d9c4 100644 --- a/src/adiar/bdd.h +++ b/src/adiar/bdd.h @@ -14,15 +14,14 @@ /// possible and/or minimise the number of lvalues of said type. //////////////////////////////////////////////////////////////////////////////// -#include #include +#include +#include #include #include #include #include - -#include #include namespace adiar @@ -47,7 +46,8 @@ namespace adiar /// /// \see bdd_false bdd_true ////////////////////////////////////////////////////////////////////////////// - bdd bdd_const(bool value); + bdd + bdd_const(bool value); ////////////////////////////////////////////////////////////////////////////// /// \brief The BDD representing the given constant value. @@ -56,33 +56,42 @@ namespace adiar /// /// \see bdd_const bdd_false bdd_true ////////////////////////////////////////////////////////////////////////////// - bdd bdd_terminal(bool value); + bdd + bdd_terminal(bool value); ////////////////////////////////////////////////////////////////////////////// /// \brief The BDD representing the constant `false`. ////////////////////////////////////////////////////////////////////////////// - bdd bdd_false(); + bdd + bdd_false(); ////////////////////////////////////////////////////////////////////////////// /// \brief The bottom of the powerset lattice. /// /// \see bdd_false ////////////////////////////////////////////////////////////////////////////// - inline bdd bdd_bot() - { return bdd_false(); } + inline bdd + bdd_bot() + { + return bdd_false(); + } ////////////////////////////////////////////////////////////////////////////// /// \brief The BDD representing the constant `true`. ////////////////////////////////////////////////////////////////////////////// - bdd bdd_true(); + bdd + bdd_true(); ////////////////////////////////////////////////////////////////////////////// /// \brief The top of the powerset lattice. /// /// \see bdd_true ////////////////////////////////////////////////////////////////////////////// - inline bdd bdd_top() - { return bdd_true(); } + inline bdd + bdd_top() + { + return bdd_true(); + } ////////////////////////////////////////////////////////////////////////////// /// \brief The BDD representing the i'th variable. @@ -94,7 +103,8 @@ namespace adiar /// /// \throws invalid_argument If `var` is a too large value. ////////////////////////////////////////////////////////////////////////////// - bdd bdd_ithvar(bdd::label_type var); + bdd + bdd_ithvar(bdd::label_type var); ////////////////////////////////////////////////////////////////////////////// /// \brief The BDD representing the negation of the i'th variable. @@ -106,7 +116,8 @@ namespace adiar /// /// \throws invalid_argument If `var` is a too large value. ////////////////////////////////////////////////////////////////////////////// - bdd bdd_nithvar(bdd::label_type var); + bdd + bdd_nithvar(bdd::label_type var); ////////////////////////////////////////////////////////////////////////////// /// \brief The BDD representing the logical 'and' of all the given @@ -122,7 +133,8 @@ namespace adiar /// /// \throws invalid_argument If `vars` are not in descending order. ////////////////////////////////////////////////////////////////////////////// - bdd bdd_and(const generator &vars); + bdd + bdd_and(const generator& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief The BDD representing the logical 'and' of all the given @@ -135,7 +147,8 @@ namespace adiar /// /// \throws invalid_argument If `vars` are not in descending order. ////////////////////////////////////////////////////////////////////////////// - bdd bdd_and(const generator> &vars); + bdd + bdd_and(const generator>& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief The BDD representing the logical 'and' of all the given @@ -155,9 +168,12 @@ namespace adiar /// \throws invalid_argument If the iterator does not provide values in /// descending order. ////////////////////////////////////////////////////////////////////////////// - template - bdd bdd_and(ForwardIt begin, ForwardIt end) - { return bdd_and(make_generator(begin, end)); } + template + bdd + bdd_and(ForwardIt begin, ForwardIt end) + { + return bdd_and(make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief The BDD representing the logical 'or' of all the given @@ -173,7 +189,8 @@ namespace adiar /// /// \throws invalid_argument If `vars` are not in descending order. ////////////////////////////////////////////////////////////////////////////// - bdd bdd_or(const generator &vars); + bdd + bdd_or(const generator& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief The BDD representing the logical 'or' of all the given @@ -186,7 +203,8 @@ namespace adiar /// /// \throws invalid_argument If `vars` are not in descending order. ////////////////////////////////////////////////////////////////////////////// - bdd bdd_or(const generator> &vars); + bdd + bdd_or(const generator>& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief The BDD representing the logical 'or' of all the given @@ -206,10 +224,12 @@ namespace adiar /// \throws invalid_argument If the iterator does not provide values in /// descending order. ////////////////////////////////////////////////////////////////////////////// - template - bdd bdd_or(ForwardIt begin, ForwardIt end) - { return bdd_or(make_generator(begin, end)); } - + template + bdd + bdd_or(ForwardIt begin, ForwardIt end) + { + return bdd_or(make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief The BDD representing the cube of all the given variables. @@ -226,7 +246,8 @@ namespace adiar /// /// \see bdd_and ////////////////////////////////////////////////////////////////////////////// - bdd bdd_cube(const generator &vars); + bdd + bdd_cube(const generator& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief The BDD representing the cube of all the given variables. @@ -240,7 +261,8 @@ namespace adiar /// /// \see bdd_and ////////////////////////////////////////////////////////////////////////////// - bdd bdd_cube(const generator> &vars); + bdd + bdd_cube(const generator>& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief The BDD representing the cube of all the given variables. @@ -261,9 +283,12 @@ namespace adiar /// /// \see bdd_and ////////////////////////////////////////////////////////////////////////////// - template - bdd bdd_cube(ForwardIt begin, ForwardIt end) - { return bdd_cube(make_generator(begin, end)); } + template + bdd + bdd_cube(ForwardIt begin, ForwardIt end) + { + return bdd_cube(make_generator(begin, end)); + } /// \} ////////////////////////////////////////////////////////////////////////////// @@ -282,20 +307,25 @@ namespace adiar /// /// \returns \f$ \neg f \f$ ////////////////////////////////////////////////////////////////////////////// - bdd bdd_not(const bdd &f); + bdd + bdd_not(const bdd& f); /// \cond - bdd bdd_not(bdd &&f); + bdd + bdd_not(bdd&& f); /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \see bdd_not ////////////////////////////////////////////////////////////////////////////// - bdd operator~ (const bdd& f); + bdd + operator~(const bdd& f); /// \cond - bdd operator~ (bdd&& f); - bdd operator~ (__bdd&& f); + bdd + operator~(bdd&& f); + bdd + operator~(__bdd&& f); /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -309,15 +339,14 @@ namespace adiar /// /// \see bool_op ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_apply(const bdd &f, const bdd &g, const bool_op &op); + __bdd + bdd_apply(const bdd& f, const bdd& g, const bool_op& op); ////////////////////////////////////////////////////////////////////////////// /// \brief Apply a binary operator between two BDDs. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_apply(const exec_policy &ep, - const bdd &f, - const bdd &g, - const bool_op &op); + __bdd + bdd_apply(const exec_policy& ep, const bdd& f, const bdd& g, const bool_op& op); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'and' operator. @@ -326,12 +355,14 @@ namespace adiar /// /// \see bdd_apply ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_and(const bdd &f, const bdd &g); + __bdd + bdd_and(const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'and' operator. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_and(const exec_policy &ep, const bdd &f, const bdd &g); + __bdd + bdd_and(const exec_policy& ep, const bdd& f, const bdd& g); /// \cond /// @@ -340,20 +371,27 @@ namespace adiar /// \remark Since `bdd_and(begin, end)` has precedence over the /// implicit conversion from `bdd::shared_node_file_type` to `bdd`, we /// have to do it explicitly ourselves. - inline __bdd bdd_and(const bdd::shared_node_file_type &f, - const bdd::shared_node_file_type &g) - { return bdd_and(bdd(f), bdd(g)); } + inline __bdd + bdd_and(const bdd::shared_node_file_type& f, const bdd::shared_node_file_type& g) + { + return bdd_and(bdd(f), bdd(g)); + } + /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \see bdd_and ////////////////////////////////////////////////////////////////////////////// - __bdd operator& (const bdd &lhs, const bdd &rhs); + __bdd + operator&(const bdd& lhs, const bdd& rhs); /// \cond - __bdd operator& (const bdd &, __bdd &&); - __bdd operator& (__bdd &&, const bdd &); - __bdd operator& (__bdd &&, __bdd &&); + __bdd + operator&(const bdd&, __bdd&&); + __bdd + operator&(__bdd&&, const bdd&); + __bdd + operator&(__bdd&&, __bdd&&); /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -363,12 +401,14 @@ namespace adiar /// /// \see bdd_apply ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_nand(const bdd &f, const bdd &g); + __bdd + bdd_nand(const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'nand' operator. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_nand(const exec_policy &ep, const bdd &f, const bdd &g); + __bdd + bdd_nand(const exec_policy& ep, const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'or' operator. @@ -377,12 +417,14 @@ namespace adiar /// /// \see bdd_apply ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_or(const bdd &f, const bdd &g); + __bdd + bdd_or(const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'or' operator. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_or(const exec_policy &ep, const bdd &f, const bdd &g); + __bdd + bdd_or(const exec_policy& ep, const bdd& f, const bdd& g); /// \cond /// @@ -391,20 +433,27 @@ namespace adiar /// \remark Since `bdd_or(begin, end)` has precedence over the /// implicit conversion from `bdd::shared_node_file_type` to `bdd`, we /// have to do it explicitly ourselves. - inline __bdd bdd_or(const bdd::shared_node_file_type &f, - const bdd::shared_node_file_type &g) - { return bdd_or(bdd(f), bdd(g)); } + inline __bdd + bdd_or(const bdd::shared_node_file_type& f, const bdd::shared_node_file_type& g) + { + return bdd_or(bdd(f), bdd(g)); + } + /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \see bdd_or ////////////////////////////////////////////////////////////////////////////// - __bdd operator| (const bdd &lhs, const bdd &rhs); + __bdd + operator|(const bdd& lhs, const bdd& rhs); /// \cond - __bdd operator| (const bdd &, __bdd &&); - __bdd operator| (__bdd &&, const bdd &); - __bdd operator| (__bdd &&, __bdd &&); + __bdd + operator|(const bdd&, __bdd&&); + __bdd + operator|(__bdd&&, const bdd&); + __bdd + operator|(__bdd&&, __bdd&&); /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -414,12 +463,14 @@ namespace adiar /// /// \see bdd_apply ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_nor(const bdd &f, const bdd &g); + __bdd + bdd_nor(const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'nor' operator. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_nor(const exec_policy &ep, const bdd &f, const bdd &g); + __bdd + bdd_nor(const exec_policy& ep, const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'xor' operator. @@ -428,22 +479,28 @@ namespace adiar /// /// \see bdd_apply ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_xor(const bdd &f, const bdd &g); + __bdd + bdd_xor(const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'xor' operator. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_xor(const exec_policy &ep, const bdd &f, const bdd &g); + __bdd + bdd_xor(const exec_policy& ep, const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \see bdd_xor ////////////////////////////////////////////////////////////////////////////// - __bdd operator^ (const bdd &lhs, const bdd &rhs); + __bdd + operator^(const bdd& lhs, const bdd& rhs); /// \cond - __bdd operator^ (const bdd &, __bdd &&); - __bdd operator^ (__bdd &&, const bdd &); - __bdd operator^ (__bdd &&, __bdd &&); + __bdd + operator^(const bdd&, __bdd&&); + __bdd + operator^(__bdd&&, const bdd&); + __bdd + operator^(__bdd&&, __bdd&&); /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -453,12 +510,14 @@ namespace adiar /// /// \see bdd_apply ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_xnor(const bdd &f, const bdd &g); + __bdd + bdd_xnor(const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'xnor' operator. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_xnor(const exec_policy &ep, const bdd &f, const bdd &g); + __bdd + bdd_xnor(const exec_policy& ep, const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'implication' operator. @@ -467,12 +526,14 @@ namespace adiar /// /// \see bdd_apply ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_imp(const bdd &f, const bdd &g); + __bdd + bdd_imp(const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'implication' operator. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_imp(const exec_policy &ep, const bdd &f, const bdd &g); + __bdd + bdd_imp(const exec_policy& ep, const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'inverse implication' operator. @@ -481,12 +542,14 @@ namespace adiar /// /// \see bdd_apply ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_invimp(const bdd &f, const bdd &g); + __bdd + bdd_invimp(const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'inverse implication' operator. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_invimp(const exec_policy &ep, const bdd &f, const bdd &g); + __bdd + bdd_invimp(const exec_policy& ep, const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'equivalence' operator. @@ -495,12 +558,14 @@ namespace adiar /// /// \see bdd_apply ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_equiv(const bdd &f, const bdd &g); + __bdd + bdd_equiv(const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'equivalence' operator. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_equiv(const exec_policy &ep, const bdd &f, const bdd &g); + __bdd + bdd_equiv(const exec_policy& ep, const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'difference' operator. @@ -509,12 +574,14 @@ namespace adiar /// /// \see bdd_apply ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_diff(const bdd &f, const bdd &g); + __bdd + bdd_diff(const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'difference' operator. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_diff(const exec_policy &ep, const bdd &f, const bdd &g); + __bdd + bdd_diff(const exec_policy& ep, const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'less than' operator. @@ -523,12 +590,14 @@ namespace adiar /// /// \see bdd_apply ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_less(const bdd &f, const bdd &g); + __bdd + bdd_less(const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'less than' operator. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_less(const exec_policy &ep, const bdd &f, const bdd &g); + __bdd + bdd_less(const exec_policy& ep, const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief If-Then-Else operator. @@ -551,12 +620,14 @@ namespace adiar /// /// \see bdd_apply builder bdd_builder ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_ite(const bdd &f, const bdd &g, const bdd &h); + __bdd + bdd_ite(const bdd& f, const bdd& g, const bdd& h); ////////////////////////////////////////////////////////////////////////////// /// \brief If-Then-Else operator. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_ite(const exec_policy &ep, const bdd &f, const bdd &g, const bdd &h); + __bdd + bdd_ite(const exec_policy& ep, const bdd& f, const bdd& g, const bdd& h); ////////////////////////////////////////////////////////////////////////////// /// \brief Restrict a single variable to a constant value. @@ -571,15 +642,14 @@ namespace adiar /// /// \returns \f$ f|_{x_i = v} \f$ ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_restrict(const bdd &f, bdd::label_type var, bool val); + __bdd + bdd_restrict(const bdd& f, bdd::label_type var, bool val); ////////////////////////////////////////////////////////////////////////////// /// \brief Restrict a single variable to a constant value. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_restrict(const exec_policy &ep, - const bdd &f, - bdd::label_type var, - bool val); + __bdd + bdd_restrict(const exec_policy& ep, const bdd& f, bdd::label_type var, bool val); ////////////////////////////////////////////////////////////////////////////// /// \brief Restrict a subset of variables to constant values. @@ -595,15 +665,16 @@ namespace adiar /// /// \returns \f$ f|_{(i,v) \in xs : x_i = v} \f$ ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_restrict(const bdd &f, - const generator> &xs); + __bdd + bdd_restrict(const bdd& f, const generator>& xs); ////////////////////////////////////////////////////////////////////////////// /// \brief Restrict a subset of variables to constant values. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_restrict(const exec_policy &ep, - const bdd &f, - const generator> &xs); + __bdd + bdd_restrict(const exec_policy& ep, + const bdd& f, + const generator>& xs); ////////////////////////////////////////////////////////////////////////////// /// \brief Restrict a subset of variables to constant values. @@ -621,19 +692,22 @@ namespace adiar /// /// \returns \f$ f|_{(i,v) \in xs : x_i = v} \f$ ////////////////////////////////////////////////////////////////////////////// - template - __bdd bdd_restrict(const bdd& f, ForwardIt begin, ForwardIt end) - { return bdd_restrict(f, make_generator(begin, end)); } + template + __bdd + bdd_restrict(const bdd& f, ForwardIt begin, ForwardIt end) + { + return bdd_restrict(f, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Restrict a subset of variables to constant values. ////////////////////////////////////////////////////////////////////////////// - template - __bdd bdd_restrict(const exec_policy &ep, - const bdd& f, - ForwardIt begin, - ForwardIt end) - { return bdd_restrict(ep, f, make_generator(begin, end)); } + template + __bdd + bdd_restrict(const exec_policy& ep, const bdd& f, ForwardIt begin, ForwardIt end) + { + return bdd_restrict(ep, f, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Restrict the root to `false`, i.e. follow its low edge. @@ -646,12 +720,14 @@ namespace adiar /// /// \see bdd_restrict ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_low(const bdd &f); + __bdd + bdd_low(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Restrict the root to `false`, i.e. follow its low edge. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_low(const exec_policy &ep, const bdd &f); + __bdd + bdd_low(const exec_policy& ep, const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Restrict the root to `true`, i.e. follow its high edge. @@ -664,12 +740,14 @@ namespace adiar /// /// \see bdd_restrict ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_high(const bdd &f); + __bdd + bdd_high(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Restrict the root to `true`, i.e. follow its high edge. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_high(const exec_policy &ep, const bdd &f); + __bdd + bdd_high(const exec_policy& ep, const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Existential quantification of a single variable. @@ -683,21 +761,31 @@ namespace adiar /// /// \returns \f$ \exists x_{var} : f \f$ ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_exists(const bdd &f, bdd::label_type var); + __bdd + bdd_exists(const bdd& f, bdd::label_type var); /// \cond - inline __bdd bdd_exists(bdd &&f, bdd::label_type var) - { return bdd_exists(f, var); } + inline __bdd + bdd_exists(bdd&& f, bdd::label_type var) + { + return bdd_exists(f, var); + } + /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \brief Existential quantification of a single variable. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_exists(const exec_policy &ep, const bdd &f, bdd::label_type var); + __bdd + bdd_exists(const exec_policy& ep, const bdd& f, bdd::label_type var); /// \cond - inline __bdd bdd_exists(const exec_policy &ep, bdd &&f, bdd::label_type var) - { return bdd_exists(ep, f, var); } + inline __bdd + bdd_exists(const exec_policy& ep, bdd&& f, bdd::label_type var) + { + return bdd_exists(ep, f, var); + } + /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -715,23 +803,23 @@ namespace adiar /// /// \returns \f$ \exists x_i \in \texttt{vars} : f \f$ ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_exists(const bdd &f, const predicate &vars); + __bdd + bdd_exists(const bdd& f, const predicate& vars); /// \cond - __bdd bdd_exists(bdd &&f, const predicate &vars); + __bdd + bdd_exists(bdd&& f, const predicate& vars); /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \brief Existential quantification of multiple variables. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_exists(const exec_policy &ep, - const bdd &f, - const predicate &vars); + __bdd + bdd_exists(const exec_policy& ep, const bdd& f, const predicate& vars); /// \cond - __bdd bdd_exists(const exec_policy &ep, - bdd &&f, - const predicate &vars); + __bdd + bdd_exists(const exec_policy& ep, bdd&& f, const predicate& vars); /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -748,23 +836,24 @@ namespace adiar /// /// \returns \f$ \exists x_i \in \texttt{gen()} : f \f$ ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_exists(const bdd &f, const generator &vars); + __bdd + bdd_exists(const bdd& f, const generator& vars); /// \cond - __bdd bdd_exists(bdd &&f, const generator &vars); + __bdd + bdd_exists(bdd&& f, const generator& vars); /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \brief Existential quantification of multiple variables. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_exists(const exec_policy &ep, - const bdd &f, - const generator &vars); + __bdd + bdd_exists(const exec_policy& ep, const bdd& f, const generator& vars); /// \cond - __bdd bdd_exists(const exec_policy &ep, - bdd &&f, - const generator &vars); + __bdd + bdd_exists(const exec_policy& ep, bdd&& f, const generator& vars); + /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -783,33 +872,41 @@ namespace adiar /// /// \returns \f$ \exists x_i \in \texttt{begin} ... \texttt{end} : f \f$ ////////////////////////////////////////////////////////////////////////////// - template - __bdd bdd_exists(const bdd &f, ForwardIt begin, ForwardIt end) - { return bdd_exists(f, make_generator(begin, end)); } + template + __bdd + bdd_exists(const bdd& f, ForwardIt begin, ForwardIt end) + { + return bdd_exists(f, make_generator(begin, end)); + } /// \cond - template - __bdd bdd_exists(bdd &&f, ForwardIt begin, ForwardIt end) - { return bdd_exists(std::move(f), make_generator(begin, end)); } + template + __bdd + bdd_exists(bdd&& f, ForwardIt begin, ForwardIt end) + { + return bdd_exists(std::move(f), make_generator(begin, end)); + } + /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \brief Existential quantification of multiple variables. ////////////////////////////////////////////////////////////////////////////// - template - __bdd bdd_exists(const exec_policy &ep, - const bdd &f, - ForwardIt begin, - ForwardIt end) - { return bdd_exists(ep, f, make_generator(begin, end)); } + template + __bdd + bdd_exists(const exec_policy& ep, const bdd& f, ForwardIt begin, ForwardIt end) + { + return bdd_exists(ep, f, make_generator(begin, end)); + } /// \cond - template - __bdd bdd_exists(const exec_policy &ep, - bdd &&f, - ForwardIt begin, - ForwardIt end) - { return bdd_exists(ep, std::move(f), make_generator(begin, end)); } + template + __bdd + bdd_exists(const exec_policy& ep, bdd&& f, ForwardIt begin, ForwardIt end) + { + return bdd_exists(ep, std::move(f), make_generator(begin, end)); + } + /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -825,21 +922,31 @@ namespace adiar /// /// \returns \f$ \forall x_{var} : f \f$ ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_forall(const bdd &f, bdd::label_type var); + __bdd + bdd_forall(const bdd& f, bdd::label_type var); /// \cond - inline __bdd bdd_forall(bdd &&f, bdd::label_type var) - { return bdd_forall(f, var); } + inline __bdd + bdd_forall(bdd&& f, bdd::label_type var) + { + return bdd_forall(f, var); + } + /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \brief Forall quantification of a single variable. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_forall(const exec_policy &ep, const bdd &f, bdd::label_type var); + __bdd + bdd_forall(const exec_policy& ep, const bdd& f, bdd::label_type var); /// \cond - inline __bdd bdd_forall(const exec_policy &ep, bdd &&f, bdd::label_type var) - { return bdd_forall(ep, f, var); } + inline __bdd + bdd_forall(const exec_policy& ep, bdd&& f, bdd::label_type var) + { + return bdd_forall(ep, f, var); + } + /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -857,23 +964,23 @@ namespace adiar /// /// \returns \f$ \forall x_i \in \texttt{vars} : f \f$ ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_forall(const bdd &f, const predicate &vars); + __bdd + bdd_forall(const bdd& f, const predicate& vars); /// \cond - __bdd bdd_forall(bdd &&f, const predicate &vars); + __bdd + bdd_forall(bdd&& f, const predicate& vars); /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \brief Forall quantification of multiple variables. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_forall(const exec_policy &ep, - const bdd &f, - const predicate &vars); + __bdd + bdd_forall(const exec_policy& ep, const bdd& f, const predicate& vars); /// \cond - __bdd bdd_forall(const exec_policy &ep, - bdd &&f, - const predicate &vars); + __bdd + bdd_forall(const exec_policy& ep, bdd&& f, const predicate& vars); /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -890,23 +997,24 @@ namespace adiar /// /// \returns \f$ \forall x_i \in \texttt{gen()} : f \f$ ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_forall(const bdd &f, const generator &vars); + __bdd + bdd_forall(const bdd& f, const generator& vars); /// \cond - __bdd bdd_forall(bdd &&f, const generator &vars); + __bdd + bdd_forall(bdd&& f, const generator& vars); /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \brief Forall quantification of multiple variables. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_forall(const exec_policy &ep, - const bdd &f, - const generator &vars); + __bdd + bdd_forall(const exec_policy& ep, const bdd& f, const generator& vars); /// \cond - __bdd bdd_forall(const exec_policy &ep, - bdd &&f, - const generator &vars); + __bdd + bdd_forall(const exec_policy& ep, bdd&& f, const generator& vars); + /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -925,33 +1033,41 @@ namespace adiar /// /// \returns \f$ \forall x_i \in \texttt{begin} ... \texttt{end} : f \f$ ////////////////////////////////////////////////////////////////////////////// - template - __bdd bdd_forall(const bdd &f, ForwardIt begin, ForwardIt end) - { return bdd_forall(f, make_generator(begin, end)); } + template + __bdd + bdd_forall(const bdd& f, ForwardIt begin, ForwardIt end) + { + return bdd_forall(f, make_generator(begin, end)); + } /// \cond - template - __bdd bdd_forall(bdd &&f, ForwardIt begin, ForwardIt end) - { return bdd_forall(std::forward(f), make_generator(begin, end)); } + template + __bdd + bdd_forall(bdd&& f, ForwardIt begin, ForwardIt end) + { + return bdd_forall(std::forward(f), make_generator(begin, end)); + } + /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \brief Forall quantification of multiple variables. ////////////////////////////////////////////////////////////////////////////// - template - __bdd bdd_forall(const exec_policy &ep, - const bdd &f, - ForwardIt begin, - ForwardIt end) - { return bdd_forall(ep, f, make_generator(begin, end)); } + template + __bdd + bdd_forall(const exec_policy& ep, const bdd& f, ForwardIt begin, ForwardIt end) + { + return bdd_forall(ep, f, make_generator(begin, end)); + } /// \cond - template - __bdd bdd_forall(const exec_policy &ep, - bdd &&f, - ForwardIt begin, - ForwardIt end) - { return bdd_forall(ep, std::move(f), make_generator(begin, end)); } + template + __bdd + bdd_forall(const exec_policy& ep, bdd&& f, ForwardIt begin, ForwardIt end) + { + return bdd_forall(ep, std::move(f), make_generator(begin, end)); + } + /// \endcond /// \} @@ -967,79 +1083,94 @@ namespace adiar /// /// \copydetails adiar::internal::dd_iscanonical ////////////////////////////////////////////////////////////////////////////// - bool bdd_iscanonical(const bdd& f); + bool + bdd_iscanonical(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether a BDD is a constant. /// /// \see bdd_isfalse bdd_istrue ////////////////////////////////////////////////////////////////////////////// - bool bdd_isconst(const bdd& f); + bool + bdd_isconst(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether a BDD is a constant (terminal). /// /// \see bdd_isfalse bdd_istrue ////////////////////////////////////////////////////////////////////////////// - bool bdd_isterminal(const bdd& f); + bool + bdd_isterminal(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether a BDD is the constant `false`. ////////////////////////////////////////////////////////////////////////////// - bool bdd_isfalse(const bdd& f); + bool + bdd_isfalse(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether a BDD is the constant `true`. ////////////////////////////////////////////////////////////////////////////// - bool bdd_istrue(const bdd& f); + bool + bdd_istrue(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether a BDD is a function dependent on a single variable. /// /// \see bdd_isithvar bdd_isnithvar ////////////////////////////////////////////////////////////////////////////// - bool bdd_isvar(const bdd& f); + bool + bdd_isvar(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether a BDD is the function of a single positive variable. /// /// \see bdd_isvar bdd_ithvar ////////////////////////////////////////////////////////////////////////////// - bool bdd_isithvar(const bdd& f); + bool + bdd_isithvar(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether a BDD is the function of a single negative variable. /// /// \see bdd_isvar bdd_nithvar ////////////////////////////////////////////////////////////////////////////// - bool bdd_isnithvar(const bdd& f); + bool + bdd_isnithvar(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether a BDD represents a cube. /// /// \see bdd_cube ////////////////////////////////////////////////////////////////////////////// - bool bdd_iscube(const bdd& f); + bool + bdd_iscube(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether the two BDDs represent the same function. ////////////////////////////////////////////////////////////////////////////// - bool bdd_equal(const bdd& f, const bdd& g); + bool + bdd_equal(const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether the two BDDs represent the same function. ////////////////////////////////////////////////////////////////////////////// - bool bdd_equal(const exec_policy&, const bdd& f, const bdd& g); + bool + bdd_equal(const exec_policy&, const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \see bdd_equal ////////////////////////////////////////////////////////////////////////////// - bool operator== (const bdd& f, const bdd& g); + bool + operator==(const bdd& f, const bdd& g); /// \cond - bool operator== (__bdd &&f, const bdd &g); - bool operator== (const bdd &f, __bdd &&g); - bool operator== (__bdd &&f, __bdd &&g); + bool + operator==(__bdd&& f, const bdd& g); + bool + operator==(const bdd& f, __bdd&& g); + bool + operator==(__bdd&& f, __bdd&& g); /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -1047,22 +1178,28 @@ namespace adiar /// /// \see bdd_equal ////////////////////////////////////////////////////////////////////////////// - bool bdd_unequal(const bdd& f, const bdd& g); + bool + bdd_unequal(const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether the two BDDs represent different functions. ////////////////////////////////////////////////////////////////////////////// - bool bdd_unequal(const exec_policy& ep, const bdd& f, const bdd& g); + bool + bdd_unequal(const exec_policy& ep, const bdd& f, const bdd& g); ////////////////////////////////////////////////////////////////////////////// /// \see bdd_equal bdd_unequal ////////////////////////////////////////////////////////////////////////////// - bool operator!= (const bdd& f, const bdd& g); + bool + operator!=(const bdd& f, const bdd& g); /// \cond - bool operator!= (const bdd &f, __bdd &&g); - bool operator!= (__bdd &&f, const bdd &g); - bool operator!= (__bdd &&f, __bdd &&g); + bool + operator!=(const bdd& f, __bdd&& g); + bool + operator!=(__bdd&& f, const bdd& g); + bool + operator!=(__bdd&& f, __bdd&& g); /// \endcond /// \} @@ -1076,13 +1213,15 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// /// \brief The number of (internal) nodes used to represent the function. ////////////////////////////////////////////////////////////////////////////// - size_t bdd_nodecount(const bdd &f); + size_t + bdd_nodecount(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief The number of variables that influence the outcome of f, i.e. the /// number of levels in the BDD. ////////////////////////////////////////////////////////////////////////////// - bdd::label_type bdd_varcount(const bdd &f); + bdd::label_type + bdd_varcount(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Count all unique (but not necessarily disjoint) paths to the true @@ -1090,13 +1229,15 @@ namespace adiar /// /// \returns The number of unique paths. ////////////////////////////////////////////////////////////////////////////// - uint64_t bdd_pathcount(const bdd &f); + uint64_t + bdd_pathcount(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Count all unique (but not necessarily disjoint) paths to the true /// terminal. ////////////////////////////////////////////////////////////////////////////// - uint64_t bdd_pathcount(const exec_policy &ep, const bdd &f); + uint64_t + bdd_pathcount(const exec_policy& ep, const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Count the number of assignments x that make f(x) true. @@ -1112,14 +1253,14 @@ namespace adiar /// \throws invalid_argument If varcount is not larger than the number of /// levels in the BDD. ////////////////////////////////////////////////////////////////////////////// - uint64_t bdd_satcount(const bdd &f, bdd::label_type varcount); + uint64_t + bdd_satcount(const bdd& f, bdd::label_type varcount); ////////////////////////////////////////////////////////////////////////////// /// \brief Count the number of assignments x that make f(x) true. ////////////////////////////////////////////////////////////////////////////// - uint64_t bdd_satcount(const exec_policy &ep, - const bdd &f, - bdd::label_type varcount); + uint64_t + bdd_satcount(const exec_policy& ep, const bdd& f, bdd::label_type varcount); ////////////////////////////////////////////////////////////////////////////// /// \brief Count the number of assignments x that make f(x) true. @@ -1130,12 +1271,14 @@ namespace adiar /// /// \see domain_set bdd_varcount ////////////////////////////////////////////////////////////////////////////// - uint64_t bdd_satcount(const bdd &f); + uint64_t + bdd_satcount(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Count the number of assignments x that make f(x) true. ////////////////////////////////////////////////////////////////////////////// - uint64_t bdd_satcount(const exec_policy &ep, const bdd &f); + uint64_t + bdd_satcount(const exec_policy& ep, const bdd& f); /// \} ////////////////////////////////////////////////////////////////////////////// @@ -1153,7 +1296,8 @@ namespace adiar /// /// \param cb Callback function that consumes the variable labels. ////////////////////////////////////////////////////////////////////////////// - void bdd_support(const bdd &f, const consumer &cb); + void + bdd_support(const bdd& f, const consumer& cb); ////////////////////////////////////////////////////////////////////////////// /// \brief Copy all of the variable labels (in \em ascending order) that occur @@ -1170,8 +1314,9 @@ namespace adiar /// \throws out_of_range If the distance between `begin` and `end` is not big /// enough to contain all variables in `f`. ////////////////////////////////////////////////////////////////////////////// - template - ForwardIt bdd_support(const bdd &f, ForwardIt begin, ForwardIt end) + template + ForwardIt + bdd_support(const bdd& f, ForwardIt begin, ForwardIt end) { bdd_support(f, make_consumer(begin, end)); return begin; @@ -1182,21 +1327,24 @@ namespace adiar /// /// \throws invalid_argument If `f` is a terminal. ////////////////////////////////////////////////////////////////////////////// - bdd::label_type bdd_topvar(const bdd &f); + bdd::label_type + bdd_topvar(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Get the minimal occurring variable in the function's support. /// /// \throws invalid_argument If `f` is a terminal. ////////////////////////////////////////////////////////////////////////////// - bdd::label_type bdd_minvar(const bdd &f); + bdd::label_type + bdd_minvar(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Get the maximal occurring variable in the function's support. /// /// \throws invalid_argument If `f` is a terminal. ////////////////////////////////////////////////////////////////////////////// - bdd::label_type bdd_maxvar(const bdd &f); + bdd::label_type + bdd_maxvar(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief The lexicographically smallest cube x such that f(x) is true. @@ -1208,7 +1356,8 @@ namespace adiar /// \returns A bdd whos only path to the `true` terminal reflects the minimal /// assignment. ////////////////////////////////////////////////////////////////////////////// - bdd bdd_satmin(const bdd &f); + bdd + bdd_satmin(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief The lexicographically smallest x such that f(x) is true. @@ -1216,7 +1365,8 @@ namespace adiar /// \param c Consumer that is called in ascending order of the bdd's levels /// with the (var, value) pairs of the assignment. ////////////////////////////////////////////////////////////////////////////// - void bdd_satmin(const bdd &f, const consumer> &c); + void + bdd_satmin(const bdd& f, const consumer>& c); ////////////////////////////////////////////////////////////////////////////// /// \brief The lexicographically smallest x such that f(x) is true. @@ -1232,8 +1382,9 @@ namespace adiar /// \throws out_of_range If the distance between `begin` and `end` is not big /// enough to contain all variables in `f`. ////////////////////////////////////////////////////////////////////////////// - template - ForwardIt bdd_satmin(const bdd &f, ForwardIt begin, ForwardIt end) + template + ForwardIt + bdd_satmin(const bdd& f, ForwardIt begin, ForwardIt end) { bdd_satmin(f, make_consumer(begin, end)); return begin; @@ -1249,7 +1400,8 @@ namespace adiar /// \returns A bdd whos only path to the `true` terminal reflects the maximal /// assignment. ////////////////////////////////////////////////////////////////////////////// - bdd bdd_satmax(const bdd &f); + bdd + bdd_satmax(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief The lexicographically largest x such that f(x) is true. @@ -1257,8 +1409,8 @@ namespace adiar /// \param c Consumer that is called in ascending order of the bdd's levels /// with the (var, value) pairs of the assignment. ////////////////////////////////////////////////////////////////////////////// - void bdd_satmax(const bdd &f, const consumer> &c); - + void + bdd_satmax(const bdd& f, const consumer>& c); ////////////////////////////////////////////////////////////////////////////// /// \brief The lexicographically largest x such that f(x) is true. @@ -1274,8 +1426,9 @@ namespace adiar /// \throws out_of_range If the distance between `begin` and `end` is not big /// enough to contain all variables in `f`. ////////////////////////////////////////////////////////////////////////////// - template - ForwardIt bdd_satmax(const bdd &f, ForwardIt begin, ForwardIt end) + template + ForwardIt + bdd_satmax(const bdd& f, ForwardIt begin, ForwardIt end) { bdd_satmax(f, make_consumer(begin, end)); return begin; @@ -1292,7 +1445,8 @@ namespace adiar /// \param xs An assignment function of the type \f$ \texttt{label\_t} /// \rightarrow \texttt{bool} \f$. ////////////////////////////////////////////////////////////////////////////// - bool bdd_eval(const bdd &f, const predicate &xs); + bool + bdd_eval(const bdd& f, const predicate& xs); ////////////////////////////////////////////////////////////////////////////// /// \brief Evaluate a BDD according to an assignment to its variables. @@ -1308,7 +1462,8 @@ namespace adiar /// /// \throws invalid_argument If a level in the BDD does not exist in `xs`. ////////////////////////////////////////////////////////////////////////////// - bool bdd_eval(const bdd &f, const generator> &xs); + bool + bdd_eval(const bdd& f, const generator>& xs); ////////////////////////////////////////////////////////////////////////////// /// \brief Evaluate a BDD according to an assignment to its variables. @@ -1325,9 +1480,12 @@ namespace adiar /// /// \throws invalid_argument If a level in the BDD does not exist in `xs`. ////////////////////////////////////////////////////////////////////////////// - template - bool bdd_eval(const bdd &f, ForwardIt begin, ForwardIt end) - { return bdd_eval(f, make_generator(begin, end)); } + template + bool + bdd_eval(const bdd& f, ForwardIt begin, ForwardIt end) + { + return bdd_eval(f, make_generator(begin, end)); + } /// \} ////////////////////////////////////////////////////////////////////////////// @@ -1349,15 +1507,15 @@ namespace adiar /// \returns BDD that is true for the exact same assignments to variables in /// the given domain. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_from(const zdd &A, const generator &dom); + __bdd + bdd_from(const zdd& A, const generator& dom); ////////////////////////////////////////////////////////////////////////////// /// \brief Obtains the BDD that represents the same function/set as the given /// ZDD within the given domain. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_from(const exec_policy &ep, - const zdd &A, - const generator &dom); + __bdd + bdd_from(const exec_policy& ep, const zdd& A, const generator& dom); ////////////////////////////////////////////////////////////////////////////// /// \brief Obtains the BDD that represents the same function/set as the @@ -1374,20 +1532,23 @@ namespace adiar /// \returns BDD that is true for the exact same assignments to variables /// in the given domain. ////////////////////////////////////////////////////////////////////////////// - template - __bdd bdd_from(const zdd &A, ForwardIt begin, ForwardIt end) - { return bdd_from(A, make_generator(begin, end)); } + template + __bdd + bdd_from(const zdd& A, ForwardIt begin, ForwardIt end) + { + return bdd_from(A, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Obtains the BDD that represents the same function/set as the given /// ZDD within the given domain. ////////////////////////////////////////////////////////////////////////////// - template - __bdd bdd_from(const exec_policy &ep, - const zdd &A, - ForwardIt begin, - ForwardIt end) - { return bdd_from(ep, A, make_generator(begin, end)); } + template + __bdd + bdd_from(const exec_policy& ep, const zdd& A, ForwardIt begin, ForwardIt end) + { + return bdd_from(ep, A, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Obtains the BDD that represents the same function/set as the @@ -1403,13 +1564,15 @@ namespace adiar /// \pre The global \ref module__domain is set to a set of variables /// that is equals to or a superset of the variables in `A`. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_from(const zdd &A); + __bdd + bdd_from(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Obtains the BDD that represents the same function/set as the given /// ZDD within the global domain. ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_from(const exec_policy &ep, const zdd &A); + __bdd + bdd_from(const exec_policy& ep, const zdd& A); /// \} ////////////////////////////////////////////////////////////////////////////// @@ -1422,16 +1585,14 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// /// \brief Output a DOT drawing of a BDD to the given output stream. ////////////////////////////////////////////////////////////////////////////// - void bdd_printdot(const bdd &f, - std::ostream &out = std::cout, - bool include_id = false); + void + bdd_printdot(const bdd& f, std::ostream& out = std::cout, bool include_id = false); ////////////////////////////////////////////////////////////////////////////// /// \brief Output a DOT drawing of a BDD to the file with the given name. ////////////////////////////////////////////////////////////////////////////// - void bdd_printdot(const bdd &f, - const std::string &file_name, - bool include_id = false); + void + bdd_printdot(const bdd& f, const std::string& file_name, bool include_id = false); /// \} ////////////////////////////////////////////////////////////////////////////// diff --git a/src/adiar/bdd/apply.cpp b/src/adiar/bdd/apply.cpp index 2d6a98d60..d8bde479f 100644 --- a/src/adiar/bdd/apply.cpp +++ b/src/adiar/bdd/apply.cpp @@ -1,12 +1,12 @@ #include #include +#include #include #include +#include #include #include -#include -#include namespace adiar { @@ -15,28 +15,25 @@ namespace adiar , public internal::prod2_mixed_level_merger { public: - static __bdd resolve_same_file(const bdd &bdd_1, const bdd &bdd_2, - const bool_op &op) + static __bdd + resolve_same_file(const bdd& bdd_1, const bdd& bdd_2, const bool_op& op) { bdd::pointer_type terminal_1_F = bdd::pointer_type(bdd_1.negate); bdd::pointer_type terminal_2_F = bdd::pointer_type(bdd_2.negate); // Compute the results on all children. - bdd::pointer_type op_F = op( terminal_1_F, terminal_2_F); + bdd::pointer_type op_F = op(terminal_1_F, terminal_2_F); bdd::pointer_type op_T = op(~terminal_1_F, ~terminal_2_F); // Does it collapse to a terminal? - if (op_F == op_T) { - return bdd_terminal(op_F.value()); - } + if (op_F == op_T) { return bdd_terminal(op_F.value()); } return op_F == terminal_1_F ? bdd_1 : ~bdd_1; } public: - static __bdd resolve_terminal_root(const bdd& bdd_1, - const bdd& bdd_2, - const bool_op &op) + static __bdd + resolve_terminal_root(const bdd& bdd_1, const bdd& bdd_2, const bool_op& op) { adiar_assert(bdd_isterminal(bdd_1) || bdd_isterminal(bdd_2)); @@ -51,9 +48,7 @@ namespace adiar if (can_left_shortcut(op, p1)) { return bdd_terminal(op(p1, bdd::pointer_type(false)).value()); } - if (is_left_irrelevant(op, p1)) { - return bdd_2; - } + if (is_left_irrelevant(op, p1)) { return bdd_2; } // if (is_left_negating(op, p1)) return bdd_not(bdd_2); } else { // if (bdd_isterminal(bdd_2)) { @@ -62,9 +57,7 @@ namespace adiar if (can_right_shortcut(op, p2)) { return bdd_terminal(op(bdd::pointer_type(false), p2).value()); } - if (is_right_irrelevant(op, p2)) { - return bdd_1; - } + if (is_right_irrelevant(op, p2)) { return bdd_1; } // if (is_right_negating(op, p2)) return bdd_not(bdd_1); } @@ -72,26 +65,27 @@ namespace adiar } public: - static internal::cut left_cut(const bool_op &op) + static internal::cut + left_cut(const bool_op& op) { const bool incl_false = !can_left_shortcut(op, bdd::pointer_type(false)); - const bool incl_true = !can_left_shortcut(op, bdd::pointer_type(true)); + const bool incl_true = !can_left_shortcut(op, bdd::pointer_type(true)); return internal::cut(incl_false, incl_true); } - static internal::cut right_cut(const bool_op &op) + static internal::cut + right_cut(const bool_op& op) { const bool incl_false = !can_right_shortcut(op, bdd::pointer_type(false)); - const bool incl_true = !can_right_shortcut(op, bdd::pointer_type(true)); + const bool incl_true = !can_right_shortcut(op, bdd::pointer_type(true)); return internal::cut(incl_false, incl_true); } private: static internal::tuple - __resolve_request(const bool_op &op, - const internal::tuple &r) + __resolve_request(const bool_op& op, const internal::tuple& r) { if (r[0].is_terminal() && can_left_shortcut(op, r[0])) { return { r[0], bdd::pointer_type(true) }; @@ -104,136 +98,158 @@ namespace adiar public: static internal::prod2_rec - resolve_request(const bool_op &op, - const internal::tuple &r_low, - const internal::tuple &r_high) + resolve_request(const bool_op& op, + const internal::tuple& r_low, + const internal::tuple& r_high) { - return internal::prod2_rec_output { - __resolve_request(op, r_low), - __resolve_request(op, r_high) - }; + return internal::prod2_rec_output{ __resolve_request(op, r_low), + __resolve_request(op, r_high) }; } static constexpr bool no_skip = false; }; - __bdd bdd_apply(const exec_policy &ep, const bdd &f, const bdd &g, const bool_op &op) + __bdd + bdd_apply(const exec_policy& ep, const bdd& f, const bdd& g, const bool_op& op) { return internal::prod2(ep, f, g, op); } - __bdd bdd_apply(const bdd &f, const bdd &g, const bool_op &op) + __bdd + bdd_apply(const bdd& f, const bdd& g, const bool_op& op) { return bdd_apply(exec_policy(), f, g, op); } ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_and(const exec_policy &ep, const bdd &f, const bdd &g) + __bdd + bdd_and(const exec_policy& ep, const bdd& f, const bdd& g) { return bdd_apply(ep, f, g, and_op); } - __bdd bdd_and(const bdd &f, const bdd &g) + __bdd + bdd_and(const bdd& f, const bdd& g) { return bdd_and(exec_policy(), f, g); } - __bdd bdd_nand(const exec_policy &ep, const bdd &f, const bdd &g) + __bdd + bdd_nand(const exec_policy& ep, const bdd& f, const bdd& g) { return bdd_apply(ep, f, g, nand_op); } - __bdd bdd_nand(const bdd &f, const bdd &g) + __bdd + bdd_nand(const bdd& f, const bdd& g) { return bdd_nand(exec_policy(), f, g); } - __bdd bdd_or(const exec_policy &ep, const bdd &f, const bdd &g) + __bdd + bdd_or(const exec_policy& ep, const bdd& f, const bdd& g) { return bdd_apply(ep, f, g, or_op); } - __bdd bdd_or(const bdd &f, const bdd &g) + __bdd + bdd_or(const bdd& f, const bdd& g) { return bdd_or(exec_policy(), f, g); } - __bdd bdd_nor(const exec_policy &ep, const bdd &f, const bdd &g) + __bdd + bdd_nor(const exec_policy& ep, const bdd& f, const bdd& g) { return bdd_apply(ep, f, g, nor_op); } - __bdd bdd_nor(const bdd &f, const bdd &g) + __bdd + bdd_nor(const bdd& f, const bdd& g) { return bdd_nor(exec_policy(), f, g); } - __bdd bdd_xor(const exec_policy &ep, const bdd &f, const bdd &g) + __bdd + bdd_xor(const exec_policy& ep, const bdd& f, const bdd& g) { return bdd_apply(ep, f, g, xor_op); } - __bdd bdd_xor(const bdd &f, const bdd &g) + __bdd + bdd_xor(const bdd& f, const bdd& g) { return bdd_xor(exec_policy(), f, g); } - __bdd bdd_xnor(const exec_policy &ep, const bdd &f, const bdd &g) + __bdd + bdd_xnor(const exec_policy& ep, const bdd& f, const bdd& g) { return bdd_apply(ep, f, g, xnor_op); } - __bdd bdd_xnor(const bdd &f, const bdd &g) + __bdd + bdd_xnor(const bdd& f, const bdd& g) { return bdd_xnor(exec_policy(), f, g); } - __bdd bdd_imp(const exec_policy &ep, const bdd &f, const bdd &g) + __bdd + bdd_imp(const exec_policy& ep, const bdd& f, const bdd& g) { return bdd_apply(ep, f, g, imp_op); } - __bdd bdd_imp(const bdd &f, const bdd &g) + __bdd + bdd_imp(const bdd& f, const bdd& g) { return bdd_imp(exec_policy(), f, g); } - __bdd bdd_invimp(const exec_policy &ep, const bdd &f, const bdd &g) + __bdd + bdd_invimp(const exec_policy& ep, const bdd& f, const bdd& g) { return bdd_apply(ep, f, g, invimp_op); } - __bdd bdd_invimp(const bdd &f, const bdd &g) + __bdd + bdd_invimp(const bdd& f, const bdd& g) { return bdd_invimp(exec_policy(), f, g); } - __bdd bdd_equiv(const exec_policy &ep, const bdd &f, const bdd &g) + __bdd + bdd_equiv(const exec_policy& ep, const bdd& f, const bdd& g) { return bdd_apply(ep, f, g, equiv_op); } - __bdd bdd_equiv(const bdd &f, const bdd &g) + __bdd + bdd_equiv(const bdd& f, const bdd& g) { return bdd_equiv(exec_policy(), f, g); } - __bdd bdd_diff(const exec_policy &ep, const bdd &f, const bdd &g) + __bdd + bdd_diff(const exec_policy& ep, const bdd& f, const bdd& g) { return bdd_apply(ep, f, g, diff_op); } - __bdd bdd_diff(const bdd &f, const bdd &g) + __bdd + bdd_diff(const bdd& f, const bdd& g) { return bdd_diff(exec_policy(), f, g); } - __bdd bdd_less(const exec_policy &ep, const bdd &f, const bdd &g) + __bdd + bdd_less(const exec_policy& ep, const bdd& f, const bdd& g) { return bdd_apply(ep, f, g, less_op); } - __bdd bdd_less(const bdd &f, const bdd &g) + __bdd + bdd_less(const bdd& f, const bdd& g) { return bdd_less(exec_policy(), f, g); } diff --git a/src/adiar/bdd/bdd.cpp b/src/adiar/bdd/bdd.cpp index f4da3d1b6..41b471b90 100644 --- a/src/adiar/bdd/bdd.cpp +++ b/src/adiar/bdd/bdd.cpp @@ -1,171 +1,205 @@ #include "bdd.h" -#include - #include -#include -#include +#include #include #include +#include +#include + namespace adiar { ////////////////////////////////////////////////////////////////////////////// // '__bdd' Constructors __bdd::__bdd() = default; - __bdd::__bdd(const shared_node_file_type &f) + __bdd::__bdd(const shared_node_file_type& f) : internal::__dd(f) - { } + {} - __bdd::__bdd(const shared_arc_file_type &f, const exec_policy &ep) + __bdd::__bdd(const shared_arc_file_type& f, const exec_policy& ep) : internal::__dd(f, ep) - { } + {} - __bdd::__bdd(const bdd &dd) + __bdd::__bdd(const bdd& dd) : internal::__dd(dd) - { } + {} ////////////////////////////////////////////////////////////////////////////// // 'bdd' Constructors bdd::bdd(bool t) : bdd(bdd_terminal(t)) - { } + {} bdd::bdd() : bdd(false) - { } + {} - bdd::bdd(const shared_node_file_type &f, bool negate) + bdd::bdd(const shared_node_file_type& f, bool negate) : internal::dd(f, negate) - { } + {} - bdd::bdd(const bdd &f) + bdd::bdd(const bdd& f) : internal::dd(f) - { } + {} - bdd::bdd(bdd &&f) + bdd::bdd(bdd&& f) : internal::dd(f) - { } + {} - bdd::bdd(__bdd &&f) + bdd::bdd(__bdd&& f) : internal::dd(internal::reduce(std::move(f))) - { } + {} ////////////////////////////////////////////////////////////////////////////// // Operators - bdd operator~ (__bdd &&in) { return ~bdd(std::move(in)); } - -#define __bdd_oper(out_t, op) \ - out_t operator op (__bdd &&lhs, __bdd &&rhs) { \ - return bdd(std::move(lhs)) op bdd(std::move(rhs)); \ - } \ - \ - out_t operator op (const bdd &lhs, __bdd &&rhs) { \ - return lhs op bdd(std::move(rhs)); \ - } \ - \ - out_t operator op (__bdd &&lhs, const bdd &rhs) { \ - return bdd(std::move(lhs)) op rhs; \ - } - - __bdd_oper(__bdd, &) - __bdd_oper(__bdd, |) - __bdd_oper(__bdd, ^) - __bdd_oper(bool, ==) - __bdd_oper(bool, !=) - - bdd& bdd::operator= (const bdd &other) - { - this -> negate = other.negate; - this -> file = other.file; + bdd + operator~(__bdd&& in) + { + return ~bdd(std::move(in)); + } + +#define __bdd_oper(out_t, op) \ + out_t operator op(__bdd&& lhs, __bdd&& rhs) \ + { \ + return bdd(std::move(lhs)) op bdd(std::move(rhs)); \ + } \ + \ + out_t operator op(const bdd& lhs, __bdd&& rhs) \ + { \ + return lhs op bdd(std::move(rhs)); \ + } \ + \ + out_t operator op(__bdd&& lhs, const bdd& rhs) \ + { \ + return bdd(std::move(lhs)) op rhs; \ + } + + __bdd_oper(__bdd, &) __bdd_oper(__bdd, |) __bdd_oper(__bdd, ^) __bdd_oper(bool, ==) + __bdd_oper(bool, !=) + + bdd& bdd::operator=(const bdd & other) + { + this->negate = other.negate; + this->file = other.file; return *this; } - bdd& bdd::operator= (__bdd &&other) + bdd& + bdd::operator=(__bdd&& other) { deref(); return (*this = internal::reduce(std::move(other))); } - bdd& bdd::operator&= (const bdd &other) + bdd& + bdd::operator&=(const bdd& other) { return (*this = bdd_and(*this, other)); } - bdd& bdd::operator&= (bdd &&other) + bdd& + bdd::operator&=(bdd&& other) { __bdd temp = bdd_and(*this, other); other.deref(); return (*this = std::move(temp)); } - bdd& bdd::operator|= (const bdd &other) + bdd& + bdd::operator|=(const bdd& other) { return (*this = bdd_or(*this, other)); } - bdd& bdd::operator|= (bdd &&other) + bdd& + bdd::operator|=(bdd&& other) { __bdd temp = bdd_or(*this, other); other.deref(); return (*this = std::move(temp)); } - bdd& bdd::operator^= (const bdd &other) + bdd& + bdd::operator^=(const bdd& other) { return (*this = bdd_xor(*this, other)); } - bdd& bdd::operator^= (bdd &&other) + bdd& + bdd::operator^=(bdd&& other) { __bdd temp = bdd_xor(*this, other); other.deref(); return (*this = std::move(temp)); } - bool operator== (const bdd &lhs, const bdd &rhs) + bool + operator==(const bdd& lhs, const bdd& rhs) { return bdd_equal(lhs, rhs); } - bool operator!= (const bdd &lhs, const bdd &rhs) - { return bdd_unequal(lhs, rhs); } + bool + operator!=(const bdd& lhs, const bdd& rhs) + { + return bdd_unequal(lhs, rhs); + } - bdd operator~ (const bdd &f) - { return bdd_not(f); } + bdd + operator~(const bdd& f) + { + return bdd_not(f); + } - bdd operator~ (bdd &&f) - { return bdd_not(std::forward(f)); } + bdd + operator~(bdd&& f) + { + return bdd_not(std::forward(f)); + } - __bdd operator& (const bdd &lhs, const bdd &rhs) - { return bdd_and(lhs, rhs); } + __bdd + operator&(const bdd& lhs, const bdd& rhs) + { + return bdd_and(lhs, rhs); + } - __bdd operator| (const bdd &lhs, const bdd &rhs) - { return bdd_or(lhs, rhs); } + __bdd + operator|(const bdd& lhs, const bdd& rhs) + { + return bdd_or(lhs, rhs); + } - __bdd operator^ (const bdd &lhs, const bdd &rhs) - { return bdd_xor(lhs, rhs); } + __bdd + operator^(const bdd& lhs, const bdd& rhs) + { + return bdd_xor(lhs, rhs); + } ////////////////////////////////////////////////////////////////////////////// // Input variables - bdd::label_type bdd_topvar(const bdd &f) + bdd::label_type + bdd_topvar(const bdd& f) { return internal::dd_topvar(f); } - bdd::label_type bdd_minvar(const bdd &f) + bdd::label_type + bdd_minvar(const bdd& f) { return internal::dd_minvar(f); } - bdd::label_type bdd_maxvar(const bdd &f) + bdd::label_type + bdd_maxvar(const bdd& f) { return internal::dd_maxvar(f); } - void bdd_support(const bdd &f, const consumer &cb) + void + bdd_support(const bdd& f, const consumer& cb) { return internal::dd_support(f, cb); } diff --git a/src/adiar/bdd/bdd.h b/src/adiar/bdd/bdd.h index 76e5c7798..18a6fd254 100644 --- a/src/adiar/bdd/bdd.h +++ b/src/adiar/bdd/bdd.h @@ -29,17 +29,17 @@ namespace adiar //////////////////////////////////////////////////////////////////////////// /// \brief Wrapper for an algorithm's already reduced output. //////////////////////////////////////////////////////////////////////////// - __bdd(const shared_node_file_type &f); + __bdd(const shared_node_file_type& f); //////////////////////////////////////////////////////////////////////////// /// \brief Wrapper for an algorithm's unreduced output. //////////////////////////////////////////////////////////////////////////// - __bdd(const shared_arc_file_type &f, const exec_policy &ep); + __bdd(const shared_arc_file_type& f, const exec_policy& ep); //////////////////////////////////////////////////////////////////////////// /// \brief Conversion constructor from a `bdd` to pass along a prior value. //////////////////////////////////////////////////////////////////////////// - __bdd(const bdd &bdd); + __bdd(const bdd& bdd); }; ////////////////////////////////////////////////////////////////////////////// @@ -60,8 +60,10 @@ namespace adiar friend class apply_prod2_policy; // |- functions - friend bdd bdd_not(const bdd&); - friend bdd bdd_not(bdd&&); + friend bdd + bdd_not(const bdd&); + friend bdd + bdd_not(bdd&&); friend size_t bdd_nodecount(const bdd&); @@ -70,7 +72,7 @@ namespace adiar bdd_varcount(const bdd&); friend __bdd - bdd_ite(const exec_policy &ep, const bdd &f, const bdd &g, const bdd &h); + bdd_ite(const exec_policy& ep, const bdd& f, const bdd& g, const bdd& h); public: /// \cond @@ -107,19 +109,19 @@ namespace adiar //////////////////////////////////////////////////////////////////////////// /// \brief Constructor to wrap the node-based result of an algorithm. //////////////////////////////////////////////////////////////////////////// - bdd(const bdd::shared_node_file_type &f, bool negate = false); + bdd(const bdd::shared_node_file_type& f, bool negate = false); /// \endcond //////////////////////////////////////////////////////////////////////////// /// \brief Copy construction, incrementing the reference count on the file /// underneath. //////////////////////////////////////////////////////////////////////////// - bdd(const bdd &f); + bdd(const bdd& f); //////////////////////////////////////////////////////////////////////////// /// \brief Move construction, taking over ownership of the files underneath. //////////////////////////////////////////////////////////////////////////// - bdd(bdd &&f); + bdd(bdd&& f); //////////////////////////////////////////////////////////////////////////// /// \brief Implicit move conversion from a possibly to-be reduced result @@ -132,7 +134,7 @@ namespace adiar /// \remark Since the value `o` is forced to be moved, we force the content /// of `o` to be destructed after finishing the *Reduce* algorithm. //////////////////////////////////////////////////////////////////////////// - bdd(__bdd &&f); + bdd(__bdd&& f); //////////////////////////////////////////////////////////////////////////// // Assignment operator overloadings @@ -140,39 +142,47 @@ namespace adiar //////////////////////////////////////////////////////////////////////////// /// \brief Assigns new `bdd`. //////////////////////////////////////////////////////////////////////////// - bdd& operator= (const bdd &other); + bdd& + operator=(const bdd& other); //////////////////////////////////////////////////////////////////////////// /// \brief Assigns new `bdd` to a variable; the content is derefenced before /// the given `__bdd` is reduced into a `bdd`. //////////////////////////////////////////////////////////////////////////// - bdd& operator= (__bdd &&other); + bdd& + operator=(__bdd&& other); //////////////////////////////////////////////////////////////////////////// /// \see bdd_and //////////////////////////////////////////////////////////////////////////// - bdd& operator&= (const bdd &other); + bdd& + operator&=(const bdd& other); /// \cond - bdd& operator&= (bdd &&other); + bdd& + operator&=(bdd&& other); /// \endcond //////////////////////////////////////////////////////////////////////////// /// \see bdd_or //////////////////////////////////////////////////////////////////////////// - bdd& operator|= (const bdd &other); + bdd& + operator|=(const bdd& other); /// \cond - bdd& operator|= (bdd &&other); + bdd& + operator|=(bdd&& other); /// \endcond //////////////////////////////////////////////////////////////////////////// /// \see bdd_xor //////////////////////////////////////////////////////////////////////////// - bdd& operator^= (const bdd &other); + bdd& + operator^=(const bdd& other); /// \cond - bdd& operator^= (bdd &&other); + bdd& + operator^=(bdd&& other); /// \endcond }; } diff --git a/src/adiar/bdd/bdd_policy.h b/src/adiar/bdd/bdd_policy.h index 652a6a1f3..194c62911 100644 --- a/src/adiar/bdd/bdd_policy.h +++ b/src/adiar/bdd/bdd_policy.h @@ -3,9 +3,9 @@ #include -#include #include #include +#include namespace adiar { @@ -14,9 +14,9 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// using bdd_policy = internal::dd_policy; - template<> + template <> inline bdd::pointer_type - bdd_policy::reduction_rule(const bdd::node_type &n) + bdd_policy::reduction_rule(const bdd::node_type& n) { // If adding attributed edges, i.e. complement edges: // remove the 'unflag' below. Currently, it removes any forwarding of @@ -25,9 +25,9 @@ namespace adiar return n.uid(); } - template<> + template <> inline bdd_policy::children_type - bdd_policy::reduction_rule_inv(const bdd::pointer_type &child) + bdd_policy::reduction_rule_inv(const bdd::pointer_type& child) { return { child, child }; } diff --git a/src/adiar/bdd/build.cpp b/src/adiar/bdd/build.cpp index d51aa0ede..31220ec93 100644 --- a/src/adiar/bdd/build.cpp +++ b/src/adiar/bdd/build.cpp @@ -1,51 +1,56 @@ #include - #include + +#include #include #include -#include -#include -#include -#include #include #include +#include +#include +#include #include namespace adiar { - template - using bdd_chain_converter = - internal::chain_converter; + template + using bdd_chain_converter = internal::chain_converter; ////////////////////////////////////////////////////////////////////////////// - bdd bdd_const(bool value) + bdd + bdd_const(bool value) { return internal::build_terminal(value); } - bdd bdd_terminal(bool value) + bdd + bdd_terminal(bool value) { return bdd_const(value); } - bdd bdd_false() + bdd + bdd_false() { return bdd_const(false); } - bdd bdd_true() + bdd + bdd_true() { return bdd_const(true); } ////////////////////////////////////////////////////////////////////////////// - bdd bdd_ithvar(bdd::label_type label) + bdd + bdd_ithvar(bdd::label_type label) { return internal::build_ithvar(label); } ////////////////////////////////////////////////////////////////////////////// - bdd bdd_nithvar(bdd::label_type label) + bdd + bdd_nithvar(bdd::label_type label) { return bdd_not(internal::build_ithvar(label)); } @@ -57,13 +62,13 @@ namespace adiar static constexpr bool init_terminal = true; constexpr bool - skip(const bdd::label_type &) const - { return false; } + skip(const bdd::label_type&) const + { + return false; + } inline typename bdd::node_type - make_node(const bdd::label_type &l, - const bdd::pointer_type &r, - const bool negated) const + make_node(const bdd::label_type& l, const bdd::pointer_type& r, const bool negated) const { const bdd::pointer_type low = negated ? r : bdd::pointer_type(false); const bdd::pointer_type high = negated ? bdd::pointer_type(false) : r; @@ -72,7 +77,8 @@ namespace adiar } }; - bdd bdd_and(const generator> &vars) + bdd + bdd_and(const generator>& vars) { bdd_and_policy p; bdd_chain_converter vars_wrapper(vars); @@ -80,7 +86,8 @@ namespace adiar return internal::build_chain<>(p, vars_wrapper); } - bdd bdd_and(const generator &vars) + bdd + bdd_and(const generator& vars) { bdd_and_policy p; bdd_chain_converter vars_wrapper(vars); @@ -89,7 +96,8 @@ namespace adiar } ////////////////////////////////////////////////////////////////////////////// - bdd bdd_or(const generator> &vars) + bdd + bdd_or(const generator>& vars) { bdd_and_policy p; bdd_chain_converter vars_wrapper(vars); @@ -97,7 +105,8 @@ namespace adiar return bdd_not(internal::build_chain<>(p, vars_wrapper)); } - bdd bdd_or(const generator &vars) + bdd + bdd_or(const generator& vars) { bdd_and_policy p; bdd_chain_converter vars_wrapper(vars); @@ -106,12 +115,14 @@ namespace adiar } ////////////////////////////////////////////////////////////////////////////// - bdd bdd_cube(const generator> &vars) + bdd + bdd_cube(const generator>& vars) { return bdd_and(vars); } - bdd bdd_cube(const generator &vars) + bdd + bdd_cube(const generator& vars) { return bdd_and(vars); } diff --git a/src/adiar/bdd/convert.cpp b/src/adiar/bdd/convert.cpp index 9c88729a1..140639a1a 100644 --- a/src/adiar/bdd/convert.cpp +++ b/src/adiar/bdd/convert.cpp @@ -1,27 +1,27 @@ #include #include +#include #include -#include #include #include namespace adiar { - __bdd bdd_from(const exec_policy &ep, - const zdd &A, - const generator &dom) + __bdd + bdd_from(const exec_policy& ep, const zdd& A, const generator& dom) { - return internal::intercut> - (ep, A, dom); + return internal::intercut>(ep, A, dom); } - __bdd bdd_from(const zdd &A, const generator &dom) + __bdd + bdd_from(const zdd& A, const generator& dom) { return bdd_from(exec_policy(), A, dom); } - __bdd bdd_from(const exec_policy &ep, const zdd &A) + __bdd + bdd_from(const exec_policy& ep, const zdd& A) { const internal::shared_file dom = domain_get(); internal::file_stream ds(dom); @@ -29,7 +29,8 @@ namespace adiar return bdd_from(ep, A, make_generator(ds)); } - __bdd bdd_from(const zdd &A) + __bdd + bdd_from(const zdd& A) { return bdd_from(exec_policy(), A); } diff --git a/src/adiar/bdd/count.cpp b/src/adiar/bdd/count.cpp index 360aa0443..c67323e56 100644 --- a/src/adiar/bdd/count.cpp +++ b/src/adiar/bdd/count.cpp @@ -2,12 +2,12 @@ #include #include - #include #include + +#include #include #include -#include namespace adiar { @@ -22,7 +22,8 @@ namespace adiar bdd::label_type levels_visited; /// Sorting predicate - inline bool operator< (const sat_data &o) const + inline bool + operator<(const sat_data& o) const { return this->levels_visited < o.levels_visited; } @@ -38,25 +39,22 @@ namespace adiar static constexpr data_type init_data = { 1u, 0u }; static constexpr uint64_t - resolve_false(const data_type &/*d*/, - const typename bdd::label_type/*varcount*/) + resolve_false(const data_type& /*d*/, const typename bdd::label_type /*varcount*/) { return 0u; } static inline uint64_t - resolve_true(const data_type &d, - const typename bdd::label_type varcount) + resolve_true(const data_type& d, const typename bdd::label_type varcount) { - adiar_assert(d.levels_visited <= varcount, - "Cannot have visited more levels than exist"); + adiar_assert(d.levels_visited <= varcount, "Cannot have visited more levels than exist"); const uint64_t unvisited = varcount - d.levels_visited; return d.sum * (1u << unvisited); } static inline data_type - merge(const data_type &&acc, const data_type &next) + merge(const data_type&& acc, const data_type& next) { adiar_assert(acc.sum > 0u && next.sum > 0u, "No request should have an 'empty' set of assignemnts"); @@ -65,61 +63,70 @@ namespace adiar const uint64_t visited_diff = next.levels_visited - acc.levels_visited; - return { - acc.sum * (1u << visited_diff) + next.sum, - next.levels_visited - }; + return { acc.sum * (1u << visited_diff) + next.sum, next.levels_visited }; } static inline data_type - merge_end(const data_type &&acc) + merge_end(const data_type&& acc) { return { acc.sum, acc.levels_visited + 1u }; } }; ////////////////////////////////////////////////////////////////////////////// - size_t bdd_nodecount(const bdd &f) + size_t + bdd_nodecount(const bdd& f) { return internal::dd_nodecount(f); } - bdd::label_type bdd_varcount(const bdd &f) + bdd::label_type + bdd_varcount(const bdd& f) { return internal::dd_varcount(f); } - uint64_t bdd_pathcount(const exec_policy &ep, const bdd &f) + uint64_t + bdd_pathcount(const exec_policy& ep, const bdd& f) { return bdd_isterminal(f) ? 0 : internal::count>(ep, f, bdd_varcount(f)); } - uint64_t bdd_pathcount(const bdd &f) - { return bdd_pathcount(exec_policy(), f); } + uint64_t + bdd_pathcount(const bdd& f) + { + return bdd_pathcount(exec_policy(), f); + } - uint64_t bdd_satcount(const exec_policy &ep, const bdd& f, bdd::label_type varcount) + uint64_t + bdd_satcount(const exec_policy& ep, const bdd& f, bdd::label_type varcount) { if (varcount < bdd_varcount(f)) { throw invalid_argument("'varcount' ought to be at least the number of levels in the BDD"); } - if (bdd_isterminal(f)) { - return dd_valueof(f) ? std::min(1u, varcount) << varcount : 0u; - } + if (bdd_isterminal(f)) { return dd_valueof(f) ? std::min(1u, varcount) << varcount : 0u; } return internal::count(ep, f, varcount); } - uint64_t bdd_satcount(const bdd& f, bdd::label_type varcount) - { return bdd_satcount(exec_policy(), f, varcount); } + uint64_t + bdd_satcount(const bdd& f, bdd::label_type varcount) + { + return bdd_satcount(exec_policy(), f, varcount); + } - uint64_t bdd_satcount(const exec_policy &ep, const bdd &f) + uint64_t + bdd_satcount(const exec_policy& ep, const bdd& f) { return bdd_satcount(ep, f, std::max(domain_size(), bdd_varcount(f))); }; - uint64_t bdd_satcount(const bdd &f) - { return bdd_satcount(exec_policy(), f); }; + uint64_t + bdd_satcount(const bdd& f) + { + return bdd_satcount(exec_policy(), f); + }; } diff --git a/src/adiar/bdd/dot.cpp b/src/adiar/bdd/dot.cpp index 9d381010b..a39874e39 100644 --- a/src/adiar/bdd/dot.cpp +++ b/src/adiar/bdd/dot.cpp @@ -4,12 +4,14 @@ namespace adiar { - void bdd_printdot(const bdd &f, std::ostream &out, bool include_id) + void + bdd_printdot(const bdd& f, std::ostream& out, bool include_id) { internal::print_dot(f, out, include_id); } - void bdd_printdot(const bdd &f, const std::string &file_name, bool include_id) + void + bdd_printdot(const bdd& f, const std::string& file_name, bool include_id) { internal::print_dot(f, file_name, include_id); } diff --git a/src/adiar/bdd/evaluate.cpp b/src/adiar/bdd/evaluate.cpp index aab92d782..7fb1e9e95 100644 --- a/src/adiar/bdd/evaluate.cpp +++ b/src/adiar/bdd/evaluate.cpp @@ -1,47 +1,53 @@ #include - -#include -#include - #include #include +#include +#include -#include -#include -#include #include +#include +#include #include #include #include #include #include +#include namespace adiar { class bdd_eval_func_visitor { - const predicate ⁡ + const predicate& af; bool result = false; public: bdd_eval_func_visitor(const predicate& f) : af(f) - { } + {} - inline bdd::pointer_type visit(const bdd::node_type &n) + inline bdd::pointer_type + visit(const bdd::node_type& n) { const bool a = af(n.label()); return a ? n.high() : n.low(); } - inline void visit(const bool s) - { result = s; } + inline void + visit(const bool s) + { + result = s; + } - inline bool get_result() - { return result; } + inline bool + get_result() + { + return result; + } }; - bool bdd_eval(const bdd &bdd, const predicate &af) + bool + bdd_eval(const bdd& bdd, const predicate& af) { bdd_eval_func_visitor v(af); traverse(bdd, v); @@ -51,7 +57,7 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// class bdd_eval_generator_visitor { - const generator> &_generator; + const generator>& _generator; // The `_next_pair` value is only queried if there actually are BDD nodes. // Hence, we may as well unwrap the `optional<...>`. @@ -67,16 +73,15 @@ namespace adiar if (p) { _next_pair = p.value(); } } - inline bdd::pointer_type visit(const bdd::node_type &n) + inline bdd::pointer_type + visit(const bdd::node_type& n) { const bdd::label_type level = n.label(); while (_next_pair.first < level) { const optional> p = _generator(); - if (!p) { - throw out_of_range("Labels are insufficient to traverse BDD"); - } + if (!p) { throw out_of_range("Labels are insufficient to traverse BDD"); } if (p.value().first <= _next_pair.first) { throw invalid_argument("Labels are not in ascending order"); @@ -92,14 +97,21 @@ namespace adiar return n.child(_next_pair.second); } - inline void visit(const bool s) - { result = s; } + inline void + visit(const bool s) + { + result = s; + } - inline bool get_result() - { return result; } + inline bool + get_result() + { + return result; + } }; - bool bdd_eval(const bdd &bdd, const generator> &xs) + bool + bdd_eval(const bdd& bdd, const generator>& xs) { bdd_eval_generator_visitor v(xs); internal::traverse(bdd, v); @@ -107,7 +119,7 @@ namespace adiar } ////////////////////////////////////////////////////////////////////////////// - template + template class bdd_satX__stack { private: @@ -123,22 +135,25 @@ namespace adiar public: bdd_satX__stack(const size_t stack_size) : _stack(stack_size) - { } + {} - bdd::pointer_type visit(const bdd::node_type &n) + bdd::pointer_type + visit(const bdd::node_type& n) { const bdd::pointer_type next = _visitor.visit(n); - _stack.push({n.label(), next == n.low()}); + _stack.push({ n.label(), next == n.low() }); return next; } - void visit(const bool t) + void + visit(const bool t) { _visitor.visit(t); } public: - bdd build_bdd() + bdd + build_bdd() { adiar_assert(!_stack.empty()); @@ -154,33 +169,36 @@ namespace adiar } }; - template + template class bdd_satX__functional { private: Visitor _visitor; - const consumer> &_consumer; + const consumer>& _consumer; public: - bdd_satX__functional(const consumer> &c) + bdd_satX__functional(const consumer>& c) : _consumer(c) - { } + {} - bdd::pointer_type visit(const bdd::node_type &n) + bdd::pointer_type + visit(const bdd::node_type& n) { const bdd::pointer_type next = _visitor.visit(n); - _consumer({n.label(), next == n.high()}); + _consumer({ n.label(), next == n.high() }); return next; } - void visit(const bool t) + void + visit(const bool t) { _visitor.visit(t); } }; - template - bdd __bdd_satX(const bdd &f) + template + bdd + __bdd_satX(const bdd& f) { if (bdd_isterminal(f)) { return f; } @@ -190,29 +208,34 @@ namespace adiar return v.build_bdd(); } - template - void __bdd_satX(const bdd &f, const consumer> &c) + template + void + __bdd_satX(const bdd& f, const consumer>& c) { bdd_satX__functional v(c); internal::traverse(f, v); } - bdd bdd_satmin(const bdd &f) + bdd + bdd_satmin(const bdd& f) { return __bdd_satX(f); } - void bdd_satmin(const bdd &f, const consumer> &c) + void + bdd_satmin(const bdd& f, const consumer>& c) { return __bdd_satX(f, c); } - bdd bdd_satmax(const bdd &f) + bdd + bdd_satmax(const bdd& f) { return __bdd_satX(f); } - void bdd_satmax(const bdd &f, const consumer> &c) + void + bdd_satmax(const bdd& f, const consumer>& c) { return __bdd_satX(f, c); } diff --git a/src/adiar/bdd/if_then_else.cpp b/src/adiar/bdd/if_then_else.cpp index 030db9efc..27c54c141 100644 --- a/src/adiar/bdd/if_then_else.cpp +++ b/src/adiar/bdd/if_then_else.cpp @@ -1,25 +1,24 @@ #include - #include +#include -#include -#include #include #include #include -#include -#include -#include #include #include #include #include +#include #include #include +#include +#include #include #include #include -#include +#include +#include namespace adiar { @@ -37,31 +36,29 @@ namespace adiar // the placement of the else-BDD on whether any element from the if-BDD or // then-BDD has been forwarded. - template + template using ite_request = internal::request_data<3, internal::with_parent, nodes_carried>; - template + template using ite_priority_queue_1_t = - internal::levelized_node_priority_queue, - internal::request_data_first_lt>, - look_ahead, mem_mode, 3>; - - template - using ite_priority_queue_2_t = - internal::priority_queue, - internal::request_data_second_lt>>; - - template - using ite_priority_queue_3_t = - internal::priority_queue, - internal::request_data_third_lt>>; + internal::levelized_node_priority_queue, + internal::request_data_first_lt>, + look_ahead, + mem_mode, + 3>; + + template + using ite_priority_queue_2_t = internal:: + priority_queue, internal::request_data_second_lt>>; + + template + using ite_priority_queue_3_t = internal:: + priority_queue, internal::request_data_third_lt>>; ////////////////////////////////////////////////////////////////////////////// // Helper functions internal::shared_levelized_file - __ite_zip_bdds(const bdd &bdd_if, const bdd &bdd_then, const bdd &bdd_else) + __ite_zip_bdds(const bdd& bdd_if, const bdd& bdd_then, const bdd& bdd_else) { // TODO: What is the performance of '<<' rather than 'unsafe_push'? If there // is a major difference, then we may want to "inline" the '<<' with its @@ -83,8 +80,7 @@ namespace adiar while (in_nodes_then.can_pull() || in_nodes_else.can_pull()) { bool from_then = in_nodes_then.can_pull() - && (!in_nodes_else.can_pull() - || in_nodes_then.peek() > in_nodes_else.peek()); + && (!in_nodes_else.can_pull() || in_nodes_then.peek() > in_nodes_else.peek()); internal::node n = from_then ? in_nodes_then.pull() : in_nodes_else.pull(); @@ -103,18 +99,16 @@ namespace adiar while (in_nodes_if.can_pull()) { const internal::node n = in_nodes_if.pull(); - const internal::node::pointer_type low = n.low().is_terminal() - ? (n.low().value() ? root_then : root_else) - : n.low(); + const internal::node::pointer_type low = + n.low().is_terminal() ? (n.low().value() ? root_then : root_else) : n.low(); - const internal::node::pointer_type high = n.high().is_terminal() - ? (n.high().value() ? root_then : root_else) - : n.high(); + const internal::node::pointer_type high = + n.high().is_terminal() ? (n.high().value() ? root_then : root_else) : n.high(); nw << internal::node(n.uid(), low, high); } - for(size_t ct = 0u; ct < internal::cut::size; ct++) { + for (size_t ct = 0u; ct < internal::cut::size; ct++) { out_nodes->max_1level_cut[ct] = std::max(bdd_if->max_1level_cut[internal::cut::All], bdd_then->max_1level_cut[ct] + bdd_else->max_1level_cut[ct]); @@ -126,28 +120,31 @@ namespace adiar return out_nodes; } - inline bool ite_must_forward(internal::node v, - internal::node::pointer_type t, - internal::node::label_type out_label, - internal::node::pointer_type t_seek) + inline bool + ite_must_forward(internal::node v, + internal::node::pointer_type t, + internal::node::label_type out_label, + internal::node::pointer_type t_seek) { return // is it a node at this level? - t.is_node() && t.label() == out_label + t.is_node() + && t.label() == out_label // and we should be seeing it later && t_seek < t // and we haven't by accident just run into it anyway && v.uid() != t; } - inline void ite_init_request(internal::node_stream<> &in_nodes, - internal::node &v, - const internal::node::label_type out_label, - internal::node::pointer_type &low, - internal::node::pointer_type &high) + inline void + ite_init_request(internal::node_stream<>& in_nodes, + internal::node& v, + const internal::node::label_type out_label, + internal::node::pointer_type& low, + internal::node::pointer_type& high) { if (v.label() == out_label) { - low = v.low(); + low = v.low(); high = v.high(); if (in_nodes.can_pull()) { v = in_nodes.pull(); } @@ -156,27 +153,27 @@ namespace adiar } } - template - inline void __ite_resolve_request(pq_1_t &ite_pq_1, - internal::arc_writer &aw, - const internal::node::pointer_type source, - internal::node::pointer_type r_if, - internal::node::pointer_type r_then, - internal::node::pointer_type r_else) + template + inline void + __ite_resolve_request(pq_1_t& ite_pq_1, + internal::arc_writer& aw, + const internal::node::pointer_type source, + internal::node::pointer_type r_if, + internal::node::pointer_type r_then, + internal::node::pointer_type r_else) { // Early shortcut an ite, if the terminals of both cases have collapsed to the // same anyway - if (r_then.is_terminal() && r_else.is_terminal() && - r_then.value() == r_else.value()) { + if (r_then.is_terminal() && r_else.is_terminal() && r_then.value() == r_else.value()) { - aw.push_terminal(internal::arc { source, r_then }); + aw.push_terminal(internal::arc{ source, r_then }); return; } // Remove irrelevant parts of a request to prune requests similar to // shortcutting the operator in bdd_apply. r_then = r_if.is_false() ? internal::node::pointer_type::nil() : r_then; - r_else = r_if.is_true() ? internal::node::pointer_type::nil() : r_else; + r_else = r_if.is_true() ? internal::node::pointer_type::nil() : r_else; if (r_if.is_terminal() && r_then.is_terminal()) { // => ~internal::node::pointer_type::nil() => r_if is a terminal with the 'true' value @@ -185,16 +182,22 @@ namespace adiar // => ~internal::node::pointer_type::nil() => r_if is a terminal with the 'false' value aw.push_terminal(internal::arc(source, r_else)); } else { - ite_pq_1.push({ {r_if, r_then, r_else}, {}, {source} }); + ite_pq_1.push({ { r_if, r_then, r_else }, {}, { source } }); } } - template - __bdd __bdd_ite(const exec_policy &ep, - const bdd &bdd_if, const bdd &bdd_then, const bdd &bdd_else, - const size_t pq_1_memory, const size_t max_pq_1_size, - const size_t pq_2_memory, const size_t max_pq_2_size, - const size_t pq_3_memory, const size_t max_pq_3_size) + template + __bdd + __bdd_ite(const exec_policy& ep, + const bdd& bdd_if, + const bdd& bdd_then, + const bdd& bdd_else, + const size_t pq_1_memory, + const size_t max_pq_1_size, + const size_t pq_2_memory, + const size_t max_pq_2_size, + const size_t pq_3_memory, + const size_t max_pq_3_size) { // Now, at this point we will not defer to using the Apply, so we can take // up memory by opening the input streams and evaluating trivial @@ -202,9 +205,7 @@ namespace adiar internal::node_stream<> in_nodes_if(bdd_if); internal::node v_if = in_nodes_if.pull(); - if (v_if.is_terminal()) { - return v_if.value() ? bdd_then : bdd_else; - } + if (v_if.is_terminal()) { return v_if.value() ? bdd_then : bdd_else; } internal::node_stream<> in_nodes_then(bdd_then); internal::node v_then = in_nodes_then.pull(); @@ -215,10 +216,9 @@ namespace adiar // If the levels of 'then' and 'else' are disjoint and the 'if' BDD is above // the two others, then we can merely zip the 'then' and 'else' BDDs. This // is only O((N1+N2+N3)/B) I/Os! - if (bdd_maxvar(bdd_if) < v_then.label() && - bdd_maxvar(bdd_if) < v_else.label() && - internal::disjoint_levels(bdd_then, bdd_else)) { - return __ite_zip_bdds(bdd_if,bdd_then,bdd_else); + if (bdd_maxvar(bdd_if) < v_then.label() && bdd_maxvar(bdd_if) < v_else.label() + && internal::disjoint_levels(bdd_then, bdd_else)) { + return __ite_zip_bdds(bdd_if, bdd_then, bdd_else); } // From here on forward, we probably cannot get away from actually having to @@ -231,7 +231,7 @@ namespace adiar out_arcs->max_1level_cut = 0; // Set up cross-level priority queue - pq_1_t ite_pq_1({bdd_if, bdd_then, bdd_else}, pq_1_memory, max_pq_1_size, stats_prod3.lpq); + pq_1_t ite_pq_1({ bdd_if, bdd_then, bdd_else }, pq_1_memory, max_pq_1_size, stats_prod3.lpq); // Set up per-level priority queues pq_2_t ite_pq_2(pq_2_memory, max_pq_2_size); @@ -239,7 +239,8 @@ namespace adiar // Process root and create initial recursion requests { - const internal::node::label_type out_label = first(v_if.uid(), v_then.uid(), v_else.uid()).label(); + const internal::node::label_type out_label = + first(v_if.uid(), v_then.uid(), v_else.uid()).label(); internal::node::pointer_type low_if, low_then, low_else, high_if, high_then, high_else; ite_init_request(in_nodes_if, v_if, out_label, low_if, high_if); @@ -248,7 +249,7 @@ namespace adiar const internal::node::uid_type out_uid(out_label, 0); __ite_resolve_request(ite_pq_1, aw, out_uid.as_ptr(false), low_if, low_then, low_else); - __ite_resolve_request(ite_pq_1, aw, out_uid.as_ptr(true), high_if, high_then, high_else); + __ite_resolve_request(ite_pq_1, aw, out_uid.as_ptr(true), high_if, high_then, high_else); aw.push(internal::level_info(out_label, 1)); } @@ -259,7 +260,7 @@ namespace adiar ite_pq_1.setup_next_level(); const internal::node::label_type out_label = ite_pq_1.current_level(); - internal::node::id_type out_id = 0; + internal::node::id_type out_id = 0; // Update max 1-level cut out_arcs->max_1level_cut = std::max(out_arcs->max_1level_cut, ite_pq_1.size()); @@ -272,18 +273,22 @@ namespace adiar // Merge requests from priority queues if (ite_pq_1.can_pull() && (ite_pq_2.empty() || ite_pq_1.top().target.first() < ite_pq_2.top().target.second()) - && (ite_pq_3.empty() || ite_pq_1.top().target.first() < ite_pq_3.top().target.third())) { - req = { ite_pq_1.top().target, - {{ { internal::node::pointer_type::nil(), internal::node::pointer_type::nil() }, - { internal::node::pointer_type::nil(), internal::node::pointer_type::nil() } }}, - ite_pq_1.top().data }; + && (ite_pq_3.empty() + || ite_pq_1.top().target.first() < ite_pq_3.top().target.third())) { + req = { + ite_pq_1.top().target, + { { { internal::node::pointer_type::nil(), internal::node::pointer_type::nil() }, + { internal::node::pointer_type::nil(), internal::node::pointer_type::nil() } } }, + ite_pq_1.top().data + }; ite_pq_1.pop(); } else if (!ite_pq_2.empty() - && (ite_pq_3.empty() || ite_pq_2.top().target.second() < ite_pq_3.top().target.third())) { + && (ite_pq_3.empty() + || ite_pq_2.top().target.second() < ite_pq_3.top().target.third())) { with_data_1 = true; - req = { ite_pq_2.top().target , + req = { ite_pq_2.top().target, { ite_pq_2.top().node_carry[0], { internal::node::pointer_type::nil(), internal::node::pointer_type::nil() } }, ite_pq_2.top().data }; @@ -298,52 +303,43 @@ namespace adiar } // Seek request partially in stream - internal::node::pointer_type t_first = req.target.first(); + internal::node::pointer_type t_first = req.target.first(); internal::node::pointer_type t_second = req.target.second(); - internal::node::pointer_type t_third = req.target.third(); + internal::node::pointer_type t_third = req.target.third(); internal::node::pointer_type t_seek = with_data_2 ? t_third - : with_data_1 ? t_second - : t_first; + : with_data_1 ? t_second + : t_first; - while (v_if.uid() < t_seek && in_nodes_if.can_pull()) { - v_if = in_nodes_if.pull(); - } - while (v_then.uid() < t_seek && in_nodes_then.can_pull()) { - v_then = in_nodes_then.pull(); - } - while (v_else.uid() < t_seek && in_nodes_else.can_pull()) { - v_else = in_nodes_else.pull(); - } + while (v_if.uid() < t_seek && in_nodes_if.can_pull()) { v_if = in_nodes_if.pull(); } + while (v_then.uid() < t_seek && in_nodes_then.can_pull()) { v_then = in_nodes_then.pull(); } + while (v_else.uid() < t_seek && in_nodes_else.can_pull()) { v_else = in_nodes_else.pull(); } // Forward information across the level - if (ite_must_forward(v_if, req.target[0], out_label, t_seek) || - ite_must_forward(v_then, req.target[1], out_label, t_seek) || - ite_must_forward(v_else, req.target[2], out_label, t_seek)) { + if (ite_must_forward(v_if, req.target[0], out_label, t_seek) + || ite_must_forward(v_then, req.target[1], out_label, t_seek) + || ite_must_forward(v_else, req.target[2], out_label, t_seek)) { // An element should be forwarded, if it was not already forwarded // (t_seek <= t_x), if it isn't the last one to seek (t_x < t_third), and // if we actually are holding it. - const bool forward_if = (t_seek <= req.target[0]) - && (req.target[0] < t_third) - && (v_if.uid() == req.target[0]); + const bool forward_if = + (t_seek <= req.target[0]) && (req.target[0] < t_third) && (v_if.uid() == req.target[0]); - const bool forward_then = (t_seek == req.target[1]) - && (req.target[1] < t_third) - && (v_then.uid() == req.target[1]); + const bool forward_then = (t_seek == req.target[1]) && (req.target[1] < t_third) + && (v_then.uid() == req.target[1]); - const bool forward_else = (t_seek == req.target[2]) - && (req.target[2] < t_third) - && (v_else.uid() == req.target[2]); + const bool forward_else = (t_seek == req.target[2]) && (req.target[2] < t_third) + && (v_else.uid() == req.target[2]); - const int number_of_elements_to_forward = ((int) forward_if) - + ((int) forward_then) - + ((int) forward_else); + const int number_of_elements_to_forward = + ((int)forward_if) + ((int)forward_then) + ((int)forward_else); if (with_data_1 || number_of_elements_to_forward == 2) { adiar_assert(!with_data_1 || t_seek != t_first, "cannot have data and still seek the first element"); adiar_assert(!(with_data_1 && (number_of_elements_to_forward == 2)), - "cannot have forwarded an element, hold two unforwarded items, and still need to forward for something"); + "cannot have forwarded an element, hold two unforwarded items, and still " + "need to forward for something"); internal::node::children_type children_1; internal::node::children_type children_2; @@ -352,15 +348,15 @@ namespace adiar children_1 = req.node_carry[0]; internal::node v2 = forward_else ? v_else : v_then; - children_2 = v2.children(); + children_2 = v2.children(); } else { // if (forward_if || req.target[2] < t_seek) internal::node v1 = forward_if ? v_if : v_then; - children_1 = v1.children(); + children_1 = v1.children(); children_2 = req.node_carry[0]; } } else { - internal::node v1 = forward_if ? v_if : v_then; + internal::node v1 = forward_if ? v_if : v_then; internal::node v2 = forward_else ? v_else : v_then; children_1 = v1.children(); @@ -374,15 +370,13 @@ namespace adiar } } else { // got no data and the stream only gave us a single item to forward. - const internal::node v1 = forward_if ? v_if - : forward_then ? v_then - : v_else; + const internal::node v1 = forward_if ? v_if : forward_then ? v_then : v_else; const internal::node::children_type v1_children = v1.children(); ite_pq_2.push({ req.target, { v1_children }, req.data }); while (ite_pq_1.can_pull() && ite_pq_1.top().target == req.target) { - ite_pq_2.push({ req.target, { v1_children } , ite_pq_1.pull().data }); + ite_pq_2.push({ req.target, { v1_children }, ite_pq_1.pull().data }); } } continue; @@ -394,37 +388,35 @@ namespace adiar if (req.target[0].is_terminal() || out_label < req.target[0].label()) { low_if = high_if = req.target[0]; } else { - low_if = req.target[0] == v_if.uid() ? v_if.low() : req.node_carry[0][false]; + low_if = req.target[0] == v_if.uid() ? v_if.low() : req.node_carry[0][false]; high_if = req.target[0] == v_if.uid() ? v_if.high() : req.node_carry[0][true]; } - if (req.target[1].is_nil() - || req.target[1].is_terminal() + if (req.target[1].is_nil() || req.target[1].is_terminal() || out_label < req.target[1].label()) { low_then = high_then = req.target[1]; } else if (req.target[1] == v_then.uid()) { - low_then = v_then.low(); + low_then = v_then.low(); high_then = v_then.high(); } else if (t_seek <= req.target[0]) { - low_then = req.node_carry[0][false]; + low_then = req.node_carry[0][false]; high_then = req.node_carry[0][true]; } else { - low_then = req.node_carry[1][false]; + low_then = req.node_carry[1][false]; high_then = req.node_carry[1][true]; } - if (req.target[2].is_nil() - || req.target[2].is_terminal() + if (req.target[2].is_nil() || req.target[2].is_terminal() || out_label < req.target[2].label()) { low_else = high_else = req.target[2]; } else if (req.target[2] == v_else.uid()) { - low_else = v_else.low(); + low_else = v_else.low(); high_else = v_else.high(); } else if (t_seek <= req.target[0] && t_seek <= req.target[1]) { - low_else = req.node_carry[0][false]; + low_else = req.node_carry[0][false]; high_else = req.node_carry[0][true]; } else { - low_else = req.node_carry[1][false]; + low_else = req.node_carry[1][false]; high_else = req.node_carry[1][true]; } @@ -433,7 +425,7 @@ namespace adiar const internal::node::uid_type out_uid(out_label, out_id++); __ite_resolve_request(ite_pq_1, aw, out_uid.as_ptr(false), low_if, low_then, low_else); - __ite_resolve_request(ite_pq_1, aw, out_uid.as_ptr(true), high_if, high_then, high_else); + __ite_resolve_request(ite_pq_1, aw, out_uid.as_ptr(true), high_if, high_then, high_else); // Output ingoing arcs internal::node::pointer_type source = req.data.source; @@ -467,45 +459,52 @@ namespace adiar /// Derives an upper bound on the output's maximum i-level cut based on the /// product of the maximum i-level cut of all three inputs. ////////////////////////////////////////////////////////////////////////////// - template - size_t __ite_ilevel_upper_bound(const internal::dd &in_if, - const internal::dd &in_then, - const internal::dd &in_else) + template + size_t + __ite_ilevel_upper_bound(const internal::dd& in_if, + const internal::dd& in_then, + const internal::dd& in_else) { // 2-level cuts for 'if', where we split the false and true arcs away. const internal::safe_size_t if_cut_internal = cut::get(in_if, internal::cut::Internal); - const internal::safe_size_t if_cut_falses = cut::get(in_if, internal::cut::Internal_False) - if_cut_internal; - const internal::safe_size_t if_cut_trues = cut::get(in_if, internal::cut::Internal_True) - if_cut_internal; + const internal::safe_size_t if_cut_falses = + cut::get(in_if, internal::cut::Internal_False) - if_cut_internal; + const internal::safe_size_t if_cut_trues = + cut::get(in_if, internal::cut::Internal_True) - if_cut_internal; // 2-level cuts for 'then' const internal::safe_size_t then_cut_internal = cut::get(in_then, internal::cut::Internal); - const internal::safe_size_t then_cut_falses = cut::get(in_then, internal::cut::Internal_False) - then_cut_internal; - const internal::safe_size_t then_cut_trues = cut::get(in_then, internal::cut::Internal_True) - then_cut_internal; - const internal::safe_size_t then_cut_all = cut::get(in_then, internal::cut::All); + const internal::safe_size_t then_cut_falses = + cut::get(in_then, internal::cut::Internal_False) - then_cut_internal; + const internal::safe_size_t then_cut_trues = + cut::get(in_then, internal::cut::Internal_True) - then_cut_internal; + const internal::safe_size_t then_cut_all = cut::get(in_then, internal::cut::All); // 2-level cuts for 'else' const internal::safe_size_t else_cut_internal = cut::get(in_else, internal::cut::Internal); - const internal::safe_size_t else_cut_falses = cut::get(in_else, internal::cut::Internal_False) - else_cut_internal; - const internal::safe_size_t else_cut_trues = cut::get(in_else, internal::cut::Internal_True) - else_cut_internal; - const internal::safe_size_t else_cut_all = cut::get(in_else, internal::cut::All); + const internal::safe_size_t else_cut_falses = + cut::get(in_else, internal::cut::Internal_False) - else_cut_internal; + const internal::safe_size_t else_cut_trues = + cut::get(in_else, internal::cut::Internal_True) - else_cut_internal; + const internal::safe_size_t else_cut_all = cut::get(in_else, internal::cut::All); // Compute 2-level cut where irrelevant pairs of terminals are not paired - return internal::to_size((if_cut_internal * (then_cut_all * else_cut_internal + then_cut_internal * else_cut_all - + then_cut_falses * else_cut_trues - + then_cut_trues * else_cut_falses)) - + if_cut_trues * then_cut_internal - + if_cut_falses * else_cut_internal - + const_size_inc); + return internal::to_size( + (if_cut_internal + * (then_cut_all * else_cut_internal + then_cut_internal * else_cut_all + + then_cut_falses * else_cut_trues + then_cut_trues * else_cut_falses)) + + if_cut_trues * then_cut_internal + if_cut_falses * else_cut_internal + const_size_inc); } ////////////////////////////////////////////////////////////////////////////// /// Derives an upper bound on the output's maximum i-level cut given its size. ////////////////////////////////////////////////////////////////////////////// - size_t __ite_ilevel_upper_bound(const internal::dd &in_if, - const internal::dd &in_then, - const internal::dd &in_else) + size_t + __ite_ilevel_upper_bound(const internal::dd& in_if, + const internal::dd& in_then, + const internal::dd& in_else) { - const internal::safe_size_t if_size = in_if->size(); + const internal::safe_size_t if_size = in_if->size(); const internal::safe_size_t then_size = in_then->size(); const internal::safe_size_t else_size = in_else->size(); @@ -513,11 +512,13 @@ namespace adiar // internal node and t_then and t_else are nodes or (mismatching) terminals. // Then also count the copies of in_then and in_else for when in_if hits a // terminal early. - return internal::to_size(if_size * ((then_size + 2u) * (else_size + 2u) - 2u) + then_size + else_size + 1u + 2u); + return internal::to_size(if_size * ((then_size + 2u) * (else_size + 2u) - 2u) + then_size + + else_size + 1u + 2u); } ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_ite(const exec_policy &ep, const bdd &f, const bdd &g, const bdd &h) + __bdd + bdd_ite(const exec_policy& ep, const bdd& f, const bdd& g, const bdd& h) { // There are multiple cases, where this boils down to an Apply rather than // an If-Then-Else. The bdd_apply uses tuples rather than triples and only @@ -528,32 +529,20 @@ namespace adiar // Randal E. Bryant. // Resolve being given the same underlying file in both cases - if (g.file == h.file) { - return g.negate == h.negate - ? __bdd(g) - : bdd_xnor(f, g); - } + if (g.file == h.file) { return g.negate == h.negate ? __bdd(g) : bdd_xnor(f, g); } // Resolve being given the same underlying file for conditional and a case if (f.file == g.file) { - return f.negate == g.negate - ? bdd_or(f, h) - : bdd_and(bdd_not(f), h); + return f.negate == g.negate ? bdd_or(f, h) : bdd_and(bdd_not(f), h); } else if (f.file == h.file) { - return f.negate == h.negate - ? bdd_and(f, g) - : bdd_imp(f, g); + return f.negate == h.negate ? bdd_and(f, g) : bdd_imp(f, g); } // Resolve being given a terminal in one of the cases if (bdd_isterminal(g)) { - return bdd_apply(dd_valueof(g) ? f : bdd_not(f), - h, - dd_valueof(g) ? or_op : and_op); - } else if (bdd_isterminal(h)) { - return bdd_apply(f, - g, - dd_valueof(h) ? imp_op : and_op); + return bdd_apply(dd_valueof(g) ? f : bdd_not(f), h, dd_valueof(g) ? or_op : and_op); + } else if (bdd_isterminal(h)) { + return bdd_apply(f, g, dd_valueof(h) ? imp_op : and_op); } // Compute amount of memory available for auxiliary data structures after @@ -564,7 +553,7 @@ namespace adiar // memory variant. const tpie::memory_size_type aux_available_memory = internal::memory_available() // Input streams - - 3*internal::node_stream<>::memory_usage() + - 3 * internal::node_stream<>::memory_usage() // Output stream - internal::arc_writer::memory_usage(); @@ -578,16 +567,20 @@ namespace adiar ite_priority_queue_3_t::data_structures; const size_t pq_1_internal_memory = - (aux_available_memory / (data_structures_in_pq_1 + data_structures_in_pq_2 + data_structures_in_pq_3)) * data_structures_in_pq_1; + (aux_available_memory + / (data_structures_in_pq_1 + data_structures_in_pq_2 + data_structures_in_pq_3)) + * data_structures_in_pq_1; - const size_t pq_2_internal_memory = - ((aux_available_memory - pq_1_internal_memory) / (data_structures_in_pq_2 + data_structures_in_pq_3)) * data_structures_in_pq_2; + const size_t pq_2_internal_memory = ((aux_available_memory - pq_1_internal_memory) + / (data_structures_in_pq_2 + data_structures_in_pq_3)) + * data_structures_in_pq_2; const size_t pq_3_internal_memory = aux_available_memory - pq_1_internal_memory - pq_2_internal_memory; const size_t pq_1_memory_fits = - ite_priority_queue_1_t::memory_fits(pq_1_internal_memory); + ite_priority_queue_1_t::memory_fits( + pq_1_internal_memory); const size_t pq_2_memory_fits = ite_priority_queue_2_t::memory_fits(pq_2_internal_memory); @@ -595,42 +588,63 @@ namespace adiar const size_t pq_3_memory_fits = ite_priority_queue_3_t::memory_fits(pq_3_internal_memory); - const bool internal_only = ep.template get() == exec_policy::memory::Internal; - const bool external_only = ep.template get() == exec_policy::memory::External; + const bool internal_only = + ep.template get() == exec_policy::memory::Internal; + const bool external_only = + ep.template get() == exec_policy::memory::External; - const size_t pq_1_bound = std::min({__ite_ilevel_upper_bound(f, g, h), - __ite_ilevel_upper_bound(f, g, h)}); + const size_t pq_1_bound = + std::min({ __ite_ilevel_upper_bound(f, g, h), + __ite_ilevel_upper_bound(f, g, h) }); - const size_t max_pq_1_size = internal_only ? std::min(pq_1_memory_fits, pq_1_bound) : pq_1_bound; + const size_t max_pq_1_size = + internal_only ? std::min(pq_1_memory_fits, pq_1_bound) : pq_1_bound; const size_t pq_2_bound = __ite_ilevel_upper_bound(f, g, h); - const size_t max_pq_2_size = internal_only ? std::min(pq_2_memory_fits, pq_2_bound) : pq_2_bound; + const size_t max_pq_2_size = + internal_only ? std::min(pq_2_memory_fits, pq_2_bound) : pq_2_bound; const size_t pq_3_bound = pq_2_bound; - const size_t max_pq_3_size = internal_only ? std::min(pq_3_memory_fits, pq_3_bound) : pq_3_bound; + const size_t max_pq_3_size = + internal_only ? std::min(pq_3_memory_fits, pq_3_bound) : pq_3_bound; - if(!external_only && max_pq_1_size <= internal::no_lookahead_bound(3)) { + if (!external_only && max_pq_1_size <= internal::no_lookahead_bound(3)) { #ifdef ADIAR_STATS stats_prod3.lpq.unbucketed += 1u; #endif return __bdd_ite, ite_priority_queue_2_t, - ite_priority_queue_3_t> - (ep, f, g, h, pq_1_internal_memory, max_pq_1_size, - pq_2_internal_memory, max_pq_2_size, pq_3_internal_memory, max_pq_3_size); - } else if(!external_only && max_pq_1_size <= pq_1_memory_fits - && max_pq_2_size <= pq_2_memory_fits - && max_pq_3_size <= pq_3_memory_fits) { + ite_priority_queue_3_t>( + ep, + f, + g, + h, + pq_1_internal_memory, + max_pq_1_size, + pq_2_internal_memory, + max_pq_2_size, + pq_3_internal_memory, + max_pq_3_size); + } else if (!external_only && max_pq_1_size <= pq_1_memory_fits + && max_pq_2_size <= pq_2_memory_fits && max_pq_3_size <= pq_3_memory_fits) { #ifdef ADIAR_STATS stats_prod3.lpq.internal += 1u; #endif return __bdd_ite, ite_priority_queue_2_t, - ite_priority_queue_3_t> - (ep, f, g, h, pq_1_internal_memory, max_pq_1_size, - pq_2_internal_memory, max_pq_2_size, pq_3_internal_memory, max_pq_3_size); + ite_priority_queue_3_t>( + ep, + f, + g, + h, + pq_1_internal_memory, + max_pq_1_size, + pq_2_internal_memory, + max_pq_2_size, + pq_3_internal_memory, + max_pq_3_size); } else { #ifdef ADIAR_STATS stats_prod3.lpq.external += 1u; @@ -641,13 +655,21 @@ namespace adiar return __bdd_ite, ite_priority_queue_2_t, - ite_priority_queue_3_t> - (ep, f, g, h, pq_1_memory, max_pq_1_size, - pq_2_memory, max_pq_2_size, pq_3_memory, max_pq_3_size); + ite_priority_queue_3_t>(ep, + f, + g, + h, + pq_1_memory, + max_pq_1_size, + pq_2_memory, + max_pq_2_size, + pq_3_memory, + max_pq_3_size); } } - __bdd bdd_ite(const bdd &f, const bdd &g, const bdd &h) + __bdd + bdd_ite(const bdd& f, const bdd& g, const bdd& h) { return bdd_ite(exec_policy(), f, g, h); } diff --git a/src/adiar/bdd/if_then_else.h b/src/adiar/bdd/if_then_else.h index eac000344..67cc6c310 100644 --- a/src/adiar/bdd/if_then_else.h +++ b/src/adiar/bdd/if_then_else.h @@ -8,4 +8,4 @@ namespace adiar extern statistics::prod3_t stats_prod3; } -#endif //ADIAR_BDD_IF_THEN_ELSE_H \ No newline at end of file +#endif // ADIAR_BDD_IF_THEN_ELSE_H \ No newline at end of file diff --git a/src/adiar/bdd/negate.cpp b/src/adiar/bdd/negate.cpp index 1dbd3140e..cca0057ee 100644 --- a/src/adiar/bdd/negate.cpp +++ b/src/adiar/bdd/negate.cpp @@ -1,17 +1,19 @@ -#include - #include +#include + namespace adiar { - bdd bdd_not(const bdd &in) + bdd + bdd_not(const bdd& in) { - bdd out = in; + bdd out = in; out.negate = !in.negate; return out; } - bdd bdd_not(bdd &&b) + bdd + bdd_not(bdd&& b) { b.negate = !b.negate; return std::move(b); diff --git a/src/adiar/bdd/pred.cpp b/src/adiar/bdd/pred.cpp index 3229f82e8..3e0174b8f 100644 --- a/src/adiar/bdd/pred.cpp +++ b/src/adiar/bdd/pred.cpp @@ -1,70 +1,76 @@ #include -#include - #include +#include namespace adiar { - bool bdd_iscanonical(const bdd &f) + bool + bdd_iscanonical(const bdd& f) { return internal::dd_iscanonical(f); } - bool bdd_isconst(const bdd &f) + bool + bdd_isconst(const bdd& f) { return internal::dd_isterminal(f); } - bool bdd_isterminal(const bdd &f) + bool + bdd_isterminal(const bdd& f) { return bdd_isconst(f); } - bool bdd_isfalse(const bdd &f) + bool + bdd_isfalse(const bdd& f) { return internal::dd_isfalse(f); } - bool bdd_istrue(const bdd &f) + bool + bdd_istrue(const bdd& f) { return internal::dd_istrue(f); } - bool bdd_isvar(const bdd& f) + bool + bdd_isvar(const bdd& f) { // Assuming the BDD is fully reduced (which it should be), then it can only // be a single variable, if there are exactly two arcs to terminals. return f.number_of_terminals() == 2u; } - bool bdd_isithvar(const bdd& f) + bool + bdd_isithvar(const bdd& f) { if (!bdd_isvar(f)) { return false; } internal::node_stream<> ns(f); const bdd::node_type root = ns.pull(); - adiar_assert(root.low() != root.high(), - "A reduced BDD cannot have identical children"); + adiar_assert(root.low() != root.high(), "A reduced BDD cannot have identical children"); return root.high() == bdd::node_type::pointer_type(true); } - bool bdd_isnithvar(const bdd& f) + bool + bdd_isnithvar(const bdd& f) { if (!bdd_isvar(f)) { return false; } internal::node_stream<> ns(f); const bdd::node_type root = ns.pull(); - adiar_assert(root.low() != root.high(), - "A reduced BDD cannot have identical children"); + adiar_assert(root.low() != root.high(), "A reduced BDD cannot have identical children"); - return root.low() == bdd::node_type::pointer_type(true); + return root.low() == bdd::node_type::pointer_type(true); } - bool bdd_iscube(const bdd& f) + bool + bdd_iscube(const bdd& f) { // Assuming the BDD is fully reduced (which it should be), then it can only // be a cube if: @@ -75,27 +81,30 @@ namespace adiar // // 3. The number of arcs to `false` is the same as the number of levels // (this rejects `false` terminal). - return f.width() <= 1u - && f.number_of_terminals(true) == 1u - && f.number_of_terminals(false) == bdd_varcount(f); + return f.width() <= 1u && f.number_of_terminals(true) == 1u + && f.number_of_terminals(false) == bdd_varcount(f); } - bool bdd_equal(const exec_policy &ep, const bdd &f, const bdd &g) + bool + bdd_equal(const exec_policy& ep, const bdd& f, const bdd& g) { return internal::is_isomorphic(ep, f, g); } - bool bdd_equal(const bdd &f, const bdd &g) + bool + bdd_equal(const bdd& f, const bdd& g) { return bdd_equal(exec_policy(), f, g); } - bool bdd_unequal(const exec_policy &ep, const bdd &f, const bdd &g) + bool + bdd_unequal(const exec_policy& ep, const bdd& f, const bdd& g) { return !bdd_equal(ep, f, g); } - bool bdd_unequal(const bdd &f, const bdd &g) + bool + bdd_unequal(const bdd& f, const bdd& g) { return bdd_unequal(exec_policy(), f, g); } diff --git a/src/adiar/bdd/quantify.cpp b/src/adiar/bdd/quantify.cpp index 2ac3cda1a..1da02ea0a 100644 --- a/src/adiar/bdd/quantify.cpp +++ b/src/adiar/bdd/quantify.cpp @@ -1,17 +1,17 @@ +#include + #include #include -#include - +#include #include #include -#include #include #include #include #include -#include #include +#include namespace adiar { @@ -19,25 +19,17 @@ namespace adiar { public: static inline bdd::pointer_type - resolve_root(const bdd::node_type &r, const bool_op &op) + resolve_root(const bdd::node_type& r, const bool_op& op) { // TODO: should all but the last case not have a 'suppression taint'? // Return shortcutting terminal (including its tainting flag). - if (r.low().is_terminal() && can_left_shortcut(op, r.low())) { - return r.low(); - } - if (r.high().is_terminal() && can_right_shortcut(op, r.high())) { - return r.high(); - } + if (r.low().is_terminal() && can_left_shortcut(op, r.low())) { return r.low(); } + if (r.high().is_terminal() && can_right_shortcut(op, r.high())) { return r.high(); } // Return other child (including its tainting flag) for irrelevant terminals. - if (r.low().is_terminal() && is_left_irrelevant(op, r.low())) { - return r.high(); - } - if (r.high().is_terminal() && is_right_irrelevant(op, r.high())) { - return r.low(); - } + if (r.low().is_terminal() && is_left_irrelevant(op, r.low())) { return r.high(); } + if (r.high().is_terminal() && is_right_irrelevant(op, r.high())) { return r.low(); } // Otherwise return 'nothing' return r.uid(); @@ -45,14 +37,14 @@ namespace adiar public: static inline bool - keep_terminal(const bool_op &op, const bdd::pointer_type &p) + keep_terminal(const bool_op& op, const bdd::pointer_type& p) { // `op` is commutative, so we can check irrelevancy from either side. return !is_right_irrelevant(op, p); } static inline bool - collapse_to_terminal(const bool_op &op, const bdd::pointer_type &p) + collapse_to_terminal(const bool_op& op, const bdd::pointer_type& p) { // `op` is commutative, so we can check shortcutting from either side. return can_right_shortcut(op, p); @@ -60,7 +52,7 @@ namespace adiar public: static inline internal::cut - cut_with_terminals(const bool_op &op) + cut_with_terminals(const bool_op& op) { const bool incl_false = !can_right_shortcut(op, bdd::pointer_type(false)); const bool incl_true = !can_right_shortcut(op, bdd::pointer_type(true)); @@ -73,120 +65,124 @@ namespace adiar }; ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_exists(const exec_policy &ep, const bdd &f, bdd::label_type var) + __bdd + bdd_exists(const exec_policy& ep, const bdd& f, bdd::label_type var) { return internal::quantify(ep, f, var, or_op); } - __bdd bdd_exists(const bdd &f, bdd::label_type var) + __bdd + bdd_exists(const bdd& f, bdd::label_type var) { return bdd_exists(exec_policy(), f, var); } - __bdd bdd_exists(const exec_policy &ep, - const bdd &f, - const predicate &vars) + __bdd + bdd_exists(const exec_policy& ep, const bdd& f, const predicate& vars) { return internal::quantify(ep, f, vars, or_op); } - __bdd bdd_exists(const bdd &f, const predicate &vars) + __bdd + bdd_exists(const bdd& f, const predicate& vars) { return bdd_exists(exec_policy(), f, vars); } - __bdd bdd_exists(const exec_policy &ep, - bdd &&f, - const predicate &vars) + __bdd + bdd_exists(const exec_policy& ep, bdd&& f, const predicate& vars) { return internal::quantify(ep, std::move(f), vars, or_op); } - __bdd bdd_exists(bdd &&f, const predicate &vars) + __bdd + bdd_exists(bdd&& f, const predicate& vars) { return bdd_exists(exec_policy(), std::move(f), vars); } - __bdd bdd_exists(const exec_policy &ep, - const bdd &f, - const generator &vars) + __bdd + bdd_exists(const exec_policy& ep, const bdd& f, const generator& vars) { return internal::quantify(ep, f, vars, or_op); } - __bdd bdd_exists(const bdd &f, const generator &vars) + __bdd + bdd_exists(const bdd& f, const generator& vars) { return bdd_exists(exec_policy(), f, vars); } - __bdd bdd_exists(const exec_policy &ep, - bdd &&f, - const generator &vars) + __bdd + bdd_exists(const exec_policy& ep, bdd&& f, const generator& vars) { return internal::quantify(ep, std::move(f), vars, or_op); } - __bdd bdd_exists(bdd &&f, const generator &vars) + __bdd + bdd_exists(bdd&& f, const generator& vars) { return bdd_exists(exec_policy(), std::move(f), vars); } ////////////////////////////////////////////////////////////////////////////// - __bdd bdd_forall(const exec_policy &ep, const bdd &f, bdd::label_type var) + __bdd + bdd_forall(const exec_policy& ep, const bdd& f, bdd::label_type var) { return internal::quantify(ep, f, var, and_op); } - __bdd bdd_forall(const bdd &f, bdd::label_type var) + __bdd + bdd_forall(const bdd& f, bdd::label_type var) { return bdd_forall(exec_policy(), f, var); } - __bdd bdd_forall(const exec_policy &ep, - const bdd &f, - const predicate &vars) + __bdd + bdd_forall(const exec_policy& ep, const bdd& f, const predicate& vars) { return internal::quantify(ep, f, vars, and_op); } - __bdd bdd_forall(const bdd &f, const predicate &vars) + __bdd + bdd_forall(const bdd& f, const predicate& vars) { return bdd_forall(exec_policy(), f, vars); } - __bdd bdd_forall(const exec_policy &ep, - bdd &&f, - const predicate &vars) + __bdd + bdd_forall(const exec_policy& ep, bdd&& f, const predicate& vars) { return internal::quantify(ep, std::move(f), vars, and_op); } - __bdd bdd_forall(bdd &&f, const predicate &vars) + __bdd + bdd_forall(bdd&& f, const predicate& vars) { return bdd_forall(exec_policy(), std::move(f), vars); } - __bdd bdd_forall(const exec_policy &ep, - const bdd &f, - const generator &vars) + __bdd + bdd_forall(const exec_policy& ep, const bdd& f, const generator& vars) { return internal::quantify(ep, f, vars, and_op); } - __bdd bdd_forall(const bdd &f, const generator &vars) + __bdd + bdd_forall(const bdd& f, const generator& vars) { return bdd_forall(exec_policy(), f, vars); } - __bdd bdd_forall(const exec_policy &ep, - bdd &&f, - const generator &vars) + __bdd + bdd_forall(const exec_policy& ep, bdd&& f, const generator& vars) { return internal::quantify(ep, std::move(f), vars, and_op); } - __bdd bdd_forall(bdd &&f, const generator &vars) + __bdd + bdd_forall(bdd&& f, const generator& vars) { return bdd_forall(exec_policy(), std::move(f), vars); } diff --git a/src/adiar/bdd/restrict.cpp b/src/adiar/bdd/restrict.cpp index 17dc58c81..83a1d6919 100644 --- a/src/adiar/bdd/restrict.cpp +++ b/src/adiar/bdd/restrict.cpp @@ -1,11 +1,11 @@ #include #include -#include #include #include #include #include +#include namespace adiar { @@ -13,105 +13,119 @@ namespace adiar class bdd_restrict_policy : public bdd_policy { public: - template - static internal::select_rec keep_node(const bdd::node_type &n, AssignmentMgr &/*amgr*/) - { return n; } + template + static internal::select_rec + keep_node(const bdd::node_type& n, AssignmentMgr& /*amgr*/) + { + return n; + } - template - static internal::select_rec fix_false(const bdd::node_type &n, AssignmentMgr &/*amgr*/) - { return n.low(); } + template + static internal::select_rec + fix_false(const bdd::node_type& n, AssignmentMgr& /*amgr*/) + { + return n.low(); + } - template - static internal::select_rec fix_true(const bdd::node_type &n, AssignmentMgr &/*amgr*/) - { return n.high(); } + template + static internal::select_rec + fix_true(const bdd::node_type& n, AssignmentMgr& /*amgr*/) + { + return n.high(); + } public: - template - static inline bdd terminal(bool terminal_val, AssignmentMgr &/*amgr*/) - { return bdd_terminal(terminal_val); } + template + static inline bdd + terminal(bool terminal_val, AssignmentMgr& /*amgr*/) + { + return bdd_terminal(terminal_val); + } }; ////////////////////////////////////////////////////////////////////////////// // Variant: Generator-based Restrict class restrict_generator_mgr { - const generator> &_generator; + const generator>& _generator; optional> _next_pair; public: - restrict_generator_mgr(const generator> &g) + restrict_generator_mgr(const generator>& g) : _generator(g) { _next_pair = _generator(); } - bool empty() const + bool + empty() const { return !_next_pair.has_value(); } - assignment assignment_for_level(bdd::label_type level) + assignment + assignment_for_level(bdd::label_type level) { - while (_next_pair && _next_pair.value().first < level) { - _next_pair = _generator(); - } + while (_next_pair && _next_pair.value().first < level) { _next_pair = _generator(); } return _next_pair && _next_pair.value().first == level ? static_cast(_next_pair.value().second) : assignment::None; } }; - __bdd bdd_restrict(const exec_policy &ep, - const bdd &f, - const generator> &xs) + __bdd + bdd_restrict(const exec_policy& ep, + const bdd& f, + const generator>& xs) { restrict_generator_mgr amgr(xs); - if (amgr.empty() || bdd_isterminal(f)) { - return f; - } + if (amgr.empty() || bdd_isterminal(f)) { return f; } return internal::select(ep, f, amgr); } - __bdd bdd_restrict(const bdd &f, - const generator> &xs) + __bdd + bdd_restrict(const bdd& f, const generator>& xs) { return bdd_restrict(exec_policy(), f, xs); } ////////////////////////////////////////////////////////////////////////////// // Overload: Single-variable Restrict - __bdd bdd_restrict(const exec_policy &ep, - const bdd &f, bdd::label_type var, bool val) + __bdd + bdd_restrict(const exec_policy& ep, const bdd& f, bdd::label_type var, bool val) { - return bdd_restrict(ep, - f, - make_generator(make_pair(var, val))); + return bdd_restrict(ep, f, make_generator(make_pair(var, val))); } - __bdd bdd_restrict(const bdd &f, bdd::label_type var, bool val) + __bdd + bdd_restrict(const bdd& f, bdd::label_type var, bool val) { return bdd_restrict(exec_policy(), f, var, val); } ////////////////////////////////////////////////////////////////////////////// // Overload: Root Restrict - __bdd bdd_low(const exec_policy &ep, const bdd &f) + __bdd + bdd_low(const exec_policy& ep, const bdd& f) { return bdd_restrict(ep, f, bdd_topvar(f), false); } - __bdd bdd_low(const bdd &f) + __bdd + bdd_low(const bdd& f) { return bdd_low(exec_policy(), f); } - __bdd bdd_high(const exec_policy &ep, const bdd &f) + __bdd + bdd_high(const exec_policy& ep, const bdd& f) { return bdd_restrict(ep, f, bdd_topvar(f), true); } - __bdd bdd_high(const bdd &f) + __bdd + bdd_high(const bdd& f) { return bdd_high(exec_policy(), f); } diff --git a/src/adiar/bool_op.h b/src/adiar/bool_op.h index 7af16a07e..3b98513e9 100644 --- a/src/adiar/bool_op.h +++ b/src/adiar/bool_op.h @@ -18,69 +18,70 @@ namespace adiar /// \remark For each operator, we provide the truth table /// [(1,1), (1,0), (0,1), (0,0)]. ////////////////////////////////////////////////////////////////////////////// - using bool_op = function; + using bool_op = + function; ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'and' operator, i.e. the truth table: [1,0,0,0]. ////////////////////////////////////////////////////////////////////////////// - const bool_op and_op = [](const internal::ptr_uint64 &a, const internal::ptr_uint64 &b) -> internal::uid_uint64 - { + const bool_op and_op = [](const internal::ptr_uint64& a, + const internal::ptr_uint64& b) -> internal::uid_uint64 { return essential(a & b); }; ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'not and' operator, i.e. the truth table: [0,1,1,1]. ////////////////////////////////////////////////////////////////////////////// - const bool_op nand_op = [](const internal::ptr_uint64 &a, const internal::ptr_uint64 &b) -> internal::uid_uint64 - { + const bool_op nand_op = [](const internal::ptr_uint64& a, + const internal::ptr_uint64& b) -> internal::uid_uint64 { return !(and_op(a, b)); }; ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'or' operator, i.e. the truth table: [1,1,1,0]. ////////////////////////////////////////////////////////////////////////////// - const bool_op or_op = [](const internal::ptr_uint64 &a, const internal::ptr_uint64 &b) -> internal::uid_uint64 - { + const bool_op or_op = [](const internal::ptr_uint64& a, + const internal::ptr_uint64& b) -> internal::uid_uint64 { return essential(a | b); }; ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'not or' operator, i.e. the truth table: [0,0,0,1]. ////////////////////////////////////////////////////////////////////////////// - const bool_op nor_op = [](const internal::ptr_uint64 &a, const internal::ptr_uint64 &b) -> internal::uid_uint64 - { + const bool_op nor_op = [](const internal::ptr_uint64& a, + const internal::ptr_uint64& b) -> internal::uid_uint64 { return !(or_op(a, b)); }; ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'xor' operator, i.e. the truth table: [0,1,1,0]. ////////////////////////////////////////////////////////////////////////////// - const bool_op xor_op = [](const internal::ptr_uint64 &a, const internal::ptr_uint64 &b) -> internal::uid_uint64 - { + const bool_op xor_op = [](const internal::ptr_uint64& a, + const internal::ptr_uint64& b) -> internal::uid_uint64 { return essential(a ^ b); }; ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'xor' operator, i.e. the truth table: [1,0,0,1]. ////////////////////////////////////////////////////////////////////////////// - const bool_op xnor_op = [](const internal::ptr_uint64 &a, const internal::ptr_uint64 &b) -> internal::uid_uint64 - { + const bool_op xnor_op = [](const internal::ptr_uint64& a, + const internal::ptr_uint64& b) -> internal::uid_uint64 { return !(xor_op(a, b)); }; ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'implication' operator, i.e. the truth table: [1,0,1,1]. ////////////////////////////////////////////////////////////////////////////// - const bool_op imp_op = [](const internal::ptr_uint64 &a, const internal::ptr_uint64 &b) -> internal::uid_uint64 - { + const bool_op imp_op = [](const internal::ptr_uint64& a, + const internal::ptr_uint64& b) -> internal::uid_uint64 { return internal::ptr_uint64(essential(a) <= essential(b)); }; ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'implication' operator, i.e. the truth table: [1,1,0,1]. ////////////////////////////////////////////////////////////////////////////// - const bool_op invimp_op = [](const internal::ptr_uint64 &a, const internal::ptr_uint64 &b) -> internal::ptr_uint64 - { + const bool_op invimp_op = [](const internal::ptr_uint64& a, + const internal::ptr_uint64& b) -> internal::ptr_uint64 { return internal::ptr_uint64(essential(b) <= essential(a)); }; @@ -92,16 +93,16 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'set difference' operator, i.e. the truth table [0,1,0,0]. ////////////////////////////////////////////////////////////////////////////// - const bool_op diff_op = [](const internal::ptr_uint64 &a, const internal::ptr_uint64 &b) -> internal::ptr_uint64 - { + const bool_op diff_op = [](const internal::ptr_uint64& a, + const internal::ptr_uint64& b) -> internal::ptr_uint64 { return and_op(a, !b); }; ////////////////////////////////////////////////////////////////////////////// /// \brief Logical 'less' operator, i.e. the truth table [0,0,1,0]. ////////////////////////////////////////////////////////////////////////////// - const bool_op less_op = [](const internal::ptr_uint64 &a, const internal::ptr_uint64 &b) -> internal::ptr_uint64 - { + const bool_op less_op = [](const internal::ptr_uint64& a, + const internal::ptr_uint64& b) -> internal::ptr_uint64 { return and_op(!a, b); }; } diff --git a/src/adiar/builder.h b/src/adiar/builder.h index b2b8628c8..74a21798a 100644 --- a/src/adiar/builder.h +++ b/src/adiar/builder.h @@ -1,15 +1,16 @@ #ifndef ADIAR_BUILDER_H #define ADIAR_BUILDER_H -#include #include +#include #include + #include -#include -#include #include +#include #include #include +#include //////////////////////////////////////////////////////////////////////////////// /// \defgroup module__builder Builder @@ -36,12 +37,10 @@ namespace adiar /// \see builder buider_ptr ////////////////////////////////////////////////////////////////////////////// struct builder_shared - { - - }; + {}; /// \endcond - template + template class builder; /////////////////////////////////////////////////////////////////////////////// @@ -50,7 +49,7 @@ namespace adiar /// /// \see builder /////////////////////////////////////////////////////////////////////////////// - template + template class builder_ptr { public: @@ -83,23 +82,25 @@ namespace adiar //////////////////////////////////////////////////////////////////////////// /// \brief Copy construction. //////////////////////////////////////////////////////////////////////////// - builder_ptr(const builder_ptr &bp) = default; + builder_ptr(const builder_ptr& bp) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move construction. //////////////////////////////////////////////////////////////////////////// - builder_ptr(builder_ptr &&bp) = default; + builder_ptr(builder_ptr&& bp) = default; public: //////////////////////////////////////////////////////////////////////////// /// \brief Copy construction. //////////////////////////////////////////////////////////////////////////// - builder_ptr& operator =(const builder_ptr &bp) = default; + builder_ptr& + operator=(const builder_ptr& bp) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move construction. //////////////////////////////////////////////////////////////////////////// - builder_ptr& operator =(builder_ptr &&bp) = default; + builder_ptr& + operator=(builder_ptr&& bp) = default; private: //////////////////////////////////////////////////////////////////////////// @@ -109,10 +110,10 @@ namespace adiar /// /// \param sp Reference (read-only) to the builder's shared information. //////////////////////////////////////////////////////////////////////////// - builder_ptr(const internal::node::uid_type &p, - const shared_ptr &sp) - : uid(p), builder_ref(sp) - { } + builder_ptr(const internal::node::uid_type& p, const shared_ptr& sp) + : uid(p) + , builder_ref(sp) + {} }; /////////////////////////////////////////////////////////////////////////////// @@ -138,7 +139,7 @@ namespace adiar /// \tparam dd_policy Logic related to the specific type of decision diagram /// to construct. /////////////////////////////////////////////////////////////////////////////// - template + template class builder { private: @@ -194,13 +195,13 @@ namespace adiar /// \brief Constructor. ///////////////////////////////////////////////////////////////////////////// builder() noexcept - { } + {} ///////////////////////////////////////////////////////////////////////////// /// \brief Destructor. ///////////////////////////////////////////////////////////////////////////// ~builder() noexcept - { } + {} public: ///////////////////////////////////////////////////////////////////////////// @@ -228,33 +229,30 @@ namespace adiar /// /// \throws invalid_argument If pointers stem from another builder. ///////////////////////////////////////////////////////////////////////////// - builder_ptr add_node(typename dd_policy::label_type label, - const builder_ptr &low, - const builder_ptr &high) + builder_ptr + add_node(typename dd_policy::label_type label, + const builder_ptr& low, + const builder_ptr& high) { attach_if_needed(); // Check validity of input - if(low.builder_ref != builder_ref || high.builder_ref != builder_ref) { + if (low.builder_ref != builder_ref || high.builder_ref != builder_ref) { throw invalid_argument("Cannot use pointers from a different builder"); } - if(label > dd_policy::max_label) { - throw invalid_argument("Nodes must have a valid label"); - } - if(label > current_label) { - throw invalid_argument("Nodes must be added bottom-up"); - } - if(low.uid.is_node() && low.uid.label() <= label) { + if (label > dd_policy::max_label) { throw invalid_argument("Nodes must have a valid label"); } + if (label > current_label) { throw invalid_argument("Nodes must be added bottom-up"); } + if (low.uid.is_node() && low.uid.label() <= label) { throw invalid_argument("Low child must point to a node with higher label"); } - if(high.uid.is_node() && high.uid.label() <= label) { + if (high.uid.is_node() && high.uid.label() <= label) { throw invalid_argument("High child must point to a node with higher label"); } // Update label and ID if necessary - if(label < current_label) { + if (label < current_label) { current_label = label; - current_id = dd_policy::max_id; + current_id = dd_policy::max_id; } // Create potential node @@ -265,11 +263,11 @@ namespace adiar if (res_uid.is_terminal()) { created_terminal = true; - terminal_val = res_uid.value(); + terminal_val = res_uid.value(); } - if(res_uid == low.uid) { return low; } - if(res_uid == high.uid) { return high; } + if (res_uid == low.uid) { return low; } + if (res_uid == high.uid) { return high; } // Push node to file nw.push(n); @@ -278,13 +276,13 @@ namespace adiar // Update count of unreferenced nodes bool& low_unref = *low.unreferenced; - if(low_unref && !low.uid.is_terminal()) { + if (low_unref && !low.uid.is_terminal()) { low_unref = false; unref_nodes--; } bool& high_unref = *high.unreferenced; - if(high_unref && !high.uid.is_terminal()) { + if (high_unref && !high.uid.is_terminal()) { high_unref = false; unref_nodes--; } @@ -309,9 +307,10 @@ namespace adiar /// \throws invalid_argument If `label` and `high` are illegal (see \ref /// add_node). ///////////////////////////////////////////////////////////////////////////// - builder_ptr add_node(const typename dd_policy::label_type label, - const bool low, - const builder_ptr &high) + builder_ptr + add_node(const typename dd_policy::label_type label, + const bool low, + const builder_ptr& high) { attach_if_needed(); @@ -336,9 +335,10 @@ namespace adiar /// \throws invalid_argument If `label` and `low` are illegal (see \ref /// add_node). ///////////////////////////////////////////////////////////////////////////// - builder_ptr add_node(const typename dd_policy::label_type label, - const builder_ptr &low, - const bool high) + builder_ptr + add_node(const typename dd_policy::label_type label, + const builder_ptr& low, + const bool high) { attach_if_needed(); @@ -362,13 +362,12 @@ namespace adiar /// \throws invalid_argument If `label` violates the bottom-up ordering (see /// \ref add_node). ///////////////////////////////////////////////////////////////////////////// - builder_ptr add_node(const typename dd_policy::label_type label, - const bool low, - const bool high) + builder_ptr + add_node(const typename dd_policy::label_type label, const bool low, const bool high) { attach_if_needed(); - builder_ptr low_ptr = make_ptr(typename node_type::pointer_type(low)); + builder_ptr low_ptr = make_ptr(typename node_type::pointer_type(low)); builder_ptr high_ptr = make_ptr(typename node_type::pointer_type(high)); return add_node(label, low_ptr, high_ptr); } @@ -382,12 +381,13 @@ namespace adiar /// process since terminals are not part of the *bottom-up* /// requirement. ///////////////////////////////////////////////////////////////////////////// - builder_ptr add_node(bool terminal_value) + builder_ptr + add_node(bool terminal_value) { attach_if_needed(); created_terminal = true; - terminal_val = terminal_value; + terminal_val = terminal_value; return make_ptr(typename node_type::pointer_type(terminal_value)); } @@ -408,12 +408,13 @@ namespace adiar /// `builder_ptr` created by this object will be invalidated and /// cannot be used anymore. ///////////////////////////////////////////////////////////////////////////// - typename dd_policy::dd_type build() + typename dd_policy::dd_type + build() { attach_if_needed(); - if(!nw.has_pushed()) { - if(created_terminal) { + if (!nw.has_pushed()) { + if (created_terminal) { nw.push(node_type(terminal_val)); } else { throw domain_error("There must be at least one node or terminal in the decision diagram"); @@ -421,9 +422,7 @@ namespace adiar } nw.detach(); - if(unref_nodes > 1) { - throw domain_error("Decision diagram has more than one root"); - } + if (unref_nodes > 1) { throw domain_error("Decision diagram has more than one root"); } const typename dd_policy::dd_type res(nf); detach(); @@ -437,14 +436,18 @@ namespace adiar /// \warning This will invalidate any pointers created up to this point. You /// will not be able to use them after this. ///////////////////////////////////////////////////////////////////////////// - void clear() noexcept - { detach(); } + void + clear() noexcept + { + detach(); + } private: ///////////////////////////////////////////////////////////////////////////// /// \brief Initializes all values and the node file, if necessary. ///////////////////////////////////////////////////////////////////////////// - inline void attach_if_needed() noexcept + inline void + attach_if_needed() noexcept { if (!nf) { adiar_assert(!nw.attached(), @@ -462,14 +465,15 @@ namespace adiar unref_nodes = 0; // Initialise shared builder reference. - builder_ref = make_shared(); + builder_ref = make_shared(); } } ///////////////////////////////////////////////////////////////////////////// /// \brief Detaches the node writer and releases the pointer to the file. ///////////////////////////////////////////////////////////////////////////// - inline void detach() noexcept + inline void + detach() noexcept { nw.detach(); nf.reset(); @@ -478,7 +482,8 @@ namespace adiar ///////////////////////////////////////////////////////////////////////////// /// \brief Create a builder_ptr with 'this' builder as its parent. ///////////////////////////////////////////////////////////////////////////// - builder_ptr make_ptr(const typename node_type::pointer_type &p) noexcept + builder_ptr + make_ptr(const typename node_type::pointer_type& p) noexcept { return builder_ptr(p, builder_ref); } diff --git a/src/adiar/domain.cpp b/src/adiar/domain.cpp index 09ced323a..74f9fd145 100644 --- a/src/adiar/domain.cpp +++ b/src/adiar/domain.cpp @@ -10,7 +10,8 @@ namespace adiar shared_ptr> domain_ptr; - void domain_set(const domain_var varcount) + void + domain_set(const domain_var varcount) { internal::shared_file dom; { // Garbage collect writer to free write-lock @@ -20,7 +21,8 @@ namespace adiar domain_set(dom); } - void domain_set(const generator &gen) + void + domain_set(const generator& gen) { internal::shared_file dom; { // Garbage collect writer to free write-lock @@ -33,31 +35,34 @@ namespace adiar domain_set(dom); } - void domain_set(const internal::shared_file &dom) + void + domain_set(const internal::shared_file& dom) { domain_ptr = dom; } - void domain_unset() + void + domain_unset() { domain_ptr.reset(); } - bool domain_isset() + bool + domain_isset() { return domain_ptr ? true : false; } - internal::shared_file domain_get() + internal::shared_file + domain_get() { - if(!domain_isset()) { - throw domain_error("Domain must be set before it can be used"); - } + if (!domain_isset()) { throw domain_error("Domain must be set before it can be used"); } return domain_ptr; } - domain_var domain_size() + domain_var + domain_size() { return domain_isset() ? domain_get()->size() : 0u; } diff --git a/src/adiar/domain.h b/src/adiar/domain.h index 77f0a2c81..ba005c617 100644 --- a/src/adiar/domain.h +++ b/src/adiar/domain.h @@ -40,7 +40,8 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// /// \brief Set the domain globally for all of Adiar to be [*0, varcount*). ////////////////////////////////////////////////////////////////////////////// - void domain_set(const domain_var varcount); + void + domain_set(const domain_var varcount); ////////////////////////////////////////////////////////////////////////////// /// \brief Set the domain globally for all of Adiar to be the variables @@ -50,7 +51,8 @@ namespace adiar /// \em ascending order. When none are left, it must return a value /// greater than `domain_max`. ////////////////////////////////////////////////////////////////////////////// - void domain_set(const generator &dom); + void + domain_set(const generator& dom); ////////////////////////////////////////////////////////////////////////////// /// \brief Set the domain globally for all of Adiar to be the variables @@ -61,9 +63,12 @@ namespace adiar /// /// \param end Marks the end for `begin`. ////////////////////////////////////////////////////////////////////////////// - template - void domain_set(ForwardIt begin, ForwardIt end) - { return domain_set(make_generator(begin, end)); } + template + void + domain_set(ForwardIt begin, ForwardIt end) + { + return domain_set(make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Set the domain globally for all of Adiar. @@ -77,19 +82,22 @@ namespace adiar /// /// \see domain_get() ////////////////////////////////////////////////////////////////////////////// - void domain_set(const internal::shared_file &dom); + void + domain_set(const internal::shared_file& dom); ////////////////////////////////////////////////////////////////////////////// /// \brief Removes any globally shared domain variables (if any). /// /// \see domain_set ////////////////////////////////////////////////////////////////////////////// - void domain_unset(); + void + domain_unset(); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether Adiar has a global domain. ////////////////////////////////////////////////////////////////////////////// - bool domain_isset(); + bool + domain_isset(); ////////////////////////////////////////////////////////////////////////////// /// \brief Returns the global domain. @@ -104,14 +112,16 @@ namespace adiar /// /// \see domain_set(const shared_file &dom) ////////////////////////////////////////////////////////////////////////////// - internal::shared_file domain_get(); + internal::shared_file + domain_get(); ////////////////////////////////////////////////////////////////////////////// /// \brief The size of the domain. /// /// \details Returns `0` if `domain_isset() == false`. ////////////////////////////////////////////////////////////////////////////// - domain_var domain_size(); + domain_var + domain_size(); /// \} ////////////////////////////////////////////////////////////////////////////// diff --git a/src/adiar/exec_policy.h b/src/adiar/exec_policy.h index 794d4dc55..5aaf7f9c2 100644 --- a/src/adiar/exec_policy.h +++ b/src/adiar/exec_policy.h @@ -158,7 +158,7 @@ namespace adiar public: constexpr transposition_growth() : _value(1.5f) - { } + {} /// \brief Wrap a `float`. constexpr transposition_growth(float value) @@ -166,7 +166,10 @@ namespace adiar {} /// \brief Reobtain the wrapped `float` - operator float() const { return this->_value; } + operator float() const + { + return this->_value; + } }; ////////////////////////////////////////////////////////////////////////// @@ -206,7 +209,10 @@ namespace adiar {} /// \brief Reobtain the wrapped `unsigned char` value - operator unsigned char() const { return this->_value; } + operator unsigned char() const + { + return this->_value; + } }; }; @@ -276,7 +282,7 @@ namespace adiar /// \brief Default value construction. constexpr fast_reduce() : _value(0.05f) - { } + {} /// \brief Conversion constructor from `float`. constexpr fast_reduce(float f) @@ -284,7 +290,10 @@ namespace adiar {} /// \brief Reobtain this value as a `float`. - operator float() const { return static_cast(this->_value) / ticks; } + operator float() const + { + return static_cast(this->_value) / ticks; + } bool operator==(const fast_reduce& other) const @@ -321,7 +330,7 @@ namespace adiar /// \brief Maximal number of repeated transpositions in `quantify`. //////////////////////////////////////////////////////////////////////////// quantify::transposition_max _quantify__transposition_max /*default*/; - ; + ; //////////////////////////////////////////////////////////////////////////// /// \brief Chosen epsilon value for Nested Sweeping to start skipping the diff --git a/src/adiar/functional.h b/src/adiar/functional.h index 155930a38..95ce3beea 100644 --- a/src/adiar/functional.h +++ b/src/adiar/functional.h @@ -35,7 +35,7 @@ namespace adiar /// /// \tparam TypeSignature The type signature of the form `ret_t (args_t...)`. ////////////////////////////////////////////////////////////////////////////// - template + template using function = std::function; ////////////////////////////////////////////////////////////////////////////// @@ -44,8 +44,8 @@ namespace adiar /// \tparam Args List of the argument's type in the order, they are supposed /// to be given. This list may be empty. ////////////////////////////////////////////////////////////////////////////// - template - using predicate = function; + template + using predicate = function; ////////////////////////////////////////////////////////////////////////////// /// \brief Consumer function of value(s) of type(s) `Args`. @@ -57,8 +57,8 @@ namespace adiar /// \tparam Args List of the argument's type in the order, they are supposed /// to be given. ////////////////////////////////////////////////////////////////////////////// - template - using consumer = function; + template + using consumer = function; ////////////////////////////////////////////////////////////////////////////// /// \brief Wrap a `begin` and `end` iterator pair into a consumer function. @@ -67,13 +67,13 @@ namespace adiar /// if `end` is reached but more values are to be added, i.e. if /// the given range is not large enough for all values to be consumed. ////////////////////////////////////////////////////////////////////////////// - template + template inline consumer - make_consumer(ForwardIt &begin, ForwardIt &end) + make_consumer(ForwardIt& begin, ForwardIt& end) { using value_type = typename ForwardIt::value_type; - return [&begin, &end](const value_type &x) { + return [&begin, &end](const value_type& x) { if (begin == end) { throw out_of_range("Iterator range unable to contain all generated values"); } @@ -88,13 +88,13 @@ namespace adiar /// if `end` is reached but more values are to be added, i.e. if /// the given range is not large enough for all values to be consumed. ////////////////////////////////////////////////////////////////////////////// - template + template inline consumer - make_consumer(ForwardIt &&begin, ForwardIt &&end) + make_consumer(ForwardIt&& begin, ForwardIt&& end) { using value_type = typename ForwardIt::value_type; - return [_begin = begin, _end = end](const value_type &x) mutable { + return [_begin = begin, _end = end](const value_type& x) mutable { if (_begin == _end) { throw out_of_range("Iterator range unable to contain all generated values"); } @@ -114,22 +114,20 @@ namespace adiar /// /// \tparam RetType Type of each yielded value from the generator. ////////////////////////////////////////////////////////////////////////////// - template - using generator = function ()>; + template + using generator = function()>; //////////////////////////////////////////////////////////////////////////// /// \brief Wrap a `begin` and `end` iterator pair into a generator function. //////////////////////////////////////////////////////////////////////////// - template + template inline generator - make_generator(ForwardIt &begin, ForwardIt &end) + make_generator(ForwardIt& begin, ForwardIt& end) { using value_type = typename ForwardIt::value_type; return [&begin, &end]() { - if (begin == end) { - return make_optional(); - } + if (begin == end) { return make_optional(); } return make_optional(*(begin++)); }; } @@ -137,16 +135,14 @@ namespace adiar //////////////////////////////////////////////////////////////////////////// /// \brief Wrap a `begin` and `end` iterator pair into a generator function. //////////////////////////////////////////////////////////////////////////// - template + template inline generator - make_generator(ForwardIt &&begin, ForwardIt &&end) + make_generator(ForwardIt&& begin, ForwardIt&& end) { using value_type = typename ForwardIt::value_type; return [_begin = begin, _end = end]() mutable { - if (_begin == _end) { - return make_optional(); - } + if (_begin == _end) { return make_optional(); } return make_optional(*(_begin++)); }; } @@ -154,16 +150,14 @@ namespace adiar //////////////////////////////////////////////////////////////////////////// /// \brief Wrap an `adiar::internal::file_stream` into a generator function. //////////////////////////////////////////////////////////////////////////// - template + template inline generator - make_generator(Stream &s) + make_generator(Stream& s) { using value_type = typename Stream::value_type; return [&s]() { - if (!s.can_pull()) { - return make_optional(); - } + if (!s.can_pull()) { return make_optional(); } return make_optional(s.pull()); }; } @@ -171,9 +165,9 @@ namespace adiar //////////////////////////////////////////////////////////////////////////// /// \brief Wrap a single value into a generator. //////////////////////////////////////////////////////////////////////////// - template + template inline generator - make_generator(const RetType &r) + make_generator(const RetType& r) { return [=, _end = false]() mutable { if (_end) { return make_optional(); } diff --git a/src/adiar/internal/algorithms/build.h b/src/adiar/internal/algorithms/build.h index 4914a7b17..cd4b5476f 100644 --- a/src/adiar/internal/algorithms/build.h +++ b/src/adiar/internal/algorithms/build.h @@ -3,10 +3,11 @@ #include #include + #include #include -#include #include +#include #include #include #include @@ -16,9 +17,8 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Builder for a terminal value ////////////////////////////////////////////////////////////////////////////// - template - inline - shared_levelized_file + template + inline shared_levelized_file build_terminal(bool value) { using node_type = typename DdPolicy::node_type; @@ -36,12 +36,11 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Builder for a single-node with children (`false`, `true`). ////////////////////////////////////////////////////////////////////////////// - template - inline - shared_levelized_file + template + inline shared_levelized_file build_ithvar(typename DdPolicy::label_type label) { - using node_type = typename DdPolicy::node_type; + using node_type = typename DdPolicy::node_type; using pointer_type = typename node_type::pointer_type; if (node_type::max_label < label) { @@ -52,7 +51,7 @@ namespace adiar::internal { node_writer nw(nf); nw.unsafe_push(node(label, pointer_type::max_id, pointer_type(false), pointer_type(true))); - nw.unsafe_push(level_info(label,1u)); + nw.unsafe_push(level_info(label, 1u)); nw.unsafe_set_canonical(true); } @@ -62,33 +61,31 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Builds a chain of nodes bottom-up. ////////////////////////////////////////////////////////////////////////////// - template + template inline typename Policy::dd_type - build_chain(const Policy &policy, const Generator &vars) + build_chain(const Policy& policy, const Generator& vars) { using label_type = typename Policy::label_type; optional> next = vars(); - if (!next) { - return build_terminal(Policy::init_terminal); - } + if (!next) { return build_terminal(Policy::init_terminal); } shared_levelized_file nf; node_writer nw(nf); - size_t max_internal_cut = 1; + size_t max_internal_cut = 1; - size_t terminals_internal[2] = {0u, 0u}; - bool terminal_at_bottom[2] = {false, false}; - size_t terminals[2] = {0u, 0u}; + size_t terminals_internal[2] = { 0u, 0u }; + bool terminal_at_bottom[2] = { false, false }; + size_t terminals[2] = { 0u, 0u }; typename Policy::pointer_type root(Policy::init_terminal); adiar_assert(root.is_terminal()); do { - const label_type next_var = next.value().first; - const label_type next_negated = next.value().second; + const label_type next_var = next.value().first; + const label_type next_negated = next.value().second; // Fail if generator is increasing. if (!root.is_terminal() && root.label() < next_var) { @@ -114,11 +111,10 @@ namespace adiar::internal const node_type n = policy.make_node(next_var, root, next_negated); - adiar_assert(n.label() == next_var, "Policy ought to make a node for this level node"); + adiar_assert(n.label() == next_var, "Policy ought to make a node for this level node"); adiar_assert(n.id() == node_type::max_id, "Policy ought to make a canonical node"); - max_internal_cut = std::max(max_internal_cut, - n.low().is_node() + n.high().is_node()); + max_internal_cut = std::max(max_internal_cut, n.low().is_node() + n.high().is_node()); if (n.low().is_terminal()) { terminals_internal[n.low().value()] = @@ -149,9 +145,7 @@ namespace adiar::internal } while (next); // If all values have been skipped by the policy, then collapse to a terminal - if (nw.size() == 0u) { - return build_terminal(Policy::init_terminal); - } + if (nw.size() == 0u) { return build_terminal(Policy::init_terminal); } // Canonicity (assuming the policies are correct) nw.unsafe_set_canonical(true); @@ -160,26 +154,19 @@ namespace adiar::internal nf->max_1level_cut[cut::Internal] = max_internal_cut; nf->max_1level_cut[cut::Internal_False] = - std::max({ - nf->max_1level_cut[cut::Internal], - terminals_internal[false] + terminals[false] - terminal_at_bottom[false], - terminals[false] - }); + std::max({ nf->max_1level_cut[cut::Internal], + terminals_internal[false] + terminals[false] - terminal_at_bottom[false], + terminals[false] }); nf->max_1level_cut[cut::Internal_True] = - std::max({ - nf->max_1level_cut[cut::Internal], - terminals_internal[true] + terminals[true] - terminal_at_bottom[true], - terminals[true] - }); - - nf->max_1level_cut[cut::All] = - std::max({ - nf->max_1level_cut[cut::Internal], - nf->max_1level_cut[cut::Internal_False], - nf->max_1level_cut[cut::Internal_True], - terminals[false] + terminals[true] - }); + std::max({ nf->max_1level_cut[cut::Internal], + terminals_internal[true] + terminals[true] - terminal_at_bottom[true], + terminals[true] }); + + nf->max_1level_cut[cut::All] = std::max({ nf->max_1level_cut[cut::Internal], + nf->max_1level_cut[cut::Internal_False], + nf->max_1level_cut[cut::Internal_True], + terminals[false] + terminals[true] }); return nf; } @@ -189,50 +176,50 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Policy for `build_chain` where the chain goes up the *low* arcs. ////////////////////////////////////////////////////////////////////////////// - template + template class chain_low : public DdPolicy { public: static constexpr bool init_terminal = InitTerminal; constexpr bool - skip(const typename DdPolicy::label_type &) const - { return false; } + skip(const typename DdPolicy::label_type&) const + { + return false; + } inline typename DdPolicy::node_type - make_node(const typename DdPolicy::label_type &l, - const typename DdPolicy::pointer_type &r, - const bool/*negated*/) const + make_node(const typename DdPolicy::label_type& l, + const typename DdPolicy::pointer_type& r, + const bool /*negated*/) const { - return typename DdPolicy::node_type(l, - DdPolicy::max_id, - r, - typename DdPolicy::pointer_type(HighValue)); + return typename DdPolicy::node_type( + l, DdPolicy::max_id, r, typename DdPolicy::pointer_type(HighValue)); } }; ////////////////////////////////////////////////////////////////////////////// /// \brief Policy for `build_chain` where the chain goes up the *high* arcs. ////////////////////////////////////////////////////////////////////////////// - template + template class chain_high : public DdPolicy { public: static constexpr bool init_terminal = InitTerminal; constexpr bool - skip(const typename DdPolicy::label_type &) const - { return false; } + skip(const typename DdPolicy::label_type&) const + { + return false; + } inline typename DdPolicy::node_type - make_node(const typename DdPolicy::label_type &l, - const typename DdPolicy::pointer_type &r, - const bool/*negated*/) const + make_node(const typename DdPolicy::label_type& l, + const typename DdPolicy::pointer_type& r, + const bool /*negated*/) const { - return typename DdPolicy::node_type(l, - DdPolicy::max_id, - typename DdPolicy::pointer_type(LowValue), - r); + return typename DdPolicy::node_type( + l, DdPolicy::max_id, typename DdPolicy::pointer_type(LowValue), r); } }; @@ -240,20 +227,22 @@ namespace adiar::internal /// \brief Policy for `build_chain` where the chain goes up both the *low* and /// the *high* arcs. ////////////////////////////////////////////////////////////////////////////// - template + template class chain_both : public DdPolicy { public: static constexpr bool init_terminal = InitTerminal; constexpr bool - skip(const typename DdPolicy::label_type &) const - { return false; } + skip(const typename DdPolicy::label_type&) const + { + return false; + } inline typename DdPolicy::node_type - make_node(const typename DdPolicy::label_type &l, - const typename DdPolicy::pointer_type &r, - const bool/*negated*/) const + make_node(const typename DdPolicy::label_type& l, + const typename DdPolicy::pointer_type& r, + const bool /*negated*/) const { return typename DdPolicy::node_type(l, DdPolicy::max_id, r, r); } @@ -263,38 +252,42 @@ namespace adiar::internal /// \brief Wrapper for a generator to map its output to fit the `build_chain` /// algorithm. ////////////////////////////////////////////////////////////////////////////// - template + template class chain_converter { private: - const Generator &_gen; + const Generator& _gen; public: using value_type = pair; using result_type = optional; private: - inline value_type map(const value_type &x) const + inline value_type + map(const value_type& x) const { return make_pair(x.first, negate ^ x.second); } - inline value_type map(const typename DdPolicy::label_type &x) const + inline value_type + map(const typename DdPolicy::label_type& x) const { return make_pair(x, negate); } - inline value_type map(const int &x) const + inline value_type + map(const int& x) const { return make_pair(std::abs(x), negate ? 0 < x : x < 0); } public: - chain_converter(const Generator &gen) + chain_converter(const Generator& gen) : _gen(gen) - { } + {} - inline result_type operator()() const + inline result_type + operator()() const { // NOTE: This is similar to a monadic 'bind'/'map'. diff --git a/src/adiar/internal/algorithms/convert.h b/src/adiar/internal/algorithms/convert.h index 3aa210e12..ab965fa20 100644 --- a/src/adiar/internal/algorithms/convert.h +++ b/src/adiar/internal/algorithms/convert.h @@ -3,23 +3,23 @@ #include -#include -#include -#include #include +#include #include #include +#include #include #include +#include namespace adiar::internal { - template + template class convert_dd_policy { - static_assert(std::is_base_of::value); + static_assert(std::is_base_of::value); static_assert(std::is_base_of<__dd, typename from_policy::__dd_type>::value); - static_assert(std::is_base_of::value); + static_assert(std::is_base_of::value); static_assert(std::is_base_of<__dd, typename to_policy::__dd_type>::value); public: @@ -27,9 +27,9 @@ namespace adiar::internal using pointer_type = typename from_policy::pointer_type; using node_type = typename from_policy::node_type; - using __dd_type = typename to_policy::__dd_type; - using label_type = typename to_policy::label_type; - using id_type = typename to_policy::id_type; + using __dd_type = typename to_policy::__dd_type; + using label_type = typename to_policy::label_type; + using id_type = typename to_policy::id_type; static constexpr label_type max_label = to_policy::max_label; @@ -53,7 +53,7 @@ namespace adiar::internal static typename to_policy::dd_type on_terminal_input(const bool terminal_value, const typename from_policy::dd_type& /*dd*/, - const shared_file &dom) + const shared_file& dom) { adiar_assert(dom->size() > 0, "Emptiness check is before terminal check"); @@ -66,18 +66,19 @@ namespace adiar::internal file_stream ls(dom); - while(ls.can_pull()) { + while (ls.can_pull()) { const typename to_policy::label_type next_label = ls.pull(); const tuple children = from_policy::reduction_rule_inv(prior_node); const node next_node = node(next_label, to_policy::max_id, children[0], children[1]); - const typename to_policy::pointer_type reduction_result = to_policy::reduction_rule(next_node); + const typename to_policy::pointer_type reduction_result = + to_policy::reduction_rule(next_node); if (reduction_result == next_node.uid()) { // Output prior_node = next_node.uid(); nw.unsafe_push(next_node); - nw.unsafe_push(level_info(next_label,1u)); + nw.unsafe_push(level_info(next_label, 1u)); } else { // If we kill the resulting node once, then we will also do it for all // the other labels we still are missing. @@ -86,9 +87,7 @@ namespace adiar::internal } } - if (!has_output) { - nw.unsafe_push(node(terminal_value)); - } + if (!has_output) { nw.unsafe_push(node(terminal_value)); } return nf; } @@ -99,29 +98,33 @@ namespace adiar::internal return terminal_value; } - static intercut_rec hit_existing(const node &n) + static intercut_rec + hit_existing(const node& n) { const node::pointer_type to_reduction = to_policy::reduction_rule(n); - if (to_reduction != n.uid()) { - return intercut_rec_skipto { to_reduction }; - } - return intercut_rec_output { n.low(), n.high() }; + if (to_reduction != n.uid()) { return intercut_rec_skipto{ to_reduction }; } + return intercut_rec_output{ n.low(), n.high() }; } - static intercut_rec_output hit_cut(const node::pointer_type target) - { + static intercut_rec_output + hit_cut(const node::pointer_type target) + { const tuple children = from_policy::reduction_rule_inv(target); // Debug mode: double-check we don't create irrelevant nodes - adiar_assert(to_policy::reduction_rule(node(0,0, children[0], children[1])) != target, + adiar_assert(to_policy::reduction_rule(node(0, 0, children[0], children[1])) != target, "Should not cut an arc where the one created will be killed anyways."); - return intercut_rec_output { children[0], children[1] }; + return intercut_rec_output{ children[0], children[1] }; } // LCOV_EXCL_START - static intercut_rec miss_existing(const node &/*n*/) - { adiar_unreachable(); } + static intercut_rec + miss_existing(const node& /*n*/) + { + adiar_unreachable(); + } + // LCOV_EXCL_STOP }; } diff --git a/src/adiar/internal/algorithms/count.h b/src/adiar/internal/algorithms/count.h index b03727268..fe49e8743 100644 --- a/src/adiar/internal/algorithms/count.h +++ b/src/adiar/internal/algorithms/count.h @@ -6,10 +6,10 @@ #include #include -#include #include -#include #include +#include +#include #include namespace adiar::internal @@ -30,7 +30,7 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// // Data structures - template + template using count_request = request_data<1, Data>; template @@ -59,7 +59,7 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// Policy with logic for specializing Count algorithm into PathCount. ////////////////////////////////////////////////////////////////////////////// - template + template class path_count_policy : public DdPolicy { public: @@ -68,61 +68,54 @@ namespace adiar::internal static constexpr data_type init_data = { 1u }; static constexpr uint64_t - resolve_false(const data_type &/*d*/, - const typename DdPolicy::label_type/*varcount*/) + resolve_false(const data_type& /*d*/, const typename DdPolicy::label_type /*varcount*/) { return 0u; } static inline uint64_t - resolve_true(const data_type &d, - const typename DdPolicy::label_type/*varcount*/) + resolve_true(const data_type& d, const typename DdPolicy::label_type /*varcount*/) { return d.sum; } static inline data_type - merge(const data_type &&acc, const data_type &next) + merge(const data_type&& acc, const data_type& next) { - adiar_assert(acc.sum > 0u && next.sum > 0u, - "No request should have an 'empty' set of paths"); + adiar_assert(acc.sum > 0u && next.sum > 0u, "No request should have an 'empty' set of paths"); return { acc.sum + next.sum }; } static inline data_type - merge_end(const data_type &&acc) + merge_end(const data_type&& acc) { return acc; } }; ////////////////////////////////////////////////////////////////////////////// - template + template inline uint64_t - __count_resolve(PriorityQueue &count_pq, - const typename Policy::pointer_type &target, - const typename Policy::data_type &data, + __count_resolve(PriorityQueue& count_pq, + const typename Policy::pointer_type& target, + const typename Policy::data_type& data, const typename Policy::label_type varcount) { - if (target.is_false()) { - return Policy::resolve_false(data, varcount); - } - if (target.is_true()) { - return Policy::resolve_true(data, varcount); - } - count_pq.push({ {target}, {}, data }); + if (target.is_false()) { return Policy::resolve_false(data, varcount); } + if (target.is_true()) { return Policy::resolve_true(data, varcount); } + count_pq.push({ { target }, {}, data }); return 0u; } - template - uint64_t __count(const typename Policy::dd_type &dd, - const typename Policy::label_type varcount, - const size_t pq_max_memory, - const size_t pq_max_size) + template + uint64_t + __count(const typename Policy::dd_type& dd, + const typename Policy::label_type varcount, + const size_t pq_max_memory, + const size_t pq_max_size) { - adiar_assert(!dd->is_terminal(), - "Count Algorithm does not support terminal case"); + adiar_assert(!dd->is_terminal(), "Count Algorithm does not support terminal case"); // Set up output uint64_t result = 0u; @@ -131,11 +124,11 @@ namespace adiar::internal node_stream<> ns(dd); // Set up cross-level priority queue with a request for the root - PriorityQueue count_pq({dd}, pq_max_memory, pq_max_size, stats_count.lpq); + PriorityQueue count_pq({ dd }, pq_max_memory, pq_max_size, stats_count.lpq); { const node root = ns.peek(); - count_pq.push({ {root.uid()}, {}, Policy::init_data }); + count_pq.push({ { root.uid() }, {}, Policy::init_data }); } // Take out the rest of the nodes and process them one by one @@ -146,12 +139,11 @@ namespace adiar::internal // Assuming there are no dead nodes, we should visit every node of dd const node n = ns.pull(); - adiar_assert(count_pq.top().target == n.uid(), - "Decision Diagram includes dead nodes"); + adiar_assert(count_pq.top().target == n.uid(), "Decision Diagram includes dead nodes"); // Merge requests for 'n' const typename PriorityQueue::value_type request = count_pq.pull(); - typename Policy::data_type data = request.data; + typename Policy::data_type data = request.data; while (count_pq.can_pull() && count_pq.top().target == n.uid()) { data = Policy::merge(std::move(data), count_pq.pull().data); @@ -160,7 +152,7 @@ namespace adiar::internal data = Policy::merge_end(std::move(data)); // Forward requests for children of 'n' - result += __count_resolve(count_pq, n.low(), data, varcount); + result += __count_resolve(count_pq, n.low(), data, varcount); result += __count_resolve(count_pq, n.high(), data, varcount); } } @@ -168,13 +160,13 @@ namespace adiar::internal return result; } - template - uint64_t count(const exec_policy &ep, - const typename Policy::dd_type &dd, - const typename Policy::label_type varcount) + template + uint64_t + count(const exec_policy& ep, + const typename Policy::dd_type& dd, + const typename Policy::label_type varcount) { - adiar_assert(!dd_isterminal(dd), - "Count algorithm does not work on terminal-only edge case"); + adiar_assert(!dd_isterminal(dd), "Count algorithm does not work on terminal-only edge case"); // Compute amount of memory available for auxiliary data structures after // having opened all streams. @@ -186,39 +178,44 @@ namespace adiar::internal const size_t aux_available_memory = memory_available() - node_stream<>::memory_usage(); const size_t pq_memory_fits = - count_priority_queue_t::memory_fits(aux_available_memory); + count_priority_queue_t::memory_fits(aux_available_memory); - const bool internal_only = ep.template get() == exec_policy::memory::Internal; - const bool external_only = ep.template get() == exec_policy::memory::External; + const bool internal_only = + ep.template get() == exec_policy::memory::Internal; + const bool external_only = + ep.template get() == exec_policy::memory::External; const size_t pq_bound = dd.max_2level_cut(cut::Internal); const size_t max_pq_size = internal_only ? std::min(pq_memory_fits, pq_bound) : pq_bound; - if(!external_only && max_pq_size <= no_lookahead_bound()) { + if (!external_only && max_pq_size <= no_lookahead_bound()) { #ifdef ADIAR_STATS stats_count.lpq.unbucketed += 1u; #endif - return __count> - (dd, varcount, aux_available_memory, max_pq_size); - } else if(!external_only && max_pq_size <= pq_memory_fits) { + return __count>( + dd, varcount, aux_available_memory, max_pq_size); + } else if (!external_only && max_pq_size <= pq_memory_fits) { #ifdef ADIAR_STATS stats_count.lpq.internal += 1u; #endif - return __count> - (dd, varcount, aux_available_memory, max_pq_size); + return __count>( + dd, varcount, aux_available_memory, max_pq_size); } else { #ifdef ADIAR_STATS stats_count.lpq.external += 1u; #endif - return __count> - (dd, varcount, aux_available_memory, max_pq_size); + return __count>( + dd, varcount, aux_available_memory, max_pq_size); } } } diff --git a/src/adiar/internal/algorithms/dot.h b/src/adiar/internal/algorithms/dot.h index f3190d7dd..08bc20f34 100644 --- a/src/adiar/internal/algorithms/dot.h +++ b/src/adiar/internal/algorithms/dot.h @@ -1,9 +1,8 @@ #ifndef ADIAR_INTERNAL_ALGORITHMS_DOT_H #define ADIAR_INTERNAL_ALGORITHMS_DOT_H -#include - #include +#include #include #include @@ -26,67 +25,77 @@ namespace adiar::internal /// debugging purposes. ////////////////////////////////////////////////////////////////////////////////////////////////// template - inline void __print_dot(const File& nodes, std::ostream &out, bool include_id) + inline void + __print_dot(const File& nodes, std::ostream& out, bool include_id) { - out << "digraph DD {" << "\n"; + out << "digraph DD {" + << "\n"; node_stream<> ns(nodes); if (nodes->is_terminal()) { const bool value = ns.pull().value(); - out << "\tn" << ptr_uint64(value)._raw - << " [shape=box, label=<" << (value ? File::true_print : File::false_print) << ">];" << "\n"; + out << "\tn" << ptr_uint64(value)._raw << " [shape=box, label=<" + << (value ? File::true_print : File::false_print) << ">];" + << "\n"; } else { - out << "\t// Nodes" << "\n"; - out << "\tnode [shape=" << (include_id ? "box" : "circle") << "];" << "\n"; + out << "\t// Nodes" + << "\n"; + out << "\tnode [shape=" << (include_id ? "box" : "circle") << "];" + << "\n"; while (ns.can_pull()) { const node n = ns.pull(); out << "\tn" << n.uid()._raw << " [label=" << n.label(); - if (include_id) { - out << ", " << n.id(); - } - out << ">, style=rounded];\n"; + if (include_id) { out << ", " << n.id(); } + out << ">, style=rounded];\n"; } - out << "\tnode [shape=box];" << "\n"; - out << "\tn" << ptr_uint64(false)._raw - << " [label=<" << File::false_print << ">];" << "\n"; - out << "\tn" << ptr_uint64(true)._raw - << " [label=<" << File::true_print << ">];" << "\n"; + out << "\tnode [shape=box];" + << "\n"; + out << "\tn" << ptr_uint64(false)._raw << " [label=<" << File::false_print << ">];" + << "\n"; + out << "\tn" << ptr_uint64(true)._raw << " [label=<" << File::true_print << ">];" + << "\n"; - out << std::endl << "\t// Arcs" << "\n"; + out << std::endl + << "\t// Arcs" + << "\n"; ns.reset(); while (ns.can_pull()) { const node node = ns.pull(); - out << "\tn" << node.uid()._raw - << " -> " - << "n" << node.low()._raw - << " [style=dashed];" << "\n"; - out << "\tn" << node.uid()._raw - << " -> " - << "n" << node.high()._raw - << " [style=solid];" << "\n"; + out << "\tn" << node.uid()._raw << " -> " + << "n" << node.low()._raw << " [style=dashed];" + << "\n"; + out << "\tn" << node.uid()._raw << " -> " + << "n" << node.high()._raw << " [style=solid];" + << "\n"; } - out << "\n" << "\t// Ranks" << "\n"; + out << "\n" + << "\t// Ranks" + << "\n"; ns.reset(); - out << "\t{ rank=same; " << "n" << ns.pull().uid()._raw << " }" << "\n"; + out << "\t{ rank=same; " + << "n" << ns.pull().uid()._raw << " }" + << "\n"; while (ns.can_pull()) { const node current_node = ns.pull(); - out << "\t{ rank=same; " << "n" << current_node.uid()._raw << " "; + out << "\t{ rank=same; " + << "n" << current_node.uid()._raw << " "; - while(ns.can_pull() && current_node.label() == ns.peek().label()) { + while (ns.can_pull() && current_node.label() == ns.peek().label()) { out << "n" << ns.pull().uid()._raw << " "; } - out << "}" << "\n"; + out << "}" + << "\n"; } } out << "}" << std::endl; @@ -96,9 +105,8 @@ namespace adiar::internal /// \brief Output a container of nodes to a given file name ////////////////////////////////////////////////////////////////////////////// template - inline void __print_dot(const dd_t& dd, - const std::string& filename, - bool include_id) + inline void + __print_dot(const dd_t& dd, const std::string& filename, bool include_id) { // Create output stream for file std::ofstream out; @@ -117,21 +125,27 @@ namespace adiar::internal /// \brief Output a decision diagram to a given output stream. ////////////////////////////////////////////////////////////////////////////// template - void print_dot(const dd_t& dd, std::ostream &out, bool include_id) - { __print_dot(dd, out, include_id); } + void + print_dot(const dd_t& dd, std::ostream& out, bool include_id) + { + __print_dot(dd, out, include_id); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Output a decision diagram to a given file ////////////////////////////////////////////////////////////////////////////// template - void print_dot(const dd_t& dd, const std::string &filename, bool include_id) - { __print_dot(dd, filename, include_id); } + void + print_dot(const dd_t& dd, const std::string& filename, bool include_id) + { + __print_dot(dd, filename, include_id); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Print dot file of an intermediate output of arcs. ////////////////////////////////////////////////////////////////////////////// - inline void print_dot(const shared_levelized_file& arcs, - const std::string &filename) + inline void + print_dot(const shared_levelized_file& arcs, const std::string& filename) { std::ofstream out; out.open(filename); @@ -144,11 +158,9 @@ namespace adiar::internal while (as.can_pull_internal()) { const arc a = as.pull_internal(); out << "\t" - << "n" << a.target().label() << "_" << a.target().id() - << " -> " + << "n" << a.target().label() << "_" << a.target().id() << " -> " << "n" << a.source().label() << "_" << a.source().id() - << " [style=" << (a.out_idx() ? "solid" : "dashed") << ", color=blue];" - << std::endl; + << " [style=" << (a.out_idx() ? "solid" : "dashed") << ", color=blue];" << std::endl; } out << std::endl << "\t// Sink Arcs" << std::endl; @@ -159,11 +171,9 @@ namespace adiar::internal while (as.can_pull_terminal()) { const arc a = as.pull_terminal(); out << "\t" - << "n" << a.source().label() << "_" << a.source().id() - << " -> " - << "s" << a.target().value() - << " [style=" << (a.out_idx() ? "solid" : "dashed") << ", color=red];" - << std::endl; + << "n" << a.source().label() << "_" << a.source().id() << " -> " + << "s" << a.target().value() << " [style=" << (a.out_idx() ? "solid" : "dashed") + << ", color=red];" << std::endl; } out << "\t{ rank=min; s0 s1 }" << std::endl << "}" << std::endl; diff --git a/src/adiar/internal/algorithms/intercut.h b/src/adiar/internal/algorithms/intercut.h index b4dbc8544..c905fdeca 100644 --- a/src/adiar/internal/algorithms/intercut.h +++ b/src/adiar/internal/algorithms/intercut.h @@ -6,18 +6,17 @@ #include #include #include -#include #include -#include -#include #include +#include +#include +#include #include #include #include #include #include - namespace adiar::internal { ////////////////////////////////////////////////////////////////////////////// @@ -51,39 +50,40 @@ namespace adiar::internal ptr_uint64::label_type _level = ptr_uint64::max_label + 1u; public: - intercut_req() = default; + intercut_req() = default; intercut_req(const intercut_req&) = default; - ~intercut_req() = default; + ~intercut_req() = default; public: - intercut_req(ptr_uint64 source, ptr_uint64 target, ptr_uint64::label_type lvl) : arc(source, target), _level(lvl) - { } + intercut_req(ptr_uint64 source, ptr_uint64 target, ptr_uint64::label_type lvl) + : arc(source, target) + , _level(lvl) + {} public: - ptr_uint64::label_type level() const - { return _level; } + ptr_uint64::label_type + level() const + { + return _level; + } }; struct intercut_req_lt { - bool operator()(const intercut_req &a, const intercut_req &b) + bool + operator()(const intercut_req& a, const intercut_req& b) { - return a.level() < b.level() - || (a.level() == b.level() && a.target() < b.target()) + return a.level() < b.level() || (a.level() == b.level() && a.target() < b.target()) #ifndef NDEBUG || (a.level() == b.level() && a.target() == b.target() && a.source() < b.source()) #endif - ; + ; } }; - template + template using intercut_priority_queue_t = - levelized_label_priority_queue; + levelized_label_priority_queue; ////////////////////////////////////////////////////////////////////////////// @@ -102,36 +102,37 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// // Helper functions - template - bool cut_terminal(const typename intercut_policy::label_type curr_level, - const typename intercut_policy::label_type cut_level, - const bool terminal_value) + template + bool + cut_terminal(const typename intercut_policy::label_type curr_level, + const typename intercut_policy::label_type cut_level, + const bool terminal_value) { - return curr_level < cut_level - && cut_level <= intercut_policy::max_label + return curr_level < cut_level && cut_level <= intercut_policy::max_label && (!terminal_value || intercut_policy::cut_true_terminal) - && ( terminal_value || intercut_policy::cut_false_terminal); + && (terminal_value || intercut_policy::cut_false_terminal); } - template + template class intercut_out__pq { public: static constexpr bool ignore_nil = false; - template - static inline void forward(arc_writer &aw, - pq_t &pq, - const typename intercut_policy::pointer_type source, - const typename intercut_policy::pointer_type target, - const typename intercut_policy::label_type curr_level, - const typename intercut_policy::label_type next_cut) + template + static inline void + forward(arc_writer& aw, + pq_t& pq, + const typename intercut_policy::pointer_type source, + const typename intercut_policy::pointer_type target, + const typename intercut_policy::label_type curr_level, + const typename intercut_policy::label_type next_cut) { - const typename intercut_policy::label_type target_level = target.is_node() - ? target.label() - : intercut_policy::max_label+1; + const typename intercut_policy::label_type target_level = + target.is_node() ? target.label() : intercut_policy::max_label + 1; - if (target.is_terminal() && !cut_terminal(curr_level, next_cut, target.value())) { + if (target.is_terminal() + && !cut_terminal(curr_level, next_cut, target.value())) { aw.push_terminal(arc(source, target)); return; } @@ -144,32 +145,32 @@ namespace adiar::internal public: static constexpr bool ignore_nil = true; - template - static inline void forward(arc_writer &aw, - pq_t &/*pq*/, - const ptr_uint64 source, - const ptr_uint64 target, - const ptr_uint64::label_type /*curr_level*/, - const ptr_uint64::label_type /*next_cut*/) + template + static inline void + forward(arc_writer& aw, + pq_t& /*pq*/, + const ptr_uint64 source, + const ptr_uint64 target, + const ptr_uint64::label_type /*curr_level*/, + const ptr_uint64::label_type /*next_cut*/) { aw.push_internal(arc(source, target)); } }; - template - inline void intercut_in__pq(arc_writer &aw, - pq_t &pq, - const typename intercut_policy::label_type out_label, - const typename intercut_policy::pointer_type pq_target, - const typename intercut_policy::pointer_type out_target, - const typename intercut_policy::label_type l) + template + inline void + intercut_in__pq(arc_writer& aw, + pq_t& pq, + const typename intercut_policy::label_type out_label, + const typename intercut_policy::pointer_type pq_target, + const typename intercut_policy::pointer_type out_target, + const typename intercut_policy::label_type l) { adiar_assert(out_label <= out_target.label(), "should forward/output a node on this level or ahead."); - while (pq.can_pull() - && pq.top().level() == out_label - && pq.top().target() == pq_target) { + while (pq.can_pull() && pq.top().level() == out_label && pq.top().target() == pq_target) { const intercut_req parent = pq.pull(); if (in_policy::ignore_nil && parent.source().is_nil()) { continue; } @@ -177,12 +178,13 @@ namespace adiar::internal } } - template - typename intercut_policy::__dd_type __intercut (const exec_policy &ep, - const typename intercut_policy::dd_type &dd, - const generator &xs, - const size_t pq_memory, - const size_t max_pq_size) + template + typename intercut_policy::__dd_type + __intercut(const exec_policy& ep, + const typename intercut_policy::dd_type& dd, + const generator& xs, + const size_t pq_memory, + const size_t max_pq_size) { node_stream<> in_nodes(dd); node n = in_nodes.pull(); @@ -197,18 +199,12 @@ namespace adiar::internal shared_file hit_levels; { file_writer lw(hit_levels); - for (auto x = xs(); x; x = xs()) { - lw << x.value(); - } + for (auto x = xs(); x; x = xs()) { lw << x.value(); } - if (lw.size() == 0) { - return intercut_policy::on_empty_labels(dd); - } + if (lw.size() == 0) { return intercut_policy::on_empty_labels(dd); } } - if (n.is_terminal()) { - return intercut_policy::on_terminal_input(n.value(), dd, hit_levels); - } + if (n.is_terminal()) { return intercut_policy::on_terminal_input(n.value(), dd, hit_levels); } file_stream ls(hit_levels); typename intercut_policy::label_type l = ls.pull(); @@ -221,13 +217,11 @@ namespace adiar::internal shared_file dd_levels; { file_writer lw(dd_levels); - dd_support(dd, [&lw](const typename intercut_policy::label_type x) { - lw << x; - }); + dd_support(dd, [&lw](const typename intercut_policy::label_type x) { lw << x; }); } // Add request for root in the queue - pq_t intercut_pq({dd_levels, hit_levels}, pq_memory, max_pq_size, stats_intercut.lpq); + pq_t intercut_pq({ dd_levels, hit_levels }, pq_memory, max_pq_size, stats_intercut.lpq); intercut_pq.push(intercut_req(ptr_uint64::nil(), n.uid(), std::min(l, n.label()))); // Process nodes of the decision diagram in topological order @@ -236,39 +230,32 @@ namespace adiar::internal intercut_pq.setup_next_level(); const typename intercut_policy::label_type out_label = intercut_pq.current_level(); - typename intercut_policy::id_type out_id = 0; + typename intercut_policy::id_type out_id = 0; const bool hit_level = out_label == l; // Forward to next label to cut on after this level - while (ls.can_pull() && l <= out_label) { - l = ls.pull(); - } + while (ls.can_pull() && l <= out_label) { l = ls.pull(); } - if (!ls.can_pull() && l <= out_label) { - l = intercut_policy::max_label + 1; - } + if (!ls.can_pull() && l <= out_label) { l = intercut_policy::max_label + 1; } // Update max 1-level cut out_arcs->max_1level_cut = std::max(out_arcs->max_1level_cut, intercut_pq.size()); // Resolve requests that end at the cut for this level - while (intercut_pq.can_pull() && intercut_pq.peek().target().label() == intercut_pq.peek().level()) { - while (n.uid() < intercut_pq.top().target()) { - n = in_nodes.pull(); - } + while (intercut_pq.can_pull() + && intercut_pq.peek().target().label() == intercut_pq.peek().level()) { + while (n.uid() < intercut_pq.top().target()) { n = in_nodes.pull(); } adiar_assert(n.uid() == intercut_pq.top().target(), "should always find desired node"); - const intercut_rec r = hit_level - ? intercut_policy::hit_existing(n) - : intercut_policy::miss_existing(n); + const intercut_rec r = + hit_level ? intercut_policy::hit_existing(n) : intercut_policy::miss_existing(n); if (intercut_policy::may_skip && std::holds_alternative(r)) { const intercut_rec_skipto rs = std::get(r); - if (rs.tgt.is_terminal() - && intercut_pq.top().source().is_nil() + if (rs.tgt.is_terminal() && intercut_pq.top().source().is_nil() && !cut_terminal(out_label, l, rs.tgt.value())) { return intercut_policy::terminal(rs.tgt.value()); } @@ -276,65 +263,64 @@ namespace adiar::internal // better with 'intercut_policy::on_terminal_input' but where the // label file are only of the remaining labels. - intercut_in__pq> - (aw, intercut_pq, out_label, n.uid(), rs.tgt, l); + intercut_in__pq>( + aw, intercut_pq, out_label, n.uid(), rs.tgt, l); } else { const intercut_rec_output ro = std::get(r); const node::uid_type out_uid(out_label, out_id++); - intercut_out__pq::forward - (aw, intercut_pq, out_uid.as_ptr(false), ro.low, out_label, l); + intercut_out__pq::forward( + aw, intercut_pq, out_uid.as_ptr(false), ro.low, out_label, l); - intercut_out__pq::forward - (aw, intercut_pq, out_uid.as_ptr(true), ro.high, out_label, l); + intercut_out__pq::forward( + aw, intercut_pq, out_uid.as_ptr(true), ro.high, out_label, l); - intercut_in__pq - (aw, intercut_pq, out_label, n.uid(), out_uid, l); + intercut_in__pq( + aw, intercut_pq, out_label, n.uid(), out_uid, l); } } // Resolve requests that end after the cut for this level - while(intercut_pq.can_pull()) { + while (intercut_pq.can_pull()) { adiar_assert(out_label <= l, "the last iteration in this case is for the very last label to cut on"); - const intercut_req request = intercut_pq.top(); + const intercut_req request = intercut_pq.top(); const intercut_rec_output ro = intercut_policy::hit_cut(request.target()); const node::uid_type out_uid(out_label, out_id++); - intercut_out__pq::forward - (aw, intercut_pq, out_uid.as_ptr(false), ro.low, out_label, l); + intercut_out__pq::forward( + aw, intercut_pq, out_uid.as_ptr(false), ro.low, out_label, l); - intercut_out__pq::forward - (aw, intercut_pq, out_uid.as_ptr(true), ro.high, out_label, l); + intercut_out__pq::forward( + aw, intercut_pq, out_uid.as_ptr(true), ro.high, out_label, l); - intercut_in__pq - (aw, intercut_pq, out_label, request.target(), out_uid, l); + intercut_in__pq( + aw, intercut_pq, out_label, request.target(), out_uid, l); } // Update meta data - if (out_id > 0) { - aw.push(level_info(out_label, out_id)); - } + if (out_id > 0) { aw.push(level_info(out_label, out_id)); } } return typename intercut_policy::__dd_type(out_arcs, ep); } - template - size_t __intercut_2level_upper_bound(const typename intercut_policy::dd_type &dd) + template + size_t + __intercut_2level_upper_bound(const typename intercut_policy::dd_type& dd) { - const cut ct = cut(intercut_policy::cut_false_terminal, - intercut_policy::cut_true_terminal); + const cut ct = cut(intercut_policy::cut_false_terminal, intercut_policy::cut_true_terminal); const safe_size_t max_1level_cut = dd.max_1level_cut(ct); return to_size((3 * intercut_policy::mult_factor * max_1level_cut) / 2 + 2); } - template - typename intercut_policy::__dd_type intercut(const exec_policy &ep, - const typename intercut_policy::dd_type &dd, - const generator &xs) + template + typename intercut_policy::__dd_type + intercut(const exec_policy& ep, + const typename intercut_policy::dd_type& dd, + const generator& xs) { // Compute amount of memory available for auxiliary data structures after // having opened all streams. @@ -353,34 +339,35 @@ namespace adiar::internal const size_t pq_memory_fits = intercut_priority_queue_t::memory_fits(pq_memory); - const bool internal_only = ep.template get() == exec_policy::memory::Internal; - const bool external_only = ep.template get() == exec_policy::memory::External; + const bool internal_only = + ep.template get() == exec_policy::memory::Internal; + const bool external_only = + ep.template get() == exec_policy::memory::External; const size_t pq_bound = __intercut_2level_upper_bound(dd); const size_t max_pq_size = internal_only ? std::min(pq_memory_fits, pq_bound) : pq_bound; - if(!external_only && max_pq_size <= no_lookahead_bound()) { + if (!external_only && max_pq_size <= no_lookahead_bound()) { #ifdef ADIAR_STATS stats_intercut.lpq.unbucketed += 1u; #endif - return __intercut> - (ep, dd, xs, pq_memory, max_pq_size); - } else if(!external_only && max_pq_size <= pq_memory_fits) { + return __intercut>( + ep, dd, xs, pq_memory, max_pq_size); + } else if (!external_only && max_pq_size <= pq_memory_fits) { #ifdef ADIAR_STATS stats_intercut.lpq.internal += 1u; #endif return __intercut> - (ep, dd, xs, pq_memory, max_pq_size); + intercut_priority_queue_t>( + ep, dd, xs, pq_memory, max_pq_size); } else { #ifdef ADIAR_STATS stats_intercut.lpq.external += 1u; #endif return __intercut> - (ep, dd, xs, pq_memory, max_pq_size); + intercut_priority_queue_t>( + ep, dd, xs, pq_memory, max_pq_size); } } } diff --git a/src/adiar/internal/algorithms/nested_sweeping.h b/src/adiar/internal/algorithms/nested_sweeping.h index cf0b92aa2..50198baf9 100644 --- a/src/adiar/internal/algorithms/nested_sweeping.h +++ b/src/adiar/internal/algorithms/nested_sweeping.h @@ -1,20 +1,19 @@ #ifndef ADIAR_INTERNAL_ALGORITHMS_NESTED_SWEEPING_H #define ADIAR_INTERNAL_ALGORITHMS_NESTED_SWEEPING_H +#include #include #include -#include - -#include -#include -#include -#include #include +#include #include #include #include #include +#include +#include +#include namespace adiar::internal { @@ -28,17 +27,15 @@ namespace adiar::internal /// Struct to hold statistics extern statistics::nested_sweeping_t stats; - template + template inline void - __reduce_decrement_cut(cuts_t &c, const pointer_type& p) + __reduce_decrement_cut(cuts_t& c, const pointer_type& p) { if (p.is_terminal()) { c[cut::All]--; c[cut(!p.value(), p.value())]--; } else { - for(size_t ct = 0u; ct < cut::size; ct++) { - c[ct]--; - } + for (size_t ct = 0u; ct < cut::size; ct++) { c[ct]--; } } } @@ -51,23 +48,21 @@ namespace adiar::internal /// /// \see __reduce_level //////////////////////////////////////////////////////////////////////////// - template + template void - __reduce_level__fast(arc_stream_t &arcs, + __reduce_level__fast(arc_stream_t& arcs, const typename dd_policy::label_type label, - pq_t &pq, - node_writer &out_writer, - [[maybe_unused]] statistics::reduce_t &stats = internal::stats_reduce) + pq_t& pq, + node_writer& out_writer, + [[maybe_unused]] statistics::reduce_t& stats = internal::stats_reduce) { // Count number of arcs that cross this level (including tainted ones) // TODO: move into helper function - cuts_t one_level_cut = {{ 0u, 0u, 0u, 0u }}; + cuts_t one_level_cut = { { 0u, 0u, 0u, 0u } }; __reduce_cut_add(one_level_cut, pq.size_without_terminals(), pq.terminals(false) + arcs.unread_terminals(false), - pq.terminals(true) + arcs.unread_terminals(true)); + pq.terminals(true) + arcs.unread_terminals(true)); // Remember the latest terminal value due to Reduction Rule 1 bool terminal_val = false /* <-- dummy value */; @@ -76,9 +71,12 @@ namespace adiar::internal typename dd_policy::id_type out_id = dd_policy::max_id; // Remember previously outputted node - node out_node = { node::uid_type(), node::pointer_type::nil(), node::pointer_type::nil() } /* <-- dummy value */; + node out_node = { node::uid_type(), + node::pointer_type::nil(), + node::pointer_type::nil() } /* <-- dummy value */; - while (pq.can_pull() || (arcs.can_pull_terminal() && arcs.peek_terminal().source().label() == label)) { + while (pq.can_pull() + || (arcs.can_pull_terminal() && arcs.peek_terminal().source().label() == label)) { // TODO (MDD / QMDD): // Use __reduce_get_next node_type::outdegree times to create a node_type::children_type. const arc e_high = __reduce_get_next(pq, arcs); @@ -135,7 +133,7 @@ namespace adiar::internal while (arcs.can_pull_internal() && arcs.peek_internal().target() == n.uid()) { // The out_idx is included in arc.source() pulled from the internal arcs. const node::pointer_type s = arcs.pull_internal().source(); - pq.push(arc(s,t)); + pq.push(arc(s, t)); } } @@ -148,9 +146,7 @@ namespace adiar::internal const size_t width = dd_policy::max_id - out_id; out_writer.unsafe_push(level_info(label, width)); - if (width > 1u) { - out_writer.unsafe_set_canonical(false); - } + if (width > 1u) { out_writer.unsafe_set_canonical(false); } } // Set up priority queue for next level (or collapse to a terminal) @@ -170,9 +166,7 @@ namespace adiar::internal /// /// \see sorter nested_sweep ////////////////////////////////////////////////////////////////////////// - template + template class roots_sorter { public: @@ -228,12 +222,16 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////// static tpie::memory_size_type memory_usage(tpie::memory_size_type no_elements) - { return sorter_t::memory_usage(no_elements); } + { + return sorter_t::memory_usage(no_elements); + } //////////////////////////////////////////////////////////////////////// static tpie::memory_size_type memory_fits(tpie::memory_size_type memory_bytes) - { return sorter_t::memory_fits(memory_bytes); } + { + return sorter_t::memory_fits(memory_bytes); + } public: //////////////////////////////////////////////////////////////////////// @@ -241,13 +239,14 @@ namespace adiar::internal : _sorter_ptr(sorter_t::make_unique(memory_bytes, no_arcs)) , _memory_bytes(memory_bytes) , _no_arcs(no_arcs) - { } + {} public: //////////////////////////////////////////////////////////////////////// /// \brief Whether a request can be pushed. //////////////////////////////////////////////////////////////////////// - bool can_push() + bool + can_push() { return _sorter_ptr->can_push(); } @@ -255,26 +254,26 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////// /// \brief Push request (marked as from outer sweep). //////////////////////////////////////////////////////////////////////// - void push(const value_type& v) + void + push(const value_type& v) { adiar_assert(v.target.first().is_node(), - "Requests should have at least one internal node"); + "Requests should have at least one internal node"); - _max_source = _max_source.is_nil() - ? v.data.source - : std::max(_max_source, v.data.source); + _max_source = _max_source.is_nil() ? v.data.source : std::max(_max_source, v.data.source); // TODO: support requests with more than just the source - _sorter_ptr->push({ v.target, {}, {flag(v.data.source)} }); + _sorter_ptr->push({ v.target, {}, { flag(v.data.source) } }); } //////////////////////////////////////////////////////////////////////// /// \brief Convert arc to request (and mark it as from outer sweep). //////////////////////////////////////////////////////////////////////// - void push(const reduce_arc& a) + void + push(const reduce_arc& a) { adiar_assert(!a.target().is_terminal(), - "Arcs to terminals always reside in the outer PQ"); + "Arcs to terminals always reside in the outer PQ"); // TODO: support requests with more than just the source @@ -282,9 +281,9 @@ namespace adiar::internal // target to nil? if constexpr (value_type::cardinality == 1u) { - push(value_type({a.target()}, {}, {a.source()})); + push(value_type({ a.target() }, {}, { a.source() })); } else if constexpr (value_type::cardinality == 2u) { - push(value_type({a.target(), value_type::pointer_type::nil()}, {}, {a.source()})); + push(value_type({ a.target(), value_type::pointer_type::nil() }, {}, { a.source() })); } else { static_assert(value_type::cardinality <= 2u, "Missing implementation for larger than binary combinators"); @@ -292,19 +291,29 @@ namespace adiar::internal } //////////////////////////////////////////////////////////////////////// - void sort() - { _sorter_ptr->sort(); } + void + sort() + { + _sorter_ptr->sort(); + } //////////////////////////////////////////////////////////////////////// - bool can_pull() /*const*/ - { return _sorter_ptr->can_pull(); } + bool + can_pull() /*const*/ + { + return _sorter_ptr->can_pull(); + } //////////////////////////////////////////////////////////////////////// - value_type top() /*const*/ - { return _sorter_ptr->top(); } + value_type + top() /*const*/ + { + return _sorter_ptr->top(); + } //////////////////////////////////////////////////////////////////////// - value_type pull() + value_type + pull() { // TODO: decrement terminal count (is this number ever relevant before // it already is 'reset()'?) @@ -312,7 +321,8 @@ namespace adiar::internal } //////////////////////////////////////////////////////////////////////// - void reset() + void + reset() { sorter_t::reset_unique(_sorter_ptr, _memory_bytes, _no_arcs); _max_source = value_type::pointer_type::nil(); @@ -324,30 +334,40 @@ namespace adiar::internal /// \details This leaves the other in an illegal state that requires a /// call to `reset()`. //////////////////////////////////////////////////////////////////////// - void move(roots_sorter &o) + void + move(roots_sorter& o) { _sorter_ptr = std::move(o._sorter_ptr); _max_source = o._max_source; } //////////////////////////////////////////////////////////////////////// - size_t size() /*const*/ - { return _sorter_ptr->size(); } + size_t + size() /*const*/ + { + return _sorter_ptr->size(); + } - bool empty() /*const*/ - { return _sorter_ptr->empty(); } + bool + empty() /*const*/ + { + return _sorter_ptr->empty(); + } //////////////////////////////////////////////////////////////////////// /// \brief Level of the deepest source //////////////////////////////////////////////////////////////////////// - typename value_type::label_type deepest_source() - { return _max_source.is_nil() ? no_level : _max_source.label(); } + typename value_type::label_type + deepest_source() + { + return _max_source.is_nil() ? no_level : _max_source.label(); + } }; ////////////////////////////////////////////////////////////////////////// /// \brief Default priority queue for the Outer Up Sweep. ////////////////////////////////////////////////////////////////////////// - template + template using up__pq_t = reduce_priority_queue; ////////////////////////////////////////////////////////////////////////// @@ -359,7 +379,7 @@ namespace adiar::internal /// /// \see pq_t, levelized_priority_queue, nested_sweep ////////////////////////////////////////////////////////////////////////// - template + template class up__pq_decorator { public: @@ -383,13 +403,13 @@ namespace adiar::internal /// \brief Reference to the outer sweep's (levelized) priority queue. //////////////////////////////////////////////////////////////////////// // TODO (optimisation): public inheritance? - outer_pq_t &_outer_pq; + outer_pq_t& _outer_pq; //////////////////////////////////////////////////////////////////////// /// \brief Reference to the sorter in the outer sweep that contains the /// root requests generated for the next inner sweep. //////////////////////////////////////////////////////////////////////// - outer_roots_t &_outer_roots; + outer_roots_t& _outer_roots; //////////////////////////////////////////////////////////////////////// /// \brief Type of a level. @@ -413,70 +433,95 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////// /// \brief Instantiate decorator. //////////////////////////////////////////////////////////////////////// - up__pq_decorator(outer_pq_t &outer_pq, - outer_roots_t &outer_roots, + up__pq_decorator(outer_pq_t& outer_pq, + outer_roots_t& outer_roots, const level_type next_inner) : _outer_pq(outer_pq) , _outer_roots(outer_roots) , _next_inner(next_inner) - { } + {} public: //////////////////////////////////////////////////////////////////////// /// \brief Number of terminals (of each type) placed within the priority /// queue. //////////////////////////////////////////////////////////////////////// - size_t terminals(const bool terminal_value) const - { return _outer_pq.terminals(terminal_value); } + size_t + terminals(const bool terminal_value) const + { + return _outer_pq.terminals(terminal_value); + } //////////////////////////////////////////////////////////////////////// /// \brief Numer of elements in both the priority queue and the sorter. //////////////////////////////////////////////////////////////////////// - size_t size() const - { return _outer_pq.size() + _outer_roots.size(); } + size_t + size() const + { + return _outer_pq.size() + _outer_roots.size(); + } //////////////////////////////////////////////////////////////////////// /// \brief Total number of arcs (across all levels) ignoring terminals. //////////////////////////////////////////////////////////////////////// - size_t size_without_terminals() const - { return size() - terminals(false) - terminals(true); } + size_t + size_without_terminals() const + { + return size() - terminals(false) - terminals(true); + } //////////////////////////////////////////////////////////////////////// /// \brief Whether the current level is empty. //////////////////////////////////////////////////////////////////////// - bool empty_level() const - { return _outer_pq.empty_level(); } + bool + empty_level() const + { + return _outer_pq.empty_level(); + } //////////////////////////////////////////////////////////////////////// /// \brief Whether there are more elements to pull for this level. //////////////////////////////////////////////////////////////////////// - bool can_pull() const - { return _outer_pq.can_pull(); } + bool + can_pull() const + { + return _outer_pq.can_pull(); + } //////////////////////////////////////////////////////////////////////// /// \brief Obtain and remove the next element from this level. //////////////////////////////////////////////////////////////////////// - reduce_arc pull() - { return _outer_pq.pull(); } + reduce_arc + pull() + { + return _outer_pq.pull(); + } //////////////////////////////////////////////////////////////////////// /// \brief Obtain the next element from this level. //////////////////////////////////////////////////////////////////////// - reduce_arc top() - { return _outer_pq.top(); } + reduce_arc + top() + { + return _outer_pq.top(); + } //////////////////////////////////////////////////////////////////////// /// \brief Remove the top arc on the current level. //////////////////////////////////////////////////////////////////////// - void pop() - { _outer_pq.pull(); } + void + pop() + { + _outer_pq.pull(); + } //////////////////////////////////////////////////////////////////////// /// \brief Adds an element to the priority queue or the sorter, /// depending on the level. Terminals always stay in the priority /// queue //////////////////////////////////////////////////////////////////////// - void push(const reduce_arc &a) + void + push(const reduce_arc& a) { if (a.source().is_nil() || (a.source().label() < _next_inner && a.target().is_node())) { #ifdef ADIAR_STATS @@ -503,7 +548,8 @@ namespace adiar::internal /// /// \see request request_with_data //////////////////////////////////////////////////////////////////////// - void push(const typename outer_roots_t::value_type &e) + void + push(const typename outer_roots_t::value_type& e) { adiar_assert(e.data.source.is_nil() || e.data.source.label() < _next_inner); if (e.target.first().is_terminal()) { @@ -514,7 +560,7 @@ namespace adiar::internal } else { #ifdef ADIAR_STATS const size_t modifying = e.targets() > 1; // 0 or 1 - nested_sweeping::stats.inner_down.requests.modifying += modifying; + nested_sweeping::stats.inner_down.requests.modifying += modifying; nested_sweeping::stats.inner_down.requests.preserving += 1 - modifying; // !modifying #endif _outer_roots.push(e); @@ -525,25 +571,29 @@ namespace adiar::internal /// \brief Set up the next nonempty level in the priority queue and the /// sorter (down to the given `stop_level`). //////////////////////////////////////////////////////////////////////// - void setup_next_level(level_type stop_level = no_label) + void + setup_next_level(level_type stop_level = no_label) { _outer_pq.setup_next_level(stop_level); adiar_assert(_next_inner <= _outer_pq.current_level(), - "Outer PQ stays below next Inner Level"); + "Outer PQ stays below next Inner Level"); } //////////////////////////////////////////////////////////////////////// /// \brief Whether the priority queue and the sorter are empty. //////////////////////////////////////////////////////////////////////// - bool empty() const - { return size() == 0u; } + bool + empty() const + { + return size() == 0u; + } }; ////////////////////////////////////////////////////////////////////////// /// \brief Class to obtain from the Inner Down Sweep what is the next /// level (ahead of the current one being processed). ////////////////////////////////////////////////////////////////////////// - template + template class inner_iterator { public: @@ -553,18 +603,20 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////// static tpie::memory_size_type memory_usage() - { return level_info_stream<>::memory_usage(); } + { + return level_info_stream<>::memory_usage(); + } private: level_info_stream<> _lis; - nesting_policy &_policy_impl; + nesting_policy& _policy_impl; public: - inner_iterator(const typename nesting_policy::shared_arc_file_type &dag, - nesting_policy &policy_impl) + inner_iterator(const typename nesting_policy::shared_arc_file_type& dag, + nesting_policy& policy_impl) : _lis(dag) , _policy_impl(policy_impl) - { } + {} public: static constexpr level_type end = static_cast(-1); @@ -575,7 +627,8 @@ namespace adiar::internal /// \returns The next inner level that should be recursed on (or `end` /// if none are left) //////////////////////////////////////////////////////////////////////// - level_type next_inner() + level_type + next_inner() { while (_lis.can_pull()) { const level_type l = _lis.pull().level(); @@ -601,7 +654,7 @@ namespace adiar::internal /// /// \see levelized_priority_queue, nested_sweep ////////////////////////////////////////////////////////////////////////// - template + template class down__pq_decorator { public: @@ -632,7 +685,7 @@ namespace adiar::internal /// \brief Reference to the inner sweep's (levelized) priority queue. //////////////////////////////////////////////////////////////////////// // TODO (optimisation): public inheritance? - inner_pq_t &_inner_pq; + inner_pq_t& _inner_pq; //////////////////////////////////////////////////////////////////////////// /// \brief Instantiation of the comparator between elements. @@ -643,7 +696,7 @@ namespace adiar::internal /// \brief Reference to the sorter in the outer sweep that contains the /// root requests generated for the next inner sweep. //////////////////////////////////////////////////////////////////////// - outer_roots_t &_outer_roots; + outer_roots_t& _outer_roots; public: //////////////////////////////////////////////////////////////////////////// @@ -655,53 +708,72 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////// /// \brief Instantiate decorator. //////////////////////////////////////////////////////////////////////// - down__pq_decorator(inner_pq_t &inner_pq, outer_roots_t &outer_roots) + down__pq_decorator(inner_pq_t& inner_pq, outer_roots_t& outer_roots) : _inner_pq(inner_pq) , _outer_roots(outer_roots) - { } + {} public: //////////////////////////////////////////////////////////////////////// /// \brief Whether there is any current level to pull elements from. //////////////////////////////////////////////////////////////////////// - bool has_current_level() const - { return _inner_pq.has_current_level(); } + bool + has_current_level() const + { + return _inner_pq.has_current_level(); + } //////////////////////////////////////////////////////////////////////// /// \brief The label of the current level. //////////////////////////////////////////////////////////////////////// - level_type current_level() const - { return _inner_pq.current_level(); } + level_type + current_level() const + { + return _inner_pq.current_level(); + } //////////////////////////////////////////////////////////////////////// /// \brief Whether there are any more (possibly all empty) levels. //////////////////////////////////////////////////////////////////////// - bool has_next_level() /*const*/ - { return _inner_pq.has_next_level(); } + bool + has_next_level() /*const*/ + { + return _inner_pq.has_next_level(); + } //////////////////////////////////////////////////////////////////////// /// \brief The label of the next (possibly empty) level. //////////////////////////////////////////////////////////////////////// - level_type next_level() /*const*/ - { return _inner_pq.next_level(); } + level_type + next_level() /*const*/ + { + return _inner_pq.next_level(); + } //////////////////////////////////////////////////////////////////////// /// \brief Whether one can push elements. //////////////////////////////////////////////////////////////////////// - bool can_push() /*const*/ - { return _inner_pq.can_push(); } + bool + can_push() /*const*/ + { + return _inner_pq.can_push(); + } //////////////////////////////////////////////////////////////////////// /// \brief Push request to inner priority queue. //////////////////////////////////////////////////////////////////////// - void push(const value_type& e) - { _inner_pq.push(e); } + void + push(const value_type& e) + { + _inner_pq.push(e); + } //////////////////////////////////////////////////////////////////////// /// \brief Set up the next nonempty level in the priority queue and the /// sorter (down to the given `stop_level`). //////////////////////////////////////////////////////////////////////// - void setup_next_level(level_type stop_level = no_label) + void + setup_next_level(level_type stop_level = no_label) { if (_outer_roots.can_pull()) { stop_level = std::min(stop_level, _outer_roots.top().level()); @@ -716,7 +788,8 @@ namespace adiar::internal /// /// \see can_pull, empty //////////////////////////////////////////////////////////////////////// - bool empty_level() const + bool + empty_level() const { return _inner_pq.empty_level() && (!_outer_roots.can_pull() || _outer_roots.top().level() != current_level()); @@ -725,19 +798,21 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////// /// \brief Whether there are more requests to pull for this level. //////////////////////////////////////////////////////////////////////// - bool can_pull() const - { return !empty_level(); } + bool + can_pull() const + { + return !empty_level(); + } //////////////////////////////////////////////////////////////////////// /// \brief Obtain the top request of this level. /// /// \pre `can_pull() == true` //////////////////////////////////////////////////////////////////////// - value_type top() + value_type + top() { - return __pq_first() - ? _inner_pq.top() - : __essential(_outer_roots.top()); + return __pq_first() ? _inner_pq.top() : __essential(_outer_roots.top()); } //////////////////////////////////////////////////////////////////////// @@ -745,19 +820,21 @@ namespace adiar::internal /// /// \pre `can_pull() == true` //////////////////////////////////////////////////////////////////////// - value_type peek() - { return top(); } + value_type + peek() + { + return top(); + } //////////////////////////////////////////////////////////////////////// /// \brief Obtain and remove the top request of this level. /// /// \pre `can_pull() == true` //////////////////////////////////////////////////////////////////////// - value_type pull() + value_type + pull() { - return __pq_first() - ? _inner_pq.pull() - : __essential(_outer_roots.pull()); + return __pq_first() ? _inner_pq.pull() : __essential(_outer_roots.pull()); } //////////////////////////////////////////////////////////////////////// @@ -765,29 +842,39 @@ namespace adiar::internal /// /// \pre `can_pull() == true` //////////////////////////////////////////////////////////////////////// - void pop() - { pull(); } + void + pop() + { + pull(); + } //////////////////////////////////////////////////////////////////////// /// \brief The number of requests in the priority queue and the sorter. //////////////////////////////////////////////////////////////////////// - size_t size() /*const*/ - { return _inner_pq.size() + _outer_roots.size(); } + size_t + size() /*const*/ + { + return _inner_pq.size() + _outer_roots.size(); + } //////////////////////////////////////////////////////////////////////// /// \brief Whether the priority queue and the sorter are empty. //////////////////////////////////////////////////////////////////////// - bool empty() /*const*/ - { return _inner_pq.empty() && _outer_roots.empty(); } + bool + empty() /*const*/ + { + return _inner_pq.empty() && _outer_roots.empty(); + } private: //////////////////////////////////////////////////////////////////////// /// \brief Predicate whether to take the next element from the priority /// queue or not. If not, it should be take from the sorter. //////////////////////////////////////////////////////////////////////// - bool __pq_first() + bool + __pq_first() { - if (_inner_pq.empty_level()) { return false; } + if (_inner_pq.empty_level()) { return false; } if (!_outer_roots.can_pull()) { return true; } const level_type _outer_roots_level = _outer_roots.top().level(); @@ -796,7 +883,8 @@ namespace adiar::internal return _v_comparator(_inner_pq.top(), _outer_roots.top()); } - value_type __essential(const value_type &r) + value_type + __essential(const value_type& r) { // TODO: generalize into a `map(r.target, essential)` in // . Ensure everything can be @@ -807,9 +895,8 @@ namespace adiar::internal typename value_type::target_t r_tgt; if constexpr (value_type::cardinality == 1) { r_tgt = typename value_type::target_t(essential(r.target[0])); - } else {// if constexpr (value_type::cardinality == 2) { - r_tgt = typename value_type::target_t(essential(r.target[0]), - essential(r.target[1])); + } else { // if constexpr (value_type::cardinality == 2) { + r_tgt = typename value_type::target_t(essential(r.target[0]), essential(r.target[1])); } return value_type(r_tgt, {}, r.data); } @@ -822,16 +909,15 @@ namespace adiar::internal /// \par Side Effects: /// Sorts and resets the given `outer_roots` sorter. ////////////////////////////////////////////////////////////////////////// - template + template typename nesting_policy::__dd_type - down(const exec_policy &ep, - nesting_policy &policy_impl, - const typename nesting_policy::shared_node_file_type &outer_file, - outer_roots_t &outer_roots, + down(const exec_policy& ep, + nesting_policy& policy_impl, + const typename nesting_policy::shared_node_file_type& outer_file, + outer_roots_t& outer_roots, const size_t inner_memory) { - adiar_assert(outer_roots.size() > 0, - "Nested Sweep needs one or more roots"); + adiar_assert(outer_roots.size() > 0, "Nested Sweep needs one or more roots"); outer_roots.sort(); @@ -854,14 +940,14 @@ namespace adiar::internal /// Sweep to (1) switch based on `memory_mode` and (2) decorate the /// priority queue and the `roots_sorter`. ////////////////////////////////////////////////////////////////////////// - template + template inline typename nesting_policy::__dd_type - down__sweep_switch(const exec_policy &ep, - nesting_policy &policy_impl, - const typename nesting_policy::shared_node_file_type &outer_file, - outer_roots_t &outer_roots, + down__sweep_switch(const exec_policy& ep, + nesting_policy& policy_impl, + const typename nesting_policy::shared_node_file_type& outer_file, + outer_roots_t& outer_roots, const size_t inner_memory, - statistics::__alg_base::__lpq_t &lpq_stats) + statistics::__alg_base::__lpq_t& lpq_stats) { // --------------------------------------------------------------------- @@ -873,7 +959,7 @@ namespace adiar::internal // memory variant. const size_t inner_stream_memory = nesting_policy::stream_memory(); adiar_assert(inner_stream_memory <= inner_memory, - "There should be enough memory to include all streams"); + "There should be enough memory to include all streams"); // --------------------------------------------------------------------- // Case: Run Inner Sweep (with random access) @@ -884,45 +970,52 @@ namespace adiar::internal const size_t inner_pq_memory = policy_impl.pq_memory(inner_memory - inner_stream_memory); adiar_assert(inner_pq_memory <= inner_memory - inner_stream_memory, - "There should be enough memory to include all streams and priority queue"); + "There should be enough memory to include all streams and priority queue"); const size_t inner_remaining_memory = inner_memory - inner_stream_memory - inner_pq_memory; const size_t inner_pq_fits = - nesting_policy::template pq_t::memory_fits(inner_pq_memory); + nesting_policy::template pq_t::memory_fits( + inner_pq_memory); const size_t inner_pq_bound = policy_impl.pq_bound(outer_file, outer_roots.size()); - const bool external_only = ep.template get() == exec_policy::memory::External; + const bool external_only = + ep.template get() == exec_policy::memory::External; - const size_t inner_pq_max_size = ep.template get() == exec_policy::memory::Internal + const size_t inner_pq_max_size = + ep.template get() == exec_policy::memory::Internal ? std::min(inner_pq_fits, inner_pq_bound) : inner_pq_bound; // TODO (bdd_compose): ask 'nesting_policy' implementation for the initalizer list - if(!external_only && inner_pq_max_size <= no_lookahead_bound(outer_roots_t::value_type::cardinality)) { + if (!external_only + && inner_pq_max_size <= no_lookahead_bound(outer_roots_t::value_type::cardinality)) { #ifdef ADIAR_STATS lpq_stats.unbucketed += 1u; #endif adiar_assert(inner_pq_max_size <= inner_pq_fits, - "'no_lookahead' implies it should (in practice) satisfy the '<='"); + "'no_lookahead' implies it should (in practice) satisfy the '<='"); using inner_pq_t = typename nesting_policy::template pq_t<0, memory_mode::Internal>; - inner_pq_t inner_pq({typename nesting_policy::dd_type(outer_file)}, - inner_pq_memory, inner_pq_max_size, + inner_pq_t inner_pq({ typename nesting_policy::dd_type(outer_file) }, + inner_pq_memory, + inner_pq_max_size, lpq_stats); using decorator_t = down__pq_decorator; decorator_t decorated_pq(inner_pq, outer_roots); return policy_impl.sweep_pq(ep, outer_file, decorated_pq, inner_remaining_memory); - } else if(!external_only && inner_pq_max_size <= inner_pq_fits) { + } else if (!external_only && inner_pq_max_size <= inner_pq_fits) { #ifdef ADIAR_STATS lpq_stats.internal += 1u; #endif - using inner_pq_t = typename nesting_policy::template pq_t; - inner_pq_t inner_pq({typename nesting_policy::dd_type(outer_file)}, - inner_pq_memory, inner_pq_max_size, + using inner_pq_t = + typename nesting_policy::template pq_t; + inner_pq_t inner_pq({ typename nesting_policy::dd_type(outer_file) }, + inner_pq_memory, + inner_pq_max_size, lpq_stats); using decorator_t = down__pq_decorator; @@ -933,9 +1026,11 @@ namespace adiar::internal #ifdef ADIAR_STATS lpq_stats.external += 1u; #endif - using inner_pq_t = typename nesting_policy::template pq_t; - inner_pq_t inner_pq({typename nesting_policy::dd_type(outer_file)}, - inner_pq_memory, inner_pq_max_size, + using inner_pq_t = + typename nesting_policy::template pq_t; + inner_pq_t inner_pq({ typename nesting_policy::dd_type(outer_file) }, + inner_pq_memory, + inner_pq_max_size, lpq_stats); using decorator_t = down__pq_decorator; @@ -948,7 +1043,7 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////// /// \brief Default priority queue for the Inner Up Sweep. ////////////////////////////////////////////////////////////////////////// - template + template using up__pq_t = outer::up__pq_t; ////////////////////////////////////////////////////////////////////////// @@ -961,7 +1056,7 @@ namespace adiar::internal /// /// \see levelized_priority_queue, nested_sweep ////////////////////////////////////////////////////////////////////////// - template + template class up__pq_decorator { public: @@ -990,7 +1085,7 @@ namespace adiar::internal /// \brief Reference to the inner sweep's (levelized) priority queue. //////////////////////////////////////////////////////////////////////// // TODO (optimisation): public inheritance? - inner_pq_t &_inner_pq; + inner_pq_t& _inner_pq; //////////////////////////////////////////////////////////////////////////// /// \brief Instantiation of the comparator between elements. @@ -1000,7 +1095,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////// /// \brief Reference to the outer sweep's (levelized) priority queue. //////////////////////////////////////////////////////////////////////// - outer_pq_t &_outer_pq; + outer_pq_t& _outer_pq; public: //////////////////////////////////////////////////////////////////////////// @@ -1012,46 +1107,62 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////// /// \brief Instantiate decorator. //////////////////////////////////////////////////////////////////////// - up__pq_decorator(inner_pq_t &inner_pq, outer_pq_t &outer_pq) + up__pq_decorator(inner_pq_t& inner_pq, outer_pq_t& outer_pq) : _inner_pq(inner_pq) , _outer_pq(outer_pq) - { } + {} public: //////////////////////////////////////////////////////////////////////// /// \brief Whether there is any current level to pull elements from. //////////////////////////////////////////////////////////////////////// - bool has_current_level() const - { return _inner_pq.has_current_level(); } + bool + has_current_level() const + { + return _inner_pq.has_current_level(); + } //////////////////////////////////////////////////////////////////////// /// \brief The label of the current level. //////////////////////////////////////////////////////////////////////// - level_type current_level() const - { return _inner_pq.current_level(); } + level_type + current_level() const + { + return _inner_pq.current_level(); + } //////////////////////////////////////////////////////////////////////// /// \brief Whether there are any more (possibly all empty) levels. //////////////////////////////////////////////////////////////////////// - bool has_next_level() /*const*/ - { return _inner_pq.has_next_level(); } + bool + has_next_level() /*const*/ + { + return _inner_pq.has_next_level(); + } //////////////////////////////////////////////////////////////////////// /// \brief The label of the next (possibly empty) level. //////////////////////////////////////////////////////////////////////// - level_type next_level() /*const*/ - { return _inner_pq.next_level(); } + level_type + next_level() /*const*/ + { + return _inner_pq.next_level(); + } //////////////////////////////////////////////////////////////////////// /// \brief Whether one can push elements. //////////////////////////////////////////////////////////////////////// - bool can_push() const - { return true; } + bool + can_push() const + { + return true; + } //////////////////////////////////////////////////////////////////////// /// \brief Push request to inner priority queue. //////////////////////////////////////////////////////////////////////// - void push(const value_type& v) + void + push(const value_type& v) { if (v.source().is_flagged()) { #ifdef ADIAR_STATS @@ -1070,8 +1181,11 @@ namespace adiar::internal /// \brief Set up the next nonempty level in the priority queue and the /// sorter (down to the given `stop_level`). //////////////////////////////////////////////////////////////////////// - void setup_next_level(level_type stop_level = no_label) - { _inner_pq.setup_next_level(stop_level); } + void + setup_next_level(level_type stop_level = no_label) + { + _inner_pq.setup_next_level(stop_level); + } //////////////////////////////////////////////////////////////////////// /// \brief Whether this level is empty of requests. @@ -1080,61 +1194,80 @@ namespace adiar::internal /// /// \see can_pull, empty //////////////////////////////////////////////////////////////////////// - bool empty_level() const - { return _inner_pq.empty_level(); } + bool + empty_level() const + { + return _inner_pq.empty_level(); + } //////////////////////////////////////////////////////////////////////// /// \brief Whether there are more requests to pull for this level. //////////////////////////////////////////////////////////////////////// - bool can_pull() const - { return _inner_pq.can_pull(); } + bool + can_pull() const + { + return _inner_pq.can_pull(); + } //////////////////////////////////////////////////////////////////////// /// \brief Obtain the top request of this level. /// /// \pre `can_pull() == true` //////////////////////////////////////////////////////////////////////// - value_type top() - { return _inner_pq.top(); } + value_type + top() + { + return _inner_pq.top(); + } //////////////////////////////////////////////////////////////////////// /// \brief Obtain the top request of this level. /// /// \pre `can_pull() == true` //////////////////////////////////////////////////////////////////////// - value_type peek() - { return _inner_pq.peek(); } + value_type + peek() + { + return _inner_pq.peek(); + } //////////////////////////////////////////////////////////////////////// /// \brief Obtain and remove the top request of this level. /// /// \pre `can_pull() == true` //////////////////////////////////////////////////////////////////////// - value_type pull() - { return _inner_pq.pull(); } + value_type + pull() + { + return _inner_pq.pull(); + } //////////////////////////////////////////////////////////////////////// /// \brief Remove the top arc on the current level. /// /// \pre `can_pull() == true` //////////////////////////////////////////////////////////////////////// - void pop() - { _inner_pq.pop(); } + void + pop() + { + _inner_pq.pop(); + } //////////////////////////////////////////////////////////////////////// /// \brief Number of terminals (of each type) placed within either of /// the priority queues. //////////////////////////////////////////////////////////////////////// - size_t terminals(const bool terminal_value) const + size_t + terminals(const bool terminal_value) const { - return _outer_pq.terminals(terminal_value) - + _inner_pq.terminals(terminal_value); + return _outer_pq.terminals(terminal_value) + _inner_pq.terminals(terminal_value); } //////////////////////////////////////////////////////////////////////// /// \brief Number of elements in both priority queues. //////////////////////////////////////////////////////////////////////// - size_t size() const + size_t + size() const { return _outer_pq.size() + _inner_pq.size(); } @@ -1143,17 +1276,20 @@ namespace adiar::internal /// \brief Total number of arcs (across all levels) ignoring terminals /// in both priority queues. //////////////////////////////////////////////////////////////////////// - size_t size_without_terminals() const + size_t + size_without_terminals() const { - return _outer_pq.size_without_terminals() - + _inner_pq.size_without_terminals(); + return _outer_pq.size_without_terminals() + _inner_pq.size_without_terminals(); } //////////////////////////////////////////////////////////////////////// /// \brief Whether the priority queue and the sorter are empty. //////////////////////////////////////////////////////////////////////// - bool empty() /*const*/ - { return _inner_pq.empty(); } + bool + empty() /*const*/ + { + return _inner_pq.empty(); + } }; ////////////////////////////////////////////////////////////////////////// @@ -1162,66 +1298,88 @@ namespace adiar::internal class up__arc_stream__decorator { private: - arc_stream<> &_inner_arcs; - const arc_stream<> &_outer_arcs; + arc_stream<>& _inner_arcs; + const arc_stream<>& _outer_arcs; public: - up__arc_stream__decorator(arc_stream<> &inner_arcs, - const arc_stream<> &outer_arcs) - : _inner_arcs(inner_arcs), _outer_arcs(outer_arcs) - { } + up__arc_stream__decorator(arc_stream<>& inner_arcs, const arc_stream<>& outer_arcs) + : _inner_arcs(inner_arcs) + , _outer_arcs(outer_arcs) + {} public: //////////////////////////////////////////////////////////////////////////// /// \brief Whether the stream contains more internal arcs. //////////////////////////////////////////////////////////////////////////// - bool can_pull_internal() const - { return _inner_arcs.can_pull_internal(); } + bool + can_pull_internal() const + { + return _inner_arcs.can_pull_internal(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the next internal arc (and move the read head). //////////////////////////////////////////////////////////////////////////// - const arc pull_internal() - { return _inner_arcs.pull_internal(); } + const arc + pull_internal() + { + return _inner_arcs.pull_internal(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the next internal arc (but do not move the read head). //////////////////////////////////////////////////////////////////////////// - const arc peek_internal() - { return _inner_arcs.peek_internal(); } + const arc + peek_internal() + { + return _inner_arcs.peek_internal(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the number of unread terminals. //////////////////////////////////////////////////////////////////////////// - size_t unread_terminals() const - { return _outer_arcs.unread_terminals() + _inner_arcs.unread_terminals(); } + size_t + unread_terminals() const + { + return _outer_arcs.unread_terminals() + _inner_arcs.unread_terminals(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the number of unread terminals of a specific value. //////////////////////////////////////////////////////////////////////////// - size_t unread_terminals(const bool terminal_value) const + size_t + unread_terminals(const bool terminal_value) const { return _outer_arcs.unread_terminals(terminal_value) - + _inner_arcs.unread_terminals(terminal_value); + + _inner_arcs.unread_terminals(terminal_value); } //////////////////////////////////////////////////////////////////////////// /// \brief Whether the stream contains more terminal arcs. //////////////////////////////////////////////////////////////////////////// - bool can_pull_terminal() const - { return _inner_arcs.can_pull_terminal(); } + bool + can_pull_terminal() const + { + return _inner_arcs.can_pull_terminal(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the next arc (and move the read head). //////////////////////////////////////////////////////////////////////////// - const arc pull_terminal() - { return _inner_arcs.pull_terminal(); } + const arc + pull_terminal() + { + return _inner_arcs.pull_terminal(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the next arc (but do not move the read head). //////////////////////////////////////////////////////////////////////////// - const arc peek_terminal() - { return _inner_arcs.peek_terminal(); } + const arc + peek_terminal() + { + return _inner_arcs.peek_terminal(); + } }; ////////////////////////////////////////////////////////////////////////// @@ -1231,17 +1389,17 @@ namespace adiar::internal /// /// \see nested_sweep ////////////////////////////////////////////////////////////////////////// - template + template inline bool - up(const exec_policy &ep, - const arc_stream<> &outer_arcs, - outer_pq_t &outer_pq, - node_writer &outer_writer, - const typename nesting_policy::shared_arc_file_type &inner_arcs_file, + up(const exec_policy& ep, + const arc_stream<>& outer_arcs, + outer_pq_t& outer_pq, + node_writer& outer_writer, + const typename nesting_policy::shared_arc_file_type& inner_arcs_file, const size_t inner_pq_memory, const size_t inner_pq_max_size, const size_t inner_sorters_memory, - const bool is_last_inner) + const bool is_last_inner) { #ifdef ADIAR_STATS stats.inner_up.sum_node_arcs += inner_arcs_file->size(0); @@ -1255,7 +1413,9 @@ namespace adiar::internal level_info_stream<> inner_levels(inner_arcs_file); // Set up (decorated) priority queue - inner_pq_t inner_pq({inner_arcs_file}, inner_pq_memory, inner_pq_max_size, + inner_pq_t inner_pq({ inner_arcs_file }, + inner_pq_memory, + inner_pq_max_size, nested_sweeping::stats.inner_up.lpq); using decorator_t = up__pq_decorator; @@ -1282,30 +1442,40 @@ namespace adiar::internal nested_sweeping::stats.inner_up.reduced_levels += 1; #endif - if (/*constexpr*/ !nesting_policy::final_canonical || - (!is_last_inner && auto_fast_reduce)) { + if (/*constexpr*/ !nesting_policy::final_canonical + || (!is_last_inner && auto_fast_reduce)) { #ifdef ADIAR_STATS nested_sweeping::stats.inner_up.reduced_levels__fast += 1; #endif - nested_sweeping::__reduce_level__fast - (decorated_arcs, level, decorated_pq, outer_writer, stats.inner_up); + nested_sweeping::__reduce_level__fast( + decorated_arcs, level, decorated_pq, outer_writer, stats.inner_up); } else { const size_t unreduced_width = inner_level_info.width(); size_t reduced_width; - if(unreduced_width <= internal_sorter_can_fit) { - reduced_width = __reduce_level - (decorated_arcs, level, decorated_pq, outer_writer, inner_sorters_memory, unreduced_width, stats.inner_up); + if (unreduced_width <= internal_sorter_can_fit) { + reduced_width = __reduce_level(decorated_arcs, + level, + decorated_pq, + outer_writer, + inner_sorters_memory, + unreduced_width, + stats.inner_up); } else { - reduced_width = __reduce_level - (decorated_arcs, level, decorated_pq, outer_writer, inner_sorters_memory, unreduced_width, stats.inner_up); + reduced_width = __reduce_level(decorated_arcs, + level, + decorated_pq, + outer_writer, + inner_sorters_memory, + unreduced_width, + stats.inner_up); } if constexpr (nesting_policy::final_canonical) { - const float epsilon = ep.template get(); - const double prior = static_cast(unreduced_width); - const double delta = static_cast(unreduced_width - reduced_width); + const float epsilon = ep.template get(); + const double prior = static_cast(unreduced_width); + const double delta = static_cast(unreduced_width - reduced_width); auto_fast_reduce |= (delta / prior) < epsilon; } @@ -1328,15 +1498,15 @@ namespace adiar::internal /// /// \see nested_sweep ////////////////////////////////////////////////////////////////////////// - template + template bool - up(const exec_policy &ep, - const arc_stream<> &outer_arcs, - outer_pq_t &outer_pq, - node_writer &outer_writer, - const typename nesting_policy::shared_arc_file_type &inner_arcs_file, + up(const exec_policy& ep, + const arc_stream<>& outer_arcs, + outer_pq_t& outer_pq, + node_writer& outer_writer, + const typename nesting_policy::shared_arc_file_type& inner_arcs_file, const size_t inner_memory, - const bool is_last_inner) + const bool is_last_inner) { // Compute amount of memory available for auxiliary data structures after // having opened all streams. @@ -1359,20 +1529,26 @@ namespace adiar::internal // Resolve `inner_arcs_file->max_1level_cut == 0` in a separate while-loop. const size_t inner_pq_bound = std::max(inner_arcs_file->max_1level_cut, 1); - const size_t inner_pq_max_size = ep.template get() == exec_policy::memory::Internal + const size_t inner_pq_max_size = + ep.template get() == exec_policy::memory::Internal ? std::min(inner_pq_memory_fits, inner_pq_bound) : inner_pq_bound; - const bool external_only = ep.template get() == exec_policy::memory::External; + const bool external_only = + ep.template get() == exec_policy::memory::External; if (!external_only && inner_pq_max_size <= no_lookahead_bound(1)) { #ifdef ADIAR_STATS stats.inner_up.lpq.unbucketed += 1u; #endif using inner_pq_t = up__pq_t<0, memory_mode::Internal>; return up(ep, - outer_arcs, outer_pq, outer_writer, + outer_arcs, + outer_pq, + outer_writer, inner_arcs_file, - inner_pq_memory, inner_pq_max_size, inner_sorters_memory, + inner_pq_memory, + inner_pq_max_size, + inner_sorters_memory, is_last_inner); } else if (!external_only && inner_pq_max_size <= inner_pq_memory_fits) { @@ -1381,9 +1557,13 @@ namespace adiar::internal #endif using inner_pq_t = up__pq_t; return up(ep, - outer_arcs, outer_pq, outer_writer, + outer_arcs, + outer_pq, + outer_writer, inner_arcs_file, - inner_pq_memory, inner_pq_max_size, inner_sorters_memory, + inner_pq_memory, + inner_pq_max_size, + inner_sorters_memory, is_last_inner); } else { #ifdef ADIAR_STATS @@ -1391,27 +1571,29 @@ namespace adiar::internal #endif using inner_pq_t = up__pq_t; return up(ep, - outer_arcs, outer_pq, outer_writer, + outer_arcs, + outer_pq, + outer_writer, inner_arcs_file, - inner_pq_memory, inner_pq_max_size, inner_sorters_memory, + inner_pq_memory, + inner_pq_max_size, + inner_sorters_memory, is_last_inner); } } } // namespace inner - } // namespace nested_sweeping + } // namespace nested_sweeping ////////////////////////////////////////////////////////////////////////////// /// \brief Primary logic for the framework for I/O-efficient translation of /// recursive functions that re-recurse on (a single) intermediate /// result. ////////////////////////////////////////////////////////////////////////////// - template + template typename nesting_policy::dd_type - __nested_sweep(const exec_policy &ep, - const typename nesting_policy::shared_arc_file_type &dag, - nesting_policy &policy_impl, + __nested_sweep(const exec_policy& ep, + const typename nesting_policy::shared_arc_file_type& dag, + nesting_policy& policy_impl, const size_t outer_pq_memory, const size_t outer_roots_memory, const size_t outer_pq_roots_max, @@ -1462,14 +1644,13 @@ namespace adiar::internal "Enough memory should be left priority queue and inner sweep"); using outer_pq_t = nested_sweeping::outer::up__pq_t; - outer_pq_t outer_pq({dag}, outer_pq_memory, outer_pq_roots_max, - nested_sweeping::stats.outer_up.lpq); + outer_pq_t outer_pq( + { dag }, outer_pq_memory, outer_pq_roots_max, nested_sweeping::stats.outer_up.lpq); // Outer Up Sweep: Use the 'inner_memory' for the per-level data structures // and streams. This is safe, since these data structures are only // instantiated when the Inner Sweep is not. - const size_t outer_sorters_memory = - inner_memory - tpie::file_stream::memory_usage(); + const size_t outer_sorters_memory = inner_memory - tpie::file_stream::memory_usage(); const size_t outer_internal_sorter_can_fit = internal_sorter::memory_fits(outer_sorters_memory / 2); @@ -1509,8 +1690,7 @@ namespace adiar::internal const level_info outer_level = outer_levels.pull(); - adiar_assert(!outer_pq.has_current_level() - || outer_level.level() == outer_pq.current_level(), + adiar_assert(!outer_pq.has_current_level() || outer_level.level() == outer_pq.current_level(), "level and priority queue should be in sync"); adiar_assert(next_inner == inner_iter_t::end || next_inner <= outer_level.level(), "next_inner level should (if it exists) be above current level (inclusive)."); @@ -1528,20 +1708,29 @@ namespace adiar::internal nested_sweeping::stats.outer_up.reduced_levels__fast += 1; #endif - nested_sweeping::__reduce_level__fast - (outer_arcs, outer_level.level(), outer_pq, outer_writer, nested_sweeping::stats.outer_up); + nested_sweeping::__reduce_level__fast(outer_arcs, + outer_level.level(), + outer_pq, + outer_writer, + nested_sweeping::stats.outer_up); } else { const size_t unreduced_width = outer_level.width(); - if(unreduced_width <= outer_internal_sorter_can_fit) { - __reduce_level - (outer_arcs, outer_level.level(), outer_pq, outer_writer, - outer_sorters_memory, unreduced_width, - nested_sweeping::stats.outer_up); + if (unreduced_width <= outer_internal_sorter_can_fit) { + __reduce_level(outer_arcs, + outer_level.level(), + outer_pq, + outer_writer, + outer_sorters_memory, + unreduced_width, + nested_sweeping::stats.outer_up); } else { - __reduce_level - (outer_arcs, outer_level.level(), outer_pq, outer_writer, - outer_sorters_memory, unreduced_width, - nested_sweeping::stats.outer_up); + __reduce_level(outer_arcs, + outer_level.level(), + outer_pq, + outer_writer, + outer_sorters_memory, + unreduced_width, + nested_sweeping::stats.outer_up); } } @@ -1563,31 +1752,41 @@ namespace adiar::internal nested_sweeping::stats.outer_up.reduced_levels__fast += 1; #endif - nested_sweeping::__reduce_level__fast - (outer_arcs, outer_level.level(), outer_pq_decorator, outer_writer, - nested_sweeping::stats.outer_up); + nested_sweeping::__reduce_level__fast(outer_arcs, + outer_level.level(), + outer_pq_decorator, + outer_writer, + nested_sweeping::stats.outer_up); } else { const size_t unreduced_width = outer_level.width(); size_t reduced_width; - if(unreduced_width <= outer_internal_sorter_can_fit) { - reduced_width = __reduce_level - (outer_arcs, outer_level.level(), outer_pq_decorator, outer_writer, - outer_sorters_memory, unreduced_width, - nested_sweeping::stats.outer_up); + if (unreduced_width <= outer_internal_sorter_can_fit) { + reduced_width = + __reduce_level(outer_arcs, + outer_level.level(), + outer_pq_decorator, + outer_writer, + outer_sorters_memory, + unreduced_width, + nested_sweeping::stats.outer_up); } else { - reduced_width = __reduce_level - (outer_arcs, outer_level.level(), outer_pq_decorator, outer_writer, - outer_sorters_memory, unreduced_width, - nested_sweeping::stats.outer_up); + reduced_width = + __reduce_level(outer_arcs, + outer_level.level(), + outer_pq_decorator, + outer_writer, + outer_sorters_memory, + unreduced_width, + nested_sweeping::stats.outer_up); } // Strategy: Use the fast reduce from the next level (until next inner sweep) if this // level did not change considerably in size. if constexpr (nesting_policy::final_canonical) { - const float epsilon = ep.template get(); - const double prior = static_cast(unreduced_width); - const double delta = static_cast(unreduced_width - reduced_width); + const float epsilon = ep.template get(); + const double prior = static_cast(unreduced_width); + const double delta = static_cast(unreduced_width - reduced_width); auto_fast_reduce |= (delta / prior) < epsilon; } @@ -1599,8 +1798,7 @@ namespace adiar::internal // ----------------------------------------------------------------------- // CASE Nested Level: // Sweep down re-reduce it back up to this level. - adiar_assert(outer_level.level() == next_inner, - "'next_inner' level is not skipped"); + adiar_assert(outer_level.level() == next_inner, "'next_inner' level is not skipped"); // ----------------------------------------------------------------------- // Collect all recursions for this level @@ -1627,7 +1825,8 @@ namespace adiar::internal if (reduction_rule_ret != n.uid()) { // If so, preserve child in inner sweep if (!outer_levels.can_pull()) { - adiar_assert(!outer_arcs.can_pull_internal(), "Should not have any parents at top-most level"); + adiar_assert(!outer_arcs.can_pull_internal(), + "Should not have any parents at top-most level"); if (reduction_rule_ret.is_terminal()) { return reduced_t(reduction_rule_ret.value()); @@ -1641,23 +1840,23 @@ namespace adiar::internal #ifdef ADIAR_STATS nested_sweeping::stats.inner_down.removed_by_rule_1 += 1; #endif - outer_pq_decorator.push(arc(outer_arcs.pull_internal().source(), flag(reduction_rule_ret))); - } while (outer_arcs.can_pull_internal() && outer_arcs.peek_internal().target() == n.uid()); + outer_pq_decorator.push( + arc(outer_arcs.pull_internal().source(), flag(reduction_rule_ret))); + } while (outer_arcs.can_pull_internal() + && outer_arcs.peek_internal().target() == n.uid()); } } else { // Otherwise, create request if (!outer_levels.can_pull()) { - adiar_assert(!outer_arcs.can_pull_internal(), "Should not have any parents at top-most level"); + adiar_assert(!outer_arcs.can_pull_internal(), + "Should not have any parents at top-most level"); - const request_t r = - policy_impl.request_from_node(n, node::pointer_type::nil()); + const request_t r = policy_impl.request_from_node(n, node::pointer_type::nil()); adiar_assert(r.targets() > 0, "Requests are always to something"); non_gc_request |= r.targets() > 1; - if (r.target.first().is_terminal()) { - return reduced_t(r.target.first().value()); - } + if (r.target.first().is_terminal()) { return reduced_t(r.target.first().value()); } outer_pq_decorator.push(r); } else { do { @@ -1668,7 +1867,8 @@ namespace adiar::internal non_gc_request |= r.targets() > 1; outer_pq_decorator.push(r); - } while (outer_arcs.can_pull_internal() && outer_arcs.peek_internal().target() == n.uid()); + } while (outer_arcs.can_pull_internal() + && outer_arcs.peek_internal().target() == n.uid()); } } } @@ -1694,21 +1894,20 @@ namespace adiar::internal #ifdef ADIAR_STATS nested_sweeping::stats.outer_up.nested_levels += 1; #endif - adiar_assert(outer_roots.size() > 0, - "Nested Sweep needs some number of requests"); + adiar_assert(outer_roots.size() > 0, "Nested Sweep needs some number of requests"); outer_writer.detach(); #ifdef ADIAR_STATS - nested_sweeping::stats.inner_down.inputs.acc_size += outer_file->size(); - nested_sweeping::stats.inner_down.inputs.max_size = std::max(nested_sweeping::stats.inner_down.inputs.max_size, - outer_file->size()); - nested_sweeping::stats.inner_down.inputs.acc_width += outer_file->width; - nested_sweeping::stats.inner_down.inputs.max_width = std::max(nested_sweeping::stats.inner_down.inputs.max_width, - outer_file->width); + nested_sweeping::stats.inner_down.inputs.acc_size += outer_file->size(); + nested_sweeping::stats.inner_down.inputs.max_size = + std::max(nested_sweeping::stats.inner_down.inputs.max_size, outer_file->size()); + nested_sweeping::stats.inner_down.inputs.acc_width += outer_file->width; + nested_sweeping::stats.inner_down.inputs.max_width = + std::max(nested_sweeping::stats.inner_down.inputs.max_width, outer_file->width); nested_sweeping::stats.inner_down.inputs.acc_levels += outer_file->levels(); - nested_sweeping::stats.inner_down.inputs.max_levels = std::max(nested_sweeping::stats.inner_down.inputs.max_levels, - outer_file->levels()); + nested_sweeping::stats.inner_down.inputs.max_levels = std::max( + nested_sweeping::stats.inner_down.inputs.max_levels, outer_file->levels()); #endif // TODO (optimisation): is_last_inner && !non_gc_request @@ -1728,8 +1927,7 @@ namespace adiar::internal // --------------------------------------------------------------------- // Inner Up Sweep - adiar_assert(!inner_unreduced.template has(), - "Inner Sweep returned something"); + adiar_assert(!inner_unreduced.template has(), "Inner Sweep returned something"); const shared_arc_file_type inner_arcs = inner_unreduced.template get(); @@ -1738,9 +1936,8 @@ namespace adiar::internal outer_writer.attach(outer_file); if (is_last_inner) { - auto_fast_reduce = nested_sweeping::inner::up(ep, - outer_arcs, outer_pq, outer_writer, - inner_arcs, inner_memory, is_last_inner); + auto_fast_reduce = nested_sweeping::inner::up( + ep, outer_arcs, outer_pq, outer_writer, inner_arcs, inner_memory, is_last_inner); } else { adiar_assert(next_inner < outer_level.level(), "If 'next_inner' is not illegal, then it is above current level"); @@ -1748,8 +1945,12 @@ namespace adiar::internal outer_pq_decorator_t outer_pq_decorator(outer_pq, outer_roots, next_inner); auto_fast_reduce = nested_sweeping::inner::up(ep, - outer_arcs, outer_pq_decorator, outer_writer, - inner_arcs, inner_memory, is_last_inner); + outer_arcs, + outer_pq_decorator, + outer_writer, + inner_arcs, + inner_memory, + is_last_inner); } } else if (outer_roots.size() > 0) { // --------------------------------------------------------------------- @@ -1777,8 +1978,8 @@ namespace adiar::internal outer_roots.move(tmp_outer_roots); } else { // if (outer_roots.size() == 0) { - // --------------------------------------------------------------------- - // Nothing within 'outer_file' should survive + // --------------------------------------------------------------------- + // Nothing within 'outer_file' should survive #ifdef ADIAR_STATS nested_sweeping::stats.outer_up.skipped_nested_levels += 1; nested_sweeping::stats.outer_up.skipped_nested_levels__prune += 1; @@ -1793,30 +1994,33 @@ namespace adiar::internal // ----------------------------------------------------------------------- // Set up next level in Outer PQ if (!outer_pq.empty() || !outer_roots.empty()) { - adiar_assert(!outer_arcs.can_pull_terminal() || outer_arcs.peek_terminal().source().label() < outer_level.level(), + adiar_assert(!outer_arcs.can_pull_terminal() + || outer_arcs.peek_terminal().source().label() < outer_level.level(), "All terminal arcs for 'label' should be processed"); - adiar_assert(!outer_arcs.can_pull_internal() || outer_arcs.peek_internal().target().label() < outer_level.level(), + adiar_assert(!outer_arcs.can_pull_internal() + || outer_arcs.peek_internal().target().label() < outer_level.level(), "All internal arcs for 'label' should be processed"); adiar_assert(outer_pq.empty() || !outer_pq.can_pull(), "All forwarded arcs for 'label' should be processed"); - const size_t terminal_stop_level = - outer_arcs.can_pull_terminal() ? outer_arcs.peek_terminal().source().label() : outer_pq_t::no_label; + const size_t terminal_stop_level = outer_arcs.can_pull_terminal() + ? outer_arcs.peek_terminal().source().label() + : outer_pq_t::no_label; const size_t outer_roots_stop_level = !outer_roots.empty() ? outer_roots.deepest_source() : outer_pq_t::no_label; adiar_assert(terminal_stop_level != outer_pq_t::no_label - || outer_roots_stop_level != outer_pq_t::no_label - || !outer_pq.empty(), + || outer_roots_stop_level != outer_pq_t::no_label || !outer_pq.empty(), "There must be some (known) level ready to be forwarded to."); - const size_t stop_level = terminal_stop_level == outer_pq_t::no_label ? outer_roots_stop_level - : outer_roots_stop_level == outer_pq_t::no_label ? terminal_stop_level - : std::max(terminal_stop_level, outer_roots_stop_level) - ; + const size_t stop_level = terminal_stop_level == outer_pq_t::no_label + ? outer_roots_stop_level + : outer_roots_stop_level == outer_pq_t::no_label + ? terminal_stop_level + : std::max(terminal_stop_level, outer_roots_stop_level); adiar_assert(stop_level != outer_pq_t::no_label || !outer_pq.empty(), "There must be some (known) level ready to be forwarded to."); @@ -1854,22 +2058,23 @@ namespace adiar::internal /// \param policy_impl Provides the non-static parts of the inner logic /// that determines when to start the nested sweep. ////////////////////////////////////////////////////////////////////////////// - template + template typename nesting_policy::dd_type - nested_sweep(const exec_policy &ep, - const typename nesting_policy::__dd_type &input, - nesting_policy &policy_impl) + nested_sweep(const exec_policy& ep, + const typename nesting_policy::__dd_type& input, + nesting_policy& policy_impl) { - using reduced_t = typename nesting_policy::dd_type; - using request_t = typename nesting_policy::request_t; - using request_pred_t = typename nesting_policy::request_pred_t; + using reduced_t = typename nesting_policy::dd_type; + using request_t = typename nesting_policy::request_t; + using request_pred_t = typename nesting_policy::request_pred_t; using shared_arc_file_type = typename nesting_policy::shared_arc_file_type; using shared_node_file_type = typename nesting_policy::shared_node_file_type; adiar_assert(!input.empty(), "Input for Nested Sweeping should always be non-empty"); // Is it a terminal? - if (input.template has() && input.template get()->is_terminal()) { + if (input.template has() + && input.template get()->is_terminal()) { return reduced_t(input.template get(), input.negate); } @@ -1901,7 +2106,8 @@ namespace adiar::internal // Output streams - node_writer::memory_usage(); - using outer_default_lpq_t = nested_sweeping::outer::up__pq_t; + using outer_default_lpq_t = + nested_sweeping::outer::up__pq_t; constexpr size_t data_structures_in_pq = outer_default_lpq_t::data_structures; @@ -1911,40 +2117,62 @@ namespace adiar::internal constexpr size_t data_structures_in_roots = internal_roots_sorter_t::data_structures; const size_t outer_pq_memory = - (aux_outer_memory / (data_structures_in_pq + data_structures_in_roots)) * data_structures_in_pq; + (aux_outer_memory / (data_structures_in_pq + data_structures_in_roots)) + * data_structures_in_pq; const size_t outer_roots_memory = aux_outer_memory - outer_pq_memory; - const tpie::memory_size_type outer_pq_memory_fits = outer_default_lpq_t::memory_fits(outer_pq_memory); + const tpie::memory_size_type outer_pq_memory_fits = + outer_default_lpq_t::memory_fits(outer_pq_memory); const tpie::memory_size_type outer_roots_memory_fits = internal_roots_sorter_t::memory_fits(outer_pq_memory); const size_t pq_roots_bound = dag->max_1level_cut; - const size_t outer_pq_roots_max = ep.template get() == exec_policy::memory::Internal - ? std::min({outer_pq_memory_fits, outer_roots_memory_fits, pq_roots_bound}) + const size_t outer_pq_roots_max = + ep.template get() == exec_policy::memory::Internal + ? std::min({ outer_pq_memory_fits, outer_roots_memory_fits, pq_roots_bound }) : pq_roots_bound; - const bool external_only = ep.template get() == exec_policy::memory::External; + const bool external_only = + ep.template get() == exec_policy::memory::External; if (!external_only && outer_pq_roots_max <= no_lookahead_bound(1)) { #ifdef ADIAR_STATS nested_sweeping::stats.outer_up.lpq.unbucketed += 1u; #endif - return __nested_sweep - (ep, dag, policy_impl, outer_pq_memory, outer_roots_memory, outer_pq_roots_max, inner_memory); - } else if(!external_only && outer_pq_roots_max <= outer_pq_memory_fits && outer_pq_roots_max <= outer_roots_memory_fits) { + return __nested_sweep(ep, + dag, + policy_impl, + outer_pq_memory, + outer_roots_memory, + outer_pq_roots_max, + inner_memory); + } else if (!external_only && outer_pq_roots_max <= outer_pq_memory_fits + && outer_pq_roots_max <= outer_roots_memory_fits) { #ifdef ADIAR_STATS nested_sweeping::stats.outer_up.lpq.internal += 1u; #endif - return __nested_sweep - (ep, dag, policy_impl, outer_pq_memory, outer_roots_memory, outer_pq_roots_max, inner_memory); + return __nested_sweep( + ep, + dag, + policy_impl, + outer_pq_memory, + outer_roots_memory, + outer_pq_roots_max, + inner_memory); } else { #ifdef ADIAR_STATS nested_sweeping::stats.outer_up.lpq.external += 1u; #endif - return __nested_sweep - (ep, dag, policy_impl, outer_pq_memory, outer_roots_memory, outer_pq_roots_max, inner_memory); + return __nested_sweep( + ep, + dag, + policy_impl, + outer_pq_memory, + outer_roots_memory, + outer_pq_roots_max, + inner_memory); } } } diff --git a/src/adiar/internal/algorithms/pred.cpp b/src/adiar/internal/algorithms/pred.cpp index f51a395ff..88662b489 100644 --- a/src/adiar/internal/algorithms/pred.cpp +++ b/src/adiar/internal/algorithms/pred.cpp @@ -5,7 +5,6 @@ #include #include - namespace adiar::internal { statistics::equality_t stats_equality; @@ -18,48 +17,51 @@ namespace adiar::internal // Check whether more requests were processed on this level than allowed. An // isomorphic DAG would not create more requests than the original number of // nodes. - template + template class input_bound_levels { private: level_info_stream<> in_meta_1; - size_t curr_level_size = 0; + size_t curr_level_size = 0; size_t curr_level_processed = 0; public: - static size_t pq1_upper_bound(const shared_levelized_file &in_1, - const shared_levelized_file &in_2) + static size_t + pq1_upper_bound(const shared_levelized_file& in_1, + const shared_levelized_file& in_2) { - return std::max(in_1->max_2level_cut[cut::Internal], - in_2->max_2level_cut[cut::Internal]); + return std::max(in_1->max_2level_cut[cut::Internal], in_2->max_2level_cut[cut::Internal]); } - static size_t pq2_upper_bound(const shared_levelized_file &in_1, - const shared_levelized_file &in_2) + static size_t + pq2_upper_bound(const shared_levelized_file& in_1, + const shared_levelized_file& in_2) { - return std::max(in_1->max_1level_cut[cut::Internal], - in_2->max_1level_cut[cut::Internal]); + return std::max(in_1->max_1level_cut[cut::Internal], in_2->max_1level_cut[cut::Internal]); } - static constexpr size_t memory_usage() + static constexpr size_t + memory_usage() { return level_info_stream<>::memory_usage(); } public: - input_bound_levels(const shared_levelized_file &f0, - const shared_levelized_file &/*f1*/) + input_bound_levels(const shared_levelized_file& f0, + const shared_levelized_file& /*f1*/) : in_meta_1(f0) - { } + {} - void next_level(ptr_uint64::label_type /* level */) + void + next_level(ptr_uint64::label_type /* level */) { // Ignore input, since only used with the isomorphism_policy below. - curr_level_size = in_meta_1.pull().width(); + curr_level_size = in_meta_1.pull().width(); curr_level_processed = 0; } - bool on_step() + bool + on_step() { curr_level_processed++; const bool ret_value = curr_level_size < curr_level_processed; @@ -83,19 +85,22 @@ namespace adiar::internal // TODO (Decision Diagrams with other kinds of pointers): // template class isomorphism_policy - : public dd_policy, public prod2_same_level_merger> + : public dd_policy + , public prod2_same_level_merger> { public: using level_check_t = input_bound_levels; public: - static constexpr size_t lookahead_bound() + static constexpr size_t + lookahead_bound() { return 2u; } public: - static bool resolve_terminals(const dd::node_type &v1, const dd::node_type &v2, bool &ret_value) + static bool + resolve_terminals(const dd::node_type& v1, const dd::node_type& v2, bool& ret_value) { ret_value = v1.is_terminal() && v2.is_terminal() && v1.value() == v2.value(); #ifdef ADIAR_STATS @@ -105,7 +110,8 @@ namespace adiar::internal } public: - static bool resolve_singletons(const dd::node_type &v1, const dd::node_type &v2) + static bool + resolve_singletons(const dd::node_type& v1, const dd::node_type& v2) { #ifdef ADIAR_STATS stats_equality.slow_check.exit_on_root += 1u; @@ -115,8 +121,9 @@ namespace adiar::internal } public: - template - static bool resolve_request(pq_1_t &pq, const tuple &rp) + template + static bool + resolve_request(pq_1_t& pq, const tuple& rp) { // Are they both a terminal (and the same terminal)? if (rp[0].is_terminal() || rp[1].is_terminal()) { @@ -144,7 +151,7 @@ namespace adiar::internal } public: - static constexpr bool early_return_value = false; + static constexpr bool early_return_value = false; static constexpr bool no_early_return_value = true; }; @@ -168,8 +175,9 @@ namespace adiar::internal /// (3) The negation flags given to both shared_levelized_files agree /// (breaks canonicity) ////////////////////////////////////////////////////////////////////////////// - bool fast_isomorphism_check(const shared_levelized_file &f0, - const shared_levelized_file &f1) + bool + fast_isomorphism_check(const shared_levelized_file& f0, + const shared_levelized_file& f1) { node_stream<> in_nodes_1(f0); node_stream<> in_nodes_2(f1); @@ -187,11 +195,12 @@ namespace adiar::internal } ////////////////////////////////////////////////////////////////////////////// - bool is_isomorphic(const exec_policy &ep, - const shared_levelized_file &f0, - const shared_levelized_file &f1, - const bool negate0, - const bool negate1) + bool + is_isomorphic(const exec_policy& ep, + const shared_levelized_file& f0, + const shared_levelized_file& f1, + const bool negate0, + const bool negate1) { // Are they literally referring to the same underlying file? if (f0 == f1) { @@ -220,8 +229,8 @@ namespace adiar::internal // Are they trivially not the same, since they have different number of // terminal arcs? - if(f0->number_of_terminals[negate0] != f1->number_of_terminals[negate1] || - f0->number_of_terminals[!negate0] != f1->number_of_terminals[!negate1]) { + if (f0->number_of_terminals[negate0] != f1->number_of_terminals[negate1] + || f0->number_of_terminals[!negate0] != f1->number_of_terminals[!negate1]) { #ifdef ADIAR_STATS stats_equality.exit_on_terminalcount += 1u; #endif @@ -273,7 +282,8 @@ namespace adiar::internal } } - bool is_isomorphic(const exec_policy &ep, const dd &a, const dd &b) + bool + is_isomorphic(const exec_policy& ep, const dd& a, const dd& b) { return is_isomorphic(ep, a.file, b.file, a.negate, b.negate); } diff --git a/src/adiar/internal/algorithms/pred.h b/src/adiar/internal/algorithms/pred.h index 1cd640756..d793906ea 100644 --- a/src/adiar/internal/algorithms/pred.h +++ b/src/adiar/internal/algorithms/pred.h @@ -3,13 +3,13 @@ #include -#include #include #include -#include #include #include #include +#include +#include #include #include @@ -33,11 +33,12 @@ namespace adiar::internal /// \return Whether `f0` and `f1` have isomorphic DAGs when applying the given /// negation flags. ////////////////////////////////////////////////////////////////////////////// - bool is_isomorphic(const exec_policy &ep, - const shared_levelized_file &f0, - const shared_levelized_file &f1, - const bool negate0 = false, - const bool negate1 = false); + bool + is_isomorphic(const exec_policy& ep, + const shared_levelized_file& f0, + const shared_levelized_file& f1, + const bool negate0 = false, + const bool negate1 = false); ////////////////////////////////////////////////////////////////////////////// /// \brief Computes whether two decision diagrams are isomorphic; i.e. whether @@ -52,16 +53,18 @@ namespace adiar::internal /// /// \return Whether a and b have isomorphic DAGs. ////////////////////////////////////////////////////////////////////////////// - bool is_isomorphic(const exec_policy &ep, const dd &a, const dd &b); + bool + is_isomorphic(const exec_policy& ep, const dd& a, const dd& b); ////////////////////////////////////////////////////////////////////////////// // Data structures - template + template using pred_request = request<2, nodes_carried>; - template + template using comparison_priority_queue_1_t = - levelized_node_priority_queue, request_first_lt>, + levelized_node_priority_queue, + request_first_lt>, look_ahead, mem_mode, 2u, @@ -69,18 +72,19 @@ namespace adiar::internal using pred_request_2 = request<2, 1>; - template + template using comparison_priority_queue_2_t = priority_queue, request_second_lt>>; - template - bool __comparison_check(const shared_levelized_file &f0, - const shared_levelized_file &f1, - const bool negate0, - const bool negate1, - const tpie::memory_size_type pq_1_memory, - const tpie::memory_size_type pq_2_memory, - const size_t max_pq_size) + template + bool + __comparison_check(const shared_levelized_file& f0, + const shared_levelized_file& f1, + const bool negate0, + const bool negate1, + const tpie::memory_size_type pq_1_memory, + const tpie::memory_size_type pq_2_memory, + const size_t max_pq_size) { // Set up input node_stream<> in_nodes_0(f0, negate0); @@ -92,25 +96,23 @@ namespace adiar::internal // Edge-case for terminals if (v0.is_terminal() || v1.is_terminal()) { bool ret_value; - if (comp_policy::resolve_terminals(v0, v1, ret_value)) { - return ret_value; - } + if (comp_policy::resolve_terminals(v0, v1, ret_value)) { return ret_value; } } - if (v0.low().is_terminal() && v0.high().is_terminal() && - v1.low().is_terminal() && v1.high().is_terminal()) { + if (v0.low().is_terminal() && v0.high().is_terminal() && v1.low().is_terminal() + && v1.high().is_terminal()) { return comp_policy::resolve_singletons(v0, v1); } // Set up cross-level priority queue - pq_1_t comparison_pq_1({f0, f1}, pq_1_memory, max_pq_size, stats_equality.lpq); + pq_1_t comparison_pq_1({ f0, f1 }, pq_1_memory, max_pq_size, stats_equality.lpq); comparison_pq_1.push({ { v0.uid(), v1.uid() }, {} }); // Set up per-level priority queue pq_2_t comparison_pq_2(pq_2_memory, max_pq_size); // Initialise level checking - typename comp_policy::level_check_t level_checker(f0,f1); + typename comp_policy::level_check_t level_checker(f0, f1); while (!comparison_pq_1.empty()) { // Set up next level @@ -122,10 +124,11 @@ namespace adiar::internal pred_request_2 req; // Merge requests from comparison_pq_1 and comparison_pq_2 - if (comparison_pq_1.can_pull() && (comparison_pq_2.empty() || - comparison_pq_1.top().target.first() < comparison_pq_2.top().target.second())) { + if (comparison_pq_1.can_pull() + && (comparison_pq_2.empty() + || comparison_pq_1.top().target.first() < comparison_pq_2.top().target.second())) { req = { comparison_pq_1.top().target, - { {{ node::pointer_type::nil(), node::pointer_type::nil() }} } }; + { { { node::pointer_type::nil(), node::pointer_type::nil() } } } }; comparison_pq_1.pop(); } else { req = comparison_pq_2.top(); @@ -136,12 +139,8 @@ namespace adiar::internal const typename comp_policy::pointer_type t_seek = req.empty_carry() ? req.target.first() : req.target.second(); - while (v0.uid() < t_seek && in_nodes_0.can_pull()) { - v0 = in_nodes_0.pull(); - } - while (v1.uid() < t_seek && in_nodes_1.can_pull()) { - v1 = in_nodes_1.pull(); - } + while (v0.uid() < t_seek && in_nodes_0.can_pull()) { v0 = in_nodes_0.pull(); } + while (v1.uid() < t_seek && in_nodes_1.can_pull()) { v1 = in_nodes_1.pull(); } // Skip all remaining requests to the same node while (comparison_pq_1.can_pull() && (comparison_pq_1.top().target == req.target)) { @@ -149,8 +148,7 @@ namespace adiar::internal } // Forward information across the level - if (req.empty_carry() - && req.target[0].is_node() && req.target[1].is_node() + if (req.empty_carry() && req.target[0].is_node() && req.target[1].is_node() && req.target[0].label() == req.target[1].label() && (v0.uid() != req.target[0] || v1.uid() != req.target[1])) { const typename comp_policy::children_type children = @@ -161,20 +159,18 @@ namespace adiar::internal continue; } - if (level_checker.on_step()) { - return level_checker.termination_value; - } + if (level_checker.on_step()) { return level_checker.termination_value; } // Obtain children or root for both nodes (depending on level) const tuple children = comp_policy::merge(req, t_seek, v0, v1); // Create pairing of product children and obtain new recursion targets - const tuple rec_pair_0 = - { children[0][false], children[1][false] }; + const tuple rec_pair_0 = { children[0][false], + children[1][false] }; - const tuple rec_pair_1 = - { children[0][true], children[1][true] }; + const tuple rec_pair_1 = { children[0][true], + children[1][true] }; // Forward pairing and return early if possible if (comp_policy::resolve_request(comparison_pq_1, rec_pair_0) @@ -206,12 +202,13 @@ namespace adiar::internal /// the decision_diagram used (i.e. bdd_policy in bdd/bdd.h, zdd_policy in /// zdd/zdd.h and so on). This provides the following functions ////////////////////////////////////////////////////////////////////////////// - template - bool comparison_check(const exec_policy &ep, - const shared_levelized_file &f0, - const shared_levelized_file &f1, - const bool negate0, - const bool negate1) + template + bool + comparison_check(const exec_policy& ep, + const shared_levelized_file& f0, + const shared_levelized_file& f1, + const bool negate0, + const bool negate1) { // Compute amount of memory available for auxiliary data structures after // having opened all streams. @@ -221,7 +218,7 @@ namespace adiar::internal // memory variant. const size_t aux_available_memory = memory_available() // Input - - 2*node_stream<>::memory_usage() + - 2 * node_stream<>::memory_usage() // Level checker policy - comp_policy::level_check_t::memory_usage(); @@ -232,45 +229,52 @@ namespace adiar::internal comparison_priority_queue_2_t::data_structures; const size_t pq_1_internal_memory = - (aux_available_memory / (data_structures_in_pq_1 + data_structures_in_pq_2)) * data_structures_in_pq_1; + (aux_available_memory / (data_structures_in_pq_1 + data_structures_in_pq_2)) + * data_structures_in_pq_1; const size_t pq_2_internal_memory = aux_available_memory - pq_1_internal_memory; const size_t pq_1_memory_fits = - comparison_priority_queue_1_t::memory_fits(pq_1_internal_memory); + comparison_priority_queue_1_t::memory_fits( + pq_1_internal_memory); const size_t pq_2_memory_fits = comparison_priority_queue_2_t::memory_fits(pq_2_internal_memory); - const bool internal_only = ep.template get() == exec_policy::memory::Internal; - const bool external_only = ep.template get() == exec_policy::memory::External; + const bool internal_only = + ep.template get() == exec_policy::memory::Internal; + const bool external_only = + ep.template get() == exec_policy::memory::External; const size_t pq_1_bound = comp_policy::level_check_t::pq1_upper_bound(f0, f1); - const size_t max_pq_1_size = internal_only ? std::min(pq_1_memory_fits, pq_1_bound) : pq_1_bound; + const size_t max_pq_1_size = + internal_only ? std::min(pq_1_memory_fits, pq_1_bound) : pq_1_bound; const size_t pq_2_bound = comp_policy::level_check_t::pq2_upper_bound(f0, f1); - const size_t max_pq_2_size = internal_only ? std::min(pq_2_memory_fits, pq_2_bound) : pq_2_bound; + const size_t max_pq_2_size = + internal_only ? std::min(pq_2_memory_fits, pq_2_bound) : pq_2_bound; // TODO: Only one element per node in pq_2, so maximum is width (or their product)! - if(!external_only && max_pq_1_size <= no_lookahead_bound(comp_policy::lookahead_bound())) { + if (!external_only && max_pq_1_size <= no_lookahead_bound(comp_policy::lookahead_bound())) { #ifdef ADIAR_STATS stats_equality.lpq.unbucketed += 1u; #endif return __comparison_check, - comparison_priority_queue_2_t> - (f0, f1, negate0, negate1, pq_1_internal_memory, pq_2_internal_memory, max_pq_1_size); - } else if(!external_only && max_pq_1_size <= pq_1_memory_fits - && max_pq_2_size <= pq_2_memory_fits) { + comparison_priority_queue_2_t>( + f0, f1, negate0, negate1, pq_1_internal_memory, pq_2_internal_memory, max_pq_1_size); + } else if (!external_only && max_pq_1_size <= pq_1_memory_fits + && max_pq_2_size <= pq_2_memory_fits) { #ifdef ADIAR_STATS stats_equality.lpq.internal += 1u; #endif - return __comparison_check, - comparison_priority_queue_2_t> - (f0, f1, negate0, negate1, pq_1_internal_memory, pq_2_internal_memory, max_pq_1_size); + return __comparison_check< + comp_policy, + comparison_priority_queue_1_t, + comparison_priority_queue_2_t>( + f0, f1, negate0, negate1, pq_1_internal_memory, pq_2_internal_memory, max_pq_1_size); } else { #ifdef ADIAR_STATS stats_equality.lpq.external += 1u; @@ -278,15 +282,17 @@ namespace adiar::internal const size_t pq_1_memory = aux_available_memory / 2; const size_t pq_2_memory = pq_1_memory; - return __comparison_check, - comparison_priority_queue_2_t> - (f0, f1, negate0, negate1, pq_1_memory, pq_2_memory, max_pq_1_size); + return __comparison_check< + comp_policy, + comparison_priority_queue_1_t, + comparison_priority_queue_2_t>( + f0, f1, negate0, negate1, pq_1_memory, pq_2_memory, max_pq_1_size); } } - template - bool comparison_check(const exec_policy &ep, const dd &a, const dd &b) + template + bool + comparison_check(const exec_policy& ep, const dd& a, const dd& b) { return comparison_check(ep, a.file, b.file, a.negate, b.negate); } diff --git a/src/adiar/internal/algorithms/prod2.h b/src/adiar/internal/algorithms/prod2.h index ec9d00998..6679295cb 100644 --- a/src/adiar/internal/algorithms/prod2.h +++ b/src/adiar/internal/algorithms/prod2.h @@ -5,24 +5,24 @@ #include +#include #include #include #include #include #include -#include -#include -#include -#include #include -#include #include -#include #include +#include +#include +#include +#include #include #include #include #include +#include namespace adiar::internal { @@ -39,38 +39,39 @@ namespace adiar::internal // Examples of uses are `bdd_apply` and `zdd_binop`. ////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////// /// Struct to hold statistics extern statistics::prod2_t stats_prod2; ////////////////////////////////////////////////////////////////////////////// // Data structures - template + template using prod2_request = request_data<2, with_parent, nodes_carried>; - template - using prod_priority_queue_t = - levelized_node_priority_queue, request_data_lt>, - look_ahead, - mem_mode, - 2, - 0>; + template + using prod_priority_queue_t = levelized_node_priority_queue, + request_data_lt>, + look_ahead, + mem_mode, + 2, + 0>; - template + template using prod_priority_queue_1_t = - levelized_node_priority_queue, request_data_first_lt>, + levelized_node_priority_queue, + request_data_first_lt>, look_ahead, mem_mode, 2, 0>; - template + template using prod_priority_queue_2_t = priority_queue, request_data_second_lt>>; // TODO: turn into 'tuple>' - struct prod2_rec_output { + struct prod2_rec_output + { tuple low; tuple high; }; @@ -91,11 +92,13 @@ namespace adiar::internal /// /// \pre `source` level is strictly before `target` ////////////////////////////////////////////////////////////////////////////// - template - inline void __prod2_recurse_out(PriorityQueue_1 &prod_pq_1, arc_writer &aw, - const bool_op &op, - const ptr_uint64 &source, - const tuple &target) + template + inline void + __prod2_recurse_out(PriorityQueue_1& prod_pq_1, + arc_writer& aw, + const bool_op& op, + const ptr_uint64& source, + const tuple& target) { if (target[0].is_terminal() && target[1].is_terminal()) { const arc out_arc = { source, op(target[0], target[1]) }; @@ -104,7 +107,7 @@ namespace adiar::internal adiar_assert(source.label() < std::min(target[0], target[1]).label(), "should always push recursion for 'later' level"); - prod_pq_1.push({ target, {}, {source} }); + prod_pq_1.push({ target, {}, { source } }); } } @@ -112,11 +115,12 @@ namespace adiar::internal /// \brief Run `Policy::go(...)` as long as there are in-going arcs to /// `target` in the Levelized Priority Queue. ////////////////////////////////////////////////////////////////////////////// - template - inline void __prod2_recurse_in__1(PriorityQueue &prod_pq, - arc_writer &aw, - const ExtraArg &ea, - const tuple &target) + template + inline void + __prod2_recurse_in__1(PriorityQueue& prod_pq, + arc_writer& aw, + const ExtraArg& ea, + const tuple& target) { // TODO: merge with the per-level priority queue below. This requires adding // `can_pull()` or similar to `internal::priority_queue`. Maybe it @@ -130,11 +134,12 @@ namespace adiar::internal /// \brief Run `Policy::go(...)` as long as there are in-going arcs to /// `target` in the Per-level Priority Queue. ////////////////////////////////////////////////////////////////////////////// - template - inline void __prod2_recurse_in__2(PriorityQueue &prod_pq, - arc_writer &aw, - const ExtraArg &ea, - const tuple &target) + template + inline void + __prod2_recurse_in__2(PriorityQueue& prod_pq, + arc_writer& aw, + const ExtraArg& ea, + const tuple& target) { while (!prod_pq.empty() && prod_pq.top().target == target) { Policy::go(prod_pq, aw, ea, prod_pq.top().data.source); @@ -146,11 +151,12 @@ namespace adiar::internal /// \brief Run `Policy::go(...)` as long as there are in-going arcs to /// `target` in the priority queue. ////////////////////////////////////////////////////////////////////////////// - template - inline void __prod2_recurse_in(PriorityQueue &prod_pq, - arc_writer &aw, - const ExtraArg &ea, - const tuple &target) + template + inline void + __prod2_recurse_in(PriorityQueue& prod_pq, + arc_writer& aw, + const ExtraArg& ea, + const tuple& target) { // HACK for hiding '__1' and '__2' versions __prod2_recurse_in__1(prod_pq, aw, ea, target); @@ -160,11 +166,13 @@ namespace adiar::internal /// \brief Run `Policy::go(...)` as long as there are in-going arcs to /// `target` in either of the priority queues. ////////////////////////////////////////////////////////////////////////////// - template - inline void __prod2_recurse_in(PriorityQueue_1 &prod_pq_1, PriorityQueue_2 &prod_pq_2, - arc_writer &aw, - const ExtraArg &ea, - const tuple &target) + template + inline void + __prod2_recurse_in(PriorityQueue_1& prod_pq_1, + PriorityQueue_2& prod_pq_2, + arc_writer& aw, + const ExtraArg& ea, + const tuple& target) { __prod2_recurse_in__1(prod_pq_1, aw, ea, target); __prod2_recurse_in__2(prod_pq_2, aw, ea, target); @@ -175,14 +183,14 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// struct __prod2_recurse_in__output_node { - template - static inline void go(PriorityQueue& /*prod_pq_1*/, arc_writer &aw, - const node::uid_type &out_uid, - const node::pointer_type &source) + template + static inline void + go(PriorityQueue& /*prod_pq_1*/, + arc_writer& aw, + const node::uid_type& out_uid, + const node::pointer_type& source) { - if (!source.is_nil()) { - aw.push_internal({ source, out_uid }); - } + if (!source.is_nil()) { aw.push_internal({ source, out_uid }); } } }; @@ -191,10 +199,12 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// struct __prod2_recurse_in__output_terminal { - template - static inline void go(PriorityQueue_1& /*prod_pq_1*/, arc_writer &aw, - const ptr_uint64 &out_terminal, - const ptr_uint64 &source) + template + static inline void + go(PriorityQueue_1& /*prod_pq_1*/, + arc_writer& aw, + const ptr_uint64& out_terminal, + const ptr_uint64& source) { aw.push_terminal({ source, out_terminal }); } @@ -206,21 +216,20 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// struct __prod2_recurse_in__forward { - template - static inline void go(PriorityQueue &prod_pq, arc_writer&, - const prod2_rec_skipto &r, - const ptr_uint64 &source) + template + static inline void + go(PriorityQueue& prod_pq, arc_writer&, const prod2_rec_skipto& r, const ptr_uint64& source) { - prod_pq.push({ { r[0], r[1] }, {}, {source} }); + prod_pq.push({ { r[0], r[1] }, {}, { source } }); } }; ////////////////////////////////////////////////////////////////////////////// /// \brief Construct a terminal for the result of two pointers. ////////////////////////////////////////////////////////////////////////////// - template + template inline shared_levelized_file - __prod2_terminal(const tuple &rp, const bool_op &op) + __prod2_terminal(const tuple& rp, const bool_op& op) { // TODO: Abuse that op(tgt[0], tgt[1]) already is a pointer. return build_terminal(op(rp[0], rp[1]).value()); @@ -237,16 +246,13 @@ namespace adiar::internal /// /// \see prod2_mixed_level_merger ////////////////////////////////////////////////////////////////////////////// - template + template class prod2_same_level_merger { public: - template + template static tuple - merge(const Request &r, - const ptr_uint64 &t_seek, - const node &v0, - const node &v1) + merge(const Request& r, const ptr_uint64& t_seek, const node& v0, const node& v1) { const typename DdPolicy::children_type pair_0 = r.target[0] < t_seek ? r.node_carry[0] : v0.children(); @@ -269,35 +275,29 @@ namespace adiar::internal /// /// \see prod2_same_level_merger ////////////////////////////////////////////////////////////////////////////// - template + template class prod2_mixed_level_merger { public: - template + template static tuple - merge(const Request &r, - const typename DdPolicy::pointer_type &t_seek, - const typename DdPolicy::node_type &v0, - const typename DdPolicy::node_type &v1) + merge(const Request& r, + const typename DdPolicy::pointer_type& t_seek, + const typename DdPolicy::node_type& v0, + const typename DdPolicy::node_type& v1) { - if (r.target[0].is_terminal() || - r.target[1].is_terminal() || - r.target[0].label() != r.target[1].label()) { + if (r.target[0].is_terminal() || r.target[1].is_terminal() + || r.target[0].label() != r.target[1].label()) { - adiar_assert(r.target[0] != r.target[1], - "Cannot have mismatching levels and be equal"); + adiar_assert(r.target[0] != r.target[1], "Cannot have mismatching levels and be equal"); // t.target[0].label() < r.target[1].label() || r.target[1].is_terminal() ? const typename DdPolicy::children_type pair_0 = - r.target[0] < r.target[1] - ? v0.children() - : DdPolicy::reduction_rule_inv(r.target[0]); + r.target[0] < r.target[1] ? v0.children() : DdPolicy::reduction_rule_inv(r.target[0]); // r.target[1].label() < r.target[0].label() || r.target[0].is_terminal() ? const typename DdPolicy::children_type pair_1 = - r.target[1] < r.target[0] - ? v1.children() - : DdPolicy::reduction_rule_inv(r.target[1]); + r.target[1] < r.target[0] ? v1.children() : DdPolicy::reduction_rule_inv(r.target[1]); return { pair_0, pair_1 }; } else { @@ -316,13 +316,14 @@ namespace adiar::internal // TODO (Optimiation): Flip 'in_1' to be the one to do Random Access on. This // simplifies the request ordering by merging the `idx` // comparison with the final lexicographical tie-breaker. - template + template typename Policy::__dd_type - __prod2_ra(const exec_policy &ep, - const typename Policy::dd_type &in_pq, - const typename Policy::dd_type &in_ra, - const bool_op &op, - const size_t pq_memory, const size_t max_pq_size) + __prod2_ra(const exec_policy& ep, + const typename Policy::dd_type& in_pq, + const typename Policy::dd_type& in_ra, + const bool_op& op, + const size_t pq_memory, + const size_t max_pq_size) { constexpr size_t pq_idx = 0; constexpr size_t ra_idx = 1; @@ -338,18 +339,18 @@ namespace adiar::internal node v_pq = in_nodes_pq.pull(); // Set up cross-level priority queue - PriorityQueue_1 prod_pq({in_pq, in_ra}, pq_memory, max_pq_size, stats_prod2.lpq); + PriorityQueue_1 prod_pq({ in_pq, in_ra }, pq_memory, max_pq_size, stats_prod2.lpq); prod_pq.push({ { v_pq.uid(), in_nodes_ra.root() }, {}, { ptr_uint64::nil() } }); out_arcs->max_1level_cut = prod_pq.size(); // Process all requests - while (!prod_pq.empty()){ + while (!prod_pq.empty()) { // Set up level prod_pq.setup_next_level(); typename Policy::label_type out_label = prod_pq.current_level(); - typename Policy::id_type out_id = 0; + typename Policy::id_type out_id = 0; in_nodes_ra.setup_next_level(out_label); @@ -366,31 +367,27 @@ namespace adiar::internal v_pq = in_nodes_pq.pull(); } - adiar_assert(v_pq.uid() == req.target[pq_idx], - "Must have found correct node in `in_pq`"); + adiar_assert(v_pq.uid() == req.target[pq_idx], "Must have found correct node in `in_pq`"); } // Recreate/Obtain children of req.target (possibly of suppressed node) - const typename Policy::children_type children_pq = - req.target[pq_idx].level() == out_label - ? v_pq.children() - : Policy::reduction_rule_inv(req.target[pq_idx]); + const typename Policy::children_type children_pq = req.target[pq_idx].level() == out_label + ? v_pq.children() + : Policy::reduction_rule_inv(req.target[pq_idx]); - const typename Policy::children_type children_ra = - req.target[ra_idx].level() == out_label + const typename Policy::children_type children_ra = req.target[ra_idx].level() == out_label ? in_nodes_ra.at(req.target[ra_idx]).children() : Policy::reduction_rule_inv(req.target[ra_idx]); // Create pairing of product children - const tuple rec_pair_0 = - { children_pq[false], children_ra[false] }; + const tuple rec_pair_0 = { children_pq[false], + children_ra[false] }; - const tuple rec_pair_1 = - { children_pq[true], children_ra[true] }; + const tuple rec_pair_1 = { children_pq[true], + children_ra[true] }; // Obtain new recursion targets - const prod2_rec rec_res = - Policy::resolve_request(op, rec_pair_0, rec_pair_1); + const prod2_rec rec_res = Policy::resolve_request(op, rec_pair_0, rec_pair_1); // Forward recursion targets if (Policy::no_skip || std::holds_alternative(rec_res)) { @@ -400,10 +397,9 @@ namespace adiar::internal const node::uid_type out_uid(out_label, out_id++); __prod2_recurse_out(prod_pq, aw, op, out_uid.as_ptr(false), r.low); - __prod2_recurse_out(prod_pq, aw, op, out_uid.as_ptr(true), r.high); + __prod2_recurse_out(prod_pq, aw, op, out_uid.as_ptr(true), r.high); - __prod2_recurse_in<__prod2_recurse_in__output_node> - (prod_pq, aw, out_uid, req.target); + __prod2_recurse_in<__prod2_recurse_in__output_node>(prod_pq, aw, out_uid, req.target); } else { // std::holds_alternative(root_rec) const prod2_rec_skipto r = std::get(rec_res); @@ -412,25 +408,22 @@ namespace adiar::internal // Skipped in both DAGs all the way from the root until a pair of terminals. return __prod2_terminal(r, op); } - __prod2_recurse_in<__prod2_recurse_in__output_terminal> - (prod_pq, aw, op(r[0], r[1]), req.target); + __prod2_recurse_in<__prod2_recurse_in__output_terminal>( + prod_pq, aw, op(r[0], r[1]), req.target); } else { - __prod2_recurse_in<__prod2_recurse_in__forward> - (prod_pq, aw, r, req.target); + __prod2_recurse_in<__prod2_recurse_in__forward>(prod_pq, aw, r, req.target); } } } // Update meta information - if (Policy::no_skip || out_id > 0) { - aw.push(level_info(out_label, out_id)); - } + if (Policy::no_skip || out_id > 0) { aw.push(level_info(out_label, out_id)); } } // Ensure the edge case, where the in-going edge from nil to the root pair // does not dominate the max_1level_cut out_arcs->max_1level_cut = std::min(aw.size() - out_arcs->number_of_terminals[false] - - out_arcs->number_of_terminals[true], + - out_arcs->number_of_terminals[true], out_arcs->max_1level_cut); return typename Policy::__dd_type(out_arcs, ep); @@ -441,14 +434,16 @@ namespace adiar::internal /// with a secondary priority queue such that they are accessible at /// the same time. ////////////////////////////////////////////////////////////////////////////// - template + template typename Policy::__dd_type - __prod2_pq(const exec_policy &ep, - const typename Policy::dd_type &in_0, - const typename Policy::dd_type &in_1, - const bool_op &op, - const size_t pq_1_memory, const size_t max_pq_1_size, - const size_t pq_2_memory, const size_t max_pq_2_size) + __prod2_pq(const exec_policy& ep, + const typename Policy::dd_type& in_0, + const typename Policy::dd_type& in_1, + const bool_op& op, + const size_t pq_1_memory, + const size_t max_pq_1_size, + const size_t pq_2_memory, + const size_t max_pq_2_size) { // Set up output shared_levelized_file out_arcs; @@ -464,7 +459,7 @@ namespace adiar::internal node v1 = in_nodes_1.pull(); // Set up cross-level priority queue - PriorityQueue_1 prod_pq_1({in_0, in_1}, pq_1_memory, max_pq_1_size, stats_prod2.lpq); + PriorityQueue_1 prod_pq_1({ in_0, in_1 }, pq_1_memory, max_pq_1_size, stats_prod2.lpq); prod_pq_1.push({ { v0.uid(), v1.uid() }, {}, { ptr_uint64::nil() } }); // Set up per-level priority queue @@ -476,7 +471,7 @@ namespace adiar::internal prod_pq_1.setup_next_level(); const typename Policy::label_type out_label = prod_pq_1.current_level(); - typename Policy::id_type out_id = 0; + typename Policy::id_type out_id = 0; // Update max 1-level cut out_arcs->max_1level_cut = std::max(out_arcs->max_1level_cut, prod_pq_1.size()); @@ -486,10 +481,11 @@ namespace adiar::internal prod2_request<1> req; // Merge requests from prod_pq_1 or prod_pq_2 - if (prod_pq_1.can_pull() && (prod_pq_2.empty() || - prod_pq_1.top().target.first() < prod_pq_2.top().target.second())) { + if (prod_pq_1.can_pull() + && (prod_pq_2.empty() + || prod_pq_1.top().target.first() < prod_pq_2.top().target.second())) { req = { prod_pq_1.top().target, - {{ { node::pointer_type::nil(), node::pointer_type::nil() } }}, + { { { node::pointer_type::nil(), node::pointer_type::nil() } } }, { prod_pq_1.top().data } }; } else { req = prod_pq_2.top(); @@ -504,16 +500,11 @@ namespace adiar::internal const typename Policy::pointer_type t_seek = req.empty_carry() ? req.target.first() : req.target.second(); - while (v0.uid() < t_seek && in_nodes_0.can_pull()) { - v0 = in_nodes_0.pull(); - } - while (v1.uid() < t_seek && in_nodes_1.can_pull()) { - v1 = in_nodes_1.pull(); - } + while (v0.uid() < t_seek && in_nodes_0.can_pull()) { v0 = in_nodes_0.pull(); } + while (v1.uid() < t_seek && in_nodes_1.can_pull()) { v1 = in_nodes_1.pull(); } // Forward information across the level - if (req.empty_carry() - && req.target[0].is_node() && req.target[1].is_node() + if (req.empty_carry() && req.target[0].is_node() && req.target[1].is_node() && req.target[0].label() == req.target[1].label() && (v0.uid() != req.target[0] || v1.uid() != req.target[1])) { const typename Policy::children_type children = @@ -529,19 +520,17 @@ namespace adiar::internal } // Recreate children of nodes for req.target - const tuple children = - Policy::merge(req, t_seek, v0, v1); + const tuple children = Policy::merge(req, t_seek, v0, v1); // Create pairing of product children - const tuple rec_pair_0 = - { children[0][false], children[1][false] }; + const tuple rec_pair_0 = { children[0][false], + children[1][false] }; - const tuple rec_pair_1 = - { children[0][true], children[1][true] }; + const tuple rec_pair_1 = { children[0][true], + children[1][true] }; // Obtain new recursion targets - const prod2_rec rec_res = - Policy::resolve_request(op, rec_pair_0, rec_pair_1); + const prod2_rec rec_res = Policy::resolve_request(op, rec_pair_0, rec_pair_1); // Forward recursion targets if (Policy::no_skip || std::holds_alternative(rec_res)) { @@ -551,10 +540,10 @@ namespace adiar::internal const node::uid_type out_uid(out_label, out_id++); __prod2_recurse_out(prod_pq_1, aw, op, out_uid.as_ptr(false), r.low); - __prod2_recurse_out(prod_pq_1, aw, op, out_uid.as_ptr(true), r.high); + __prod2_recurse_out(prod_pq_1, aw, op, out_uid.as_ptr(true), r.high); - __prod2_recurse_in<__prod2_recurse_in__output_node> - (prod_pq_1, prod_pq_2, aw, out_uid, req.target); + __prod2_recurse_in<__prod2_recurse_in__output_node>( + prod_pq_1, prod_pq_2, aw, out_uid, req.target); } else { // std::holds_alternative(root_rec) const prod2_rec_skipto r = std::get(rec_res); @@ -563,25 +552,23 @@ namespace adiar::internal // Skipped in both DAGs all the way from the root until a pair of terminals. return __prod2_terminal(r, op); } - __prod2_recurse_in<__prod2_recurse_in__output_terminal> - (prod_pq_1, prod_pq_2, aw, op(r[0], r[1]), req.target); + __prod2_recurse_in<__prod2_recurse_in__output_terminal>( + prod_pq_1, prod_pq_2, aw, op(r[0], r[1]), req.target); } else { - __prod2_recurse_in<__prod2_recurse_in__forward> - (prod_pq_1, prod_pq_2, aw, r, req.target); + __prod2_recurse_in<__prod2_recurse_in__forward>( + prod_pq_1, prod_pq_2, aw, r, req.target); } } } // Push meta data about this level - if (Policy::no_skip || out_id > 0) { - aw.push(level_info(out_label, out_id)); - } + if (Policy::no_skip || out_id > 0) { aw.push(level_info(out_label, out_id)); } } // Ensure the edge case, where the in-going edge from nil to the root pair // does not dominate the max_1level_cut out_arcs->max_1level_cut = std::min(aw.size() - out_arcs->number_of_terminals[false] - - out_arcs->number_of_terminals[true], + - out_arcs->number_of_terminals[true], out_arcs->max_1level_cut); return typename Policy::__dd_type(out_arcs, ep); @@ -591,101 +578,104 @@ namespace adiar::internal /// Derives an upper bound on the output's maximum i-level cut based on the /// product of the maximum i-level cut of both inputs. ////////////////////////////////////////////////////////////////////////////// - template - size_t __prod2_ilevel_upper_bound(const typename Policy::dd_type &in_0, - const typename Policy::dd_type &in_1, - const bool_op &op) + template + size_t + __prod2_ilevel_upper_bound(const typename Policy::dd_type& in_0, + const typename Policy::dd_type& in_1, + const bool_op& op) { // Cuts for left-hand side const safe_size_t left_cut_internal = cut::get(in_0, cut::type::Internal); - const typename cut::type left_ct = Policy::left_cut(op); + const typename cut::type left_ct = Policy::left_cut(op); const safe_size_t left_cut_terminals = cut::get(in_0, left_ct) - left_cut_internal; // Cuts for right-hand side const safe_size_t right_cut_internal = cut::get(in_1, cut::type::Internal); - const typename cut::type right_ct = Policy::right_cut(op); + const typename cut::type right_ct = Policy::right_cut(op); const safe_size_t right_cut_terminals = cut::get(in_1, right_ct) - right_cut_internal; // Compute cut, where we make sure not to pair terminals with terminals. - return to_size(left_cut_internal * right_cut_internal - + left_cut_terminals * right_cut_internal - + left_cut_internal * right_cut_terminals - + const_size_inc); + return to_size(left_cut_internal * right_cut_internal + left_cut_terminals * right_cut_internal + + left_cut_internal * right_cut_terminals + const_size_inc); } ////////////////////////////////////////////////////////////////////////////// /// Derives an upper bound on the output's maximum 2-level cut based on both /// using the max 1 and 2-level cuts and the number of relevant terminals. ////////////////////////////////////////////////////////////////////////////// - template - size_t __prod2_2level_upper_bound(const typename Policy::dd_type &in_0, - const typename Policy::dd_type &in_1, - const bool_op &op) + template + size_t + __prod2_2level_upper_bound(const typename Policy::dd_type& in_0, + const typename Policy::dd_type& in_1, + const bool_op& op) { // Left-hand side const safe_size_t left_2level_cut = in_0.max_2level_cut(cut::Internal); const safe_size_t left_1level_cut = in_0.max_1level_cut(cut::Internal); - const cut left_ct = Policy::left_cut(op); + const cut left_ct = Policy::left_cut(op); const safe_size_t left_terminal_vals = left_ct.number_of_terminals(); - const safe_size_t left_terminal_arcs = in_0.max_1level_cut(left_ct) - left_1level_cut; + const safe_size_t left_terminal_arcs = in_0.max_1level_cut(left_ct) - left_1level_cut; // Right-hand side const safe_size_t right_2level_cut = in_1.max_2level_cut(cut::Internal); const safe_size_t right_1level_cut = in_1.max_1level_cut(cut::Internal); - const cut right_ct = Policy::right_cut(op); + const cut right_ct = Policy::right_cut(op); const safe_size_t right_terminal_vals = right_ct.number_of_terminals(); const safe_size_t right_terminal_arcs = in_1.max_1level_cut(right_ct) - right_1level_cut; // Compute cut, where we count the product, the input-terminal pairings, and the // connection from the product to the input-terminal pairings separately. - return to_size(left_2level_cut * right_2level_cut - + (right_1level_cut * left_terminal_arcs) + left_terminal_vals * right_2level_cut - + (left_1level_cut * right_terminal_arcs) + right_terminal_vals * left_2level_cut - + 2u); + return to_size(left_2level_cut * right_2level_cut + (right_1level_cut * left_terminal_arcs) + + left_terminal_vals * right_2level_cut + (left_1level_cut * right_terminal_arcs) + + right_terminal_vals * left_2level_cut + 2u); } ////////////////////////////////////////////////////////////////////////////// /// Upper bound on i-level cut based on the maximum possible number of nodes /// in the output. ////////////////////////////////////////////////////////////////////////////// - template - size_t __prod2_ilevel_upper_bound(const typename Policy::dd_type &in_0, - const typename Policy::dd_type &in_1, - const bool_op &op) + template + size_t + __prod2_ilevel_upper_bound(const typename Policy::dd_type& in_0, + const typename Policy::dd_type& in_1, + const bool_op& op) { - const cut left_ct = Policy::left_cut(op); + const cut left_ct = Policy::left_cut(op); const safe_size_t left_terminal_vals = left_ct.number_of_terminals(); - const safe_size_t left_size = in_0->size(); + const safe_size_t left_size = in_0->size(); - const cut right_ct = Policy::right_cut(op); + const cut right_ct = Policy::right_cut(op); const safe_size_t right_terminal_vals = right_ct.number_of_terminals(); - const safe_size_t right_size = in_1->size(); + const safe_size_t right_size = in_1->size(); return to_size((left_size + left_terminal_vals) * (right_size + right_terminal_vals) + 1u + 2u); } ////////////////////////////////////////////////////////////////////////////// - template + template typename Policy::__dd_type - __prod2_ra(const exec_policy &ep, - const typename Policy::dd_type &in_0, - const typename Policy::dd_type &in_1, - const bool_op &op) + __prod2_ra(const exec_policy& ep, + const typename Policy::dd_type& in_0, + const typename Policy::dd_type& in_1, + const bool_op& op) { adiar_assert(in_0->canonical || in_1->canonical, "At least one input must be canonical"); - const bool internal_only = ep.template get() == exec_policy::memory::Internal; - const bool external_only = ep.template get() == exec_policy::memory::External; + const bool internal_only = + ep.template get() == exec_policy::memory::Internal; + const bool external_only = + ep.template get() == exec_policy::memory::External; - const size_t pq_bound = std::min({__prod2_ilevel_upper_bound(in_0, in_1, op), - __prod2_2level_upper_bound(in_0, in_1, op), - __prod2_ilevel_upper_bound(in_0, in_1, op)}); + const size_t pq_bound = + std::min({ __prod2_ilevel_upper_bound(in_0, in_1, op), + __prod2_2level_upper_bound(in_0, in_1, op), + __prod2_ilevel_upper_bound(in_0, in_1, op) }); // Possibly flip inputs (and operator) such that 'in_ra' is always the // second argument to `__prod2_ra(...)` algorithm. @@ -714,47 +704,48 @@ namespace adiar::internal - arc_writer::memory_usage(); const size_t pq_memory_fits = - prod_priority_queue_t::memory_fits(pq_available_memory); + prod_priority_queue_t::memory_fits( + pq_available_memory); const size_t max_pq_size = internal_only ? std::min(pq_memory_fits, pq_bound) : pq_bound; - if(!external_only && max_pq_size <= no_lookahead_bound(2)) { + if (!external_only && max_pq_size <= no_lookahead_bound(2)) { #ifdef ADIAR_STATS stats_prod2.lpq.unbucketed += 1u; #endif - return __prod2_ra> - (ep, in_pq, in_ra, ra_op, pq_available_memory, max_pq_size); + return __prod2_ra>( + ep, in_pq, in_ra, ra_op, pq_available_memory, max_pq_size); } else if (!external_only && max_pq_size <= pq_memory_fits) { #ifdef ADIAR_STATS stats_prod2.lpq.internal += 1u; #endif - return __prod2_ra> - (ep, in_pq, in_ra, ra_op, pq_available_memory, max_pq_size); + return __prod2_ra>( + ep, in_pq, in_ra, ra_op, pq_available_memory, max_pq_size); } else { #ifdef ADIAR_STATS stats_prod2.lpq.external += 1u; #endif - return __prod2_ra> - (ep, in_pq, in_ra, ra_op, pq_available_memory, max_pq_size); + return __prod2_ra>( + ep, in_pq, in_ra, ra_op, pq_available_memory, max_pq_size); } } - template + template typename Policy::__dd_type - __prod2_pq(const exec_policy &ep, - const typename Policy::dd_type &in_0, - const typename Policy::dd_type &in_1, - const bool_op &op) + __prod2_pq(const exec_policy& ep, + const typename Policy::dd_type& in_0, + const typename Policy::dd_type& in_1, + const bool_op& op) { - const bool internal_only = ep.template get() == exec_policy::memory::Internal; - const bool external_only = ep.template get() == exec_policy::memory::External; + const bool internal_only = + ep.template get() == exec_policy::memory::Internal; + const bool external_only = + ep.template get() == exec_policy::memory::External; - const size_t pq_1_bound = std::min({__prod2_ilevel_upper_bound(in_0, in_1, op), - __prod2_2level_upper_bound(in_0, in_1, op), - __prod2_ilevel_upper_bound(in_0, in_1, op)}); + const size_t pq_1_bound = + std::min({ __prod2_ilevel_upper_bound(in_0, in_1, op), + __prod2_2level_upper_bound(in_0, in_1, op), + __prod2_ilevel_upper_bound(in_0, in_1, op) }); // Compute amount of memory available for auxiliary data structures after // having opened all streams. @@ -764,7 +755,7 @@ namespace adiar::internal // memory variant. const size_t aux_available_memory = memory_available() // Input streams - - 2*node_stream<>::memory_usage() + - 2 * node_stream<>::memory_usage() // Output stream - arc_writer::memory_usage(); @@ -775,39 +766,56 @@ namespace adiar::internal prod_priority_queue_2_t::data_structures; const size_t pq_1_internal_memory = - (aux_available_memory / (data_structures_in_pq_1 + data_structures_in_pq_2)) * data_structures_in_pq_1; + (aux_available_memory / (data_structures_in_pq_1 + data_structures_in_pq_2)) + * data_structures_in_pq_1; const size_t pq_2_internal_memory = aux_available_memory - pq_1_internal_memory; const size_t pq_1_memory_fits = - prod_priority_queue_1_t::memory_fits(pq_1_internal_memory); + prod_priority_queue_1_t::memory_fits( + pq_1_internal_memory); const size_t pq_2_memory_fits = prod_priority_queue_2_t::memory_fits(pq_2_internal_memory); - const size_t max_pq_1_size = internal_only ? std::min(pq_1_memory_fits, pq_1_bound) : pq_1_bound; + const size_t max_pq_1_size = + internal_only ? std::min(pq_1_memory_fits, pq_1_bound) : pq_1_bound; - const size_t pq_2_bound = __prod2_ilevel_upper_bound(in_0, in_1, op); + const size_t pq_2_bound = + __prod2_ilevel_upper_bound(in_0, in_1, op); - const size_t max_pq_2_size = internal_only ? std::min(pq_2_memory_fits, pq_2_bound) : pq_2_bound; + const size_t max_pq_2_size = + internal_only ? std::min(pq_2_memory_fits, pq_2_bound) : pq_2_bound; - if(!external_only && max_pq_1_size <= no_lookahead_bound(2)) { + if (!external_only && max_pq_1_size <= no_lookahead_bound(2)) { #ifdef ADIAR_STATS stats_prod2.lpq.unbucketed += 1u; #endif return __prod2_pq, - prod_priority_queue_2_t> - (ep, in_0, in_1, op, pq_1_internal_memory, max_pq_1_size, pq_2_internal_memory, max_pq_2_size); - } else if(!external_only && max_pq_1_size <= pq_1_memory_fits - && max_pq_2_size <= pq_2_memory_fits) { + prod_priority_queue_2_t>(ep, + in_0, + in_1, + op, + pq_1_internal_memory, + max_pq_1_size, + pq_2_internal_memory, + max_pq_2_size); + } else if (!external_only && max_pq_1_size <= pq_1_memory_fits + && max_pq_2_size <= pq_2_memory_fits) { #ifdef ADIAR_STATS stats_prod2.lpq.internal += 1u; #endif return __prod2_pq, - prod_priority_queue_2_t> - (ep, in_0, in_1, op, pq_1_internal_memory, max_pq_1_size, pq_2_internal_memory, max_pq_2_size); + prod_priority_queue_2_t>(ep, + in_0, + in_1, + op, + pq_1_internal_memory, + max_pq_1_size, + pq_2_internal_memory, + max_pq_2_size); } else { #ifdef ADIAR_STATS stats_prod2.lpq.external += 1u; @@ -817,8 +825,8 @@ namespace adiar::internal return __prod2_pq, - prod_priority_queue_2_t> - (ep, in_0, in_1, op, pq_1_memory, max_pq_1_size, pq_2_memory, max_pq_2_size); + prod_priority_queue_2_t>( + ep, in_0, in_1, op, pq_1_memory, max_pq_1_size, pq_2_memory, max_pq_2_size); } } @@ -828,12 +836,12 @@ namespace adiar::internal /// \return A class that inherits from `__dd` and describes the product the /// two given DAGs. ////////////////////////////////////////////////////////////////////////////// - template + template typename Policy::__dd_type - prod2(const exec_policy &ep, - const typename Policy::dd_type &in_0, - const typename Policy::dd_type &in_1, - const bool_op &op) + prod2(const exec_policy& ep, + const typename Policy::dd_type& in_0, + const typename Policy::dd_type& in_1, + const bool_op& op) { // ------------------------------------------------------------------------- // Case: Same file, i.e. exactly the same DAG. @@ -847,8 +855,7 @@ namespace adiar::internal // ------------------------------------------------------------------------- // Case: At least one terminal. if (dd_isterminal(in_0) || dd_isterminal(in_1)) { - typename Policy::__dd_type maybe_resolved = - Policy::resolve_terminal_root(in_0, in_1, op); + typename Policy::__dd_type maybe_resolved = Policy::resolve_terminal_root(in_0, in_1, op); if (!(maybe_resolved.template has())) { #ifdef ADIAR_STATS @@ -878,20 +885,20 @@ namespace adiar::internal constexpr size_t node_size = sizeof(typename Policy::node_type); - const size_t ra_threshold__min = - get_block_size(); + const size_t ra_threshold__min = get_block_size(); const size_t ra_threshold__max = - (memory_available() * data_structures_in_pq_2) / 2*(data_structures_in_pqs); + (memory_available() * data_structures_in_pq_2) / 2 * (data_structures_in_pqs); const size_t ra_threshold = std::max(ra_threshold__min, ra_threshold__max) / node_size; - const size_t width_0 = in_0->canonical ? in_0.width() : Policy::max_id; - const size_t width_1 = in_1->canonical ? in_1.width() : Policy::max_id; + const size_t width_0 = in_0->canonical ? in_0.width() : Policy::max_id; + const size_t width_1 = in_1->canonical ? in_1.width() : Policy::max_id; const size_t min_width = std::min(width_0, width_1); - if (// Use `__prod2_ra` if user has forced Random Access - ep.template get() == exec_policy::access::Random_Access - || (// Heuristically, if the narrowest canonical fits - ep.template get() == exec_policy::access::Auto && (min_width <= ra_threshold))) { + if ( // Use `__prod2_ra` if user has forced Random Access + ep.template get() == exec_policy::access::Random_Access + || ( // Heuristically, if the narrowest canonical fits + ep.template get() == exec_policy::access::Auto + && (min_width <= ra_threshold))) { #ifdef ADIAR_STATS stats_prod2.ra.runs += 1u; #endif diff --git a/src/adiar/internal/algorithms/quantify.h b/src/adiar/internal/algorithms/quantify.h index d97a3b815..052875bf5 100644 --- a/src/adiar/internal/algorithms/quantify.h +++ b/src/adiar/internal/algorithms/quantify.h @@ -909,10 +909,10 @@ namespace adiar::internal // Do Partial Quantification as long as... // 1. ... it stays smaller than 1+epsilon of the input size. - const size_t transposition__size_threshold = - (std::min(static_cast(std::numeric_limits::max() / 2u), - static_cast(ep.template get()) - * static_cast(dd_size))); + const size_t transposition__size_threshold = (std::min( + static_cast(std::numeric_limits::max() / 2u), + static_cast(ep.template get()) + * static_cast(dd_size))); // 2. ... it has not run more than the maximum number of iterations. const size_t transposition__max_iterations = diff --git a/src/adiar/internal/algorithms/reduce.h b/src/adiar/internal/algorithms/reduce.h index 379955630..7356875f4 100644 --- a/src/adiar/internal/algorithms/reduce.h +++ b/src/adiar/internal/algorithms/reduce.h @@ -2,21 +2,21 @@ #define ADIAR_INTERNAL_ALGORITHMS_REDUCE_H #include +#include #include #include -#include #include #include #include +#include #include #include -#include #include #include #include #include -#include +#include namespace adiar::internal { @@ -42,23 +42,29 @@ namespace adiar::internal { reduce_arc() = default; - reduce_arc(const reduce_arc &) = default; + reduce_arc(const reduce_arc&) = default; - reduce_arc(const arc &a) : arc(a) - { } + reduce_arc(const arc& a) + : arc(a) + {} - reduce_arc& operator= (const reduce_arc &a) = default; + reduce_arc& + operator=(const reduce_arc& a) = default; //////////////////////////////////////////////////////////////////////////// /// \brief The level at which this nodes source belongs to. //////////////////////////////////////////////////////////////////////////// - arc::label_type level() const - { return source().label(); } + arc::label_type + level() const + { + return source().label(); + } }; struct reduce_queue_lt { - bool operator()(const arc &a, const arc &b) + bool + operator()(const arc& a, const arc& b) { // We want the high arc first, but that is already placed on the // least-significant bit on the source variable. @@ -70,15 +76,13 @@ namespace adiar::internal /// \brief Decorator on the levelized priority queue to also keep track of /// the number of arcs to each terminal. //////////////////////////////////////////////////////////////////////////// - template - class reduce_priority_queue : public levelized_arc_priority_queue + template + class reduce_priority_queue + : public levelized_arc_priority_queue { private: - using inner_lpq = levelized_arc_priority_queue; + using inner_lpq = + levelized_arc_priority_queue; //////////////////////////////////////////////////////////////////////////// /// \brief Number of terminals (of each type) placed within the priority queue. @@ -86,26 +90,27 @@ namespace adiar::internal size_t _terminals[2] = { 0u, 0u }; public: - reduce_priority_queue(const shared_levelized_file (&files) [1u], + reduce_priority_queue(const shared_levelized_file (&files)[1u], size_t memory_given, size_t max_size, - statistics::levelized_priority_queue_t &stats) + statistics::levelized_priority_queue_t& stats) : inner_lpq(files, memory_given, max_size, stats) - { } + {} - reduce_priority_queue(const shared_levelized_file (&files) [1u], + reduce_priority_queue(const shared_levelized_file (&files)[1u], size_t memory_given, size_t max_size) : reduce_priority_queue(files, memory_given, max_size, stats_reduce.lpq) - { } + {} //////////////////////////////////////////////////////////////////////////// /// \brief Push an arc into the priority queue. //////////////////////////////////////////////////////////////////////////// - void push(const arc &a) + void + push(const arc& a) { _terminals[false] += a.target().is_false(); - _terminals[true] += a.target().is_true(); + _terminals[true] += a.target().is_true(); inner_lpq::push(a); } @@ -113,12 +118,13 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the top arc on the current level and remove it. //////////////////////////////////////////////////////////////////////////// - arc pull() + arc + pull() { arc a = inner_lpq::pull(); _terminals[false] -= a.target().is_false(); - _terminals[true] -= a.target().is_true(); + _terminals[true] -= a.target().is_true(); return a; } @@ -126,7 +132,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Remove the top arc on the current level. //////////////////////////////////////////////////////////////////////////// - void pop() + void + pop() { pull(); } @@ -134,7 +141,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Number of terminals (of each type) placed within the priority queue. //////////////////////////////////////////////////////////////////////////// - const size_t& terminals(const bool terminal_value) const + const size_t& + terminals(const bool terminal_value) const { return _terminals[terminal_value]; } @@ -142,7 +150,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Total number of arcs (across all levels) ignoring terminals. //////////////////////////////////////////////////////////////////////////// - size_t size_without_terminals() const + size_t + size_without_terminals() const { return inner_lpq::size() - _terminals[false] - _terminals[true]; } @@ -152,17 +161,18 @@ namespace adiar::internal // Reduction Rule 2 sorting (and back again) struct reduce_node_children_lt { - bool operator()(const node &a, const node &b) + bool + operator()(const node& a, const node& b) { // TODO (Attributed Edges): // Use the 'flag' bit on children to mark attributed edges. Currently, // we use this flag to mark whether Reduction Rule 1 was applied to // some node across some arc. const ptr_uint64 a_high = unflag(a.high()); - const ptr_uint64 a_low = unflag(a.low()); + const ptr_uint64 a_low = unflag(a.low()); const ptr_uint64 b_high = unflag(b.high()); - const ptr_uint64 b_low = unflag(b.low()); + const ptr_uint64 b_low = unflag(b.low()); return a_high > b_high || (a_high == b_high && a_low > b_low) #ifndef NDEBUG @@ -174,7 +184,8 @@ namespace adiar::internal struct reduce_uid_lt { - bool operator()(const mapping &a, const mapping &b) + bool + operator()(const mapping& a, const mapping& b) { return a.old_uid > b.old_uid; } @@ -186,7 +197,7 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Create the output file with correct initial meta data already set. ////////////////////////////////////////////////////////////////////////////// - template + template shared_levelized_file __reduce_init_output() { @@ -205,11 +216,11 @@ namespace adiar::internal /// \brief Merging priority queue with terminal_arc stream. ////////////////////////////////////////////////////////////////////////////// template - inline arc __reduce_get_next(pq_t &reduce_pq, arc_stream_t &arcs) + inline arc + __reduce_get_next(pq_t& reduce_pq, arc_stream_t& arcs) { if (!reduce_pq.can_pull() - || (arcs.can_pull_terminal() - && arcs.peek_terminal().source() > reduce_pq.top().source())) { + || (arcs.can_pull_terminal() && arcs.peek_terminal().source() > reduce_pq.top().source())) { return arcs.pull_terminal(); } else { return reduce_pq.pull(); @@ -219,23 +230,25 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Update a cut size with some number of arcs. ////////////////////////////////////////////////////////////////////////////// - inline void __reduce_cut_add(cuts_t &cut, - const cut::size_type internal_arcs, - const cut::size_type false_arcs, - const cut::size_type true_arcs) + inline void + __reduce_cut_add(cuts_t& cut, + const cut::size_type internal_arcs, + const cut::size_type false_arcs, + const cut::size_type true_arcs) { - cut[cut::Internal] += internal_arcs; + cut[cut::Internal] += internal_arcs; cut[cut::Internal_False] += internal_arcs + false_arcs; - cut[cut::Internal_True] += internal_arcs + true_arcs; - cut[cut::All] += internal_arcs + false_arcs + true_arcs; + cut[cut::Internal_True] += internal_arcs + true_arcs; + cut[cut::All] += internal_arcs + false_arcs + true_arcs; } - inline void __reduce_cut_add(cuts_t &cut, const ptr_uint64 target) + inline void + __reduce_cut_add(cuts_t& cut, const ptr_uint64 target) { - cut[cut::Internal] += target.is_node(); + cut[cut::Internal] += target.is_node(); cut[cut::Internal_False] += target.is_node() + target.is_false(); - cut[cut::Internal_True] += target.is_node() + target.is_true(); - cut[cut::All] += 1u; + cut[cut::Internal_True] += target.is_node() + target.is_true(); + cut[cut::All] += 1u; } ////////////////////////////////////////////////////////////////////////////// @@ -247,14 +260,12 @@ namespace adiar::internal /// /// \see __reduce_level ////////////////////////////////////////////////////////////////////////////// - template + template inline void - __reduce_level__epilogue(arc_stream_t &arcs, + __reduce_level__epilogue(arc_stream_t& arcs, label_t label, - pq_t &reduce_pq, - node_writer &out_writer, + pq_t& reduce_pq, + node_writer& out_writer, const bool terminal_val); ////////////////////////////////////////////////////////////////////////////// @@ -263,31 +274,30 @@ namespace adiar::internal /// \returns width of output level ////////////////////////////////////////////////////////////////////////////// template typename sorter_t, + template + typename sorter_t, typename pq_t, typename arc_stream_t> size_t - __reduce_level(arc_stream_t &arcs, + __reduce_level(arc_stream_t& arcs, const typename dd_policy::label_type label, - pq_t &reduce_pq, - node_writer &out_writer, + pq_t& reduce_pq, + node_writer& out_writer, const size_t sorters_memory, const size_t unreduced_width, - [[maybe_unused]] statistics::reduce_t &stats = stats_reduce) + [[maybe_unused]] statistics::reduce_t& stats = stats_reduce) { // Temporary file for Reduction Rule 1 mappings (opened later if need be) tpie::file_stream red1_mapping; // Sorter to find Reduction Rule 2 mappings - sorter_t - child_grouping(sorters_memory, unreduced_width, 2); + sorter_t child_grouping(sorters_memory, unreduced_width, 2); - sorter_t - red2_mapping(sorters_memory, unreduced_width, 2); + sorter_t red2_mapping(sorters_memory, unreduced_width, 2); // Pull out all nodes from reduce_pq and terminal_arcs for this level while ((arcs.can_pull_terminal() && arcs.peek_terminal().source().label() == label) - || reduce_pq.can_pull()) { + || reduce_pq.can_pull()) { // TODO (MDD): // TODO (QMDD): // Use __reduce_get_next node_type::outdegree times to create a @@ -314,8 +324,8 @@ namespace adiar::internal } // Count number of arcs that cross this level - cuts_t local_1level_cut = {{ 0u, 0u, 0u, 0u }}; - cuts_t tainted_1level_cut = {{ 0u, 0u, 0u, 0u }}; + cuts_t local_1level_cut = { { 0u, 0u, 0u, 0u } }; + cuts_t tainted_1level_cut = { { 0u, 0u, 0u, 0u } }; __reduce_cut_add(local_1level_cut, reduce_pq.size_without_terminals(), @@ -331,12 +341,13 @@ namespace adiar::internal while (child_grouping.can_pull()) { const node next_node = child_grouping.pull(); - if (out_node.low() != unflag(next_node.low()) || out_node.high() != unflag(next_node.high())) { + if (out_node.low() != unflag(next_node.low()) + || out_node.high() != unflag(next_node.high())) { adiar_assert(0 <= out_id, "Should still have more ids left"); out_node = node(label, out_id--, unflag(next_node.low()), unflag(next_node.high())); out_writer.unsafe_push(out_node); - __reduce_cut_add(next_node.low().is_flagged() ? tainted_1level_cut : local_1level_cut, + __reduce_cut_add(next_node.low().is_flagged() ? tainted_1level_cut : local_1level_cut, out_node.low()); __reduce_cut_add(next_node.high().is_flagged() ? tainted_1level_cut : local_1level_cut, out_node.high()); @@ -351,37 +362,33 @@ namespace adiar::internal // Add number of nodes to level information, if any nodes were pushed to the output. const size_t reduced_width = dd_policy::max_id - out_id; - if (reduced_width > 0) { - out_writer.unsafe_push(level_info(label, reduced_width)); - } + if (reduced_width > 0) { out_writer.unsafe_push(level_info(label, reduced_width)); } // Sort mappings for Reduction rule 2 back in order of arcs.internal red2_mapping.sort(); // Merging of red1_mapping and red2_mapping - mapping next_red1 = { node::uid_type(), node::uid_type() }; // <-- dummy value + mapping next_red1 = { node::uid_type(), node::uid_type() }; // <-- dummy value bool has_next_red1 = red1_mapping.is_open() && red1_mapping.size() > 0; if (has_next_red1) { red1_mapping.seek(0); next_red1 = red1_mapping.read(); } - mapping next_red2 = { node::uid_type(), node::uid_type() }; // <-- dummy value + mapping next_red2 = { node::uid_type(), node::uid_type() }; // <-- dummy value bool has_next_red2 = red2_mapping.can_pull(); - if (has_next_red2) { - next_red2 = red2_mapping.pull(); - } + if (has_next_red2) { next_red2 = red2_mapping.pull(); } // Pass all the mappings to Q while (has_next_red1 || has_next_red2) { // Find the mapping with largest old_uid - const bool is_red1_current = !has_next_red2 - || (has_next_red1 && next_red1.old_uid > next_red2.old_uid); + const bool is_red1_current = + !has_next_red2 || (has_next_red1 && next_red1.old_uid > next_red2.old_uid); const mapping current_map = is_red1_current ? next_red1 : next_red2; adiar_assert(!arcs.can_pull_internal() - || current_map.old_uid == arcs.peek_internal().target(), + || current_map.old_uid == arcs.peek_internal().target(), "Mapping forwarded in sync with internal arcs"); // Find all arcs that have the target that match the current mapping's old_uid @@ -390,25 +397,20 @@ namespace adiar::internal const ptr_uint64 s = arcs.pull_internal().source(); // If Reduction Rule 1 was used, then tell the parents to add to the global cut. - const ptr_uint64 t = is_red1_current - ? flag(current_map.new_uid) - : static_cast(current_map.new_uid); + const ptr_uint64 t = is_red1_current ? flag(current_map.new_uid) + : static_cast(current_map.new_uid); adiar_assert(t.is_terminal() || t.out_idx() == false, "Created target is without an index"); - reduce_pq.push(arc(s,t)); + reduce_pq.push(arc(s, t)); } // Update the mapping that was used if (is_red1_current) { has_next_red1 = red1_mapping.can_read(); - if (has_next_red1) { - next_red1 = red1_mapping.read(); - } + if (has_next_red1) { next_red1 = red1_mapping.read(); } } else { has_next_red2 = red2_mapping.can_pull(); - if (has_next_red2) { - next_red2 = red2_mapping.pull(); - } + if (has_next_red2) { next_red2 = red2_mapping.pull(); } } } @@ -424,26 +426,22 @@ namespace adiar::internal const bool terminal_value = next_red1.new_uid.is_terminal() && next_red1.new_uid.value(); __reduce_level__epilogue<>(arcs, label, reduce_pq, out_writer, terminal_value); - adiar_assert(reduced_width <= unreduced_width, - "Reduction should only ever remove nodes"); + adiar_assert(reduced_width <= unreduced_width, "Reduction should only ever remove nodes"); return reduced_width; } ////////////////////////////////////////////////////////////////////////////// - template + template inline void - __reduce_level__epilogue(arc_stream_t &arcs, + __reduce_level__epilogue(arc_stream_t& arcs, [[maybe_unused]] label_t label, - pq_t &reduce_pq, - node_writer &out_writer, + pq_t& reduce_pq, + node_writer& out_writer, const bool terminal_val) { - adiar_assert(reduce_pq.empty_level(), - "All forwarded arcs for 'label' should be processed"); + adiar_assert(reduce_pq.empty_level(), "All forwarded arcs for 'label' should be processed"); if (!reduce_pq.empty()) { adiar_assert(!arcs.can_pull_terminal() || arcs.peek_terminal().source().label() < label, @@ -472,11 +470,12 @@ namespace adiar::internal adiar_assert(!arcs.can_pull_internal() && !arcs.can_pull_terminal(), "All nodes should be processed at this point"); - adiar_assert(reduce_pq.size() == 0 && reduce_pq.empty(), - "'reduce_pq.size() == 0' -> 'reduce_pq.empty()', i.e. no parents have been forwarded to'"); + adiar_assert( + reduce_pq.size() == 0 && reduce_pq.empty(), + "'reduce_pq.size() == 0' -> 'reduce_pq.empty()', i.e. no parents have been forwarded to'"); - //adiar_assert(next_red1.new_uid.is_terminal(), - // "A node must have been suppressed in favour of a terminal"); + // adiar_assert(next_red1.new_uid.is_terminal(), + // "A node must have been suppressed in favour of a terminal"); out_writer.unsafe_push(node(terminal_val)); out_writer.unsafe_set_number_of_terminals(!terminal_val, terminal_val); @@ -489,9 +488,9 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Reduce an entire decision diagram bottom-up. ////////////////////////////////////////////////////////////////////////////// - template + template shared_levelized_file - __reduce(const shared_levelized_file &in_file, + __reduce(const shared_levelized_file& in_file, const size_t lpq_memory, const size_t sorters_memory) { @@ -516,13 +515,13 @@ namespace adiar::internal const arc e_low = arcs.pull_terminal(); // Apply reduction rule 1, if applicable - const ptr_uint64 reduction_rule_ret = dd_policy::reduction_rule(node_of(e_low,e_high)); + const ptr_uint64 reduction_rule_ret = dd_policy::reduction_rule(node_of(e_low, e_high)); if (reduction_rule_ret != e_low.source()) { #ifdef ADIAR_STATS stats_reduce.removed_by_rule_1 += 1u; #endif const bool terminal_val = reduction_rule_ret.value(); - const node out_node = node(terminal_val); + const node out_node = node(terminal_val); out_writer.unsafe_push(out_node); out_writer.unsafe_set_number_of_terminals(!terminal_val, terminal_val); @@ -532,21 +531,21 @@ namespace adiar::internal out_writer.unsafe_push(node(label, dd_policy::max_id, e_low.target(), e_high.target())); - out_writer.unsafe_push(level_info(label,1u)); + out_writer.unsafe_push(level_info(label, 1u)); - out_file->max_1level_cut[cut::Internal] = 1u; + out_file->max_1level_cut[cut::Internal] = 1u; out_file->max_1level_cut[cut::Internal_False] = std::max(!e_low.target().value() + !e_high.target().value(), 1); - out_file->max_1level_cut[cut::Internal_True] = + out_file->max_1level_cut[cut::Internal_True] = std::max(e_low.target().value() + e_high.target().value(), 1); - out_file->max_1level_cut[cut::All] = 2u; + out_file->max_1level_cut[cut::All] = 2u; } // Copy over 1-level cut to 2-level cut. - for(size_t ct = 0u; ct < cut::size; ct++) { + for (size_t ct = 0u; ct < cut::size; ct++) { out_file->max_2level_cut[ct] = out_file->max_1level_cut[ct]; } @@ -554,7 +553,7 @@ namespace adiar::internal } // Initialize (levelized) priority queue and run Reduce algorithm - pq_t reduce_pq({in_file}, lpq_memory, in_file->max_1level_cut); + pq_t reduce_pq({ in_file }, lpq_memory, in_file->max_1level_cut); const size_t internal_sorter_can_fit = internal_sorter::memory_fits(sorters_memory / 2); @@ -562,19 +561,19 @@ namespace adiar::internal while (levels.can_pull()) { adiar_assert(arcs.can_pull_terminal() || !reduce_pq.empty(), "If there is a level, then there should also be something for it."); - const level_info current_level_info = levels.pull(); + const level_info current_level_info = levels.pull(); const typename dd_policy::label_type level = current_level_info.level(); adiar_assert(!reduce_pq.has_current_level() || level == reduce_pq.current_level(), "level and priority queue should be in sync"); const size_t unreduced_width = current_level_info.width(); - if(unreduced_width <= internal_sorter_can_fit) { - __reduce_level - (arcs, level, reduce_pq, out_writer, sorters_memory, unreduced_width); + if (unreduced_width <= internal_sorter_can_fit) { + __reduce_level( + arcs, level, reduce_pq, out_writer, sorters_memory, unreduced_width); } else { - __reduce_level - (arcs, level, reduce_pq, out_writer, sorters_memory, unreduced_width); + __reduce_level( + arcs, level, reduce_pq, out_writer, sorters_memory, unreduced_width); } } @@ -589,20 +588,21 @@ namespace adiar::internal /// /// \return The reduced decision diagram in a node-based representation ////////////////////////////////////////////////////////////////////////////// - template + template typename dd_policy::dd_type - reduce(const typename dd_policy::__dd_type &input) + reduce(const typename dd_policy::__dd_type& input) { adiar_assert(!input.empty(), "Input for Reduce should always be non-empty"); // Is it already reduced? if (input.template has()) { - return typename dd_policy::dd_type(input.template get(), - input.negate); + return typename dd_policy::dd_type( + input.template get(), input.negate); } // Get unreduced input - const typename dd_policy::shared_arc_file_type in_file = input.template get(); + const typename dd_policy::shared_arc_file_type in_file = + input.template get(); // Compute amount of memory available for auxiliary data structures after // having opened all streams. @@ -618,13 +618,16 @@ namespace adiar::internal - node_writer::memory_usage(); const size_t pq_memory = aux_available_memory / 2; - const size_t sorters_memory = aux_available_memory - pq_memory - tpie::file_stream::memory_usage(); + const size_t sorters_memory = + aux_available_memory - pq_memory - tpie::file_stream::memory_usage(); const tpie::memory_size_type pq_memory_fits = reduce_priority_queue::memory_fits(pq_memory); - const bool internal_only = input._policy.template get() == exec_policy::memory::Internal; - const bool external_only = input._policy.template get() == exec_policy::memory::External; + const bool internal_only = + input._policy.template get() == exec_policy::memory::Internal; + const bool external_only = + input._policy.template get() == exec_policy::memory::External; const size_t pq_bound = in_file->max_1level_cut; @@ -634,20 +637,20 @@ namespace adiar::internal #ifdef ADIAR_STATS stats_reduce.lpq.unbucketed += 1u; #endif - return __reduce> - (in_file, pq_memory, sorters_memory); - } else if(!external_only && max_pq_size <= pq_memory_fits) { + return __reduce>( + in_file, pq_memory, sorters_memory); + } else if (!external_only && max_pq_size <= pq_memory_fits) { #ifdef ADIAR_STATS stats_reduce.lpq.internal += 1u; #endif - return __reduce> - (in_file, pq_memory, sorters_memory); + return __reduce>( + in_file, pq_memory, sorters_memory); } else { #ifdef ADIAR_STATS stats_reduce.lpq.external += 1u; #endif - return __reduce> - (in_file, pq_memory, sorters_memory); + return __reduce>( + in_file, pq_memory, sorters_memory); } } } diff --git a/src/adiar/internal/algorithms/select.h b/src/adiar/internal/algorithms/select.h index dc5ee7d14..f1cbd1950 100644 --- a/src/adiar/internal/algorithms/select.h +++ b/src/adiar/internal/algorithms/select.h @@ -8,11 +8,11 @@ #include #include -#include #include #include #include #include +#include #include #include #include @@ -51,9 +51,10 @@ namespace adiar::internal // Data Structures using select_request = request_data<1, with_parent>; - template + template using select_priority_queue_t = - levelized_node_priority_queue, + levelized_node_priority_queue, look_ahead, mem_mode, 1u, @@ -65,52 +66,53 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// // Helper functions - template + template inline void - __select_recurse_out(PriorityQueue &pq, arc_writer &aw, - const ptr_uint64 &source, - const ptr_uint64 &target) + __select_recurse_out(PriorityQueue& pq, + arc_writer& aw, + const ptr_uint64& source, + const ptr_uint64& target) { - if(target.is_terminal()) { + if (target.is_terminal()) { aw.push_terminal({ source, target }); } else { - pq.push({ {target}, {}, {source} }); + pq.push({ { target }, {}, { source } }); } } ////////////////////////////////////////////////////////////////////////////// - template + template typename SelectPolicy::__dd_type - __select(const exec_policy &ep, - const typename SelectPolicy::dd_type &dd, - AssignmentMgr &amgr, - const size_t pq_memory, - const size_t pq_max_size) + __select(const exec_policy& ep, + const typename SelectPolicy::dd_type& dd, + AssignmentMgr& amgr, + const size_t pq_memory, + const size_t pq_max_size) { // Set up outputs shared_levelized_file out_arcs; arc_writer aw(out_arcs); out_arcs->max_1level_cut = 0; - bool output_changes = false; + bool output_changes = false; // Set up inputs node_stream<> ns(dd); // Set up priority queue with initial request to the root - PriorityQueue select_pq({dd}, pq_memory, pq_max_size, stats_select.lpq); + PriorityQueue select_pq({ dd }, pq_memory, pq_max_size, stats_select.lpq); { const node root = ns.peek(); - select_pq.push({{ root.uid() }, {}, { SelectPolicy::pointer_type::nil() } }); + select_pq.push({ { root.uid() }, {}, { SelectPolicy::pointer_type::nil() } }); } // Process all to-be-visited nodes in topological order - while(!select_pq.empty()) { + while (!select_pq.empty()) { // Set up next level select_pq.setup_next_level(); const typename SelectPolicy::label_type level = select_pq.current_level(); - typename SelectPolicy::id_type level_size = 0; + typename SelectPolicy::id_type level_size = 0; const assignment a = amgr.assignment_for_level(level); @@ -127,25 +129,25 @@ namespace adiar::internal // Process node // TODO: Move the switch on `a` into Selection Policy? - const select_rec rec = a == assignment::False ? SelectPolicy::fix_false(n, amgr) - : a == assignment::True ? SelectPolicy::fix_true(n, amgr) - : /*a == assignment::None:*/ SelectPolicy::keep_node(n, amgr); + const select_rec rec = a == assignment::False ? SelectPolicy::fix_false(n, amgr) + : a == assignment::True ? SelectPolicy::fix_true(n, amgr) + : /*a == assignment::None:*/ SelectPolicy::keep_node(n, amgr); // Output/Forward resulting node - if(std::holds_alternative(rec)) { + if (std::holds_alternative(rec)) { const node rec_node = std::get(rec); output_changes |= rec_node != n; // Output/Forward outgoing arcs __select_recurse_out(select_pq, aw, n.uid().as_ptr(false), rec_node.low()); - __select_recurse_out(select_pq, aw, n.uid().as_ptr(true), rec_node.high()); + __select_recurse_out(select_pq, aw, n.uid().as_ptr(true), rec_node.high()); // Output ingoing arcs - while(select_pq.can_pull() && select_pq.top().target == rec_node.uid()) { + while (select_pq.can_pull() && select_pq.top().target == rec_node.uid()) { const select_request request_pq = select_pq.pull(); - if(!request_pq.data.source.is_nil()) { + if (!request_pq.data.source.is_nil()) { aw.push_internal({ request_pq.data.source, rec_node.uid() }); } } @@ -158,10 +160,10 @@ namespace adiar::internal output_changes = true; // Output/Forward extension of arc - while(select_pq.can_pull() && select_pq.top().target == n.uid()) { + while (select_pq.can_pull() && select_pq.top().target == n.uid()) { const typename SelectPolicy::pointer_type source = select_pq.pull().data.source; - if(rec_target.is_terminal() && source.is_nil()) { + if (rec_target.is_terminal() && source.is_nil()) { // Edge-case: restriction to a terminal return SelectPolicy::terminal(rec_target.value(), amgr); } @@ -172,30 +174,25 @@ namespace adiar::internal } // Push meta data about this level - if (level_size > 0) { - aw.push(level_info(level, level_size)); - } + if (level_size > 0) { aw.push(level_info(level, level_size)); } } - if (!output_changes) { - return dd; - } + if (!output_changes) { return dd; } return typename SelectPolicy::__dd_type(out_arcs, ep); } - template - size_t __select_2level_upper_bound(const typename SelectPolicy::dd_type &dd) + template + size_t + __select_2level_upper_bound(const typename SelectPolicy::dd_type& dd) { const safe_size_t max_2level_cut = dd.max_2level_cut(cut::Internal); return to_size(max_2level_cut + 2u); } - template + template typename SelectPolicy::__dd_type - select(const exec_policy &ep, - const typename SelectPolicy::dd_type &dd, - AssignmentMgr &amgr) + select(const exec_policy& ep, const typename SelectPolicy::dd_type& dd, AssignmentMgr& amgr) { // Compute amount of memory available for auxiliary data structures after // having opened all streams. @@ -203,40 +200,46 @@ namespace adiar::internal // We then may derive an upper bound on the size of auxiliary data // structures and check whether we can run them with a faster internal // memory variant. - const tpie::memory_size_type aux_available_memory = memory_available() - - node_stream<>::memory_usage() - arc_writer::memory_usage(); + const tpie::memory_size_type aux_available_memory = + memory_available() - node_stream<>::memory_usage() - arc_writer::memory_usage(); const tpie::memory_size_type pq_memory_fits = - select_priority_queue_t::memory_fits(aux_available_memory); + select_priority_queue_t::memory_fits( + aux_available_memory); - const bool internal_only = ep.template get() == exec_policy::memory::Internal; - const bool external_only = ep.template get() == exec_policy::memory::External; + const bool internal_only = + ep.template get() == exec_policy::memory::Internal; + const bool external_only = + ep.template get() == exec_policy::memory::External; const size_t pq_bound = __select_2level_upper_bound(dd); const size_t max_pq_size = internal_only ? std::min(pq_memory_fits, pq_bound) : pq_bound; - if(!external_only && max_pq_size <= no_lookahead_bound(1)) { + if (!external_only && max_pq_size <= no_lookahead_bound(1)) { #ifdef ADIAR_STATS stats_select.lpq.unbucketed += 1u; #endif - return __select> - (ep, dd, amgr, aux_available_memory, max_pq_size); - } else if(!external_only && max_pq_size <= pq_memory_fits) { + return __select>( + ep, dd, amgr, aux_available_memory, max_pq_size); + } else if (!external_only && max_pq_size <= pq_memory_fits) { #ifdef ADIAR_STATS stats_select.lpq.internal += 1u; #endif - return __select> - (ep, dd, amgr, aux_available_memory, max_pq_size); + return __select>( + ep, dd, amgr, aux_available_memory, max_pq_size); } else { #ifdef ADIAR_STATS stats_select.lpq.external += 1u; #endif - return __select> - (ep, dd, amgr, aux_available_memory, max_pq_size); + return __select>( + ep, dd, amgr, aux_available_memory, max_pq_size); } } } diff --git a/src/adiar/internal/algorithms/traverse.h b/src/adiar/internal/algorithms/traverse.h index 3dce57045..78be59488 100644 --- a/src/adiar/internal/algorithms/traverse.h +++ b/src/adiar/internal/algorithms/traverse.h @@ -2,9 +2,9 @@ #define ADIAR_INTERNAL_ALGORITHMS_TRAVERSE_H #include -#include -#include #include +#include +#include #include #include @@ -19,8 +19,9 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// - template - void traverse(const Dd &dd, Visitor &visitor) + template + void + traverse(const Dd& dd, Visitor& visitor) { node_stream<> in_nodes(dd); @@ -30,17 +31,14 @@ namespace adiar::internal while (!tgt.is_terminal() && !tgt.is_nil()) { while (n.uid() < tgt) { n = in_nodes.pull(); } - adiar_assert(n.uid() == tgt, - "Invalid uid chasing; fell out of Decision Diagram"); + adiar_assert(n.uid() == tgt, "Invalid uid chasing; fell out of Decision Diagram"); tgt = visitor.visit(n); adiar_assert((tgt == n.low()) || (tgt == n.high()) || (tgt.is_nil()), "Visitor pointer should be a child or nil"); } - if (!tgt.is_nil()) { - visitor.visit(tgt.value()); - } + if (!tgt.is_nil()) { visitor.visit(tgt.value()); } } ////////////////////////////////////////////////////////////////////////////// @@ -54,13 +52,15 @@ namespace adiar::internal public: static constexpr bool default_direction = false; - inline node::pointer_type visit(const node &n) + inline node::pointer_type + visit(const node& n) { return n.low().is_false() ? n.high() : n.low(); } - inline void visit(const bool/*t*/) - { } + inline void + visit(const bool /*t*/) + {} }; ////////////////////////////////////////////////////////////////////////////// @@ -74,13 +74,15 @@ namespace adiar::internal public: static constexpr bool default_direction = true; - inline node::pointer_type visit(const node &n) + inline node::pointer_type + visit(const node& n) { return n.high().is_false() ? n.low() : n.high(); } - inline void visit(const bool/*t*/) - { } + inline void + visit(const bool /*t*/) + {} }; } diff --git a/src/adiar/internal/assert.h b/src/adiar/internal/assert.h index 5f4f628ca..f0568348c 100644 --- a/src/adiar/internal/assert.h +++ b/src/adiar/internal/assert.h @@ -17,11 +17,11 @@ namespace adiar public: //////////////////////////////////////////////////////////////////////////// - assert_error(const std::string &what) + assert_error(const std::string& what) : _what(what) - { } + {} - assert_error(const std::string &file, const int line) + assert_error(const std::string& file, const int line) { std::stringstream s; s << file << "::" << line; @@ -29,7 +29,7 @@ namespace adiar } //////////////////////////////////////////////////////////////////////////// - assert_error(const std::string &file, const int line, const std::string &what) + assert_error(const std::string& file, const int line, const std::string& what) { std::stringstream s; s << file << "::" << line << ": " << what; @@ -40,24 +40,27 @@ namespace adiar //////////////////////////////////////////////////////////////////////////// /// \brief Explanatory string //////////////////////////////////////////////////////////////////////////// - char* what() - { return _what.data(); } + char* + what() + { + return _what.data(); + } }; - -#ifdef __GNUC__ // GCC 4.8+, Clang, Intel and other compilers compatible with GCC (-std=c++0x or above) +#ifdef __GNUC__ // GCC 4.8+, Clang, Intel and other compilers compatible with GCC (-std=c++0x or + // above) // Macros based on: // - Assert with file information and messages: https://stackoverflow.com/a/37264642 // - Variadic macro arguments: https://stackoverflow.com/a/11763277 -#define adiar_assert_overload(_1,_2,NAME,...) NAME -#define adiar_assert(...) adiar_assert_overload(__VA_ARGS__, adiar_assert2, adiar_assert1)(__VA_ARGS__) +#define adiar_assert_overload(_1, _2, NAME, ...) NAME +#define adiar_assert(...) \ + adiar_assert_overload(__VA_ARGS__, adiar_assert2, adiar_assert1)(__VA_ARGS__) #ifndef NDEBUG -# define adiar_assert1(Expr) __adiar_assert(#Expr, Expr, __FILE__, __LINE__) -# define adiar_assert2(Expr, Msg) __adiar_assert(#Expr, Expr, __FILE__, __LINE__, Msg) +#define adiar_assert1(Expr) __adiar_assert(#Expr, Expr, __FILE__, __LINE__) +#define adiar_assert2(Expr, Msg) __adiar_assert(#Expr, Expr, __FILE__, __LINE__, Msg) - inline - void + inline void __adiar_assert(const char* expr_str, bool expr, const char* file, int line) { if (!expr) { @@ -69,8 +72,7 @@ namespace adiar } } - inline - void + inline void __adiar_assert(const char* expr_str, bool expr, const char* file, int line, const char* msg) { if (!expr) { @@ -82,13 +84,13 @@ namespace adiar } } #else -# define adiar_assert1(Expr) ; -# define adiar_assert2(Expr, Msg) ; +#define adiar_assert1(Expr) ; +#define adiar_assert2(Expr, Msg) ; #endif #else // MSVC and ??? compilers - inline void adiar_assert([[maybe_unused]] const bool expr, - [[maybe_unused]] const std::string &what = "") + inline void + adiar_assert([[maybe_unused]] const bool expr, [[maybe_unused]] const std::string& what = "") { #ifndef NDEBUG if (!expr) { throw assert_error(what); } diff --git a/src/adiar/internal/block_size.h b/src/adiar/internal/block_size.h index 6c1a9b53c..6738e118a 100644 --- a/src/adiar/internal/block_size.h +++ b/src/adiar/internal/block_size.h @@ -15,7 +15,8 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Sets the block size for TPIE. ////////////////////////////////////////////////////////////////////////////// - inline void set_block_size(size_t block_size_bytes) + inline void + set_block_size(size_t block_size_bytes) { tpie::set_block_size(block_size_bytes); } @@ -23,7 +24,8 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Get the block size from TPIE. ////////////////////////////////////////////////////////////////////////////// - inline size_t get_block_size() + inline size_t + get_block_size() { return tpie::get_block_size(); } @@ -32,7 +34,8 @@ namespace adiar::internal /// \brief Computes a recommended block size to be used with a specific /// amount of available internal memory. ////////////////////////////////////////////////////////////////////////////// - inline size_t recommended_block_size(size_t /*memory_limit_bytes*/) + inline size_t + recommended_block_size(size_t /*memory_limit_bytes*/) { return minimum_block_size; } diff --git a/src/adiar/internal/bool_op.h b/src/adiar/internal/bool_op.h index ee273b7fb..c22cdea43 100644 --- a/src/adiar/internal/bool_op.h +++ b/src/adiar/internal/bool_op.h @@ -5,11 +5,12 @@ namespace adiar::internal { - ////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// /// \brief Whether the terminal shortcuts the operator from the right, /// i.e. `op(T,t) == op(F,t)`. ////////////////////////////////////////////////////////////////////////////// - inline bool can_right_shortcut(const bool_op &op, const internal::ptr_uint64 &terminal) + inline bool + can_right_shortcut(const bool_op& op, const internal::ptr_uint64& terminal) { adiar_assert(terminal.is_terminal()); return op(internal::ptr_uint64(false), terminal) == op(internal::ptr_uint64(true), terminal); @@ -19,7 +20,8 @@ namespace adiar::internal /// \brief Whether the terminal shortcuts the operator from the left, /// i.e. `op(t, T) == op(t, F)`. ////////////////////////////////////////////////////////////////////////////// - inline bool can_left_shortcut(const bool_op &op, const internal::ptr_uint64 &terminal) + inline bool + can_left_shortcut(const bool_op& op, const internal::ptr_uint64& terminal) { adiar_assert(terminal.is_terminal()); return op(terminal, internal::ptr_uint64(false)) == op(terminal, internal::ptr_uint64(true)); @@ -29,7 +31,8 @@ namespace adiar::internal /// \brief Whether the terminal is irrelevant for the operator from the right, /// i.e. `op(X, t) == X`. ////////////////////////////////////////////////////////////////////////////// - inline bool is_right_irrelevant(const bool_op &op, const internal::ptr_uint64 &terminal) + inline bool + is_right_irrelevant(const bool_op& op, const internal::ptr_uint64& terminal) { adiar_assert(terminal.is_terminal()); return op(internal::ptr_uint64(false), terminal) == internal::ptr_uint64(false) @@ -40,7 +43,8 @@ namespace adiar::internal /// \brief Whether the terminal is irrelevant for the operator from the left, /// i.e. `op(t, X) == X`. ////////////////////////////////////////////////////////////////////////////// - inline bool is_left_irrelevant(const bool_op &op, const internal::ptr_uint64 &terminal) + inline bool + is_left_irrelevant(const bool_op& op, const internal::ptr_uint64& terminal) { adiar_assert(terminal.is_terminal()); return op(terminal, internal::ptr_uint64(false)) == internal::ptr_uint64(false) @@ -51,7 +55,8 @@ namespace adiar::internal /// \brief Whether the terminal for this operator negates the value of the other /// from the right, i.e. `op(X, t) == ~X`. ////////////////////////////////////////////////////////////////////////////// - inline bool is_right_negating(const bool_op &op, const internal::ptr_uint64 &terminal) + inline bool + is_right_negating(const bool_op& op, const internal::ptr_uint64& terminal) { adiar_assert(terminal.is_terminal()); return op(terminal, internal::ptr_uint64(false)) == internal::ptr_uint64(true) @@ -62,7 +67,8 @@ namespace adiar::internal /// \brief Whether the terminal for this operator negates the value of the other /// from the left, i.e. `op(t, X) == ~X` ////////////////////////////////////////////////////////////////////////////// - inline bool is_left_negating(const bool_op &op, const internal::ptr_uint64 &terminal) + inline bool + is_left_negating(const bool_op& op, const internal::ptr_uint64& terminal) { adiar_assert(terminal.is_terminal()); return op(terminal, internal::ptr_uint64(false)) == internal::ptr_uint64(true) @@ -72,7 +78,8 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Whether an operator is commutative, `op(X, Y) == op(Y, X)`. ////////////////////////////////////////////////////////////////////////////// - inline bool is_commutative(const bool_op &op) + inline bool + is_commutative(const bool_op& op) { internal::ptr_uint64 terminal_T = internal::ptr_uint64(true); internal::ptr_uint64 terminal_F = internal::ptr_uint64(false); @@ -83,12 +90,12 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Return the flipped operator, i.e. `op'(X, Y) == op(Y, X)`. ////////////////////////////////////////////////////////////////////////////// - inline bool_op flip(const bool_op &op) + inline bool_op + flip(const bool_op& op) { if (is_commutative(op)) return op; - return [&op](const internal::ptr_uint64 &a, const internal::ptr_uint64 &b) - {return op(b, a);}; + return [&op](const internal::ptr_uint64& a, const internal::ptr_uint64& b) { return op(b, a); }; } } diff --git a/src/adiar/internal/cnl.h b/src/adiar/internal/cnl.h index e47731bd8..dc48f2ed1 100644 --- a/src/adiar/internal/cnl.h +++ b/src/adiar/internal/cnl.h @@ -25,7 +25,8 @@ namespace adiar //////////////////////////////////////////////////////////////////////////// /// \brief Unpacks the value from a 'safe_size_t'. //////////////////////////////////////////////////////////////////////////// - inline size_t to_size(const safe_size_t s) + inline size_t + to_size(const safe_size_t s) { return cnl::convert(s); } @@ -33,7 +34,8 @@ namespace adiar //////////////////////////////////////////////////////////////////////////// /// \brief Compute nominator / denominator as a double. //////////////////////////////////////////////////////////////////////////// - inline double frac(uintwide numerator, uintwide denominator) + inline double + frac(uintwide numerator, uintwide denominator) { using frac_type = cnl::fraction; @@ -44,7 +46,8 @@ namespace adiar //////////////////////////////////////////////////////////////////////////// /// \brief Compute (100 * nominator) / denominator as a double. //////////////////////////////////////////////////////////////////////////// - inline double percent_frac(uintwide numerator, uintwide denominator) + inline double + percent_frac(uintwide numerator, uintwide denominator) { return 100.0 * frac(numerator, denominator); } @@ -53,18 +56,18 @@ namespace adiar /// Derivative of the 'cnl:_impl:to_chars_natural' (and 'cnl::_impl:itoc' /// inlined) for the 'cnl::wide_integer' without compiler errors. //////////////////////////////////////////////////////////////////////////// - inline void to_stringstream(const uintwide &value, std::stringstream &s) + inline void + to_stringstream(const uintwide& value, std::stringstream& s) { - constexpr size_t base = 10u; + constexpr size_t base = 10u; const uintwide quotient = value / base; - if (quotient) { - to_stringstream(quotient, s); - } + if (quotient) { to_stringstream(quotient, s); } const uintwide remainder = value - (quotient * base); - const int remainder_int = cnl::convert(remainder); - const char remainder_char = static_cast('0'+remainder_int); + const int remainder_int = + cnl::convert(remainder); + const char remainder_char = static_cast('0' + remainder_int); s << remainder_char; } @@ -72,7 +75,8 @@ namespace adiar //////////////////////////////////////////////////////////////////////////// /// \brief Convert a wide integer to a string. //////////////////////////////////////////////////////////////////////////// - inline std::string to_string(const uintwide &value) + inline std::string + to_string(const uintwide& value) { std::stringstream s; to_stringstream(value, s); diff --git a/src/adiar/internal/cut.h b/src/adiar/internal/cut.h index d8bffca75..effc46e1f 100644 --- a/src/adiar/internal/cut.h +++ b/src/adiar/internal/cut.h @@ -2,8 +2,8 @@ #define ADIAR_INTERNAL_CUT_H #include -#include #include +#include #include @@ -42,13 +42,13 @@ namespace adiar::internal enum type { /** Internal arcs only */ - Internal = 0, // 0x00 + Internal = 0, // 0x00 /** Internal arcs and false arcs only */ Internal_False = 1, // 0x01 /** Internal arcs and true arcs only */ - Internal_True = 2, // 0x10 + Internal_True = 2, // 0x10 /** All types of arcs: internal, false, and true */ - All = 3 // 0x11 + All = 3 // 0x11 }; //////////////////////////////////////////////////////////////////////////// @@ -70,14 +70,14 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// constexpr cut(type ct) : _ct(ct) - { } + {} //////////////////////////////////////////////////////////////////////////// /// \brief Conversion from a `size_t` enum value (possibly at compile-time). //////////////////////////////////////////////////////////////////////////// constexpr cut(size_t ct) : _ct(static_cast(ct)) - { } + {} //////////////////////////////////////////////////////////////////////////// /// \brief Convert the boolean values of whether to include the `false` and @@ -85,29 +85,39 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// constexpr cut(bool incl_false, bool incl_true) : _ct(static_cast((incl_true << 1) + incl_false)) - { } + {} //////////////////////////////////////////////////////////////////////////// /// \brief Implicit conversion to enum to allow for switch and comparisons. //////////////////////////////////////////////////////////////////////////// - constexpr operator type() const - { return _ct; } + constexpr + operator type() const + { + return _ct; + } // Prevent usage: if(cut) - explicit operator bool() const = delete; + explicit + operator bool() const = delete; public: //////////////////////////////////////////////////////////////////////////// /// \brief Whether this cut includes the given terminal. //////////////////////////////////////////////////////////////////////////// - bool includes(const terminal_type &t) const - { return t ? _ct >= Internal_True : (_ct == Internal_False || _ct == All); } + bool + includes(const terminal_type& t) const + { + return t ? _ct >= Internal_True : (_ct == Internal_False || _ct == All); + } //////////////////////////////////////////////////////////////////////////// /// \brief The number of terminals included in this cut. //////////////////////////////////////////////////////////////////////////// - size_t number_of_terminals() const - { return this->includes(false) + this->includes(true); } + size_t + number_of_terminals() const + { + return this->includes(false) + this->includes(true); + } }; ////////////////////////////////////////////////////////////////////////////// @@ -122,8 +132,9 @@ namespace adiar::internal { using type = cut; - template - static inline cut::size_type get(const dd_t &dd, const type ct) + template + static inline cut::size_type + get(const dd_t& dd, const type ct) { return dd.max_1level_cut(ct); } @@ -136,8 +147,9 @@ namespace adiar::internal { using type = cut; - template - static inline cut::size_type get(const dd_t &dd, const type ct) + template + static inline cut::size_type + get(const dd_t& dd, const type ct) { return dd.max_2level_cut(ct); } diff --git a/src/adiar/internal/data_structures/level_merger.h b/src/adiar/internal/data_structures/level_merger.h index a7d8723d8..9a2879320 100644 --- a/src/adiar/internal/data_structures/level_merger.h +++ b/src/adiar/internal/data_structures/level_merger.h @@ -3,11 +3,11 @@ #include #include -#include #include #include #include #include +#include #include namespace adiar::internal @@ -25,7 +25,7 @@ namespace adiar::internal /// /// \tparam FileCount Number of files to read from. ////////////////////////////////////////////////////////////////////////////// - template + template class level_merger { static_assert(0 < FileCount, "At least one file should be merged"); @@ -33,7 +33,8 @@ namespace adiar::internal using stream_t = typename level_stream_t::template stream_t; public: - static size_t memory_usage() + static size_t + memory_usage() { return FileCount * stream_t::memory_usage(); } @@ -49,7 +50,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Attach onto the given list of files. //////////////////////////////////////////////////////////////////////////// - void hook(const File (&fs) [FileCount]) + void + hook(const File (&fs)[FileCount]) { for (size_t idx = 0u; idx < FileCount; idx++) { _level_streams[idx] = adiar::make_unique(fs[idx]); @@ -59,7 +61,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Attach onto the given list of decision diagrams. //////////////////////////////////////////////////////////////////////////// - void hook(const dd (&dds) [FileCount]) + void + hook(const dd (&dds)[FileCount]) { for (size_t idx = 0u; idx < FileCount; idx++) { _level_streams[idx] = adiar::make_unique(dds[idx].file); @@ -69,7 +72,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Attach onto the given list of (unreduced) decision diagrams. //////////////////////////////////////////////////////////////////////////// - void hook(const __dd (&dds) [FileCount]) + void + hook(const __dd (&dds)[FileCount]) { for (size_t idx = 0u; idx < FileCount; idx++) { _level_streams[idx] = adiar::make_unique(dds[idx]); @@ -79,12 +83,11 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether there are more levels to fetch. //////////////////////////////////////////////////////////////////////////// - bool can_pull() + bool + can_pull() { for (size_t idx = 0u; idx < FileCount; idx++) { - if (_level_streams[idx]->can_pull()) { - return true; - } + if (_level_streams[idx]->can_pull()) { return true; } } return false; } @@ -94,17 +97,18 @@ namespace adiar::internal /// /// \pre `can_pull() == true` //////////////////////////////////////////////////////////////////////////// - level_type peek() + level_type + peek() { adiar_assert(can_pull(), "Cannot peek past end of all streams"); - bool has_min_level = false; + bool has_min_level = false; level_type min_level = 0u; for (size_t idx = 0u; idx < FileCount; idx++) { if (_level_streams[idx]->can_pull() && (!has_min_level || _comparator(level_of(_level_streams[idx]->peek()), min_level))) { has_min_level = true; - min_level = level_of(_level_streams[idx]->peek()); + min_level = level_of(_level_streams[idx]->peek()); } } @@ -116,14 +120,15 @@ namespace adiar::internal /// /// \pre `can_pull() == true` //////////////////////////////////////////////////////////////////////////// - level_type pull() + level_type + pull() { adiar_assert(can_pull(), "Cannot pull past end of all streams"); level_type min_level = peek(); // pull from all with min_level - for (const unique_ptr &level_info_stream : _level_streams) { + for (const unique_ptr& level_info_stream : _level_streams) { if (level_info_stream->can_pull() && level_of(level_info_stream->peek()) == min_level) { level_info_stream->pull(); } diff --git a/src/adiar/internal/data_structures/levelized_priority_queue.h b/src/adiar/internal/data_structures/levelized_priority_queue.h index ac61e628a..bc98f84a2 100644 --- a/src/adiar/internal/data_structures/levelized_priority_queue.h +++ b/src/adiar/internal/data_structures/levelized_priority_queue.h @@ -3,22 +3,24 @@ #include +#include + #include -#include -#include #include #include #include +#include #include #include -#include +#include namespace adiar::internal { //////////////////////////////////////////////////////////////////////////// /// \brief Number of items for which the unbucketed queue can be used //////////////////////////////////////////////////////////////////////////// - constexpr size_t no_lookahead_bound(const size_t degree = 1) + constexpr size_t + no_lookahead_bound(const size_t degree = 1) { return 8 * (1 << degree); } @@ -26,10 +28,11 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Strictly less ' < ' between two levels. //////////////////////////////////////////////////////////////////////////// - template - inline bool level_cmp_lt(const ptr_uint64::label_type l1, - const ptr_uint64::label_type l2, - const LevelFileComp &level_comp) + template + inline bool + level_cmp_lt(const ptr_uint64::label_type l1, + const ptr_uint64::label_type l2, + const LevelFileComp& level_comp) { return level_comp(l1, l2); } @@ -37,10 +40,11 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Less or equal ' <= ' between two levels. //////////////////////////////////////////////////////////////////////////// - template - inline bool level_cmp_le(const ptr_uint64::label_type l1, - const ptr_uint64::label_type l2, - const LevelFileComp &level_comp) + template + inline bool + level_cmp_le(const ptr_uint64::label_type l1, + const ptr_uint64::label_type l2, + const LevelFileComp& level_comp) { return level_comp(l1, l2) || l1 == l2; } @@ -93,16 +97,15 @@ namespace adiar::internal /// \tparam LevelSkip The index for the first level one can push to. In /// other words, the number of levels to 'skip'. ////////////////////////////////////////////////////////////////////////////// - template , - size_t LookAhead = ADIAR_LPQ_LOOKAHEAD, - memory_mode MemoryMode = memory_mode::External, - typename LevelFile = shared_file_ptr>, - size_t LevelFileCount = 1u, - typename LevelFileComp = std::less<>, - bool LevelReverse = false, - size_t LevelSkip = 1u - > + template , + size_t LookAhead = ADIAR_LPQ_LOOKAHEAD, + memory_mode MemoryMode = memory_mode::External, + typename LevelFile = shared_file_ptr>, + size_t LevelFileCount = 1u, + typename LevelFileComp = std::less<>, + bool LevelReverse = false, + size_t LevelSkip = 1u> class levelized_priority_queue { public: @@ -161,14 +164,12 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Value to reflect 'out of levels'. //////////////////////////////////////////////////////////////////////////// - static constexpr ptr_uint64::label_type no_label = ptr_uint64::max_label+1; + static constexpr ptr_uint64::label_type no_label = ptr_uint64::max_label + 1; private: - static_assert(0 < LookAhead, - "LookAhead must at least be of one level"); + static_assert(0 < LookAhead, "LookAhead must at least be of one level"); - static_assert(0 < ptr_uint64::max_label, - "A larger LookAhead than max_label is wasteful"); + static_assert(0 < ptr_uint64::max_label, "A larger LookAhead than max_label is wasteful"); static_assert(buckets < out_of_buckets_idx, "LookAhead must not be so large to also include '-1'"); @@ -176,44 +177,50 @@ namespace adiar::internal static_assert(out_of_buckets_idx + 1 == 0, "Overflow to '0' is necessary for internal logic to work"); - static_assert(ptr_uint64::max_label+1 > ptr_uint64::max_label, - "'ptr_uint64::label_type' should leave a window of at least one above 'max_label'"); + static_assert( + ptr_uint64::max_label + 1 > ptr_uint64::max_label, + "'ptr_uint64::label_type' should leave a window of at least one above 'max_label'"); private: - static tpie::memory_size_type const_memory_usage() + static tpie::memory_size_type + const_memory_usage() { return level_merger_t::memory_usage(); } public: - static tpie::memory_size_type memory_usage(tpie::memory_size_type no_elements) + static tpie::memory_size_type + memory_usage(tpie::memory_size_type no_elements) { - return priority_queue::memory_usage(no_elements) - + buckets * sorter::memory_usage(no_elements) + return priority_queue::memory_usage( + no_elements) + + buckets + * sorter::memory_usage(no_elements) + const_memory_usage(); } - static tpie::memory_size_type memory_fits(tpie::memory_size_type memory_bytes) + static tpie::memory_size_type + memory_fits(tpie::memory_size_type memory_bytes) { const size_t const_memory_bytes = const_memory_usage(); - if (memory_bytes < const_memory_bytes) { - return 0u; - } + if (memory_bytes < const_memory_bytes) { return 0u; } // HACK: just provide the minimum of what either of the data structures // can hold when given an equal share of the memory. - const size_t memory_per_data_structure = (memory_bytes - const_memory_bytes) / data_structures; + const size_t memory_per_data_structure = + (memory_bytes - const_memory_bytes) / data_structures; - const size_t sorter_fits = sorter - ::memory_fits(memory_per_data_structure); + const size_t sorter_fits = + sorter::memory_fits( + memory_per_data_structure); - const size_t priority_queue_fits = priority_queue - ::memory_fits(memory_per_data_structure); + const size_t priority_queue_fits = + priority_queue::memory_fits( + memory_per_data_structure); const size_t res = std::min(sorter_fits, priority_queue_fits); - adiar_assert(memory_usage(res) <= memory_bytes, - "memory_fits and memory_usage should agree."); + adiar_assert(memory_usage(res) <= memory_bytes, "memory_fits and memory_usage should agree."); return res; } @@ -264,8 +271,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Memory used by the label merger. //////////////////////////////////////////////////////////////////////////// - const tpie::memory_size_type _memory_occupied_by_merger = - level_merger_t::memory_usage(); + const tpie::memory_size_type _memory_occupied_by_merger = level_merger_t::memory_usage(); //////////////////////////////////////////////////////////////////////////// /// \brief Memory to be used for the buckets. @@ -285,12 +291,12 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Level of each bucket. //////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type _buckets_level [buckets]; + ptr_uint64::label_type _buckets_level[buckets]; //////////////////////////////////////////////////////////////////////////// /// \brief Sorter for each bucket. //////////////////////////////////////////////////////////////////////////// - unique_ptr _buckets_sorter [buckets]; + unique_ptr _buckets_sorter[buckets]; //////////////////////////////////////////////////////////////////////////// /// \brief Index of the currently read-from bucket (if any). @@ -300,7 +306,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Index of the last available bucket (if any). //////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type _back_bucket_idx = out_of_buckets_idx; + ptr_uint64::label_type _back_bucket_idx = out_of_buckets_idx; //////////////////////////////////////////////////////////////////////////// /// \brief Next element to take out of the bucket (if any) @@ -329,16 +335,16 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Reference to struct to store non-global stats into. //////////////////////////////////////////////////////////////////////////// - statistics::levelized_priority_queue_t &_stats; + statistics::levelized_priority_queue_t& _stats; #endif private: - static tpie::memory_size_type mem_overflow_queue(tpie::memory_size_type memory_given) + static tpie::memory_size_type + mem_overflow_queue(tpie::memory_size_type memory_given) { const size_t const_memory = const_memory_usage(); - adiar_assert(const_memory < memory_given, - "There should be enough memory for the merger"); + adiar_assert(const_memory < memory_given, "There should be enough memory for the merger"); // subtract memory of the merger to not take any of its memory. memory_given -= const_memory; @@ -359,7 +365,7 @@ namespace adiar::internal // LCOV_EXCL_START // TODO: Unit test external memory variants? - const tpie::memory_size_type eight_MiB = 8 * 1024; + const tpie::memory_size_type eight_MiB = 8 * 1024; const tpie::memory_size_type weighted_share = memory_given / (4 * buckets + 1); return std::max(eight_MiB, weighted_share); @@ -371,22 +377,24 @@ namespace adiar::internal } } - levelized_priority_queue(tpie::memory_size_type memory_given, size_t max_size, - [[maybe_unused]] statistics::levelized_priority_queue_t &stats) + levelized_priority_queue(tpie::memory_size_type memory_given, + size_t max_size, + [[maybe_unused]] statistics::levelized_priority_queue_t& stats) : _max_size(max_size) , _memory_given(memory_given) - , _memory_for_buckets(memory_given - _memory_occupied_by_merger - mem_overflow_queue(memory_given)) + , _memory_for_buckets(memory_given - _memory_occupied_by_merger + - mem_overflow_queue(memory_given)) , _memory_occupied_by_overflow(mem_overflow_queue(memory_given)) , _overflow_queue(mem_overflow_queue(memory_given), max_size) #ifdef ADIAR_STATS , _stats(stats) #endif { - adiar_assert(_memory_occupied_by_merger + _memory_for_buckets + _memory_occupied_by_overflow <= _memory_given, + adiar_assert(_memory_occupied_by_merger + _memory_for_buckets + _memory_occupied_by_overflow + <= _memory_given, "the amount of memory used should be within the given bounds"); } - public: //////////////////////////////////////////////////////////////////////////// /// \brief Instantiate with the given amount of memory. @@ -395,10 +403,10 @@ namespace adiar::internal /// /// \param memory_given Total amount of memory to use //////////////////////////////////////////////////////////////////////////// - levelized_priority_queue(const LevelFile (& files) [LevelFileCount], + levelized_priority_queue(const LevelFile (&files)[LevelFileCount], tpie::memory_size_type memory_given, size_t max_size, - statistics::levelized_priority_queue_t &stats) + statistics::levelized_priority_queue_t& stats) : levelized_priority_queue(memory_given, max_size, stats) { _level_merger.hook(files); @@ -412,10 +420,10 @@ namespace adiar::internal /// /// \param memory_given Total amount of memory to use //////////////////////////////////////////////////////////////////////////// - levelized_priority_queue(const dd (& dds) [LevelFileCount], + levelized_priority_queue(const dd (&dds)[LevelFileCount], tpie::memory_size_type memory_given, size_t max_size, - statistics::levelized_priority_queue_t &stats) + statistics::levelized_priority_queue_t& stats) : levelized_priority_queue(memory_given, max_size, stats) { _level_merger.hook(dds); @@ -429,10 +437,10 @@ namespace adiar::internal /// /// \param memory_given Total amount of memory to use //////////////////////////////////////////////////////////////////////////// - levelized_priority_queue(const __dd (& dds) [LevelFileCount], + levelized_priority_queue(const __dd (&dds)[LevelFileCount], tpie::memory_size_type memory_given, size_t max_size, - statistics::levelized_priority_queue_t &stats) + statistics::levelized_priority_queue_t& stats) : levelized_priority_queue(memory_given, max_size, stats) { _level_merger.hook(dds); @@ -447,7 +455,8 @@ namespace adiar::internal /// \remark Call this function at the end of the constructor after the /// level_merger has hooked into the input. //////////////////////////////////////////////////////////////////////////// - void init_buckets() + void + init_buckets() { // Initially skip the number of levels for (size_t idx = 0; _level_merger.can_pull() && idx < LevelSkip; idx++) { @@ -459,13 +468,13 @@ namespace adiar::internal while (_back_bucket_idx + 1 < buckets && _level_merger.can_pull()) { const ptr_uint64::label_type level = _level_merger.pull(); - adiar_assert(_front_bucket_idx == out_of_buckets_idx, - "Front bucket not moved"); + adiar_assert(_front_bucket_idx == out_of_buckets_idx, "Front bucket not moved"); _back_bucket_idx++; _buckets_level[_back_bucket_idx] = level; - _buckets_sorter[_back_bucket_idx] = sorter_t::make_unique(_memory_for_buckets, _max_size, buckets); + _buckets_sorter[_back_bucket_idx] = + sorter_t::make_unique(_memory_for_buckets, _max_size, buckets); } } @@ -491,7 +500,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether there is any current level to pull elements from. //////////////////////////////////////////////////////////////////////////// - bool has_current_level() const + bool + has_current_level() const { return _current_level != no_label; } @@ -501,10 +511,10 @@ namespace adiar::internal /// /// \pre `has_current_level() == true` //////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type current_level() const + ptr_uint64::label_type + current_level() const { - adiar_assert(has_current_level(), - "Needs to have a 'current' level to read the level from"); + adiar_assert(has_current_level(), "Needs to have a 'current' level to read the level from"); return _current_level; } @@ -512,7 +522,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether there are any more (possibly all empty) levels. //////////////////////////////////////////////////////////////////////////// - bool has_next_level() const + bool + has_next_level() const { return has_next_bucket(); } @@ -522,7 +533,8 @@ namespace adiar::internal /// /// \pre `has_next_level() == true` //////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type next_level() const + ptr_uint64::label_type + next_level() const { return next_bucket_level(); } @@ -530,7 +542,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether one can push elements. //////////////////////////////////////////////////////////////////////////// - bool can_push() const + bool + can_push() const { return has_next_level(); } @@ -538,10 +551,10 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Push an element into the priority queue. //////////////////////////////////////////////////////////////////////////// - void push(const value_type &e) + void + push(const value_type& e) { - adiar_assert(can_push(), - "Should only push when there is a yet unvisited level."); + adiar_assert(can_push(), "Should only push when there is a yet unvisited level."); const ptr_uint64::label_type level = e.level(); @@ -550,8 +563,7 @@ namespace adiar::internal const size_t pushable_buckets = active_buckets() - has_front_bucket(); - adiar_assert(pushable_buckets > 0, - "There is at least one pushable bucket (i.e. level)"); + adiar_assert(pushable_buckets > 0, "There is at least one pushable bucket (i.e. level)"); _size++; #ifdef ADIAR_STATS @@ -563,7 +575,7 @@ namespace adiar::internal const ptr_uint64::label_type bucket_idx = (_front_bucket_idx + bucket_offset++) % buckets; if (_buckets_level[bucket_idx] == level) { - _buckets_sorter[bucket_idx] -> push(e); + _buckets_sorter[bucket_idx]->push(e); #ifdef ADIAR_STATS stats_levelized_priority_queue.push_bucket += 1u; _stats.push_bucket += 1u; @@ -587,7 +599,8 @@ namespace adiar::internal /// stop level is given then the next level is based on /// the next existing element in the priority queue. //////////////////////////////////////////////////////////////////////////// - void setup_next_level(ptr_uint64::label_type stop_level = no_label) + void + setup_next_level(ptr_uint64::label_type stop_level = no_label) { adiar_assert(stop_level <= ptr_uint64::max_label || stop_level == no_label, "The stop level should be a legal value (or not given)"); @@ -598,32 +611,34 @@ namespace adiar::internal adiar_assert(stop_level != no_label || !empty(), "Either a stop level is given or we have some non-empty level to forward to"); - const ptr_uint64::label_type overflow_level = !_overflow_queue.empty() - ? _overflow_queue.top().level() - : stop_level; + const ptr_uint64::label_type overflow_level = + !_overflow_queue.empty() ? _overflow_queue.top().level() : stop_level; - stop_level = stop_level == no_label || level_cmp_lt(overflow_level, stop_level, _level_comparator) + stop_level = stop_level == no_label + || level_cmp_lt(overflow_level, stop_level, _level_comparator) ? overflow_level : stop_level; const bool has_stop_level = stop_level != no_label; - adiar_assert(has_next_level(), - "There should be a next level to go to"); + adiar_assert(has_next_level(), "There should be a next level to go to"); - adiar_assert(!has_stop_level || !has_front_bucket() - || level_cmp_lt(front_bucket_level(), stop_level, _level_comparator), - "'stop_level' should be past the current front bucket (if it exists)"); + adiar_assert( + !has_stop_level || !has_front_bucket() + || level_cmp_lt(front_bucket_level(), stop_level, _level_comparator), + "'stop_level' should be past the current front bucket (if it exists)"); - adiar_assert(!has_front_bucket() || - level_cmp_lt(front_bucket_level(), back_bucket_level(), _level_comparator), + adiar_assert(!has_front_bucket() + || level_cmp_lt( + front_bucket_level(), back_bucket_level(), _level_comparator), "Back bucket should be (strictly) ahead of the back bucket"); // TODO: Add statistics on what case is hit. // Edge Case: ---------------------------------------------------------- : // The given stop_level is prior to the next bucket - if (has_stop_level && level_cmp_lt(stop_level, next_bucket_level(), _level_comparator)) { + if (has_stop_level + && level_cmp_lt(stop_level, next_bucket_level(), _level_comparator)) { return; } @@ -648,17 +663,17 @@ namespace adiar::internal /// \brief Whether the current level is empty. Is false, if there is no /// 'current' level. //////////////////////////////////////////////////////////////////////////// - bool empty_level() + bool + empty_level() { // TODO: change semantics to require 'has_current_level' - return !has_current_level() || - (// Do we not have any cached element from top()? - !_has_top_elem - // and the current bucket is empty? - && !_has_next_from_bucket - // and the priority queue has nothing for this level? - && (_overflow_queue.empty() - || current_level() != _overflow_queue.top().level() ) ); + return !has_current_level() + || ( // Do we not have any cached element from top()? + !_has_top_elem + // and the current bucket is empty? + && !_has_next_from_bucket + // and the priority queue has nothing for this level? + && (_overflow_queue.empty() || current_level() != _overflow_queue.top().level())); } //////////////////////////////////////////////////////////////////////////// @@ -666,7 +681,8 @@ namespace adiar::internal /// /// \see levelized_priority_queue::empty_level //////////////////////////////////////////////////////////////////////////// - bool can_pull() + bool + can_pull() { return !empty_level(); } @@ -676,12 +692,13 @@ namespace adiar::internal /// /// \pre `can_pull() == true` //////////////////////////////////////////////////////////////////////////// - value_type top() + value_type + top() { adiar_assert(can_pull(), "Can only obtain top element on non-empty level"); if (!_has_top_elem) { - _top_elem = pull(); + _top_elem = pull(); _has_top_elem = true; } @@ -695,7 +712,8 @@ namespace adiar::internal /// /// \see levelized_priority_queue::top //////////////////////////////////////////////////////////////////////////// - value_type peek() + value_type + peek() { return top(); } @@ -705,7 +723,8 @@ namespace adiar::internal /// /// \pre `can_pull() == true` //////////////////////////////////////////////////////////////////////////// - value_type pull() + value_type + pull() { adiar_assert(!empty_level(), "Can only pull on non-empty level"); @@ -718,11 +737,11 @@ namespace adiar::internal _size--; // Merge bucket with overflow queue - if (_overflow_queue.empty() || (_has_next_from_bucket - && _v_comparator(_next_from_bucket, _overflow_queue.top()))) { + if (_overflow_queue.empty() + || (_has_next_from_bucket && _v_comparator(_next_from_bucket, _overflow_queue.top()))) { const value_type ret = _next_from_bucket; - if (_buckets_sorter[_front_bucket_idx] -> can_pull()) { - _next_from_bucket = _buckets_sorter[_front_bucket_idx] -> pull(); + if (_buckets_sorter[_front_bucket_idx]->can_pull()) { + _next_from_bucket = _buckets_sorter[_front_bucket_idx]->pull(); } else { _has_next_from_bucket = false; } @@ -741,7 +760,8 @@ namespace adiar::internal /// /// \see levelized_priority_queue::pull //////////////////////////////////////////////////////////////////////////// - void pop() + void + pop() { pull(); } @@ -749,7 +769,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief The total number of elements (across all levels). //////////////////////////////////////////////////////////////////////////// - size_t size() const + size_t + size() const { // TODO: also separate '_size' away from the overflow queue? return _size + _has_top_elem; @@ -764,7 +785,8 @@ namespace adiar::internal /// \see levelized_priority_queue::empty_level // levelized_priority_queue::can_pull //////////////////////////////////////////////////////////////////////////// - bool empty() const + bool + empty() const { return size() == 0; } @@ -777,11 +799,10 @@ namespace adiar::internal /// \remark To compute the number of pushable buckets, please write /// active_buckets() - has_front_bucket(). //////////////////////////////////////////////////////////////////////////// - size_t active_buckets() const + size_t + active_buckets() const { - if (_front_bucket_idx == out_of_buckets_idx) { - return _back_bucket_idx + 1; - } + if (_front_bucket_idx == out_of_buckets_idx) { return _back_bucket_idx + 1; } return _front_bucket_idx <= _back_bucket_idx ? (_back_bucket_idx - _front_bucket_idx) + 1 @@ -791,7 +812,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether more buckets are available. //////////////////////////////////////////////////////////////////////////// - bool has_next_bucket() const + bool + has_next_bucket() const { return _front_bucket_idx != _back_bucket_idx; } @@ -799,10 +821,10 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Label of the next bucket. //////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type next_bucket_level() const + ptr_uint64::label_type + next_bucket_level() const { - adiar_assert(has_next_bucket(), - "Cannot obtain level of non-existing next bucket"); + adiar_assert(has_next_bucket(), "Cannot obtain level of non-existing next bucket"); const ptr_uint64::label_type next_idx = (_front_bucket_idx + 1) % buckets; const ptr_uint64::label_type next_level = _buckets_level[next_idx]; @@ -813,7 +835,8 @@ namespace adiar::internal /// \brief Whether there is an 'active' bucket from which ca be pulled /// (though it may need to be sorted). //////////////////////////////////////////////////////////////////////////// - bool has_front_bucket() const + bool + has_front_bucket() const { return _front_bucket_idx != out_of_buckets_idx; } @@ -821,7 +844,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Level of the front bucket. //////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type front_bucket_level() const + ptr_uint64::label_type + front_bucket_level() const { return _buckets_level[_front_bucket_idx]; } @@ -829,7 +853,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Level of the back bucket. //////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type back_bucket_level() const + ptr_uint64::label_type + back_bucket_level() const { return _buckets_level[_back_bucket_idx]; } @@ -846,19 +871,21 @@ namespace adiar::internal /// /// \see levelized_priority_queue::setup_next_level //////////////////////////////////////////////////////////////////////////// - inline void forward_to_nonempty_bucket(const ptr_uint64::label_type stop_level, const bool has_stop_level) + inline void + forward_to_nonempty_bucket(const ptr_uint64::label_type stop_level, const bool has_stop_level) { do { - adiar_assert(has_next_bucket(), - "At least one more bucket can be forwarded to"); + adiar_assert(has_next_bucket(), "At least one more bucket can be forwarded to"); // Is the next bucket past the 'stop_level'? - if (has_stop_level && level_cmp_lt(stop_level, next_bucket_level(), _level_comparator)) { + if (has_stop_level + && level_cmp_lt(stop_level, next_bucket_level(), _level_comparator)) { break; } adiar_assert(!has_front_bucket() - || level_cmp_lt(front_bucket_level(), back_bucket_level(), _level_comparator), + || level_cmp_lt( + front_bucket_level(), back_bucket_level(), _level_comparator), "Inconsistency in has_next_bucket predicate"); // Replace the current read-only bucket, if there is one @@ -866,27 +893,28 @@ namespace adiar::internal const ptr_uint64::label_type next_level = _level_merger.pull(); _buckets_level[_front_bucket_idx] = next_level; - sorter_t::reset_unique(_buckets_sorter[_front_bucket_idx], - _memory_for_buckets, _max_size, buckets); + sorter_t::reset_unique( + _buckets_sorter[_front_bucket_idx], _memory_for_buckets, _max_size, buckets); _back_bucket_idx = _front_bucket_idx; } _front_bucket_idx = (_front_bucket_idx + 1) % buckets; adiar_assert(!has_next_bucket() || !has_front_bucket() - || level_cmp_lt(front_bucket_level(), back_bucket_level(), _level_comparator), + || level_cmp_lt( + front_bucket_level(), back_bucket_level(), _level_comparator), "Inconsistency in has_next_bucket predicate"); adiar_assert(has_next_bucket() || !has_front_bucket() - || front_bucket_level() == back_bucket_level(), + || front_bucket_level() == back_bucket_level(), "Inconsistency in has_next_bucket predicate"); // Sort front bucket - _buckets_sorter[_front_bucket_idx] -> sort(); + _buckets_sorter[_front_bucket_idx]->sort(); - _has_next_from_bucket = _buckets_sorter[_front_bucket_idx] -> can_pull(); + _has_next_from_bucket = _buckets_sorter[_front_bucket_idx]->can_pull(); if (_has_next_from_bucket) { - _next_from_bucket = _buckets_sorter[_front_bucket_idx] -> pull(); + _next_from_bucket = _buckets_sorter[_front_bucket_idx]->pull(); } } while (!_has_next_from_bucket && has_next_bucket()); @@ -894,14 +922,18 @@ namespace adiar::internal adiar_assert(has_front_bucket(), "Ends with a front bucket"); - adiar_assert((has_stop_level - && (level_cmp_le(stop_level, front_bucket_level(), _level_comparator) - || (!has_next_bucket() || level_cmp_lt(stop_level, next_bucket_level(), _level_comparator))) ) - || _has_next_from_bucket, - "Either we stopped early or we found a non-bucket"); - - adiar_assert(level_cmp_le(front_bucket_level(), back_bucket_level(), _level_comparator), - "Consistent bucket levels"); + adiar_assert( + (has_stop_level + && (level_cmp_le(stop_level, front_bucket_level(), _level_comparator) + || (!has_next_bucket() + || level_cmp_lt( + stop_level, next_bucket_level(), _level_comparator)))) + || _has_next_from_bucket, + "Either we stopped early or we found a non-bucket"); + + adiar_assert( + level_cmp_le(front_bucket_level(), back_bucket_level(), _level_comparator), + "Consistent bucket levels"); } //////////////////////////////////////////////////////////////////////////// @@ -911,14 +943,14 @@ namespace adiar::internal /// /// \see levelized_priority_queue::setup_next_level //////////////////////////////////////////////////////////////////////////// - inline void relabel_buckets(const ptr_uint64::label_type stop_level) + inline void + relabel_buckets(const ptr_uint64::label_type stop_level) { - adiar_assert(stop_level != no_label, - "Relabelling of buckets require a valid 'stop_level'"); + adiar_assert(stop_level != no_label, "Relabelling of buckets require a valid 'stop_level'"); // Backup of start and end of circular array const size_t old_front_bucket_idx = _front_bucket_idx; - const size_t old_back_bucket_idx = _back_bucket_idx; + const size_t old_back_bucket_idx = _back_bucket_idx; // Create a list of the new levels ptr_uint64::label_type new_levels[buckets]; @@ -940,7 +972,8 @@ namespace adiar::internal _front_bucket_idx = out_of_buckets_idx; // Add as many levels from the level_merger as we can fit in - while (_level_merger.can_pull() && level_cmp_le(_level_merger.peek(), stop_level, _level_comparator)) { + while (_level_merger.can_pull() + && level_cmp_le(_level_merger.peek(), stop_level, _level_comparator)) { _current_level = _level_merger.pull(); } @@ -959,8 +992,8 @@ namespace adiar::internal // Reset the prior read-only bucket, if relevant if (old_front_bucket_idx <= _back_bucket_idx) { - sorter_t::reset_unique(_buckets_sorter[old_front_bucket_idx], - _memory_for_buckets, _max_size, buckets); + sorter_t::reset_unique( + _buckets_sorter[old_front_bucket_idx], _memory_for_buckets, _max_size, buckets); } // We can clean up all the dead buckets with a '.reset()' on the @@ -973,19 +1006,22 @@ namespace adiar::internal /// \brief Specialization of the levelized priority queue with a LookAhead /// of '0', i.e. **without** any buckets. //////////////////////////////////////////////////////////////////////////// - template - class levelized_priority_queue + class levelized_priority_queue { public: @@ -1024,17 +1060,21 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Value to reflect 'out of levels'. //////////////////////////////////////////////////////////////////////////// - static constexpr ptr_uint64::label_type no_label = ptr_uint64::max_label+1; + static constexpr ptr_uint64::label_type no_label = ptr_uint64::max_label + 1; public: - static tpie::memory_size_type memory_usage(tpie::memory_size_type no_elements) + static tpie::memory_size_type + memory_usage(tpie::memory_size_type no_elements) { - return priority_queue::memory_usage(no_elements); + return priority_queue::memory_usage( + no_elements); } - static tpie::memory_size_type memory_fits(tpie::memory_size_type memory_bytes) + static tpie::memory_size_type + memory_fits(tpie::memory_size_type memory_bytes) { - return priority_queue::memory_fits(memory_bytes); + return priority_queue::memory_fits( + memory_bytes); } private: @@ -1078,19 +1118,20 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Reference to struct to store non-global stats into. //////////////////////////////////////////////////////////////////////////// - statistics::levelized_priority_queue_t &_stats; + statistics::levelized_priority_queue_t& _stats; #endif private: - levelized_priority_queue(tpie::memory_size_type memory_given, size_t max_size, - [[maybe_unused]] statistics::levelized_priority_queue_t &stats) - : _max_size(max_size), - _memory_given(memory_given), - _priority_queue(memory_given, max_size) + levelized_priority_queue(tpie::memory_size_type memory_given, + size_t max_size, + [[maybe_unused]] statistics::levelized_priority_queue_t& stats) + : _max_size(max_size) + , _memory_given(memory_given) + , _priority_queue(memory_given, max_size) #ifdef ADIAR_STATS , _stats(stats) #endif - { } + {} public: //////////////////////////////////////////////////////////////////////////// @@ -1100,12 +1141,12 @@ namespace adiar::internal /// /// \param memory_given Total amount of memory to use //////////////////////////////////////////////////////////////////////////// - levelized_priority_queue(const LevelFile (& /*files*/) [LevelFileCount], + levelized_priority_queue(const LevelFile (& /*files*/)[LevelFileCount], tpie::memory_size_type memory_given, size_t max_size, - statistics::levelized_priority_queue_t &stats) + statistics::levelized_priority_queue_t& stats) : levelized_priority_queue(memory_given, max_size, stats) - { } + {} //////////////////////////////////////////////////////////////////////////// /// \brief Instantiate with the given amount of memory. @@ -1114,12 +1155,12 @@ namespace adiar::internal /// /// \param memory_given Total amount of memory to use //////////////////////////////////////////////////////////////////////////// - levelized_priority_queue(const dd (& /*dds*/) [LevelFileCount], + levelized_priority_queue(const dd (& /*dds*/)[LevelFileCount], tpie::memory_size_type memory_given, size_t max_size, - statistics::levelized_priority_queue_t &stats) + statistics::levelized_priority_queue_t& stats) : levelized_priority_queue(memory_given, max_size, stats) - { } + {} //////////////////////////////////////////////////////////////////////////// /// \brief Instantiate with the given amount of memory. @@ -1128,12 +1169,12 @@ namespace adiar::internal /// /// \param memory_given Total amount of memory to use //////////////////////////////////////////////////////////////////////////// - levelized_priority_queue(const __dd (& /*dds*/) [LevelFileCount], + levelized_priority_queue(const __dd (& /*dds*/)[LevelFileCount], tpie::memory_size_type memory_given, size_t max_size, - statistics::levelized_priority_queue_t &stats) + statistics::levelized_priority_queue_t& stats) : levelized_priority_queue(memory_given, max_size, stats) - { } + {} public: ~levelized_priority_queue() @@ -1157,7 +1198,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether there is any current level to pull elements from. //////////////////////////////////////////////////////////////////////////// - bool has_current_level() const + bool + has_current_level() const { return _current_level != no_label; } @@ -1167,10 +1209,10 @@ namespace adiar::internal /// /// \pre `has_current_level() == true` //////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type current_level() const + ptr_uint64::label_type + current_level() const { - adiar_assert(has_current_level(), - "Needs to have a 'current' level to read the level from"); + adiar_assert(has_current_level(), "Needs to have a 'current' level to read the level from"); return _current_level; } @@ -1178,16 +1220,15 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether there are any more (possibly all empty) levels. //////////////////////////////////////////////////////////////////////////// - bool has_next_level() /*const*/ + bool + has_next_level() /*const*/ { - if(_priority_queue.empty()) { - return false; - } + if (_priority_queue.empty()) { return false; } ptr_uint64::label_type next_label_from_queue = _priority_queue.top().level(); - return (has_current_level() && level_cmp_lt(_current_level, - next_label_from_queue, - _level_comparator)) - || (!has_current_level() && !_priority_queue.empty()); + return (has_current_level() + && level_cmp_lt( + _current_level, next_label_from_queue, _level_comparator)) + || (!has_current_level() && !_priority_queue.empty()); } //////////////////////////////////////////////////////////////////////////// @@ -1195,7 +1236,8 @@ namespace adiar::internal /// /// \pre `has_next_level() == true` //////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type next_level() /*const*/ + ptr_uint64::label_type + next_level() /*const*/ { return _priority_queue.top().level(); } @@ -1203,7 +1245,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether one can push elements. //////////////////////////////////////////////////////////////////////////// - bool can_push() /*const*/ + bool + can_push() /*const*/ { return true; } @@ -1211,7 +1254,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Push an element into the priority queue. //////////////////////////////////////////////////////////////////////////// - void push(const value_type &v) + void + push(const value_type& v) { #ifdef ADIAR_STATS _actual_max_size = std::max(_actual_max_size, _priority_queue.size()); @@ -1229,7 +1273,8 @@ namespace adiar::internal /// stop level is given then the next level is based on /// the next existing element in the priority queue. //////////////////////////////////////////////////////////////////////////// - void setup_next_level(ptr_uint64::label_type stop_level = no_label) + void + setup_next_level(ptr_uint64::label_type stop_level = no_label) { adiar_assert(stop_level <= ptr_uint64::max_label || stop_level == no_label, "The stop level should be a legal value (or not given)"); @@ -1244,17 +1289,19 @@ namespace adiar::internal // Edge Case: ---------------------------------------------------------- : // The given stop_level is prior to the next level or there is nothing in the queue - if ((has_stop_level && level_cmp_lt(stop_level, next_level(), _level_comparator)) || _priority_queue.empty()) { + if ((has_stop_level + && level_cmp_lt(stop_level, next_level(), _level_comparator)) + || _priority_queue.empty()) { _current_level = stop_level; return; } // Edge Case: ---------------------------------------------------------- : // The stop level is before the next level of the queue - adiar_assert(has_next_level(), - "There should be a next level to go to"); + adiar_assert(has_next_level(), "There should be a next level to go to"); ptr_uint64::label_type next_level_from_queue = next_level(); - if(has_stop_level && level_cmp_le(stop_level, next_level_from_queue, _level_comparator)) { + if (has_stop_level + && level_cmp_le(stop_level, next_level_from_queue, _level_comparator)) { _current_level = stop_level; return; } @@ -1268,12 +1315,12 @@ namespace adiar::internal /// \brief Whether the current level is empty. Is false, if there is no /// 'current' level. //////////////////////////////////////////////////////////////////////////// - bool empty_level() + bool + empty_level() { // TODO: change semantics to require 'has_current_level' - return !has_current_level() - || _priority_queue.empty() - || current_level() != _priority_queue.top().level(); + return !has_current_level() || _priority_queue.empty() + || current_level() != _priority_queue.top().level(); } //////////////////////////////////////////////////////////////////////////// @@ -1281,7 +1328,8 @@ namespace adiar::internal /// /// \see levelized_priority_queue::empty_level //////////////////////////////////////////////////////////////////////////// - bool can_pull() + bool + can_pull() { return !empty_level(); } @@ -1291,7 +1339,8 @@ namespace adiar::internal /// /// \pre `can_pull() == true` //////////////////////////////////////////////////////////////////////////// - value_type top() + value_type + top() { adiar_assert(can_pull(), "Can only obtain top element on non-empty level"); return _priority_queue.top(); @@ -1304,7 +1353,8 @@ namespace adiar::internal /// /// \see levelized_priority_queue::top //////////////////////////////////////////////////////////////////////////// - value_type peek() + value_type + peek() { return top(); } @@ -1314,7 +1364,8 @@ namespace adiar::internal /// /// \pre `can_pull() == true` //////////////////////////////////////////////////////////////////////////// - value_type pull() + value_type + pull() { adiar_assert(!empty_level(), "Can only pull on non-empty level"); @@ -1330,7 +1381,8 @@ namespace adiar::internal /// /// \see levelized_priority_queue::pull //////////////////////////////////////////////////////////////////////////// - void pop() + void + pop() { pull(); } @@ -1338,7 +1390,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief The total number of elements (across all levels). //////////////////////////////////////////////////////////////////////////// - size_t size() const + size_t + size() const { return _priority_queue.size(); } @@ -1352,7 +1405,8 @@ namespace adiar::internal /// \see levelized_priority_queue::empty_level // levelized_priority_queue::can_pull //////////////////////////////////////////////////////////////////////////// - bool empty() const + bool + empty() const { return _priority_queue.empty(); } @@ -1361,67 +1415,80 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Levelized Priority Queue to be used with `levelized_file`. ////////////////////////////////////////////////////////////////////////////// - template , - size_t LookAhead = ADIAR_LPQ_LOOKAHEAD, - memory_mode mem_mode = memory_mode::External, - size_t LevelFileCount = 1u, - size_t LevelSkip = 1u> - using levelized_node_priority_queue = - levelized_priority_queue, LevelFileCount, std::less, false, - LevelSkip>; + template , + size_t LookAhead = ADIAR_LPQ_LOOKAHEAD, + memory_mode mem_mode = memory_mode::External, + size_t LevelFileCount = 1u, + size_t LevelSkip = 1u> + using levelized_node_priority_queue = levelized_priority_queue, + LevelFileCount, + std::less, + false, + LevelSkip>; ////////////////////////////////////////////////////////////////////////////// /// \brief Levelized Priority Queue to be used with `levelized_file` and /// an `arc_stream`. ////////////////////////////////////////////////////////////////////////////// - template , - size_t LookAhead = ADIAR_LPQ_LOOKAHEAD, - memory_mode mem_mode = memory_mode::External, - size_t LevelFileCount = 1u, - size_t LevelSkip = 1u> - using levelized_arc_priority_queue = - levelized_priority_queue, LevelFileCount, std::greater, false, - LevelSkip>; + template , + size_t LookAhead = ADIAR_LPQ_LOOKAHEAD, + memory_mode mem_mode = memory_mode::External, + size_t LevelFileCount = 1u, + size_t LevelSkip = 1u> + using levelized_arc_priority_queue = levelized_priority_queue, + LevelFileCount, + std::greater, + false, + LevelSkip>; ////////////////////////////////////////////////////////////////////////////// /// \brief Levelized Priority Queue to be used with `levelized_file` and /// a `node_arc_stream`. ////////////////////////////////////////////////////////////////////////////// - template , - size_t LookAhead = ADIAR_LPQ_LOOKAHEAD, - memory_mode mem_mode = memory_mode::External, - size_t LevelFileCount = 1u, - size_t LevelSkip = 1u> - using levelized_node_arc_priority_queue = - levelized_priority_queue, LevelFileCount, std::less, true, - LevelSkip>; + template , + size_t LookAhead = ADIAR_LPQ_LOOKAHEAD, + memory_mode mem_mode = memory_mode::External, + size_t LevelFileCount = 1u, + size_t LevelSkip = 1u> + using levelized_node_arc_priority_queue = levelized_priority_queue, + LevelFileCount, + std::less, + true, + LevelSkip>; ////////////////////////////////////////////////////////////////////////////// /// \brief Levelized Priority Queue to be used with `shared_file`. ////////////////////////////////////////////////////////////////////////////// - template , - size_t LookAhead = ADIAR_LPQ_LOOKAHEAD, - memory_mode mem_mode = memory_mode::External, - size_t LevelFileCount = 1u, - size_t LevelSkip = 1u> + template , + size_t LookAhead = ADIAR_LPQ_LOOKAHEAD, + memory_mode mem_mode = memory_mode::External, + size_t LevelFileCount = 1u, + size_t LevelSkip = 1u> using levelized_label_priority_queue = - levelized_priority_queue, LevelFileCount, std::less, false, + shared_file, + LevelFileCount, + std::less, + false, LevelSkip>; } diff --git a/src/adiar/internal/data_structures/priority_queue.h b/src/adiar/internal/data_structures/priority_queue.h index eafc3752a..8404ce5ef 100644 --- a/src/adiar/internal/data_structures/priority_queue.h +++ b/src/adiar/internal/data_structures/priority_queue.h @@ -3,8 +3,8 @@ #include -#include #include +#include #include #include @@ -17,7 +17,7 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Wrapper for TPIE's internal binary heap. ////////////////////////////////////////////////////////////////////////////// - template + template class priority_queue { private: @@ -25,17 +25,18 @@ namespace adiar::internal pq_type pq; public: - static tpie::memory_size_type memory_usage(tpie::memory_size_type no_elements) + static tpie::memory_size_type + memory_usage(tpie::memory_size_type no_elements) { return pq_type::memory_usage(no_elements); } - static tpie::memory_size_type memory_fits(tpie::memory_size_type memory_bytes) + static tpie::memory_size_type + memory_fits(tpie::memory_size_type memory_bytes) { const tpie::memory_size_type ret = pq_type::memory_fits(memory_bytes); - adiar_assert(memory_usage(ret) <= memory_bytes, - "memory_fits and memory_usage should agree."); + adiar_assert(memory_usage(ret) <= memory_bytes, "memory_fits and memory_usage should agree."); return ret; } @@ -51,20 +52,35 @@ namespace adiar::internal "Must be instantiated with enough memory."); } - value_type top() const - { return pq.top(); } + value_type + top() const + { + return pq.top(); + } - void pop() - { pq.pop(); } + void + pop() + { + pq.pop(); + } - void push(const value_type &v) - { pq.push(v); } + void + push(const value_type& v) + { + pq.push(v); + } - size_t size() const - { return pq.size(); } + size_t + size() const + { + return pq.size(); + } - bool empty() const - { return pq.empty(); } + bool + empty() const + { + return pq.empty(); + } }; ////////////////////////////////////////////////////////////////////////////// @@ -80,7 +96,7 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Wrapper for TPIE's internal binary heap. ////////////////////////////////////////////////////////////////////////////// - template + template class priority_queue { public: @@ -97,20 +113,35 @@ namespace adiar::internal : pq(memory_bytes) {} - value_type top() - { return pq.top(); } + value_type + top() + { + return pq.top(); + } - void pop() - { pq.pop(); } + void + pop() + { + pq.pop(); + } - void push(const value_type &v) - { pq.push(v); } + void + push(const value_type& v) + { + pq.push(v); + } - size_t size() const - { return pq.size(); } + size_t + size() const + { + return pq.size(); + } - bool empty() const - { return pq.empty(); } + bool + empty() const + { + return pq.empty(); + } }; ////////////////////////////////////////////////////////////////////////////// diff --git a/src/adiar/internal/data_structures/sorter.h b/src/adiar/internal/data_structures/sorter.h index 241cc6061..6bc845af7 100644 --- a/src/adiar/internal/data_structures/sorter.h +++ b/src/adiar/internal/data_structures/sorter.h @@ -1,13 +1,13 @@ #ifndef ADIAR_INTERNAL_DATA_STRUCTURES_SORTER_H #define ADIAR_INTERNAL_DATA_STRUCTURES_SORTER_H -#include -#include #include +#include #include +#include -#include #include +#include #include #include @@ -45,29 +45,25 @@ namespace adiar::internal { const tpie::memory_size_type ret = array_type::memory_fits(memory_bytes); - adiar_assert(memory_usage(ret) <= memory_bytes, - "memory_fits and memory_usage should agree."); + adiar_assert(memory_usage(ret) <= memory_bytes, "memory_fits and memory_usage should agree."); return ret; } static constexpr size_t data_structures = 1u; static unique_ptr> - make_unique(size_t memory_bytes, - size_t no_elements, - size_t no_sorters = 1, - Comp comp = Comp()) + make_unique(size_t memory_bytes, size_t no_elements, size_t no_sorters = 1, Comp comp = Comp()) { - return adiar::make_unique> - (memory_bytes, no_elements, no_sorters, comp); + return adiar::make_unique>( + memory_bytes, no_elements, no_sorters, comp); } static void - reset_unique(unique_ptr> &u_ptr, + reset_unique(unique_ptr>& u_ptr, size_t /*memory_bytes*/, size_t /*no_elements*/, size_t /*no_sorters*/ = 1, - Comp /*comp*/ = Comp()) + Comp /*comp*/ = Comp()) { u_ptr->reset(); } @@ -76,61 +72,73 @@ namespace adiar::internal sorter([[maybe_unused]] size_t memory_bytes, size_t no_elements, [[maybe_unused]] size_t no_sorters = 1, - Comp comp = Comp()) - : _array(no_elements), _pred(comp), _size(0), _front_idx(0) + Comp comp = Comp()) + : _array(no_elements) + , _pred(comp) + , _size(0) + , _front_idx(0) { adiar_assert(no_elements <= memory_fits(memory_bytes / no_sorters), "Must be instantiated with enough memory."); } public: - bool can_push() + bool + can_push() { return _front_idx == 0u && _array.size() > _size; } - void push(const value_type& v) + void + push(const value_type& v) { adiar_assert(can_push()); _array[_size++] = v; } - void sort() + void + sort() { tpie::parallel_sort(_array.begin(), _array.begin() + _size, _pred); _front_idx = 0; } - bool can_pull() const + bool + can_pull() const { // TODO (debug): check it has been sorted return _size != _front_idx; } - value_type top() const + value_type + top() const { adiar_assert(can_pull()); return _array[_front_idx]; } - value_type pull() + value_type + pull() { adiar_assert(can_pull()); return _array[_front_idx++]; } - void reset() + void + reset() { - _size = 0; + _size = 0; _front_idx = 0; } - size_t size() const + size_t + size() const { return _size - _front_idx; } - bool empty() const + bool + empty() const { return size() == 0; } @@ -162,7 +170,7 @@ namespace adiar::internal private: tpie::merge_sorter _sorter; - bool _has_peeked = false; + bool _has_peeked = false; value_type _peeked; size_t _pulls = 0u; @@ -171,29 +179,24 @@ namespace adiar::internal static constexpr size_t data_structures = 1u; static unique_ptr> - make_unique(size_t memory_bytes, - size_t no_elements, - size_t no_sorters = 1, - Comp comp = Comp()) + make_unique(size_t memory_bytes, size_t no_elements, size_t no_sorters = 1, Comp comp = Comp()) { - return adiar::make_unique> - (memory_bytes, no_elements, no_sorters, comp); + return adiar::make_unique>( + memory_bytes, no_elements, no_sorters, comp); } - static void reset_unique(unique_ptr> &u_ptr, - size_t memory_bytes, - size_t no_elements, - size_t no_sorters = 1, - Comp comp = Comp()) + static void + reset_unique(unique_ptr>& u_ptr, + size_t memory_bytes, + size_t no_elements, + size_t no_sorters = 1, + Comp comp = Comp()) { u_ptr = make_unique(memory_bytes, no_elements, no_sorters, comp); } public: - sorter(size_t memory_bytes, - size_t no_elements, - size_t number_of_sorters, - Comp comp = Comp()) + sorter(size_t memory_bytes, size_t no_elements, size_t number_of_sorters, Comp comp = Comp()) : _sorter(comp) { // ======================================================================= @@ -248,7 +251,8 @@ namespace adiar::internal // Phase 1 : Push Mergesort base cases // // Quickfix: Issue https://github.com/thomasmoelhave/tpie/issues/250 - constexpr tpie::memory_size_type minimum_phase1 = sizeof(value_type) * 128 * 1024 + 5 * 1024 * 1024; + constexpr tpie::memory_size_type minimum_phase1 = + sizeof(value_type) * 128 * 1024 + 5 * 1024 * 1024; // Take up at most 1/(Sorter-1)'th of 1/16th of the total memory. The last // sorter is either in the same phase or another phase. @@ -276,21 +280,20 @@ namespace adiar::internal // // Use the remaining sorter memory for this very step. If one is in this // phase, then all other sorters are in phase 1. - const tpie::memory_size_type phase2 = - memory_bytes - phase1 * (number_of_sorters - 1); + const tpie::memory_size_type phase2 = memory_bytes - phase1 * (number_of_sorters - 1); // ----------------------------------------------------------------------- // Sanity tests... adiar_assert(number_of_sorters * phase1 <= memory_bytes, "Memory is enough to have 'N' pushable sorters."); - adiar_assert((number_of_sorters-1) * phase1 + phase2 <= memory_bytes, + adiar_assert((number_of_sorters - 1) * phase1 + phase2 <= memory_bytes, "Memory is enough to have 'N-1' pushable sorters and '1' sorting one."); - adiar_assert((number_of_sorters-1) * phase1 + phase3 <= memory_bytes, + adiar_assert((number_of_sorters - 1) * phase1 + phase3 <= memory_bytes, "Memory is enough to have 'N-1' pushable sorters and '1' pullable one."); - adiar_assert((number_of_sorters-1) * phase1 + phase3 + phase1 <= memory_bytes, + adiar_assert((number_of_sorters - 1) * phase1 + phase3 + phase1 <= memory_bytes, "Memory is enough to replace the pullable sorter with an 'Nth' pushable one."); // ----------------------------------------------------------------------- @@ -299,38 +302,45 @@ namespace adiar::internal _sorter.begin(); } - bool can_push(); + bool + can_push(); + // TODO: Update TPIE merge sorter to access the current phase Enum. - void push(const value_type& v) + void + push(const value_type& v) { _sorter.push(v); } - void sort() + void + sort() { _sorter.end(); - tpie::dummy_progress_indicator dpi { }; + tpie::dummy_progress_indicator dpi{}; _sorter.calc(dpi); } - bool can_pull() /*const*/ + bool + can_pull() /*const*/ { return _has_peeked || _sorter.can_pull(); } - value_type top() + value_type + top() { adiar_assert(can_pull()); if (!_has_peeked) { _has_peeked = true; - _peeked = _sorter.pull(); + _peeked = _sorter.pull(); } return _peeked; } - value_type pull() + value_type + pull() { adiar_assert(can_pull()); _pulls++; @@ -341,14 +351,16 @@ namespace adiar::internal return _sorter.pull(); } - size_t size() /*const*/ + size_t + size() /*const*/ { // '_sorter.item_count()' from TPIE only provides the number of .push(...) // in phase 1, not the number of elements left in phase 3. return _sorter.item_count() - _pulls; } - bool empty() /*const*/ + bool + empty() /*const*/ { return size() == 0; } diff --git a/src/adiar/internal/data_types/arc.h b/src/adiar/internal/data_types/arc.h index c89cc0d35..707175146 100644 --- a/src/adiar/internal/data_types/arc.h +++ b/src/adiar/internal/data_types/arc.h @@ -74,7 +74,7 @@ namespace adiar::internal /// \details The default, copy, and move assignment has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - arc(const arc &a) = default; + arc(const arc& a) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move construction (trivial). @@ -82,7 +82,7 @@ namespace adiar::internal /// \details The default, copy, and move assignment has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - arc(arc &&a) = default; + arc(arc&& a) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Destruction (trivial). @@ -99,7 +99,8 @@ namespace adiar::internal /// \details The copy and move assignment has to be `default` to ensure it /// is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - arc& operator =(const arc &a) = default; + arc& + operator=(const arc& a) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move assignment (trivial). @@ -107,7 +108,8 @@ namespace adiar::internal /// \details The copy and move assignment has to be `default` to ensure it /// is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - arc& operator =(arc &&a) = default; + arc& + operator=(arc&& a) = default; public: // Provide 'non-default' constructors to make it easy to use outside of TPIE. @@ -118,8 +120,9 @@ namespace adiar::internal /// \pre The flags on both `source` and `target` are already set correctly /// and the out-index on `source` is too. //////////////////////////////////////////////////////////////////////////// - arc(const pointer_type &source, const pointer_type &target) - : _source(source), _target(target) + arc(const pointer_type& source, const pointer_type& target) + : _source(source) + , _target(target) { adiar_assert(!target.is_node() || target.out_idx() == 0u); } @@ -129,9 +132,9 @@ namespace adiar::internal /// /// \pre The flags on `target` is already set correctly. //////////////////////////////////////////////////////////////////////////// - arc(const uid_type &source, - const pointer_type::out_idx_type &out_idx, - const pointer_type &target) + arc(const uid_type& source, + const pointer_type::out_idx_type& out_idx, + const pointer_type& target) : _source(source.as_ptr(out_idx)) , _target(target) { @@ -144,15 +147,21 @@ namespace adiar::internal /// \brief Obtain 'source' value (including flag and out-index). //////////////////////////////////////////////////////////////////////////// // TODO Always return the essential pointer? - pointer_type source() const - { return _source; } + pointer_type + source() const + { + return _source; + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain 'target' value (including flag). //////////////////////////////////////////////////////////////////////////// // TODO Always return the essential pointer? - pointer_type target() const - { return _target; } + pointer_type + target() const + { + return _target; + } /* ================================= FLAGS ============================== */ public: @@ -160,8 +169,11 @@ namespace adiar::internal /// \brief Obtain the outdegree index, i.e. the child number this arc is of /// the `source` node. //////////////////////////////////////////////////////////////////////////// - pointer_type::out_idx_type out_idx() const - { return _source.out_idx(); } + pointer_type::out_idx_type + out_idx() const + { + return _source.out_idx(); + } /* ============================== COMPARATORS =========================== */ @@ -169,22 +181,28 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Check that both `source` and `target` match. //////////////////////////////////////////////////////////////////////////// - inline bool operator== (const arc &o) const - { return this->_source == o._source && this->_target == o._target; } + inline bool + operator==(const arc& o) const + { + return this->_source == o._source && this->_target == o._target; + } //////////////////////////////////////////////////////////////////////////// /// \brief Check either `source` or `target` mismatch. //////////////////////////////////////////////////////////////////////////// - inline bool operator!= (const arc &o) const - { return !(*this == o); } + inline bool + operator!=(const arc& o) const + { + return !(*this == o); + } /* =============================== OPERATORS ============================ */ public: - //////////////////////////////////////////////////////////////////////////// /// \brief Obtain an arc where the target's value (if any) is negated. //////////////////////////////////////////////////////////////////////////// - arc operator! () const + arc + operator!() const { return arc(this->_source, !this->_target); } @@ -197,7 +215,9 @@ namespace adiar::internal struct arc_source_lt { /// \copydoc arc_target_lt - bool operator ()(const arc& a, const arc& b) const { + bool + operator()(const arc& a, const arc& b) const + { return a.source() < b.source(); } }; @@ -208,7 +228,9 @@ namespace adiar::internal struct arc_target_lt { /// \copydoc arc_target_lt - bool operator ()(const arc& a, const arc& b) const { + bool + operator()(const arc& a, const arc& b) const + { return a.target() < b.target() #ifndef NDEBUG || (a.target() == b.target() && a.source() < b.source()) diff --git a/src/adiar/internal/data_types/convert.h b/src/adiar/internal/data_types/convert.h index 6f3aecc35..9b1c295d7 100644 --- a/src/adiar/internal/data_types/convert.h +++ b/src/adiar/internal/data_types/convert.h @@ -10,15 +10,17 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Extract the *low* arc from a node ////////////////////////////////////////////////////////////////////////////// - inline arc low_arc_of(const node &n) + inline arc + low_arc_of(const node& n) { - return { n.uid()/*.as_ptr(false)*/, n.low() }; + return { n.uid() /*.as_ptr(false)*/, n.low() }; } ////////////////////////////////////////////////////////////////////////////// /// \brief Extract the *high* arc from a node ////////////////////////////////////////////////////////////////////////////// - inline arc high_arc_of(const node &n) + inline arc + high_arc_of(const node& n) { return { n.uid().as_ptr(true), n.high() }; } @@ -29,17 +31,20 @@ namespace adiar::internal /// \param low The low arc /// \param high The high arc ////////////////////////////////////////////////////////////////////////////// - inline node node_of(const arc &low, const arc &high) + inline node + node_of(const arc& low, const arc& high) { adiar_assert(essential(low.source()) == essential(high.source()), "Source are the same origin"); - adiar_assert(low.out_idx() == 0u, "Out-index is correct on low arc"); - adiar_assert(high.out_idx() == 1u, "Out-index is correct on high arc"); + adiar_assert(low.out_idx() == 0u, "Out-index is correct on low arc"); + adiar_assert(high.out_idx() == 1u, "Out-index is correct on high arc"); - adiar_assert(!low.target().is_node() || low.target().out_idx() == 0u, "Out-index is empty in low target"); - adiar_assert(!high.target().is_node() || high.target().out_idx() == 0u, "Out-index is empty in high target"); + adiar_assert(!low.target().is_node() || low.target().out_idx() == 0u, + "Out-index is empty in low target"); + adiar_assert(!high.target().is_node() || high.target().out_idx() == 0u, + "Out-index is empty in high target"); - adiar_assert(low.source().is_flagged() == false, "Source is not flagged on low arc"); + adiar_assert(low.source().is_flagged() == false, "Source is not flagged on low arc"); adiar_assert(high.source().is_flagged() == false, "Source is not flagged on high arc"); return node(essential(low.source()), low.target(), high.target()); diff --git a/src/adiar/internal/data_types/level_info.h b/src/adiar/internal/data_types/level_info.h index 5dc7755f1..5d854b7d6 100644 --- a/src/adiar/internal/data_types/level_info.h +++ b/src/adiar/internal/data_types/level_info.h @@ -20,7 +20,6 @@ namespace adiar::internal /* ================================ VARIABLES =========================== */ private: - level_type _label; size_t _width; @@ -41,7 +40,7 @@ namespace adiar::internal /// \details The default, copy, and move construction has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - level_info(const level_info &li) = default; + level_info(const level_info& li) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move construction (trivial). @@ -49,7 +48,7 @@ namespace adiar::internal /// \details The default, copy, and move construction has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - level_info(level_info &&li) = default; + level_info(level_info&& li) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Destruction (trivial). @@ -64,8 +63,9 @@ namespace adiar::internal /// the identity variable ordering. //////////////////////////////////////////////////////////////////////////// level_info(level_type label, size_t width) - : _label(label), _width(width) - { } + : _label(label) + , _width(width) + {} public: //////////////////////////////////////////////////////////////////////////// @@ -74,7 +74,8 @@ namespace adiar::internal /// \details The copy and move assignment has to be `default` to ensure it /// is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - level_info& operator =(const level_info &li) = default; + level_info& + operator=(const level_info& li) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move assignment (trivial). @@ -82,48 +83,66 @@ namespace adiar::internal /// \details The copy and move assignment has to be `default` to ensure it /// is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - level_info& operator =(level_info &&li) = default; + level_info& + operator=(level_info&& li) = default; /* ============================ MEMBER FUNCTIONS ======================== */ public: //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the label for a level. //////////////////////////////////////////////////////////////////////////// - level_type label() const - { return _label; } + level_type + label() const + { + return _label; + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the level. //////////////////////////////////////////////////////////////////////////// - level_type level() const - { return _label; } + level_type + level() const + { + return _label; + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the width (i.e. number of nodes) of this level. //////////////////////////////////////////////////////////////////////////// - level_type width() const - { return _width; } + level_type + width() const + { + return _width; + } /* =============================== OPERATORS ============================ */ public: - //////////////////////////////////////////////////////////////////////////// /// \brief Whether all entries on this level match. //////////////////////////////////////////////////////////////////////////// - inline bool operator== (const level_info &o) const - { return this->_label == o._label && this->_width == o._width; } + inline bool + operator==(const level_info& o) const + { + return this->_label == o._label && this->_width == o._width; + } //////////////////////////////////////////////////////////////////////////// /// \brief Whether any entry on this level mismatches. //////////////////////////////////////////////////////////////////////////// - inline bool operator!= (const level_info &o) const - { return !(*this == o); } + inline bool + operator!=(const level_info& o) const + { + return !(*this == o); + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the level info for the negated decision diagram. //////////////////////////////////////////////////////////////////////////// - level_info operator! () const - { return *this; } + level_info + operator!() const + { + return *this; + } }; } diff --git a/src/adiar/internal/data_types/node.h b/src/adiar/internal/data_types/node.h index fb5df0067..a3df7abbe 100644 --- a/src/adiar/internal/data_types/node.h +++ b/src/adiar/internal/data_types/node.h @@ -3,8 +3,8 @@ #include #include -#include #include +#include namespace adiar::internal { @@ -99,7 +99,7 @@ namespace adiar::internal /// \details The default, copy, and move constructor has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - node(const node &n) = default; + node(const node& n) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move construction (trivial). @@ -107,7 +107,7 @@ namespace adiar::internal /// \details The default, copy, and move constructor has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - node(node &&n) = default; + node(node&& n) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Destruction (trivial). @@ -124,7 +124,8 @@ namespace adiar::internal /// \details The copy and move assignment has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - node& operator =(const node &n) = default; + node& + operator=(const node& n) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move assignment (trivial). @@ -132,14 +133,18 @@ namespace adiar::internal /// \details The copy and move assignment has to be `default` to ensure it /// is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - node& operator =(node &&n) = default; + node& + operator=(node&& n) = default; public: //////////////////////////////////////////////////////////////////////////// /// \brief The unique identifier of this node //////////////////////////////////////////////////////////////////////////// - inline uid_type uid() const - { return _uid; } + inline uid_type + uid() const + { + return _uid; + } /* ============================== TERMINAL NODE ========================= */ public: @@ -149,21 +154,26 @@ namespace adiar::internal /// \brief Construct *terminal* node `(value, nil, nil)`. //////////////////////////////////////////////////////////////////////////// node(const terminal_type value) - : _uid(pointer_type(value)), _children(ptr_uint64::nil()) - { } + : _uid(pointer_type(value)) + , _children(ptr_uint64::nil()) + {} //////////////////////////////////////////////////////////////////////////// /// \brief Whether this node represents a terminal value. //////////////////////////////////////////////////////////////////////////// - inline bool is_terminal() const - { return _uid.is_terminal(); } + inline bool + is_terminal() const + { + return _uid.is_terminal(); + } //////////////////////////////////////////////////////////////////////////// /// \brief The value of this terminal node (assuming it is one). /// /// \pre `is_terminal()` evaluates to `true`. //////////////////////////////////////////////////////////////////////////// - inline terminal_type value() const + inline terminal_type + value() const { adiar_assert(is_terminal()); return _uid.value(); @@ -174,16 +184,22 @@ namespace adiar::internal /// /// \details This is equivalent to `n.is_terminal() && !n.value()`. ////////////////////////////////////////////////////////////////////////////// - inline bool is_false() const - { return uid().is_false(); } + inline bool + is_false() const + { + return uid().is_false(); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Whether this node is the true terminal. /// /// \details This is equivalent to `n.is_terminal() && n.value()`. ////////////////////////////////////////////////////////////////////////////// - inline bool is_true() const - { return uid().is_true(); } + inline bool + is_true() const + { + return uid().is_true(); + } /* ============================== INTERNAL NODE ========================= */ public: @@ -196,29 +212,29 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Construct node `(uid, low, high)`. //////////////////////////////////////////////////////////////////////////// - node(const uid_type &u, const pointer_type &l, const pointer_type &h) - : _uid(u), _children{l, h} - { } + node(const uid_type& u, const pointer_type& l, const pointer_type& h) + : _uid(u) + , _children{ l, h } + {} //////////////////////////////////////////////////////////////////////////// /// \brief Construct *internal* node `((label, id), low, high)`. //////////////////////////////////////////////////////////////////////////// - node(const label_type label, const id_type id, const pointer_type &l, const pointer_type &h) - : _uid(label, id), _children{l, h} + node(const label_type label, const id_type id, const pointer_type& l, const pointer_type& h) + : _uid(label, id) + , _children{ l, h } { adiar_assert(!l.is_nil(), "Cannot create a node with nil child"); - adiar_assert(l.is_terminal() || label < l.label(), - "Node is not prior to given low child"); + adiar_assert(l.is_terminal() || label < l.label(), "Node is not prior to given low child"); adiar_assert(!h.is_nil(), "Cannot create a node with nil child"); - adiar_assert(h.is_terminal() || label < h.label(), - "Node is not prior to given high child"); + adiar_assert(h.is_terminal() || label < h.label(), "Node is not prior to given high child"); } //////////////////////////////////////////////////////////////////////////// /// \brief Construct *internal* node `((label, id), low, high)`. //////////////////////////////////////////////////////////////////////////// - node(const label_type label, const id_type id, const node &l, const pointer_type &h) + node(const label_type label, const id_type id, const node& l, const pointer_type& h) : node(label, id, l.uid(), h) { adiar_assert(outdegree == 2, "Constructor is for binary node only."); @@ -227,7 +243,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Construct *internal* node `((label, id), low, high)`. //////////////////////////////////////////////////////////////////////////// - node(const label_type label, const id_type id, const pointer_type &l, const node &h) + node(const label_type label, const id_type id, const pointer_type& l, const node& h) : node(label, id, l, h.uid()) { adiar_assert(outdegree == 2, "Constructor is for binary node only."); @@ -236,7 +252,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Construct *internal* node `((label, id), low, high)`. //////////////////////////////////////////////////////////////////////////// - node(const label_type label, const id_type id, const node &l, const node &h) + node(const label_type label, const id_type id, const node& l, const node& h) : node(label, id, l.uid(), h.uid()) { adiar_assert(outdegree == 2, "Constructor is for binary node only."); @@ -248,7 +264,8 @@ namespace adiar::internal /// \pre `is_terminal()` evaluates to `false`. //////////////////////////////////////////////////////////////////////////// // TODO: Rename to `level()` when introducing variable ordering - inline label_type label() const + inline label_type + label() const { adiar_assert(!is_terminal()); return uid().label(); @@ -259,7 +276,8 @@ namespace adiar::internal /// /// \pre `is_terminal()` evaluates to `false`. //////////////////////////////////////////////////////////////////////////// - inline id_type id() const + inline id_type + id() const { adiar_assert(!is_terminal()); return uid().id(); @@ -270,13 +288,17 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief The node's children sorted based on the semantics of this node. //////////////////////////////////////////////////////////////////////////// - inline const children_type& children() const - { return _children; } + inline const children_type& + children() const + { + return _children; + } //////////////////////////////////////////////////////////////////////////// /// \brief The node's i'th child (sorted based on the semantics). //////////////////////////////////////////////////////////////////////////// - inline pointer_type child(const size_t i) const + inline pointer_type + child(const size_t i) const { adiar_assert(i < outdegree, "'i' must be a valid children index."); return _children[i]; @@ -290,10 +312,10 @@ namespace adiar::internal /// /// \see child //////////////////////////////////////////////////////////////////////////// - inline pointer_type low() const + inline pointer_type + low() const { - adiar_assert(outdegree == 2, - "Semantics of 'low' is only defined for binary nodes."); + adiar_assert(outdegree == 2, "Semantics of 'low' is only defined for binary nodes."); return child(false); } @@ -306,63 +328,74 @@ namespace adiar::internal /// /// \see child //////////////////////////////////////////////////////////////////////////// - inline pointer_type high() const + inline pointer_type + high() const { - adiar_assert(outdegree == 2, - "Semantics of 'high' is only defined for binary node."); + adiar_assert(outdegree == 2, "Semantics of 'high' is only defined for binary node."); return child(true); } /* =============================== COMPARATORS ========================== */ public: - ////////////////////////////////////////////////////////////////////////////// /// \brief Sorting of node based based on its `uid()` (i.e. its time-stamp). /// If they are the same, then it secondly is sorted on its cildren. ////////////////////////////////////////////////////////////////////////////// - inline bool operator< (const node &o) const + inline bool + operator<(const node& o) const { - return (this->_uid < o._uid) - || (this->_uid == o._uid && this->_children < o._children); + return (this->_uid < o._uid) || (this->_uid == o._uid && this->_children < o._children); } ////////////////////////////////////////////////////////////////////////////// /// \brief Sorting of node based based on its `uid()` (i.e. its time-stamp). /// If they are the same, then it secondly is sorted on its cildren. ////////////////////////////////////////////////////////////////////////////// - inline bool operator> (const node &o) const - { return (o < *this); } + inline bool + operator>(const node& o) const + { + return (o < *this); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Check uid and children match. ////////////////////////////////////////////////////////////////////////////// - inline bool operator== (const node &o) const + inline bool + operator==(const node& o) const { - return this->_uid == o._uid - && this->_children[false] == o._children[false] - && this->_children[true] == o._children[true]; + return this->_uid == o._uid && this->_children[false] == o._children[false] + && this->_children[true] == o._children[true]; } ////////////////////////////////////////////////////////////////////////////// /// \brief Check either uid or one of the children mismatch. ////////////////////////////////////////////////////////////////////////////// - inline bool operator!= (const node &o) const - { return !(*this == o); } + inline bool + operator!=(const node& o) const + { + return !(*this == o); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Sorting of node based based on its `uid()` (i.e. its time-stamp). /// If they are the same, then it secondly is sorted on its cildren. ////////////////////////////////////////////////////////////////////////////// - inline bool operator<= (const node &o) const - { return (*this < o) || (*this == o); } + inline bool + operator<=(const node& o) const + { + return (*this < o) || (*this == o); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Sorting of node based based on its `uid()` (i.e. its time-stamp). /// If they are the same, then it secondly is sorted on its cildren. ////////////////////////////////////////////////////////////////////////////// - inline bool operator>= (const node &o) const - { return (*this > o) || (*this == o); } + inline bool + operator>=(const node& o) const + { + return (*this > o) || (*this == o); + } /* ================================ OPERATORS =========================== */ public: @@ -371,7 +404,8 @@ namespace adiar::internal /// pointers to terminal children are negated while pointers to other /// nodes are left unchanged. //////////////////////////////////////////////////////////////////////////// - node operator! () const + node + operator!() const { if (this->is_terminal()) { return node(!this->_uid, pointer_type::nil(), pointer_type::nil()); @@ -383,50 +417,74 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Ordering of node in comparison to a unique identifier. ////////////////////////////////////////////////////////////////////////////// - inline bool operator< (const node &n, const node::uid_type &u) - { return n.uid() < u; } + inline bool + operator<(const node& n, const node::uid_type& u) + { + return n.uid() < u; + } ////////////////////////////////////////////////////////////////////////////// /// \brief Ordering of node in comparison to a unique identifier. ////////////////////////////////////////////////////////////////////////////// - inline bool operator< (const node::uid_type &u, const node &n) - { return u < n.uid(); } + inline bool + operator<(const node::uid_type& u, const node& n) + { + return u < n.uid(); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Ordering of node in comparison to a unique identifier. ////////////////////////////////////////////////////////////////////////////// - inline bool operator<= (const node &n, const node::uid_type &u) - { return n.uid() <= u; } + inline bool + operator<=(const node& n, const node::uid_type& u) + { + return n.uid() <= u; + } ////////////////////////////////////////////////////////////////////////////// /// \brief Ordering of node in comparison to a unique identifier. ////////////////////////////////////////////////////////////////////////////// - inline bool operator<= (const node::uid_type &u, const node &n) - { return u <= n.uid(); } + inline bool + operator<=(const node::uid_type& u, const node& n) + { + return u <= n.uid(); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Ordering of node in comparison to a unique identifier. ////////////////////////////////////////////////////////////////////////////// - inline bool operator> (const node &n, const node::uid_type &u) - { return n.uid() > u; } + inline bool + operator>(const node& n, const node::uid_type& u) + { + return n.uid() > u; + } ////////////////////////////////////////////////////////////////////////////// /// \brief Ordering of node in comparison to a unique identifier. ////////////////////////////////////////////////////////////////////////////// - inline bool operator> (const node::uid_type &u, const node &n) - { return u > n.uid(); } + inline bool + operator>(const node::uid_type& u, const node& n) + { + return u > n.uid(); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Ordering of node in comparison to a unique identifier. ////////////////////////////////////////////////////////////////////////////// - inline bool operator>= (const node &n, const node::uid_type &u) - { return n.uid() >= u; } + inline bool + operator>=(const node& n, const node::uid_type& u) + { + return n.uid() >= u; + } ////////////////////////////////////////////////////////////////////////////// /// \brief Ordering of node in comparison to a unique identifier. ////////////////////////////////////////////////////////////////////////////// - inline bool operator>= (const node::uid_type &u, const node &n) - { return u >= n.uid(); } + inline bool + operator>=(const node::uid_type& u, const node& n) + { + return u >= n.uid(); + } } #endif // ADIAR_INTERNAL_DATA_TYPES_NODE_H diff --git a/src/adiar/internal/data_types/ptr.h b/src/adiar/internal/data_types/ptr.h index 132f725a7..1542e95cc 100644 --- a/src/adiar/internal/data_types/ptr.h +++ b/src/adiar/internal/data_types/ptr.h @@ -38,7 +38,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Compute (at compile-time) the (ceiling) log2 of a number. //////////////////////////////////////////////////////////////////////////// - constexpr uint8_t log2(size_t n) + constexpr uint8_t + log2(size_t n) { return n == 0u ? 0u : log2(n / 2u) + 1u; } @@ -99,16 +100,17 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// // befriend functions and classes that need access to 'raw'... template - friend void __print_dot(const dd_t&, std::ostream &, bool); + friend void + __print_dot(const dd_t&, std::ostream&, bool); - template + template friend class __uid; //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// /// \brief Total number of bits. //////////////////////////////////////////////////////////////////////////// - static constexpr uint8_t total_bits = sizeof(uint64_t)*8u; + static constexpr uint8_t total_bits = sizeof(uint64_t) * 8u; public: //////////////////////////////////////////////////////////////////////////// @@ -125,7 +127,7 @@ namespace adiar::internal /// \details The default, copy, and move constructor has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - ptr_uint64(const ptr_uint64 &p) = default; + ptr_uint64(const ptr_uint64& p) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move construction (trivial). @@ -133,7 +135,7 @@ namespace adiar::internal /// \details The default, copy, and move constructor has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - ptr_uint64(ptr_uint64 &&p) = default; + ptr_uint64(ptr_uint64&& p) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Destruction (trivial). @@ -150,7 +152,8 @@ namespace adiar::internal /// \details The copy and move assignment has to be `default` to ensure it /// is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - ptr_uint64& operator =(const ptr_uint64 &p) = default; + ptr_uint64& + operator=(const ptr_uint64& p) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move assignment (trivial). @@ -158,7 +161,8 @@ namespace adiar::internal /// \details The copy and move assignment has to be `default` to ensure it /// is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - ptr_uint64& operator =(ptr_uint64 &&p) = default; + ptr_uint64& + operator=(ptr_uint64&& p) = default; protected: //////////////////////////////////////////////////////////////////////////// @@ -166,7 +170,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// constexpr ptr_uint64(const raw_type raw) : _raw(raw) - { } + {} /* ============================ LEVEL FIELD ============================= */ @@ -193,8 +197,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief The maximal possible value for a level. //////////////////////////////////////////////////////////////////////////// - static constexpr level_type max_level = - (static_cast(1) << level_bits) - 1u; + static constexpr level_type max_level = (static_cast(1) << level_bits) - 1u; public: //////////////////////////////////////////////////////////////////////////// @@ -210,8 +213,10 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// // befriend flag modifying functions that need access to protected values. - friend ptr_uint64 flag(const ptr_uint64 &p); - friend ptr_uint64 unflag(const ptr_uint64 &p); + friend ptr_uint64 + flag(const ptr_uint64& p); + friend ptr_uint64 + unflag(const ptr_uint64& p); //////////////////////////////////////////////////////////////////////////// public: @@ -240,7 +245,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Retrieve the value of the bit flag within a pointer. //////////////////////////////////////////////////////////////////////////// - inline flag_type is_flagged() const + inline flag_type + is_flagged() const { return this->_raw & flag_bit; } @@ -294,8 +300,7 @@ namespace adiar::internal /// /// \see nil //////////////////////////////////////////////////////////////////////////// - static constexpr raw_type min_nil = - static_cast(nil_level) << level_shift; + static constexpr raw_type min_nil = static_cast(nil_level) << level_shift; public: //////////////////////////////////////////////////////////////////////////// @@ -303,13 +308,17 @@ namespace adiar::internal /// /// \remark A nil value always comes after all other types of pointers. //////////////////////////////////////////////////////////////////////////// - static inline constexpr ptr_uint64 nil() - { return ptr_uint64{ min_nil }; } + static inline constexpr ptr_uint64 + nil() + { + return ptr_uint64{ min_nil }; + } //////////////////////////////////////////////////////////////////////////// /// \brief Whether a pointer is nil. //////////////////////////////////////////////////////////////////////////// - inline bool is_nil() const + inline bool + is_nil() const { // Since `nil_level` is maximal and the level bits are most significant, // then we can implement `is_nil()` as a simple comparison to quickly @@ -357,7 +366,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// // befriend flag modifying functions that need access to protected values. friend ptr_uint64 - essential(const ptr_uint64 &p); + essential(const ptr_uint64& p); //////////////////////////////////////////////////////////////////////////// public: @@ -382,7 +391,7 @@ namespace adiar::internal /// \brief Number of bits used to store the out-index. //////////////////////////////////////////////////////////////////////////// static constexpr uint8_t out_idx_bits = log2(max_out_idx); - static_assert(out_idx_bits <= 8*sizeof(out_idx_type)); + static_assert(out_idx_bits <= 8 * sizeof(out_idx_type)); //////////////////////////////////////////////////////////////////////////// /// \brief The number of bits for a level identifier. @@ -391,8 +400,7 @@ namespace adiar::internal /// maximum width possible for a single level: a level cannot /// exceed \$2^{id_bits} \cdot 3 \cdot 8\$ bytes. //////////////////////////////////////////////////////////////////////////// - static constexpr uint8_t id_bits = - total_bits - level_bits - out_idx_bits - flag_bits; + static constexpr uint8_t id_bits = total_bits - level_bits - out_idx_bits - flag_bits; public: //////////////////////////////////////////////////////////////////////////// @@ -413,8 +421,8 @@ namespace adiar::internal /// weight 0. //////////////////////////////////////////////////////////////////////////// constexpr ptr_uint64(const label_type label, const id_type id) - : _raw((static_cast(label) << level_shift) | - (static_cast(id) << (data_shift + out_idx_bits))) + : _raw((static_cast(label) << level_shift) + | (static_cast(id) << (data_shift + out_idx_bits))) { // TODO: Add Debug checks for non-constexpr context // adiar_assert(label <= max_label, "Cannot represent given label"); @@ -425,12 +433,10 @@ namespace adiar::internal /// \brief Constructor for a pointer to an internal node (label, id) with /// given weight. //////////////////////////////////////////////////////////////////////////// - constexpr ptr_uint64(const label_type label, - const id_type id, - const out_idx_type out_idx) - : _raw((static_cast(label) << level_shift) | - (static_cast(id) << (data_shift + out_idx_bits)) | - (static_cast(out_idx) << data_shift)) + constexpr ptr_uint64(const label_type label, const id_type id, const out_idx_type out_idx) + : _raw((static_cast(label) << level_shift) + | (static_cast(id) << (data_shift + out_idx_bits)) + | (static_cast(out_idx) << data_shift)) { // TODO: Add Debug checks for non-constexpr context // adiar_assert(label <= max_label, "Cannot represent given label"); @@ -446,8 +452,8 @@ namespace adiar::internal is_node() const { // Derive at compile-time the maximal internal node pointer value. - constexpr raw_type max_node = ptr_uint64(max_label, max_id, max_out_idx)._raw - | ptr_uint64::flag_bit; + constexpr raw_type max_node = + ptr_uint64(max_label, max_id, max_out_idx)._raw | ptr_uint64::flag_bit; // Since nodes' levels are the smallest ones and the level bits are most // significant, then we can implement `is_node()` as a simple comparison @@ -513,7 +519,7 @@ namespace adiar::internal // Template 'terminal_type' using terminal_type = bool; - static_assert(8*sizeof(terminal_type) <= data_bits, + static_assert(8 * sizeof(terminal_type) <= data_bits, "Type for terminal values may overflow data field"); public: @@ -531,8 +537,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Minimal possible raw value for a terminal. //////////////////////////////////////////////////////////////////////////// - static constexpr raw_type min_terminal = - static_cast(terminal_level) << level_shift; + static constexpr raw_type min_terminal = static_cast(terminal_level) << level_shift; // TODO (32-bit ADD): // Add `max_terminal` at compile-time. Note, we are interested in the raw @@ -544,9 +549,9 @@ namespace adiar::internal /// \brief Constructor for a pointer to a terminal node (v). //////////////////////////////////////////////////////////////////////////// constexpr ptr_uint64(const terminal_type v) - : _raw((static_cast(terminal_level) << level_shift) | - (static_cast(v) << data_shift)) - { } + : _raw((static_cast(terminal_level) << level_shift) + | (static_cast(v) << data_shift)) + {} public: //////////////////////////////////////////////////////////////////////////// @@ -605,43 +610,61 @@ namespace adiar::internal /// \brief Lexicographical ordering on internal nodes (i, id), followed by /// terminals `false`, `true`, and finally `nil`. //////////////////////////////////////////////////////////////////////////// - inline bool operator< (const ptr_uint64 &o) const - { return this->_raw < o._raw; } + inline bool + operator<(const ptr_uint64& o) const + { + return this->_raw < o._raw; + } //////////////////////////////////////////////////////////////////////////// /// \brief Lexicographical ordering on internal nodes (i, id), followed by /// terminals `false`, `true`, and finally `nil`. //////////////////////////////////////////////////////////////////////////// - inline bool operator<= (const ptr_uint64 &o) const - { return this->_raw <= o._raw; } + inline bool + operator<=(const ptr_uint64& o) const + { + return this->_raw <= o._raw; + } //////////////////////////////////////////////////////////////////////////// /// \brief Lexicographical ordering on internal nodes (i, id), followed by /// terminals `false`, `true`, and finally `nil`. //////////////////////////////////////////////////////////////////////////// - inline bool operator> (const ptr_uint64 &o) const - { return (o < *this); } + inline bool + operator>(const ptr_uint64& o) const + { + return (o < *this); + } //////////////////////////////////////////////////////////////////////////// /// \brief Lexicographical ordering on internal nodes (i, id), followed by /// terminals `false`, `true`, and finally `nil`. //////////////////////////////////////////////////////////////////////////// - inline bool operator>= (const ptr_uint64 &o) const - { return (o <= *this); } + inline bool + operator>=(const ptr_uint64& o) const + { + return (o <= *this); + } //////////////////////////////////////////////////////////////////////////// /// \brief Whether pointers reference the same node and also share the same /// auxiliary data, i.e. `flag` and `out_idx`. //////////////////////////////////////////////////////////////////////////// - inline bool operator== (const ptr_uint64 &o) const - { return this->_raw == o._raw; } + inline bool + operator==(const ptr_uint64& o) const + { + return this->_raw == o._raw; + } //////////////////////////////////////////////////////////////////////////// /// \brief Whether pointers reference the same node and also share the same /// auxiliary data, i.e. `flag` and `out_idx`. //////////////////////////////////////////////////////////////////////////// - inline bool operator!= (const ptr_uint64 &o) const - { return !(*this == o); } + inline bool + operator!=(const ptr_uint64& o) const + { + return !(*this == o); + } /* ================================ OPERATORS ============================= */ private: @@ -649,15 +672,17 @@ namespace adiar::internal // // This is indeed the case for `bool` and unsigned and signed integers. static constexpr raw_type value_mask = - (static_cast(std::numeric_limits::max()) | - static_cast(std::numeric_limits::min())) << data_shift; + (static_cast(std::numeric_limits::max()) + | static_cast(std::numeric_limits::min())) + << data_shift; public: ////////////////////////////////////////////////////////////////////////////// /// \brief Obtain a pointer where terminal values (if any) are negated. The /// 'flag' is kept as-is. ////////////////////////////////////////////////////////////////////////////// - ptr_uint64 operator! () const + ptr_uint64 + operator!() const { // TODO (32-bit ADD): // Make this only a specialization for `ptr_uint64`. Generic version @@ -671,7 +696,8 @@ namespace adiar::internal /// /// \pre `is_terminal()` evaluates to `true`. ////////////////////////////////////////////////////////////////////////////// - ptr_uint64 operator~ () const + ptr_uint64 + operator~() const { adiar_assert(this->is_terminal()); @@ -684,7 +710,8 @@ namespace adiar::internal /// /// \pre `is_terminal()` evaluates to `true`. ////////////////////////////////////////////////////////////////////////////// - ptr_uint64 operator^ (const ptr_uint64 &o) const + ptr_uint64 + operator^(const ptr_uint64& o) const { adiar_assert(this->is_terminal()); adiar_assert(o.is_terminal()); @@ -702,7 +729,8 @@ namespace adiar::internal /// /// \pre `is_terminal()` evaluates to `true`. ////////////////////////////////////////////////////////////////////////////// - ptr_uint64 operator& (const ptr_uint64 &o) const + ptr_uint64 + operator&(const ptr_uint64& o) const { adiar_assert(this->is_terminal()); adiar_assert(o.is_terminal()); @@ -718,7 +746,8 @@ namespace adiar::internal /// /// \pre `is_terminal()` evaluates to `true`. ////////////////////////////////////////////////////////////////////////////// - ptr_uint64 operator| (const ptr_uint64 &o) const + ptr_uint64 + operator|(const ptr_uint64& o) const { adiar_assert(this->is_terminal()); adiar_assert(o.is_terminal()); @@ -734,7 +763,8 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief The pointer with its flag set to true. ////////////////////////////////////////////////////////////////////////////// - inline ptr_uint64 flag(const ptr_uint64 &p) + inline ptr_uint64 + flag(const ptr_uint64& p) { return p._raw | ptr_uint64::flag_bit; } @@ -742,7 +772,8 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief The pointer with its flag set to false. ////////////////////////////////////////////////////////////////////////////// - inline ptr_uint64 unflag(const ptr_uint64 &p) + inline ptr_uint64 + unflag(const ptr_uint64& p) { return p._raw & (~ptr_uint64::flag_bit); } @@ -751,7 +782,8 @@ namespace adiar::internal /// \brief The *essential* pointer, i.e. one without any auxiliary data, e.g. /// the Boolean flag and the out-index. ////////////////////////////////////////////////////////////////////////////// - inline ptr_uint64 essential(const ptr_uint64 &p) + inline ptr_uint64 + essential(const ptr_uint64& p) { // Assuming 'max_out_idx' is consecutive 1s. constexpr ptr_uint64::raw_type out_idx_mask = @@ -760,9 +792,8 @@ namespace adiar::internal // We can abuse the bit-layout to boil everything down to a bit mask, and a // conditional move instruction (see `ptr_uint64::is_node()`). This should // be optimisable into very few CPU instructions similar to 'std::min<>'. - return p.is_node() - ? (p._raw & ~(out_idx_mask | ptr_uint64::flag_bit)) - : (p._raw & ~ptr_uint64::flag_bit); + return p.is_node() ? (p._raw & ~(out_idx_mask | ptr_uint64::flag_bit)) + : (p._raw & ~ptr_uint64::flag_bit); } /* ============================== CONVERSION ============================== */ diff --git a/src/adiar/internal/data_types/request.h b/src/adiar/internal/data_types/request.h index 90bb4033b..42972e357 100644 --- a/src/adiar/internal/data_types/request.h +++ b/src/adiar/internal/data_types/request.h @@ -33,21 +33,20 @@ namespace adiar::internal /// such as `bdd_exists` and `bdd_compose` where the /// request includes pairs of nodes from the same input. ////////////////////////////////////////////////////////////////////////////// - template + template class request; ////////////////////////////////////////////////////////////////////////////// /// \details Common details for requests with and without a node carry. ////////////////////////////////////////////////////////////////////////////// - template + template class request { public: //////////////////////////////////////////////////////////////////////////// static_assert(0 < Cardinality, - "Request type is not designed for 0-ary targets, i.e. without at least one node in either diagram."); + "Request type is not designed for 0-ary targets, i.e. without at least one node " + "in either diagram."); //////////////////////////////////////////////////////////////////////////// /// \brief Cardinality of the request target. @@ -56,7 +55,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// static_assert(Inputs > 0, - "Request type is not designed for a 0-ary operation, i.e. an algorithm taking no diagrams as input."); + "Request type is not designed for a 0-ary operation, i.e. an algorithm taking no " + "diagrams as input."); //////////////////////////////////////////////////////////////////////////// /// \brief Number of input files. @@ -93,8 +93,11 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief The level at which this request should be resolved. //////////////////////////////////////////////////////////////////////////// - pointer_type::label_type level() const - { return target.first().label(); } + pointer_type::label_type + level() const + { + return target.first().label(); + } /* ============================= NODE CARRY ============================= */ @@ -111,25 +114,35 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief The value to be inserted in empy slots in the `node_carry`. //////////////////////////////////////////////////////////////////////////// - static inline constexpr children_type NO_CHILDREN() - { return children_type(pointer_type::nil()); } + static inline constexpr children_type + NO_CHILDREN() + { + return children_type(pointer_type::nil()); + } //////////////////////////////////////////////////////////////////////////// /// \brief The number of nodes actually carried by this request. //////////////////////////////////////////////////////////////////////////// - uint8_t nodes_carried() const - { return 0u; } + uint8_t + nodes_carried() const + { + return 0u; + } //////////////////////////////////////////////////////////////////////////// /// \brief Whether no nodes are carried by this request. //////////////////////////////////////////////////////////////////////////// - bool empty_carry() const - { return true; } + bool + empty_carry() const + { + return true; + } //////////////////////////////////////////////////////////////////////////// /// \brief The number of non-nil target values. //////////////////////////////////////////////////////////////////////////// - uint8_t targets() const + uint8_t + targets() const { if constexpr (sorted_target) { // Since nil is the greatest value, we can look for the first nil entry @@ -163,7 +176,7 @@ namespace adiar::internal /// \details The default, copy, and move construction has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - request(const request &r) = default; + request(const request& r) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move construction (trivial). @@ -171,7 +184,7 @@ namespace adiar::internal /// \details The default, copy, and move construction has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - request(request &&r) = default; + request(request&& r) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Destruction (trivial). @@ -188,7 +201,8 @@ namespace adiar::internal /// \details The copy and move assignment has to be `default` to ensure it /// is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - request& operator =(const request &r) = default; + request& + operator=(const request& r) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move assignment (trivial). @@ -196,7 +210,8 @@ namespace adiar::internal /// \details The copy and move assignment has to be `default` to ensure it /// is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - request& operator =(request &&r) = default; + request& + operator=(request&& r) = default; public: //////////////////////////////////////////////////////////////////////////// @@ -204,24 +219,24 @@ namespace adiar::internal /// /// \param t Target of the request //////////////////////////////////////////////////////////////////////////// - request(const target_t &t) : target(t) - { } + request(const target_t& t) + : target(t) + {} public: //////////////////////////////////////////////////////////////////////////// /// \brief Constructor for a request to the given `target` with an empty /// node carry. //////////////////////////////////////////////////////////////////////////// - request(const target_t &t, - const std::array&/*nc*/) + request(const target_t& t, const std::array& /*nc*/) : request(t) - { } + {} }; ////////////////////////////////////////////////////////////////////////////// /// \details Implementation of `request` template with a non-empty node carry. ////////////////////////////////////////////////////////////////////////////// - template + template class request : public request { using base = request; @@ -253,7 +268,8 @@ namespace adiar::internal /// /// \see NO_CHILDREN //////////////////////////////////////////////////////////////////////////// - uint8_t nodes_carried() const + uint8_t + nodes_carried() const { uint8_t sum = 0u; for (uint8_t n_idx = 0u; n_idx < node_carry_size; n_idx++) { @@ -273,7 +289,8 @@ namespace adiar::internal /// /// \see nodes_carried, NO_CHILDREN //////////////////////////////////////////////////////////////////////////// - bool empty_carry() const + bool + empty_carry() const { if constexpr (node_carry_size == 0u) return true; return node_carry[0][0] == base::pointer_type::nil(); @@ -295,7 +312,7 @@ namespace adiar::internal /// \details The default, copy, and move construction has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - request(const request &r) = default; + request(const request& r) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move construction (trivial). @@ -303,7 +320,7 @@ namespace adiar::internal /// \details The default, copy, and move construction has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - request(request &&r) = default; + request(request&& r) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Destruction (trivial). @@ -320,7 +337,8 @@ namespace adiar::internal /// \details The copy and move assignment has to be `default` to ensure it /// is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - request& operator =(const request &r) = default; + request& + operator=(const request& r) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move assignment (trivial). @@ -328,7 +346,8 @@ namespace adiar::internal /// \details The copy and move assignment has to be `default` to ensure it /// is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - request& operator =(request &&r) = default; + request& + operator=(request&& r) = default; public: //////////////////////////////////////////////////////////////////////////// @@ -339,10 +358,11 @@ namespace adiar::internal /// \param nc List of the children that already have been visited but needs /// to be forwarded to fully resolve the request to `t`. //////////////////////////////////////////////////////////////////////////// - request(const typename base::target_t &t, - const std::array &nc) - : base(t), node_carry(nc) - { } + request(const typename base::target_t& t, + const std::array& nc) + : base(t) + , node_carry(nc) + {} }; ////////////////////////////////////////////////////////////////////////////// @@ -356,13 +376,14 @@ namespace adiar::internal // TODO: request_lt without `idx` for a pure lexicographical ordering... // - Flip parameters, make `idx = 0` default. // - Optimise for default case. - template + template struct request_lt { static_assert(idx == 0, "Non-lexicographical ordering not (yet) supported."); /// \copydoc request_lt - inline bool operator()(const Request &a, const Request &b) + inline bool + operator()(const Request& a, const Request& b) { const typename Request::label_type label_a = a.target.first().label(); const typename Request::label_type label_b = b.target.first().label(); @@ -374,11 +395,12 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Ordering based on the first target in sorted order. ////////////////////////////////////////////////////////////////////////////// - template + template struct request_first_lt { /// \copydoc request_first_lt - inline bool operator()(const Request &a, const Request &b) + inline bool + operator()(const Request& a, const Request& b) { return tuple_first_lt()(a.target, b.target); } @@ -387,11 +409,12 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Ordering based on the second target in sorted order. ////////////////////////////////////////////////////////////////////////////// - template + template struct request_second_lt { /// \copydoc request_second_lt - inline bool operator()(const Request &a, const Request &b) + inline bool + operator()(const Request& a, const Request& b) { return tuple_second_lt()(a.target, b.target); } @@ -400,11 +423,12 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Ordering based on the third target in sorted order. ////////////////////////////////////////////////////////////////////////////// - template + template struct request_third_lt { /// \copydoc request_third_lt - inline bool operator()(const Request &a, const Request &b) + inline bool + operator()(const Request& a, const Request& b) { return tuple_third_lt()(a.target, b.target); } @@ -416,12 +440,11 @@ namespace adiar::internal /// /// \see request ////////////////////////////////////////////////////////////////////////////// - template - class request_data - : public request + template + class request_data : public request { private: using Request = request; @@ -454,7 +477,7 @@ namespace adiar::internal /// \details The default, copy, and move construction has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - request_data(const request_data &r) = default; + request_data(const request_data& r) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move construction (trivial). @@ -462,7 +485,7 @@ namespace adiar::internal /// \details The default, copy, and move construction has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - request_data(request_data &&r) = default; + request_data(request_data&& r) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Destruction (trivial). @@ -479,7 +502,8 @@ namespace adiar::internal /// \details The copy and move assignment has to be `default` to ensure it /// is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - request_data& operator =(const request_data &r) = default; + request_data& + operator=(const request_data& r) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move assignment (trivial). @@ -487,8 +511,8 @@ namespace adiar::internal /// \details The copy and move assignment has to be `default` to ensure it /// is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - request_data& operator =(request_data &&r) = default; - + request_data& + operator=(request_data&& r) = default; public: //////////////////////////////////////////////////////////////////////////// @@ -501,11 +525,12 @@ namespace adiar::internal /// /// \param d Additional data to be forwarded. //////////////////////////////////////////////////////////////////////////// - request_data(const typename Request::target_t &t, - const std::array &nc, - const data_type &d) - : Request(t, nc), data(d) - { } + request_data(const typename Request::target_t& t, + const std::array& nc, + const data_type& d) + : Request(t, nc) + , data(d) + {} }; ////////////////////////////////////////////////////////////////////////////// @@ -515,11 +540,12 @@ namespace adiar::internal /// \brief Level/Lexicographical ordering on a request's target(s). Ties are /// (potentially) broken on the data. ////////////////////////////////////////////////////////////////////////////// - template + template struct request_data_lt { /// \copydoc request_data_lt - inline bool operator()(const Request &a, const Request &b) + inline bool + operator()(const Request& a, const Request& b) { if constexpr (Request::data_type::sort_on_tiebreak) { if (a.target == b.target) return a.data < b.data; @@ -532,11 +558,12 @@ namespace adiar::internal /// \brief Ordering based on the first target in sorted order. Ties are /// (potentially) broken on the data. ////////////////////////////////////////////////////////////////////////////// - template + template struct request_data_first_lt { /// \copydoc request_first_lt - inline bool operator()(const Request &a, const Request &b) + inline bool + operator()(const Request& a, const Request& b) { if constexpr (Request::data_type::sort_on_tiebreak) { if (a.target == b.target) return a.data < b.data; @@ -549,11 +576,12 @@ namespace adiar::internal /// \brief Ordering based on the second target in sorted order. Ties are /// (potentially) broken on the data. ////////////////////////////////////////////////////////////////////////////// - template + template struct request_data_second_lt { /// \copydoc request_second_lt - inline bool operator()(const Request &a, const Request &b) + inline bool + operator()(const Request& a, const Request& b) { if constexpr (Request::data_type::sort_on_tiebreak) { if (a.target == b.target) return a.data < b.data; @@ -566,11 +594,12 @@ namespace adiar::internal /// \brief Ordering based on the third target in sorted order. Ties are /// (potentially) broken on the data. ////////////////////////////////////////////////////////////////////////////// - template + template struct request_data_third_lt { /// \copydoc request_third_lt - inline bool operator()(const Request &a, const Request &b) + inline bool + operator()(const Request& a, const Request& b) { if constexpr (Request::data_type::sort_on_tiebreak) { if (a.target == b.target) return a.data < b.data; @@ -607,8 +636,11 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Comparator to break ties based on the . //////////////////////////////////////////////////////////////////////////// - inline bool operator< (const with_parent &o) const - { return this->source < o.source; } + inline bool + operator<(const with_parent& o) const + { + return this->source < o.source; + } }; } diff --git a/src/adiar/internal/data_types/tuple.h b/src/adiar/internal/data_types/tuple.h index 3219ae545..7b33d6020 100644 --- a/src/adiar/internal/data_types/tuple.h +++ b/src/adiar/internal/data_types/tuple.h @@ -18,60 +18,74 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// // Ordered access to two elements. - template + template inline const T& - first(const T &t1, const T &t2) - { return std::min(t1, t2); } + first(const T& t1, const T& t2) + { + return std::min(t1, t2); + } - template + template inline const T& - second(const T &t1, const T &t2) - { return std::max(t1, t2); } + second(const T& t1, const T& t2) + { + return std::max(t1, t2); + } ////////////////////////////////////////////////////////////////////////////// // Ordered access to three elements. - template + template inline const T& - first(const T &t1, const T &t2, const T &t3) - { return std::min(t1, std::min(t2, t3)); } + first(const T& t1, const T& t2, const T& t3) + { + return std::min(t1, std::min(t2, t3)); + } - template + template inline const T& - second(const T &t1, const T &t2, const T &t3) - { return std::max(std::min(t1, t2), std::min(std::max(t1,t2),t3)); } + second(const T& t1, const T& t2, const T& t3) + { + return std::max(std::min(t1, t2), std::min(std::max(t1, t2), t3)); + } - template + template inline const T& - third(const T &t1, const T &t2, const T &t3) - { return std::max(t1, std::max(t2, t3)); } + third(const T& t1, const T& t2, const T& t3) + { + return std::max(t1, std::max(t2, t3)); + } ////////////////////////////////////////////////////////////////////////////// // Ordered access to four elements. - template + template inline const T& - first(const T &t1, const T &t2, const T &t3, const T &t4) - { return std::min(std::min(t1, t2), std::min(t3, t4)); } + first(const T& t1, const T& t2, const T& t3, const T& t4) + { + return std::min(std::min(t1, t2), std::min(t3, t4)); + } - template + template inline const T& - second(const T &t1, const T &t2, const T &t3, const T &t4) + second(const T& t1, const T& t2, const T& t3, const T& t4) { - return std::min(std::min(std::max(t1,t2), std::max(t3,t4)), - std::max(std::min(t1,t2), std::min(t3,t4))); + return std::min(std::min(std::max(t1, t2), std::max(t3, t4)), + std::max(std::min(t1, t2), std::min(t3, t4))); } - template + template inline const T& - third(const T &t1, const T &t2, const T &t3, const T &t4) + third(const T& t1, const T& t2, const T& t3, const T& t4) { - return std::max(std::min(std::max(t1,t2), std::max(t3,t4)), - std::max(std::min(t1,t2), std::min(t3,t4))); + return std::max(std::min(std::max(t1, t2), std::max(t3, t4)), + std::max(std::min(t1, t2), std::min(t3, t4))); } - template + template inline const T& - fourth(const T &t1, const T &t2, const T &t3, const T &t4) - { return std::max(std::max(t1, t2), std::max(t3, t4)); } + fourth(const T& t1, const T& t2, const T& t3, const T& t4) + { + return std::max(std::max(t1, t2), std::max(t3, t4)); + } ////////////////////////////////////////////////////////////////////////////// // TODO (Nested Sweeping Clean Up): @@ -89,7 +103,7 @@ namespace adiar::internal /// \tparam is_sorted Whether elements are given in sorted order /// (default: `false`). ////////////////////////////////////////////////////////////////////////////// - template + template class tuple { /* ============================== CONSTANTS ============================= */ @@ -121,7 +135,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Direct access to tuple elements in the order they were given. //////////////////////////////////////////////////////////////////////////// - inline const value_type& at(const size_t idx) const + inline const value_type& + at(const size_t idx) const { adiar_assert(idx < cardinality, "Tuple index must be within its cardinality."); return _values[idx]; @@ -130,7 +145,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Direct access to tuple elements in the order they were given. //////////////////////////////////////////////////////////////////////////// - inline const value_type& operator [] (const size_t idx) const + inline const value_type& + operator[](const size_t idx) const { return this->at(idx); } @@ -138,7 +154,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief direct (read-only) access to the underlying array. //////////////////////////////////////////////////////////////////////////// - inline const std::array& data() const + inline const std::array& + data() const { return this->_values; } @@ -148,7 +165,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Access to the first element wrt. the elements ordering. //////////////////////////////////////////////////////////////////////////// - inline const value_type& first() const + inline const value_type& + first() const { static_assert(1 <= cardinality, "Must at least be a 1-ary tuple to retrieve the first element."); @@ -167,7 +185,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Access to the second element wrt. the elements ordering. //////////////////////////////////////////////////////////////////////////// - inline const value_type& second() const + inline const value_type& + second() const { static_assert(2 <= cardinality, "Must at least be a 2-ary tuple to retrieve the second element."); @@ -186,7 +205,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Access to the second element wrt. the elements ordering. //////////////////////////////////////////////////////////////////////////// - inline const value_type& third() const + inline const value_type& + third() const { static_assert(3 <= cardinality, "Must at least be a 3-ary tuple to retrieve the third element."); @@ -203,7 +223,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Access to the second element wrt. the elements ordering. //////////////////////////////////////////////////////////////////////////// - inline const value_type& fourth() const + inline const value_type& + fourth() const { static_assert(3 <= cardinality, "Must at least be a 4-ary tuple to retrieve the fourth element."); @@ -231,7 +252,7 @@ namespace adiar::internal /// \details The default, copy, and move construction has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - tuple(const tuple &p) = default; + tuple(const tuple& p) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move construction (trivial). @@ -239,7 +260,7 @@ namespace adiar::internal /// \details The default, copy, and move construction has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - tuple(tuple &&p) = default; + tuple(tuple&& p) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Destruction (trivial). @@ -256,7 +277,8 @@ namespace adiar::internal /// \details The copy and move assignment has to be `default` to ensure it /// is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - tuple& operator =(const tuple &p) = default; + tuple& + operator=(const tuple& p) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move assignment (trivial). @@ -264,7 +286,8 @@ namespace adiar::internal /// \details The copy and move assignment has to be `default` to ensure it /// is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - tuple& operator =(tuple &&p) = default; + tuple& + operator=(tuple&& p) = default; public: // Provide other constructors for ease of use @@ -272,8 +295,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Initialize a tuple with all elements being the given one. //////////////////////////////////////////////////////////////////////////// - tuple(const value_type &elem) - : _values{elem} + tuple(const value_type& elem) + : _values{ elem } { // TODO: replace with a (templated) default value (?) if constexpr (2 <= cardinality) _values[1] = elem; @@ -284,43 +307,38 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Create a 2-ary tuple with the two given elements. //////////////////////////////////////////////////////////////////////////// - tuple(const value_type &elem1, const value_type &elem2) - : _values{elem1,elem2} + tuple(const value_type& elem1, const value_type& elem2) + : _values{ elem1, elem2 } { - static_assert(cardinality == 2, - "Constructor is only designed for 2-ary tuples."); + static_assert(cardinality == 2, "Constructor is only designed for 2-ary tuples."); - if constexpr (is_sorted) { - adiar_assert(elem1 <= elem2); - } + if constexpr (is_sorted) { adiar_assert(elem1 <= elem2); } } //////////////////////////////////////////////////////////////////////////// /// \brief Create a 3-ary tuple with the three given elements. //////////////////////////////////////////////////////////////////////////// - tuple(const value_type &elem1, const value_type &elem2, const value_type &elem3) - : _values{elem1,elem2,elem3} + tuple(const value_type& elem1, const value_type& elem2, const value_type& elem3) + : _values{ elem1, elem2, elem3 } { - static_assert(cardinality == 3, - "Constructor is only designed for 3-ary tuples."); + static_assert(cardinality == 3, "Constructor is only designed for 3-ary tuples."); if constexpr (is_sorted) { adiar_assert(elem1 <= elem2); adiar_assert(elem2 <= elem3); - } + } } //////////////////////////////////////////////////////////////////////////// /// \brief Create a 4-ary tuple with the four given elements. //////////////////////////////////////////////////////////////////////////// - tuple(const value_type &elem1, - const value_type &elem2, - const value_type &elem3, - const value_type &elem4) - : _values{elem1,elem2,elem3,elem4} + tuple(const value_type& elem1, + const value_type& elem2, + const value_type& elem3, + const value_type& elem4) + : _values{ elem1, elem2, elem3, elem4 } { - static_assert(cardinality == 4, - "Constructor is only designed for 4-ary tuples."); + static_assert(cardinality == 4, "Constructor is only designed for 4-ary tuples."); if constexpr (is_sorted) { adiar_assert(elem1 <= elem2); @@ -332,12 +350,12 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Create a tuple from a `std::array` of the same cardinality. //////////////////////////////////////////////////////////////////////////// - tuple(const std::array &elems) + tuple(const std::array& elems) : _values(elems) { if constexpr (is_sorted) { - for (size_t i = 0; i < (cardinality-1); ++i) { - adiar_assert(this->at(i) <= this->at(i+1)); + for (size_t i = 0; i < (cardinality - 1); ++i) { + adiar_assert(this->at(i) <= this->at(i + 1)); } } } @@ -347,7 +365,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Lexicographical Less-Than. //////////////////////////////////////////////////////////////////////////// - inline bool operator< (const tuple &o) const + inline bool + operator<(const tuple& o) const { // TODO: manual loop unrolling? for (size_t i = 0; i < cardinality; i++) { @@ -360,7 +379,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Less-Than comparison with a single element. //////////////////////////////////////////////////////////////////////////// - inline bool operator< (const value_type &o) const + inline bool + operator<(const value_type& o) const { static_assert(cardinality == 1); return this->_values[0] < o; @@ -369,13 +389,17 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Lexicographical Greater-Than. //////////////////////////////////////////////////////////////////////////// - inline bool operator> (const tuple &o) const - { return (o < *this); } + inline bool + operator>(const tuple& o) const + { + return (o < *this); + } //////////////////////////////////////////////////////////////////////////// /// \brief Greater-Than comparison with a single element. //////////////////////////////////////////////////////////////////////////// - inline bool operator> (const value_type &o) const + inline bool + operator>(const value_type& o) const { static_assert(cardinality == 1); return this->_values[0] > o; @@ -384,7 +408,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Point-wise Equality. //////////////////////////////////////////////////////////////////////////// - inline bool operator== (const tuple &o) const + inline bool + operator==(const tuple& o) const { // TODO: manual loop unrolling? for (size_t i = 0; i < cardinality; i++) { @@ -396,7 +421,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Equality comparison with a single element. //////////////////////////////////////////////////////////////////////////// - inline bool operator== (const value_type &o) const + inline bool + operator==(const value_type& o) const { static_assert(cardinality == 1); return this->_values[0] == o; @@ -405,13 +431,17 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Point-wise Inequality. //////////////////////////////////////////////////////////////////////////// - inline bool operator!= (const tuple &o) const - { return !(*this == o); } + inline bool + operator!=(const tuple& o) const + { + return !(*this == o); + } //////////////////////////////////////////////////////////////////////////// /// \brief Inequality comparison with a single element. //////////////////////////////////////////////////////////////////////////// - inline bool operator!= (const value_type &o) const + inline bool + operator!=(const value_type& o) const { static_assert(cardinality == 1); return this->_values[0] != o; @@ -420,14 +450,20 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Lexicographical Less-Than and Equality. //////////////////////////////////////////////////////////////////////////// - inline bool operator<= (const tuple &o) const - { return (*this < o) || (*this == o); } + inline bool + operator<=(const tuple& o) const + { + return (*this < o) || (*this == o); + } //////////////////////////////////////////////////////////////////////////// /// \brief Lexicographical Greater-Than and Equality. //////////////////////////////////////////////////////////////////////////// - inline bool operator>= (const tuple &o) const - { return (*this > o) || (*this == o); } + inline bool + operator>=(const tuple& o) const + { + return (*this > o) || (*this == o); + } }; ////////////////////////////////////////////////////////////////////////////// @@ -436,11 +472,12 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Ordering based on the first element (in sorted order). ////////////////////////////////////////////////////////////////////////////// - template + template struct tuple_first_lt { /// \copydoc tuple_first_lt - inline bool operator()(const Tuple &a, const Tuple &b) + inline bool + operator()(const Tuple& a, const Tuple& b) { // Sort primarily by the element to be encountered first. // If non-singleton, sort secondly lexicographically. @@ -455,11 +492,12 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Ordering based on the second element (in sorted order). ////////////////////////////////////////////////////////////////////////////// - template + template struct tuple_second_lt { /// \copydoc tuple_second_lt - inline bool operator()(const Tuple &a, const Tuple &b) + inline bool + operator()(const Tuple& a, const Tuple& b) { // Sort primarily by the element to be encountered second return a.second() < b.second() || @@ -471,11 +509,12 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Ordering based on the third element (in sorted order). ////////////////////////////////////////////////////////////////////////////// - template + template struct tuple_third_lt { /// \copydoc tuple_third_lt - inline bool operator()(const Tuple &a, const Tuple &b) + inline bool + operator()(const Tuple& a, const Tuple& b) { // Sort primarily by the element to be encountered third return a.third() < b.third() || @@ -487,11 +526,12 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Ordering based on the fourth element (in sorted order). ////////////////////////////////////////////////////////////////////////////// - template + template struct tuple_fourth_lt { /// \copydoc tuple_fourth_lt - inline bool operator()(const Tuple &a, const Tuple &b) + inline bool + operator()(const Tuple& a, const Tuple& b) { // Sort primarily by the element to be encountered fourth return a.fourth() < b.fourth() || diff --git a/src/adiar/internal/data_types/uid.h b/src/adiar/internal/data_types/uid.h index 64faa5de1..bae613fa7 100644 --- a/src/adiar/internal/data_types/uid.h +++ b/src/adiar/internal/data_types/uid.h @@ -15,9 +15,8 @@ namespace adiar::internal /// it is \em never nil, and without any associated information, /// e.g. \em without a flag. ////////////////////////////////////////////////////////////////////////////// - template - class __uid - : public Ptr + template + class __uid : public Ptr { public: using pointer_type = Ptr; @@ -37,7 +36,7 @@ namespace adiar::internal /// \details The default, copy, and move constructor has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - __uid(const __uid &p) = default; + __uid(const __uid& p) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move construction (trivial). @@ -45,7 +44,7 @@ namespace adiar::internal /// \details The default, copy, and move constructor has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - __uid(__uid &&p) = default; + __uid(__uid&& p) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Destruction (trivial). @@ -62,7 +61,8 @@ namespace adiar::internal /// \details The default, copy, and move assignment has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - __uid& operator =(const __uid &p) = default; + __uid& + operator=(const __uid& p) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move assignment @@ -70,13 +70,15 @@ namespace adiar::internal /// \details The default, copy, and move assignment has to be `default` to /// ensure it is a *POD* and hence can be used by TPIE's files. //////////////////////////////////////////////////////////////////////////// - __uid& operator =(__uid &&p) = default; + __uid& + operator=(__uid&& p) = default; public: //////////////////////////////////////////////////////////////////////////// /// \brief Constructor for a uid of an internal node (label, id). //////////////////////////////////////////////////////////////////////////// - __uid(const pointer_type &p) : pointer_type(essential(p)) + __uid(const pointer_type& p) + : pointer_type(essential(p)) { adiar_assert(!p.is_nil(), "UID must be created from non-nil value"); } @@ -84,19 +86,23 @@ namespace adiar::internal /* ============================= ATTRIBUTES ============================= */ // Remove anything related to the flag. - bool is_flagged() = delete; + bool + is_flagged() = delete; /* ================================= nil ================================ */ // Remove anything related to nil - static inline constexpr pointer_type nil() = delete; + static inline constexpr pointer_type + nil() = delete; - bool is_nil() = delete; + bool + is_nil() = delete; /* ================================ NODES =============================== */ // Remove anything related to out-index - typename pointer_type::out_idx_type out_idx() = delete; + typename pointer_type::out_idx_type + out_idx() = delete; //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the `ptr` for this node uid with no auxiliary information. @@ -122,10 +128,9 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Constructor for a pointer to an internal node (label, id). //////////////////////////////////////////////////////////////////////////// - __uid(const typename pointer_type::label_type label, - const typename pointer_type::id_type id) + __uid(const typename pointer_type::label_type label, const typename pointer_type::id_type id) : pointer_type(label, id) - { } + {} /* ============================== TERMINALS ============================= */ public: @@ -134,7 +139,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// __uid(typename pointer_type::terminal_type v) : pointer_type(v) - { } + {} public: //////////////////////////////////////////////////////////////////////////// @@ -142,7 +147,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// // This functions is overwritten, such that we can provide a specialization // for '__uid'. - inline bool is_terminal() const + inline bool + is_terminal() const { return this->is_terminal(); } @@ -155,7 +161,7 @@ namespace adiar::internal /// \brief Obtain the `ptr` for this node uid with the given `out_idx` as /// auxiliary information. //////////////////////////////////////////////////////////////////////////// - template<> + template <> inline ptr_uint64 __uid::as_ptr(const ptr_uint64::out_idx_type out_idx) const { @@ -165,14 +171,15 @@ namespace adiar::internal // re-encode all three values. constexpr pointer_type::raw_type out_idx_mask = ~(max_out_idx << pointer_type::data_shift); - return pointer_type((this->_raw & out_idx_mask) | - (static_cast(out_idx) << pointer_type::data_shift)); + return pointer_type( + (this->_raw & out_idx_mask) + | (static_cast(out_idx) << pointer_type::data_shift)); } ////////////////////////////////////////////////////////////////////////////// /// \brief Whether this uid identifies a terminal node. ////////////////////////////////////////////////////////////////////////////// - template<> + template <> inline bool __uid::is_terminal() const { diff --git a/src/adiar/internal/dd.h b/src/adiar/internal/dd.h index c5a1dd1ce..d11682ce3 100644 --- a/src/adiar/internal/dd.h +++ b/src/adiar/internal/dd.h @@ -70,8 +70,7 @@ namespace adiar::internal /// \brief Union of levelized node or arc files to reflect the possible /// return types of a function and a 'no_file' for 'error'. //////////////////////////////////////////////////////////////////////////// - std::variant - _union; + std::variant _union; //////////////////////////////////////////////////////////////////////////// /// \brief Propagation of the `dd.negate` flag. @@ -96,22 +95,23 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Conversion for algorithms returning already-reduced nodes. //////////////////////////////////////////////////////////////////////////// - __dd(const shared_node_file_type &f) + __dd(const shared_node_file_type& f) : _union(f) - { } + {} //////////////////////////////////////////////////////////////////////////// /// \brief Conversion for algorithms returning to-be reduced arcs //////////////////////////////////////////////////////////////////////////// - __dd(const shared_arc_file_type &f, const exec_policy &ep) - : _union(f), _policy(ep) - { } + __dd(const shared_arc_file_type& f, const exec_policy& ep) + : _union(f) + , _policy(ep) + {} //////////////////////////////////////////////////////////////////////////// /// \brief Conversion from a decision diagram (such that it can be passed /// along). //////////////////////////////////////////////////////////////////////////// - __dd(const dd &dd); + __dd(const dd& dd); //////////////////////////////////////////////////////////////////////////// // Accessors @@ -120,8 +120,9 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Whether the union currently holds a certain file type. ////////////////////////////////////////////////////////////////////////////// - template - bool has() const + template + bool + has() const { return std::holds_alternative(_union); } @@ -131,8 +132,9 @@ namespace adiar::internal /// /// \pre `has() == true` ////////////////////////////////////////////////////////////////////////////// - template - const file_t& get() const + template + const file_t& + get() const { return std::get(_union); } @@ -142,7 +144,8 @@ namespace adiar::internal /// /// \details The end user should not see this in the end. ////////////////////////////////////////////////////////////////////////////// - bool empty() const + bool + empty() const { return has(); } @@ -153,15 +156,14 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Number of nodes. //////////////////////////////////////////////////////////////////////////// - size_t size() const + size_t + size() const { if (has()) { // TODO (QMDD): Divide by node::outdegree instead of 2u return get()->size() / 2u; } - if (has()) { - return get()->size(); - } + if (has()) { return get()->size(); } return 0u; } @@ -171,17 +173,15 @@ namespace adiar::internal /// /// \param ct The type of the cut to obtain //////////////////////////////////////////////////////////////////////////// - cut::size_type max_1level_cut(const cut ct) const + cut::size_type + max_1level_cut(const cut ct) const { if (has()) { - const shared_arc_file_type &af = get(); - return af->max_1level_cut - + (ct.includes(false) ? af->number_of_terminals[false] : 0u) - + (ct.includes(true) ? af->number_of_terminals[true] : 0u); - } - if (has()) { - return get()->max_1level_cut[ct]; + const shared_arc_file_type& af = get(); + return af->max_1level_cut + (ct.includes(false) ? af->number_of_terminals[false] : 0u) + + (ct.includes(true) ? af->number_of_terminals[true] : 0u); } + if (has()) { return get()->max_1level_cut[ct]; } return 0u; } @@ -191,27 +191,26 @@ namespace adiar::internal /// /// \param ct The type of the cut to obtain //////////////////////////////////////////////////////////////////////////// - cut::size_type max_2level_cut(const cut ct) const + cut::size_type + max_2level_cut(const cut ct) const { if (has()) { - const shared_arc_file_type &af = get(); - return std::min(// 3/2 times the 1-level cut - (3 * af->max_1level_cut) / 2 - + (ct.includes(false) ? af->number_of_terminals[false] : 0u) - + (ct.includes(true) ? af->number_of_terminals[true] : 0u), - // At most the number of nodes + 1 - (af->size() / 2u) + 1); - } - if (has()) { - return get()->max_2level_cut[ct]; + const shared_arc_file_type& af = get(); + return std::min( // 3/2 times the 1-level cut + (3 * af->max_1level_cut) / 2 + (ct.includes(false) ? af->number_of_terminals[false] : 0u) + + (ct.includes(true) ? af->number_of_terminals[true] : 0u), + // At most the number of nodes + 1 + (af->size() / 2u) + 1); } + if (has()) { return get()->max_2level_cut[ct]; } return 0u; } //////////////////////////////////////////////////////////////////////////// /// \brief Number of terminals of a certain value. //////////////////////////////////////////////////////////////////////////// - size_t number_of_terminals(const bool value) const + size_t + number_of_terminals(const bool value) const { if (has()) { return get()->number_of_terminals[negate ^ value]; @@ -225,14 +224,15 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Number of terminals. //////////////////////////////////////////////////////////////////////////// - size_t number_of_terminals() const + size_t + number_of_terminals() const { if (has()) { - const shared_arc_file_type &af = get(); + const shared_arc_file_type& af = get(); return af->number_of_terminals[false] + af->number_of_terminals[true]; } if (has()) { - const shared_node_file_type &nf = get(); + const shared_node_file_type& nf = get(); return nf->number_of_terminals[false] + nf->number_of_terminals[true]; } return 0u; @@ -310,7 +310,8 @@ namespace adiar::internal /// then that object is destructed together with the physical files /// on disk (if temporary). //////////////////////////////////////////////////////////////////////////// - void deref() + void + deref() { file.reset(); } @@ -326,24 +327,27 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Constructor to wrap the node-based result of an algorithm. //////////////////////////////////////////////////////////////////////////// - dd(const shared_node_file_type &f, bool negate = false) - : file(f), negate(negate) - { } + dd(const shared_node_file_type& f, bool negate = false) + : file(f) + , negate(negate) + {} //////////////////////////////////////////////////////////////////////////// /// \brief Copy construction, incrementing the reference count on the file /// underneath. //////////////////////////////////////////////////////////////////////////// - dd(const dd &dd) - : file(dd.file), negate(dd.negate) - { } + dd(const dd& dd) + : file(dd.file) + , negate(dd.negate) + {} //////////////////////////////////////////////////////////////////////////// /// \brief Move construction, taking over ownership of the files underneath. //////////////////////////////////////////////////////////////////////////// - dd(dd &&dd) - : file(std::move(dd.file)), negate(std::move(dd.negate)) - { } + dd(dd&& dd) + : file(std::move(dd.file)) + , negate(std::move(dd.negate)) + {} //////////////////////////////////////////////////////////////////////////// // NOTE: @@ -358,7 +362,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Read-only access to the negation flag. //////////////////////////////////////////////////////////////////////////// - bool is_negated() const + bool + is_negated() const { return negate; } @@ -366,7 +371,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Read-only access to the raw files and meta information. //////////////////////////////////////////////////////////////////////////// - const shared_node_file_type file_ptr() const + const shared_node_file_type + file_ptr() const { return file; } @@ -376,7 +382,8 @@ namespace adiar::internal /// information, i.e. this is similar to writing /// `.file_ptr()->`. //////////////////////////////////////////////////////////////////////////// - const node_file_type* operator->() const + const node_file_type* + operator->() const { return file_ptr().get(); } @@ -388,7 +395,8 @@ namespace adiar::internal /// /// \param ct The type of the cut to obtain //////////////////////////////////////////////////////////////////////////// - cut::size_type max_1level_cut(const cut ct) const + cut::size_type + max_1level_cut(const cut ct) const { return file->max_1level_cut[negate_cut_type(ct)]; } @@ -399,16 +407,19 @@ namespace adiar::internal /// /// \param ct The type of the cut to obtain //////////////////////////////////////////////////////////////////////////// - cut::size_type max_2level_cut(const cut ct) const + cut::size_type + max_2level_cut(const cut ct) const { return file->max_2level_cut[negate_cut_type(ct)]; } + /// \endcond //////////////////////////////////////////////////////////////////////////// /// \brief The number of elements in the node file. //////////////////////////////////////////////////////////////////////////// - size_t size() const + size_t + size() const { return file->size(); } @@ -416,7 +427,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief The number of nodes on the widest level. //////////////////////////////////////////////////////////////////////////// - size_t width() const + size_t + width() const { return file->width; } @@ -424,7 +436,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Number of terminals of a certain value. //////////////////////////////////////////////////////////////////////////// - size_t number_of_terminals(const bool value) const + size_t + number_of_terminals(const bool value) const { return file->number_of_terminals[negate ^ value]; } @@ -432,7 +445,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Number of terminals. //////////////////////////////////////////////////////////////////////////// - size_t number_of_terminals() const + size_t + number_of_terminals() const { return number_of_terminals(false) + number_of_terminals(true); } @@ -442,17 +456,15 @@ namespace adiar::internal /// \brief Obtain the cut-type that matches with the current state of the /// negation flag. ////////////////////////////////////////////////////////////////////////////// - cut negate_cut_type(const cut ct) const + cut + negate_cut_type(const cut ct) const { if (!negate) { return ct; } switch (ct) { - case cut::Internal_False: - return cut::Internal_True; - case cut::Internal_True: - return cut::Internal_False; - default: - return ct; + case cut::Internal_False: return cut::Internal_True; + case cut::Internal_True: return cut::Internal_False; + default: return ct; } } @@ -471,34 +483,41 @@ namespace adiar::internal friend class level_merger; // |- algorithm functions and classes - friend bool is_isomorphic(const exec_policy &, const dd&, const dd&); + friend bool + is_isomorphic(const exec_policy&, const dd&, const dd&); - template - friend bool comparison_check(const exec_policy &, const dd &, const dd &); + template + friend bool + comparison_check(const exec_policy&, const dd&, const dd&); - template + template friend class convert_dd_policy; // |- public API template - friend bool dd_isterminal(const dd_t &dd); + friend bool + dd_isterminal(const dd_t& dd); template - friend bool dd_valueof(const dd_t &dd); + friend bool + dd_valueof(const dd_t& dd); template - friend label_type dd_minvar(const dd_t &dd); + friend label_type + dd_minvar(const dd_t& dd); template - friend label_type dd_maxvar(const dd_t &dd); + friend label_type + dd_maxvar(const dd_t& dd); }; - inline __dd::__dd(const dd &dd) - : _union(dd.file), negate(dd.negate) - { } + inline __dd::__dd(const dd& dd) + : _union(dd.file) + , negate(dd.negate) + {} /// \cond - template + template class dd_policy { //////////////////////////////////////////////////////////////////////////// @@ -574,7 +593,7 @@ namespace adiar::internal /// \returns A pointer to the node itself or one of its children. ////////////////////////////////////////////////////////////////////////////// static inline pointer_type - reduction_rule(const node_type &n); + reduction_rule(const node_type& n); ////////////////////////////////////////////////////////////////////////////// /// \brief Provides the children of a node that was suppressed. @@ -583,8 +602,9 @@ namespace adiar::internal /// node, add the variable label next to these children. ////////////////////////////////////////////////////////////////////////////// static inline children_type - reduction_rule_inv(const pointer_type &child); + reduction_rule_inv(const pointer_type& child); }; + /// \endcond } diff --git a/src/adiar/internal/dd_func.h b/src/adiar/internal/dd_func.h index 1ec106de3..e7ab2c809 100644 --- a/src/adiar/internal/dd_func.h +++ b/src/adiar/internal/dd_func.h @@ -25,7 +25,8 @@ namespace adiar::internal /// linear scan rather than with an *O(N log N)* time-forwarding algorithm. ////////////////////////////////////////////////////////////////////////////// template - bool dd_iscanonical(const DD &dd) + bool + dd_iscanonical(const DD& dd) { // TODO: Move into 'dd' class... return dd->canonical; @@ -35,7 +36,8 @@ namespace adiar::internal /// \brief Whether a given decision diagram represents a terminal. ////////////////////////////////////////////////////////////////////////////// template - bool dd_isterminal(const DD &dd) + bool + dd_isterminal(const DD& dd) { // TODO: Move into 'dd' class... return dd->is_terminal(); @@ -45,7 +47,8 @@ namespace adiar::internal /// \brief Obtain the terminal's value (if 'is_terminal' is true). ////////////////////////////////////////////////////////////////////////////// template - bool dd_valueof(const DD &dd) + bool + dd_valueof(const DD& dd) { // TODO: Move into 'dd' class... return dd.negate ^ dd->value(); @@ -55,7 +58,8 @@ namespace adiar::internal /// \brief Whether a given decision diagram represents the false terminal. ////////////////////////////////////////////////////////////////////////////// template - bool dd_isfalse(const DD &dd) + bool + dd_isfalse(const DD& dd) { // TODO: Move into 'dd' class... return dd_isterminal(dd) && !dd_valueof(dd); @@ -65,7 +69,8 @@ namespace adiar::internal /// \brief Whether a given decision diagram represents the true terminal. ////////////////////////////////////////////////////////////////////////////// template - bool dd_istrue(const DD &dd) + bool + dd_istrue(const DD& dd) { // TODO: Move into 'dd' class... return dd_isterminal(dd) && dd_valueof(dd); @@ -77,23 +82,22 @@ namespace adiar::internal /// \throws invalid_argument If `dd` is a terminal. ////////////////////////////////////////////////////////////////////////////// template - dd::label_type dd_topvar(const DD &dd) + dd::label_type + dd_topvar(const DD& dd) { // TODO: Move into 'dd' class... - if (dd_isterminal(dd)) { - throw invalid_argument("Cannot obtain top variable of root"); - } + if (dd_isterminal(dd)) { throw invalid_argument("Cannot obtain top variable of root"); } return dd->first_level(); } - ////////////////////////////////////////////////////////////////////////////// /// \brief Get the minimal occurring label in the decision diagram. /// /// \throws invalid_argument If `dd` is a terminal. ////////////////////////////////////////////////////////////////////////////// template - dd::label_type dd_minvar(const DD &dd) + dd::label_type + dd_minvar(const DD& dd) { // TODO: Custom implementation with an O(L) scan when variable order is not // certain to be the default ascending one. @@ -106,12 +110,11 @@ namespace adiar::internal /// \throws invalid_argument If `dd` is a terminal. ////////////////////////////////////////////////////////////////////////////// template - dd::label_type dd_maxvar(const DD &dd) + dd::label_type + dd_maxvar(const DD& dd) { // TODO: Move into 'dd' class... - if (dd_isterminal(dd)) { - throw invalid_argument("Cannot obtain maximal variable of root"); - } + if (dd_isterminal(dd)) { throw invalid_argument("Cannot obtain maximal variable of root"); } // TODO: Use an O(L) scan when variable order is not default ascending. return dd->last_level(); @@ -121,7 +124,8 @@ namespace adiar::internal /// \brief Number of nodes in a decision diagram. //////////////////////////////////////////////////////////////////////////// template - size_t dd_nodecount(const DD &dd) + size_t + dd_nodecount(const DD& dd) { return dd_isterminal(dd) ? 0u : dd->size(); } @@ -130,7 +134,8 @@ namespace adiar::internal /// \brief Number of variables, i.e. levels, present in a decision diagram. //////////////////////////////////////////////////////////////////////////// template - typename DD::label_type dd_varcount(const DD &dd) + typename DD::label_type + dd_varcount(const DD& dd) { return dd->levels(); } @@ -140,10 +145,11 @@ namespace adiar::internal /// decision diagram. //////////////////////////////////////////////////////////////////////////// template - void dd_support(const DD &dd, const consumer &cb) + void + dd_support(const DD& dd, const consumer& cb) { level_info_stream<> info_stream(dd); - while(info_stream.can_pull()) { cb(info_stream.pull().label()); } + while (info_stream.can_pull()) { cb(info_stream.pull().label()); } } } diff --git a/src/adiar/internal/io/arc_file.h b/src/adiar/internal/io/arc_file.h index dce9fb550..74b27b9fc 100644 --- a/src/adiar/internal/io/arc_file.h +++ b/src/adiar/internal/io/arc_file.h @@ -2,8 +2,9 @@ #define ADIAR_INTERNAL_IO_ARC_FILE_H #include -#include + #include +#include #include #include diff --git a/src/adiar/internal/io/arc_stream.h b/src/adiar/internal/io/arc_stream.h index ed0708ac8..317e40338 100644 --- a/src/adiar/internal/io/arc_stream.h +++ b/src/adiar/internal/io/arc_stream.h @@ -13,25 +13,23 @@ namespace adiar::internal /// /// \see shared_levelized_file ////////////////////////////////////////////////////////////////////////////// - template - class arc_stream - : public levelized_file_stream + template + class arc_stream : public levelized_file_stream { private: using parent_t = levelized_file_stream; public: - static size_t memory_usage() + static size_t + memory_usage() { return parent_t::memory_usage(); } private: - static constexpr size_t idx__internal = - file_traits::idx__internal; + static constexpr size_t idx__internal = file_traits::idx__internal; - static constexpr size_t idx__terminals__in_order = - file_traits::idx__terminals__in_order; + static constexpr size_t idx__terminals__in_order = file_traits::idx__terminals__in_order; static constexpr size_t idx__terminals__out_of_order = file_traits::idx__terminals__out_of_order; @@ -48,20 +46,24 @@ namespace adiar::internal arc_stream() = default; //////////////////////////////////////////////////////////////////////////// - arc_stream(const arc_stream &) = delete; - arc_stream(arc_stream &&) = delete; + arc_stream(const arc_stream&) = delete; + arc_stream(arc_stream&&) = delete; //////////////////////////////////////////////////////////////////////////// /// \brief Construct a stream attached to an arc file. //////////////////////////////////////////////////////////////////////////// - arc_stream(const levelized_file &file, bool negate = false) - { attach(file, negate); } + arc_stream(const levelized_file& file, bool negate = false) + { + attach(file, negate); + } //////////////////////////////////////////////////////////////////////////// /// \brief Construct a stream unattached to a shared arc file. //////////////////////////////////////////////////////////////////////////// - arc_stream(const shared_ptr> &file, bool negate = false) - { attach(file, negate); } + arc_stream(const shared_ptr>& file, bool negate = false) + { + attach(file, negate); + } //////////////////////////////////////////////////////////////////////////// /// \brief Detaches and cleans up when destructed. @@ -74,10 +76,10 @@ namespace adiar::internal /// /// \pre No `levelized_file_writer` is currently attached to this file. //////////////////////////////////////////////////////////////////////////// - void attach(const levelized_file &f, - const bool negate = false) + void + attach(const levelized_file& f, const bool negate = false) { - //adiar_assert(f.semi_transposed); + // adiar_assert(f.semi_transposed); parent_t::attach(f, negate); _unread_terminals[negate ^ false] = f.number_of_terminals[false]; _unread_terminals[negate ^ true] = f.number_of_terminals[true]; @@ -88,51 +90,57 @@ namespace adiar::internal /// /// \pre No `levelized_file_writer` is currently attached to this file. //////////////////////////////////////////////////////////////////////////// - void attach(const shared_ptr> &f, - const bool negate = false) + void + attach(const shared_ptr>& f, const bool negate = false) { - //adiar_assert(f->semi_transposed); + // adiar_assert(f->semi_transposed); parent_t::attach(f, negate); _unread_terminals[negate ^ false] = f->number_of_terminals[false]; _unread_terminals[negate ^ true] = f->number_of_terminals[true]; } - public: //////////////////////////////////////////////////////////////////////////// /// \brief Whether the stream contains more internal arcs. //////////////////////////////////////////////////////////////////////////// - bool can_pull_internal() const - { return parent_t::template can_pull(); } + bool + can_pull_internal() const + { + return parent_t::template can_pull(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the next internal arc (and move the read head). //////////////////////////////////////////////////////////////////////////// - const arc pull_internal() - { return parent_t::template pull(); } + const arc + pull_internal() + { + return parent_t::template pull(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the next internal arc (but do not move the read head). //////////////////////////////////////////////////////////////////////////// - const arc peek_internal() - { return parent_t::template peek(); } + const arc + peek_internal() + { + return parent_t::template peek(); + } private: //////////////////////////////////////////////////////////////////////////// /// \brief Whether the next element ought to be pulled from the \em in-order /// index. //////////////////////////////////////////////////////////////////////////// - bool take_in_order_terminal() + bool + take_in_order_terminal() { - const bool in_order_pullable = - parent_t::template can_pull(); + const bool in_order_pullable = parent_t::template can_pull(); const bool out_of_order_pullable = parent_t::template can_pull(); - if (in_order_pullable != out_of_order_pullable) { - return in_order_pullable; - } + if (in_order_pullable != out_of_order_pullable) { return in_order_pullable; } const arc::pointer_type in_order_source = parent_t::template peek().source(); @@ -151,19 +159,26 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the number of unread terminals. //////////////////////////////////////////////////////////////////////////// - size_t unread_terminals() const - { return _unread_terminals[false] + _unread_terminals[true]; } + size_t + unread_terminals() const + { + return _unread_terminals[false] + _unread_terminals[true]; + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the number of unread terminals of a specific value. //////////////////////////////////////////////////////////////////////////// - const size_t& unread_terminals(const bool terminal_value) const - { return _unread_terminals[terminal_value]; } + const size_t& + unread_terminals(const bool terminal_value) const + { + return _unread_terminals[terminal_value]; + } //////////////////////////////////////////////////////////////////////////// /// \brief Whether the stream contains more terminal arcs. //////////////////////////////////////////////////////////////////////////// - bool can_pull_terminal() const + bool + can_pull_terminal() const { return unread_terminals() > 0; } @@ -171,7 +186,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the next arc (and move the read head). //////////////////////////////////////////////////////////////////////////// - const arc pull_terminal() + const arc + pull_terminal() { const arc a = take_in_order_terminal() ? parent_t::template pull() @@ -187,11 +203,11 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the next arc (but do not move the read head). //////////////////////////////////////////////////////////////////////////// - const arc peek_terminal() + const arc + peek_terminal() { - return take_in_order_terminal() - ? parent_t::template peek() - : parent_t::template peek(); + return take_in_order_terminal() ? parent_t::template peek() + : parent_t::template peek(); } }; } diff --git a/src/adiar/internal/io/arc_writer.h b/src/adiar/internal/io/arc_writer.h index b789d89bc..f3e41e542 100644 --- a/src/adiar/internal/io/arc_writer.h +++ b/src/adiar/internal/io/arc_writer.h @@ -4,8 +4,8 @@ #include #include #include -#include #include +#include namespace adiar::internal { @@ -14,19 +14,16 @@ namespace adiar::internal /// /// \see shared_levelized_file ////////////////////////////////////////////////////////////////////////////// - class arc_writer - : public levelized_file_writer + class arc_writer : public levelized_file_writer { private: bool __has_latest_terminal = false; arc __latest_terminal; private: - static constexpr size_t idx__internal = - file_traits::idx__internal; + static constexpr size_t idx__internal = file_traits::idx__internal; - static constexpr size_t idx__terminals__in_order = - file_traits::idx__terminals__in_order; + static constexpr size_t idx__terminals__in_order = file_traits::idx__terminals__in_order; static constexpr size_t idx__terminals__out_of_order = file_traits::idx__terminals__out_of_order; @@ -35,15 +32,16 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Construct unattached to any levelized arc file. //////////////////////////////////////////////////////////////////////////// - arc_writer() : levelized_file_writer() - { } + arc_writer() + : levelized_file_writer() + {} //////////////////////////////////////////////////////////////////////////// /// \brief Construct attached to a levelized arc file. /// /// \pre The file is empty. //////////////////////////////////////////////////////////////////////////// - arc_writer(levelized_file &af) + arc_writer(levelized_file& af) : levelized_file_writer() { attach(af); @@ -79,7 +77,9 @@ namespace adiar::internal /// /// \pre The file is empty. //////////////////////////////////////////////////////////////////////////// - void attach(levelized_file &af) { + void + attach(levelized_file& af) + { if (attached()) detach(); adiar_assert(af.empty()); @@ -93,7 +93,9 @@ namespace adiar::internal /// /// \pre The file is empty. //////////////////////////////////////////////////////////////////////////// - void attach(shared_ptr> &af) { + void + attach(shared_ptr>& af) + { if (attached()) detach(); adiar_assert(af->empty()); @@ -105,7 +107,9 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Detaches after having sort the out-of-order terminals. ////////////////////////////////////////////////////////////////////////////// - void detach() { + void + detach() + { if (!attached()) return; #ifdef ADIAR_STATS @@ -124,7 +128,8 @@ namespace adiar::internal /// /// \pre `attached() == true`. ////////////////////////////////////////////////////////////////////////////// - void push(const level_info &li) + void + push(const level_info& li) { #ifdef ADIAR_STATS stats_arc_file.push_level += 1; @@ -139,7 +144,8 @@ namespace adiar::internal /// /// \pre `attached() == true`. //////////////////////////////////////////////////////////////////////////// - arc_writer& operator<< (const level_info& li) + arc_writer& + operator<<(const level_info& li) { this->push(li); return *this; @@ -154,7 +160,8 @@ namespace adiar::internal /// /// \see unsafe_push_internal unsafe_push_terminal ////////////////////////////////////////////////////////////////////////////// - void push(const arc &a) + void + push(const arc& a) { adiar_assert(!a.target().is_nil(), "Should not push an arc to nil."); if (a.target().is_node()) { @@ -169,7 +176,8 @@ namespace adiar::internal /// /// \pre `attached() == true`. //////////////////////////////////////////////////////////////////////////// - arc_writer& operator<< (const arc& a) + arc_writer& + operator<<(const arc& a) { this->push(a); return *this; @@ -180,7 +188,8 @@ namespace adiar::internal /// /// \pre `attached() == true`. ////////////////////////////////////////////////////////////////////////////// - void push_internal(const arc &a) + void + push_internal(const arc& a) { adiar_assert(attached()); adiar_assert(a.target().is_node()); @@ -196,7 +205,8 @@ namespace adiar::internal /// /// \pre `attached() == true`. ////////////////////////////////////////////////////////////////////////////// - void push_terminal(const arc &a) + void + push_terminal(const arc& a) { adiar_assert(attached()); adiar_assert(a.target().is_terminal()); @@ -205,7 +215,7 @@ namespace adiar::internal if (!__has_latest_terminal || a.source() > __latest_terminal.source()) { // Given arc is 'in-order' compared to latest 'in-order' pushed __has_latest_terminal = true; - __latest_terminal = a; + __latest_terminal = a; #ifdef ADIAR_STATS stats_arc_file.push_in_order += 1; #endif diff --git a/src/adiar/internal/io/file.h b/src/adiar/internal/io/file.h index 616af208d..ad3e218db 100644 --- a/src/adiar/internal/io/file.h +++ b/src/adiar/internal/io/file.h @@ -1,16 +1,16 @@ #ifndef ADIAR_INTERNAL_IO_FILE_H #define ADIAR_INTERNAL_IO_FILE_H -#include #include #include // TODO <-- remove? +#include -#include -#include +#include #include #include +#include +#include -#include #include #include @@ -93,8 +93,9 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Constructor for a new unammed \em temporary file. //////////////////////////////////////////////////////////////////////////// - file() : _tpie_file() - { } + file() + : _tpie_file() + {} public: //////////////////////////////////////////////////////////////////////////// @@ -103,9 +104,10 @@ namespace adiar::internal /// \throws runtime_error If the path does not point to an \em existing file /// on disk. //////////////////////////////////////////////////////////////////////////// - file(const std::string &path) : _tpie_file(path, true) + file(const std::string& path) + : _tpie_file(path, true) { - if (!exists()) { throw runtime_error("'"+path+"' not found."); } + if (!exists()) { throw runtime_error("'" + path + "' not found."); } } public: @@ -115,8 +117,11 @@ namespace adiar::internal /// /// \see make_persistent //////////////////////////////////////////////////////////////////////////// - bool is_persistent() const - { return _tpie_file.is_persistent(); } + bool + is_persistent() const + { + return _tpie_file.is_persistent(); + } public: //////////////////////////////////////////////////////////////////////////// @@ -125,7 +130,8 @@ namespace adiar::internal /// /// \see is_persistent //////////////////////////////////////////////////////////////////////////// - void make_persistent() + void + make_persistent() { _tpie_file.set_persistent(true); if (!exists()) { touch(); } @@ -135,8 +141,11 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \copydoc is_persistent //////////////////////////////////////////////////////////////////////////// - bool is_temp() const - { return !is_persistent(); } + bool + is_temp() const + { + return !is_persistent(); + } public: //////////////////////////////////////////////////////////////////////////// @@ -144,14 +153,18 @@ namespace adiar::internal /// /// \see path //////////////////////////////////////////////////////////////////////////// - bool exists() const - { return std::filesystem::exists(path()); } + bool + exists() const + { + return std::filesystem::exists(path()); + } public: //////////////////////////////////////////////////////////////////////////// /// \brief Number of elements in the file. //////////////////////////////////////////////////////////////////////////// - size_t size() const + size_t + size() const { if (!exists()) { return 0u; } @@ -164,11 +177,15 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether the file is empty. //////////////////////////////////////////////////////////////////////////// - bool empty() const - { return size() == 0u; } + bool + empty() const + { + return size() == 0u; + } private: - void __touch() const + void + __touch() const { if (exists()) return; @@ -181,28 +198,31 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Creates the file on disk, if it does not yet exist. //////////////////////////////////////////////////////////////////////////// - void touch() - { __touch(); } + void + touch() + { + __touch(); + } public: //////////////////////////////////////////////////////////////////////////// /// \brief Get the size of the file header. //////////////////////////////////////////////////////////////////////////// - //static size_t header_size() constexpr + // static size_t header_size() constexpr //{ TODO } public: //////////////////////////////////////////////////////////////////////////// /// \brief Set the contents of the file header. //////////////////////////////////////////////////////////////////////////// - //void set_header(const std::string &p) + // void set_header(const std::string &p) //{ TODO } public: //////////////////////////////////////////////////////////////////////////// /// \brief Get the contents of the file header. //////////////////////////////////////////////////////////////////////////// - //header_t get_header() const + // header_t get_header() const //{ TODO } public: @@ -211,21 +231,28 @@ namespace adiar::internal /// /// \see exists move //////////////////////////////////////////////////////////////////////////// - const std::string & path() const - { return _tpie_file.path(); } + const std::string& + path() const + { + return _tpie_file.path(); + } private: //////////////////////////////////////////////////////////////////////////// /// \brief Set the path for this file. //////////////////////////////////////////////////////////////////////////// - void set_path(const std::string &p) - { _tpie_file.set_path(p); } + void + set_path(const std::string& p) + { + _tpie_file.set_path(p); + } public: //////////////////////////////////////////////////////////////////////////// /// \brief Whether this file can be moved. //////////////////////////////////////////////////////////////////////////// - bool can_move() + bool + can_move() { return is_temp(); } @@ -244,31 +271,28 @@ namespace adiar::internal /// /// \throws runtime_error Moving the file is unsuccessful. //////////////////////////////////////////////////////////////////////////// - void move(const std::string &new_path) + void + move(const std::string& new_path) { // Disallow moving the file, if it is persisted - if (is_persistent()) { - throw runtime_error("'"+path()+"' is persisted."); - } + if (is_persistent()) { throw runtime_error("'" + path() + "' is persisted."); } // Disallow moving the file on-top of another. if (std::filesystem::exists(new_path)) { - throw runtime_error("'"+new_path+"' already exists."); + throw runtime_error("'" + new_path + "' already exists."); } // Move the file on disk, if it exists. if (exists()) { try { // Try to move it in O(1) time. std::filesystem::rename(path(), new_path); - } catch(std::filesystem::filesystem_error& e1) { + } catch (std::filesystem::filesystem_error& e1) { #ifndef NDEBUG std::cerr << "Adiar: unable to move file in O(1) time" << std::endl - << " what(): " << e1.what() << std::endl; + << " what(): " << e1.what() << std::endl; #endif // Did the file disappear and everything just is in shambles? - if (!std::filesystem::exists(path())) { - throw static_cast(e1); - } + if (!std::filesystem::exists(path())) { throw static_cast(e1); } try { // Most likely, this catch-case is an "Invalid cross-device link": @@ -278,7 +302,7 @@ namespace adiar::internal } catch (std::filesystem::filesystem_error& e2) { #ifndef NDEBUG std::cerr << "Adiar: unable to copy-delete file in O(N) time" << std::endl - << " what(): " << e2.what() << std::endl; + << " what(): " << e2.what() << std::endl; #endif throw static_cast(e2); } @@ -298,11 +322,11 @@ namespace adiar::internal /// attached to this file. //////////////////////////////////////////////////////////////////////////// template > - void sort(pred_t pred = pred_t()) + void + sort(pred_t pred = pred_t()) { // Disallow sorting a persistent file - if (is_persistent()) - throw runtime_error("'"+path()+"' is persisted."); + if (is_persistent()) throw runtime_error("'" + path() + "' is persisted."); // If empty, just skip all the work if (size() == 0u) return; @@ -322,7 +346,8 @@ namespace adiar::internal /// \remark This new file is a temporary file and must be marked persisted /// to be kept existing beyond the object's lifetime. //////////////////////////////////////////////////////////////////////////// - static file copy(const file &f) + static file + copy(const file& f) { if (!f.exists()) { return file(); } diff --git a/src/adiar/internal/io/file_stream.h b/src/adiar/internal/io/file_stream.h index 22eaed2f1..7bf08edb1 100644 --- a/src/adiar/internal/io/file_stream.h +++ b/src/adiar/internal/io/file_stream.h @@ -1,12 +1,12 @@ #ifndef ADIAR_INTERNAL_IO_FILE_STREAM_H #define ADIAR_INTERNAL_IO_FILE_STREAM_H -#include #include +#include #include -#include #include +#include namespace adiar::internal { @@ -28,7 +28,8 @@ namespace adiar::internal public: //////////////////////////////////////////////////////////////////////////// - static size_t memory_usage() + static size_t + memory_usage() { return tpie::file_stream::memory_usage(); } @@ -66,37 +67,41 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Construct unattached to any file. //////////////////////////////////////////////////////////////////////////// - file_stream() { } + file_stream() + {} //////////////////////////////////////////////////////////////////////////// - file_stream(const file_stream &) = delete; - file_stream(file_stream &&) = delete; + file_stream(const file_stream&) = delete; + file_stream(file_stream&&) = delete; //////////////////////////////////////////////////////////////////////////// /// \brief Construct attached to a given shared `file`. //////////////////////////////////////////////////////////////////////////// - file_stream(const file &f, - bool negate = false) - { attach(f, negate); } + file_stream(const file& f, bool negate = false) + { + attach(f, negate); + } //////////////////////////////////////////////////////////////////////////// /// \brief Construct attached to a given shared `file`. //////////////////////////////////////////////////////////////////////////// - file_stream(const adiar::shared_ptr> &f, - bool negate = false) - { attach(f, negate); } + file_stream(const adiar::shared_ptr>& f, bool negate = false) + { + attach(f, negate); + } //////////////////////////////////////////////////////////////////////////// /// \brief Detaches and cleans up when destructed. //////////////////////////////////////////////////////////////////////////// ~file_stream() - { detach(); } + { + detach(); + } protected: //////////////////////////////////////////////////////////////////////////// - void attach(const file &f, - const adiar::shared_ptr &shared_ptr, - bool negate) + void + attach(const file& f, const adiar::shared_ptr& shared_ptr, bool negate) { // Detach from prior file, if any. if (attached()) { detach(); } @@ -127,8 +132,8 @@ namespace adiar::internal /// /// \pre No `file_writer` is currently attached to this file. //////////////////////////////////////////////////////////////////////////// - void attach(const file &f, - bool negate = false) + void + attach(const file& f, bool negate = false) { attach(f, nullptr, negate); } @@ -138,8 +143,8 @@ namespace adiar::internal /// /// \pre No `file_writer` is currently attached to this file. //////////////////////////////////////////////////////////////////////////// - void attach(const adiar::shared_ptr> &f, - bool negate = false) + void + attach(const adiar::shared_ptr>& f, bool negate = false) { attach(*f, f, negate); } @@ -147,7 +152,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether the reader is currently attached. //////////////////////////////////////////////////////////////////////////// - bool attached() const + bool + attached() const { return _stream.is_open(); } @@ -155,7 +161,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Detach from the file, i.e. close the stream. //////////////////////////////////////////////////////////////////////////// - void detach() + void + detach() { _stream.close(); if (_file_ptr) { _file_ptr.reset(); } @@ -165,7 +172,8 @@ namespace adiar::internal /// \brief Reset the read head back to the beginning (relatively to the /// reading direction). //////////////////////////////////////////////////////////////////////////// - void reset() + void + reset() { if constexpr (Reverse) { _stream.seek(0, tpie::file_stream_base::end); @@ -176,7 +184,8 @@ namespace adiar::internal private: //////////////////////////////////////////////////////////////////////////// - bool __can_read() const + bool + __can_read() const { if constexpr (Reverse) { return _stream.can_read_back(); @@ -189,12 +198,16 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether the stream contains more elements. //////////////////////////////////////////////////////////////////////////// - bool can_pull() const - { return _has_peeked || __can_read(); } + bool + can_pull() const + { + return _has_peeked || __can_read(); + } private: //////////////////////////////////////////////////////////////////////////// - const value_type __read() + const value_type + __read() { value_type v; if constexpr (Reverse) { @@ -211,9 +224,10 @@ namespace adiar::internal /// /// \pre `can_pull() == true`. //////////////////////////////////////////////////////////////////////////// - const value_type pull() + const value_type + pull() { - adiar_assert(can_pull()); + adiar_assert(can_pull()); if (_has_peeked) { _has_peeked = false; return _peeked; @@ -227,11 +241,12 @@ namespace adiar::internal /// /// \pre `can_pull() == true`. //////////////////////////////////////////////////////////////////////////// - const value_type peek() + const value_type + peek() { adiar_assert(can_pull()); if (!_has_peeked) { - _peeked = __read(); + _peeked = __read(); _has_peeked = true; } return _peeked; @@ -246,8 +261,9 @@ namespace adiar::internal /// /// \pre The content is in ascending order and `can_pull() == true`. //////////////////////////////////////////////////////////////////////////// - template - const value_type seek(seek_t tgt) + template + const value_type + seek(seek_t tgt) { // Notice, the peek() also changes the state of '_peeked' and // '_has_peeked'. This initializes the invariant for 'seek' that '_peeked' diff --git a/src/adiar/internal/io/file_writer.h b/src/adiar/internal/io/file_writer.h index 0d359ebc0..365894142 100644 --- a/src/adiar/internal/io/file_writer.h +++ b/src/adiar/internal/io/file_writer.h @@ -5,10 +5,10 @@ #include #include -#include #include #include #include +#include namespace adiar::internal { @@ -29,7 +29,8 @@ namespace adiar::internal using value_type = T; public: - static size_t memory_usage() + static size_t + memory_usage() { return tpie::file_stream::memory_usage(); } @@ -52,36 +53,42 @@ namespace adiar::internal /// \brief Construct unattached to any file. //////////////////////////////////////////////////////////////////////////// file_writer() - { } + {} //////////////////////////////////////////////////////////////////////////// /// \brief Construct attached to a given `file`. /// /// \pre No `file_stream` is currently attached to this file. //////////////////////////////////////////////////////////////////////////// - file_writer(file &f) - { attach(f); } + file_writer(file& f) + { + attach(f); + } //////////////////////////////////////////////////////////////////////////// /// \brief Construct attached to a given shared `file`. /// /// \pre No `file_stream` is currently attached to this file. //////////////////////////////////////////////////////////////////////////// - file_writer(adiar::shared_ptr> &f) - { attach(f); } + file_writer(adiar::shared_ptr>& f) + { + attach(f); + } //////////////////////////////////////////////////////////////////////////// /// \brief Detaches and cleans up when destructed. //////////////////////////////////////////////////////////////////////////// ~file_writer() - { detach(); } + { + detach(); + } protected: //////////////////////////////////////////////////////////////////////////// - void attach(file &f, adiar::shared_ptr p) + void + attach(file& f, adiar::shared_ptr p) { - if (f.is_persistent()) - throw runtime_error("Cannot attach writer to a persisted file"); + if (f.is_persistent()) throw runtime_error("Cannot attach writer to a persisted file"); if (attached()) { detach(); } _file_ptr = p; @@ -105,27 +112,37 @@ namespace adiar::internal /// ensure, that the file in question is not destructed before /// `.detach()` is called. //////////////////////////////////////////////////////////////////////////// - void attach(file &f) - { attach(f, nullptr); } + void + attach(file& f) + { + attach(f, nullptr); + } //////////////////////////////////////////////////////////////////////////// /// \brief Attach to a shared file. /// /// \pre No `file_stream` is currently attached to this file. //////////////////////////////////////////////////////////////////////////// - void attach(adiar::shared_ptr> f) - { attach(*f, f); } + void + attach(adiar::shared_ptr> f) + { + attach(*f, f); + } //////////////////////////////////////////////////////////////////////////// /// \brief Whether the writer currently is attached to any file. //////////////////////////////////////////////////////////////////////////// - bool attached() const - { return _stream.is_open(); } + bool + attached() const + { + return _stream.is_open(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Detach from a file (if need be). //////////////////////////////////////////////////////////////////////////// - void detach() + void + detach() { _stream.close(); if (_file_ptr) { _file_ptr.reset(); } @@ -136,15 +153,19 @@ namespace adiar::internal /// /// \pre `attached() == true`. //////////////////////////////////////////////////////////////////////////// - void push(const value_type &e) - { _stream.write(e); } + void + push(const value_type& e) + { + _stream.write(e); + } //////////////////////////////////////////////////////////////////////////// /// \brief Push an element to the end of the file. /// /// \pre `attached() == true`. //////////////////////////////////////////////////////////////////////////// - file_writer& operator<< (const value_type& e) + file_writer& + operator<<(const value_type& e) { this->push(e); return *this; @@ -155,24 +176,33 @@ namespace adiar::internal /// /// \pre `attached() == true`. //////////////////////////////////////////////////////////////////////////// - bool has_pushed() const - { return _stream.size() > 0; } + bool + has_pushed() const + { + return _stream.size() > 0; + } //////////////////////////////////////////////////////////////////////////// /// \brief Whether the underlying file is empty. /// /// \pre `attached() == true`. //////////////////////////////////////////////////////////////////////////// - bool empty() const - { return !has_pushed(); } + bool + empty() const + { + return !has_pushed(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Number of elements written to this file. /// /// \pre `attached() == true`. //////////////////////////////////////////////////////////////////////////// - size_t size() const - { return _stream.size(); } + size_t + size() const + { + return _stream.size(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Sort the content of the attached file. @@ -180,7 +210,8 @@ namespace adiar::internal /// \pre `attached() == true`. //////////////////////////////////////////////////////////////////////////// template > - void sort(const pred_t pred = pred_t()) + void + sort(const pred_t pred = pred_t()) { if (empty()) return; @@ -190,7 +221,7 @@ namespace adiar::internal }; // TODO: remove... - using label_writer = file_writer ; + using label_writer = file_writer; } #endif // ADIAR_INTERNAL_IO_FILE_WRITER_H diff --git a/src/adiar/internal/io/levelized_file.h b/src/adiar/internal/io/levelized_file.h index 23c094515..50358084f 100644 --- a/src/adiar/internal/io/levelized_file.h +++ b/src/adiar/internal/io/levelized_file.h @@ -6,12 +6,13 @@ #include #include + #include -#include -#include #include #include #include +#include +#include namespace adiar::internal { @@ -40,8 +41,7 @@ namespace adiar::internal /// \param T Type of the file's content. //////////////////////////////////////////////////////////////////////////// template - class levelized_file - : public file_traits::stats + class levelized_file : public file_traits::stats { public: //////////////////////////////////////////////////////////////////////////// @@ -57,25 +57,25 @@ namespace adiar::internal private: /////////////////////////////////////////////////////////////////////////// - inline void throw_if_bad_idx(const size_t idx) const + inline void + throw_if_bad_idx(const size_t idx) const { - if (FILES <= idx) - throw out_of_range("Index must be within interval [0;FILES-1]"); + if (FILES <= idx) throw out_of_range("Index must be within interval [0;FILES-1]"); } /////////////////////////////////////////////////////////////////////////// - inline void throw_if_persistent() const + inline void + throw_if_persistent() const { - if (is_persistent()) - throw runtime_error("'"+_level_info_file.path()+"' is persisted."); + if (is_persistent()) throw runtime_error("'" + _level_info_file.path() + "' is persisted."); } private: /////////////////////////////////////////////////////////////////////////// /// \brief Derives the canonical path for one of the file. /////////////////////////////////////////////////////////////////////////// - static std::string canonical_file_path(const std::string &path_prefix, - const size_t idx) + static std::string + canonical_file_path(const std::string& path_prefix, const size_t idx) { std::stringstream ss; ss << path_prefix << ".file_" << idx; @@ -85,7 +85,8 @@ namespace adiar::internal /////////////////////////////////////////////////////////////////////////// /// \brief Derives the canonical path for the level information file. /////////////////////////////////////////////////////////////////////////// - static std::string canonical_levels_path(const std::string &path_prefix) + static std::string + canonical_levels_path(const std::string& path_prefix) { std::stringstream ss; ss << path_prefix << ".levels"; @@ -101,7 +102,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Files describing the directed acyclic graph. //////////////////////////////////////////////////////////////////////////// - file _files [FILES]; + file _files[FILES]; //////////////////////////////////////////////////////////////////////////// /// \brief Whether the file paths in '_level_info_file' and '_files' are @@ -127,14 +128,14 @@ namespace adiar::internal /////////////////////////////////////////////////////////////////////////// levelized_file(const typename file_traits::stats& o) : file_traits::stats(o) - { } + {} public: /////////////////////////////////////////////////////////////////////////// /// \brief Constructor for a new unamed \em temporary file. /////////////////////////////////////////////////////////////////////////// levelized_file() - { } + {} //////////////////////////////////////////////////////////////////////////// /// \brief Constructor for a prior named \em persisted file. @@ -151,7 +152,7 @@ namespace adiar::internal _files[idx].set_path(path); _files[idx].make_persistent(); } else { // '_files[idx]' is missing - throw runtime_error("'"+path+"' does not exist"); + throw runtime_error("'" + path + "' does not exist"); } } @@ -161,7 +162,7 @@ namespace adiar::internal _level_info_file.set_path(path); _level_info_file.make_persistent(); } else { // '_level_info_file' is missing - throw runtime_error("'"+path+"' does not exist"); + throw runtime_error("'" + path + "' does not exist"); } } @@ -171,8 +172,11 @@ namespace adiar::internal } public: - bool canonical_paths() - { return _canonical_paths; } + bool + canonical_paths() + { + return _canonical_paths; + } public: //////////////////////////////////////////////////////////////////////////// @@ -181,13 +185,13 @@ namespace adiar::internal /// /// \see make_persistent //////////////////////////////////////////////////////////////////////////// - bool is_persistent() const + bool + is_persistent() const { const bool res = _level_info_file.is_persistent(); #ifndef NDEBUG for (size_t idx = 0; idx < FILES; idx++) { - adiar_assert(_files[idx].is_persistent() == res, - "Persistence ought to be synchronised."); + adiar_assert(_files[idx].is_persistent() == res, "Persistence ought to be synchronised."); } #endif return res; @@ -204,14 +208,13 @@ namespace adiar::internal /// /// \see is_persistent, canonical_paths, move //////////////////////////////////////////////////////////////////////////// - void make_persistent() + void + make_persistent() { if (!canonical_paths()) { throw runtime_error("Cannot persist a file with non-canonical paths"); } - for (size_t idx = 0u; idx < FILES; idx++) { - _files[idx].make_persistent(); - } + for (size_t idx = 0u; idx < FILES; idx++) { _files[idx].make_persistent(); } _level_info_file.make_persistent(); } @@ -228,7 +231,8 @@ namespace adiar::internal /// /// \see is_persistent, move //////////////////////////////////////////////////////////////////////////// - void make_persistent(const std::string &path_prefix) + void + make_persistent(const std::string& path_prefix) { move(path_prefix); make_persistent(); @@ -238,8 +242,11 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \copydoc is_persistent //////////////////////////////////////////////////////////////////////////// - bool is_temp() const - { return !is_persistent(); } + bool + is_temp() const + { + return !is_persistent(); + } public: //////////////////////////////////////////////////////////////////////////// @@ -247,7 +254,8 @@ namespace adiar::internal /// /// \see path //////////////////////////////////////////////////////////////////////////// - bool exists() const + bool + exists() const { const bool res = std::filesystem::exists(_level_info_file.path()); #ifndef NDEBUG @@ -263,7 +271,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief The number of elements in a specific file. //////////////////////////////////////////////////////////////////////////// - size_t size(const size_t idx) const + size_t + size(const size_t idx) const { throw_if_bad_idx(idx); return _files[idx].size(); @@ -273,11 +282,11 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief The number of elements in the file(s). //////////////////////////////////////////////////////////////////////////// - size_t size() const + size_t + size() const { size_t sum_size = 0u; - for(size_t idx = 0u; idx < FILES; idx++) - sum_size += size(idx); + for (size_t idx = 0u; idx < FILES; idx++) sum_size += size(idx); return sum_size; } @@ -285,8 +294,11 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief The number of elements in the levelized meta information file //////////////////////////////////////////////////////////////////////////// - size_t levels() const - { return _level_info_file.size(); } + size_t + levels() const + { + return _level_info_file.size(); + } public: ////////////////////////////////////////////////////////////////////////////// @@ -294,7 +306,8 @@ namespace adiar::internal /// /// \pre `levels() > 0` ////////////////////////////////////////////////////////////////////////////// - size_t first_level() const + size_t + first_level() const { adiar_assert(this->levels() > 0u); file_stream fs(this->_level_info_file); @@ -306,7 +319,8 @@ namespace adiar::internal /// /// \pre `levels() > 0` ////////////////////////////////////////////////////////////////////////////// - size_t last_level() const + size_t + last_level() const { adiar_assert(this->levels() > 0u); file_stream fs(this->_level_info_file); @@ -317,14 +331,18 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether all file(s) are empty. //////////////////////////////////////////////////////////////////////////// - bool empty() const - { return size() == 0u; } + bool + empty() const + { + return size() == 0u; + } private: //////////////////////////////////////////////////////////////////////////// /// \brief Creates the file(s) on disk, if they do not yet already do. //////////////////////////////////////////////////////////////////////////// - void __touch() const + void + __touch() const { if (exists()) return; @@ -336,7 +354,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Creates the file(s) on disk, if they do not yet already do. //////////////////////////////////////////////////////////////////////////// - void touch() + void + touch() { if (exists()) return; @@ -350,12 +369,11 @@ namespace adiar::internal /// /// \see exists move //////////////////////////////////////////////////////////////////////////// - std::array paths() const + std::array + paths() const { - std::array res; - for (size_t idx = 0u; idx < FILES; idx++) { - res[idx] = _files[idx].path(); - } + std::array res; + for (size_t idx = 0u; idx < FILES; idx++) { res[idx] = _files[idx].path(); } res[FILES] = _level_info_file.path(); return res; } @@ -364,13 +382,13 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether this file can be moved. //////////////////////////////////////////////////////////////////////////// - bool can_move() + bool + can_move() { const bool res = _level_info_file.can_move(); #ifndef NDEBUG for (size_t idx = 0; idx < FILES; idx++) { - adiar_assert(_files[idx].can_move() == res, - "'can_move()' ought to be synchronised."); + adiar_assert(_files[idx].can_move() == res, "'can_move()' ought to be synchronised."); } #endif return res; @@ -388,7 +406,8 @@ namespace adiar::internal /// /// \throws runtime_error Preconditions are violated. //////////////////////////////////////////////////////////////////////////// - void move(const std::string &path_prefix) + void + move(const std::string& path_prefix) { throw_if_persistent(); @@ -397,18 +416,16 @@ namespace adiar::internal // TODO: allow this? the path-prefix might be an independently created, // but intendedly related, file made by the user. if (std::filesystem::exists(path_prefix)) - throw runtime_error("path-prefix '"+path_prefix+"' exists."); + throw runtime_error("path-prefix '" + path_prefix + "' exists."); // Disallow moving a file on-top of another. { std::string path = canonical_levels_path(path_prefix); - if (std::filesystem::exists(path)) - throw runtime_error("'"+path+"' already exists."); + if (std::filesystem::exists(path)) throw runtime_error("'" + path + "' already exists."); } for (size_t idx = 0; idx < FILES; idx++) { std::string path = canonical_file_path(path_prefix, idx); - if (std::filesystem::exists(path)) - throw runtime_error("'"+path+"' already exists."); + if (std::filesystem::exists(path)) throw runtime_error("'" + path + "' already exists."); } // Move files @@ -434,7 +451,8 @@ namespace adiar::internal /// this file. //////////////////////////////////////////////////////////////////////////// template > - void sort(size_t idx, pred_t pred = pred_t()) + void + sort(size_t idx, pred_t pred = pred_t()) { throw_if_persistent(); throw_if_bad_idx(idx); @@ -449,7 +467,8 @@ namespace adiar::internal /// \remark This new file is a temporary file and must be marked persisted /// to be kept existing beyond the object's lifetime. //////////////////////////////////////////////////////////////////////////// - static levelized_file copy(const levelized_file &lf) + static levelized_file + copy(const levelized_file& lf) { const typename file_traits::stats s(lf); levelized_file lf_copy(s); diff --git a/src/adiar/internal/io/levelized_file_stream.h b/src/adiar/internal/io/levelized_file_stream.h index fa0f262bb..05a4abf15 100644 --- a/src/adiar/internal/io/levelized_file_stream.h +++ b/src/adiar/internal/io/levelized_file_stream.h @@ -2,16 +2,16 @@ #define ADIAR_INTERNAL_IO_LEVELIZED_FILE_STREAM_H #include -#include -#include #include +#include #include #include +#include // TODO: move? #include -#include #include +#include #include namespace adiar::internal @@ -37,7 +37,8 @@ namespace adiar::internal static constexpr size_t streams = file_traits::files; static_assert(0 < streams, "There must be at least a single file to attach to."); - static size_t memory_usage() + static size_t + memory_usage() { return streams * file_stream::memory_usage(); } @@ -50,25 +51,28 @@ namespace adiar::internal /// \brief Create unattached to any file. //////////////////////////////////////////////////////////////////////////// levelized_file_stream() - { } + {} //////////////////////////////////////////////////////////////////////////// - levelized_file_stream(const levelized_file_stream &) = delete; - levelized_file_stream(levelized_file_stream &&) = delete; + levelized_file_stream(const levelized_file_stream&) = delete; + levelized_file_stream(levelized_file_stream&&) = delete; //////////////////////////////////////////////////////////////////////////// /// \brief Create attached to a levelized file. //////////////////////////////////////////////////////////////////////////// - levelized_file_stream(const levelized_file &lf, - const bool negate = false) - { attach(lf, negate); } + levelized_file_stream(const levelized_file& lf, const bool negate = false) + { + attach(lf, negate); + } //////////////////////////////////////////////////////////////////////////// /// \brief Create attached to a shared levelized file. //////////////////////////////////////////////////////////////////////////// - levelized_file_stream(const shared_ptr> &lf, + levelized_file_stream(const shared_ptr>& lf, const bool negate = false) - { attach(lf, negate); } + { + attach(lf, negate); + } //////////////////////////////////////////////////////////////////////////// /// \brief Detaches and cleans up when destructed. @@ -81,8 +85,8 @@ namespace adiar::internal /// /// \pre No `levelized_file_writer` is currently attached to this file. //////////////////////////////////////////////////////////////////////////// - void attach(const levelized_file &f, - const bool negate = false) + void + attach(const levelized_file& f, const bool negate = false) { if (!f.exists()) f.__touch(); @@ -95,8 +99,8 @@ namespace adiar::internal /// /// \pre No `levelized_file_writer` is currently attached to this file. //////////////////////////////////////////////////////////////////////////// - void attach(const shared_ptr> &f, - const bool negate = false) + void + attach(const shared_ptr>& f, const bool negate = false) { if (!f->exists()) f->touch(); @@ -107,14 +111,14 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether this stream is attached to a levelized file. //////////////////////////////////////////////////////////////////////////// - bool attached() const + bool + attached() const { const bool res = _streams[0].attached(); #ifndef NDEBUG // TODO: trust the compiler to notice this is an empty for-loop? for (size_t s_idx = 1; s_idx < streams; s_idx++) { - adiar_assert(_streams[s_idx].attached() == res, - "Attachment ought to be synchronised."); + adiar_assert(_streams[s_idx].attached() == res, "Attachment ought to be synchronised."); } #endif return res; @@ -123,27 +127,28 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Detaches the stream from a levelized file. //////////////////////////////////////////////////////////////////////////// - void detach() + void + detach() { - for (size_t s_idx = 0; s_idx < streams; s_idx++) - _streams[s_idx].detach(); + for (size_t s_idx = 0; s_idx < streams; s_idx++) _streams[s_idx].detach(); } //////////////////////////////////////////////////////////////////////////// /// \brief Reset the read heads back to the beginning (relatively to the /// reading direction). //////////////////////////////////////////////////////////////////////////// - void reset() + void + reset() { - for (size_t s_idx = 0; s_idx < streams; s_idx++) - _streams[s_idx].reset(); + for (size_t s_idx = 0; s_idx < streams; s_idx++) _streams[s_idx].reset(); } //////////////////////////////////////////////////////////////////////////// /// \brief Whether the sub-stream contains more elements. //////////////////////////////////////////////////////////////////////////// - template - bool can_pull() const + template + bool + can_pull() const { static_assert(s_idx < streams, "Sub-stream index must be within [0; streams)."); return _streams[s_idx].can_pull(); @@ -154,8 +159,9 @@ namespace adiar::internal /// /// \pre `can_pull() == true`. //////////////////////////////////////////////////////////////////////////// - template - value_type pull() + template + value_type + pull() { static_assert(s_idx < streams, "Sub-stream index must be within [0; streams)"); return _streams[s_idx].pull(); @@ -167,15 +173,15 @@ namespace adiar::internal /// /// \pre `can_pull() == true`. //////////////////////////////////////////////////////////////////////////// - template - value_type peek() + template + value_type + peek() { static_assert(s_idx < streams, "Sub-stream index must be within [0; streams)"); return _streams[s_idx].peek(); } }; - ////////////////////////////////////////////////////////////////////////////// /// \brief Stream to access per-level meta information. ////////////////////////////////////////////////////////////////////////////// @@ -191,46 +197,58 @@ namespace adiar::internal level_info_stream() = default; //////////////////////////////////////////////////////////////////////////// - level_info_stream(const level_info_stream &) = delete; - level_info_stream(level_info_stream &&) = delete; + level_info_stream(const level_info_stream&) = delete; + level_info_stream(level_info_stream&&) = delete; //////////////////////////////////////////////////////////////////////////// /// \brief Construct attached to a file. //////////////////////////////////////////////////////////////////////////// - level_info_stream(const file &f) - { parent_t::attach(f); } + level_info_stream(const file& f) + { + parent_t::attach(f); + } //////////////////////////////////////////////////////////////////////////// /// \brief Construct attached to a file. //////////////////////////////////////////////////////////////////////////// - level_info_stream(const adiar::shared_ptr> &f) - { parent_t::attach(f); } + level_info_stream(const adiar::shared_ptr>& f) + { + parent_t::attach(f); + } //////////////////////////////////////////////////////////////////////////// /// \brief Construct attached to a levelized file. //////////////////////////////////////////////////////////////////////////// - template - level_info_stream(const levelized_file &lf) - { attach(lf); } + template + level_info_stream(const levelized_file& lf) + { + attach(lf); + } //////////////////////////////////////////////////////////////////////////// /// \brief Construct attached to a shared levelized file. //////////////////////////////////////////////////////////////////////////// - template - level_info_stream(const adiar::shared_ptr> &lf) - { attach(lf); } + template + level_info_stream(const adiar::shared_ptr>& lf) + { + attach(lf); + } //////////////////////////////////////////////////////////////////////////// /// \brief Construct attached to a (reduced) decision diagram. //////////////////////////////////////////////////////////////////////////// - level_info_stream(const dd &diagram) - { attach(diagram); } + level_info_stream(const dd& diagram) + { + attach(diagram); + } //////////////////////////////////////////////////////////////////////////// /// \brief Construct attached to a (possibly unreduced) decision diagram. //////////////////////////////////////////////////////////////////////////// - level_info_stream(const __dd &diagram) - { attach(diagram); } + level_info_stream(const __dd& diagram) + { + attach(diagram); + } //////////////////////////////////////////////////////////////////////////// /// \brief Detaches and cleans up when destructed. @@ -241,8 +259,9 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Attach to a levelized file. //////////////////////////////////////////////////////////////////////////// - template - void attach(const levelized_file &lf) + template + void + attach(const levelized_file& lf) { if (!lf.exists()) lf.__touch(); parent_t::attach(lf._level_info_file, nullptr, false); @@ -251,8 +270,9 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Attach to a shared levelized file. //////////////////////////////////////////////////////////////////////////// - template - void attach(const adiar::shared_ptr> &lf) + template + void + attach(const adiar::shared_ptr>& lf) { if (!lf->exists()) lf->touch(); parent_t::attach(lf->_level_info_file, lf, false); @@ -261,13 +281,17 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Attach to a (reduced) decision diagram. //////////////////////////////////////////////////////////////////////////// - void attach(const dd &diagram) - { attach(diagram.file); } + void + attach(const dd& diagram) + { + attach(diagram.file); + } //////////////////////////////////////////////////////////////////////////// /// \brief Attach to a (possibly unreduced) decision diagram. //////////////////////////////////////////////////////////////////////////// - void attach(const __dd &diagram) + void + attach(const __dd& diagram) { if (diagram.has<__dd::shared_arc_file_type>()) { attach(diagram.get<__dd::shared_arc_file_type>()); diff --git a/src/adiar/internal/io/levelized_file_writer.h b/src/adiar/internal/io/levelized_file_writer.h index 01862138d..46e746f89 100644 --- a/src/adiar/internal/io/levelized_file_writer.h +++ b/src/adiar/internal/io/levelized_file_writer.h @@ -2,12 +2,12 @@ #define ADIAR_INTERNAL_IO_LEVELIZED_FILE_WRITER_H #include -#include +#include #include #include #include -#include #include +#include namespace adiar::internal { @@ -22,10 +22,11 @@ namespace adiar::internal public: using value_type = T; - static size_t memory_usage() + static size_t + memory_usage() { return file_traits::files * file_writer::memory_usage() - + 1u * file_writer::memory_usage(); + + 1u * file_writer::memory_usage(); } protected: @@ -44,21 +45,24 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Writers for each of the files with 'value_type'. //////////////////////////////////////////////////////////////////////////// - file_writer _elem_writers [elem_writers]; + file_writer _elem_writers[elem_writers]; public: //////////////////////////////////////////////////////////////////////////// /// \brief Construct unattached to any levelized file. //////////////////////////////////////////////////////////////////////////// - levelized_file_writer() { } + levelized_file_writer() + {} //////////////////////////////////////////////////////////////////////////// /// \brief Construct attached to a given levelized file. /// /// \pre No file stream or other writer is currently attached to this file. //////////////////////////////////////////////////////////////////////////// - levelized_file_writer(levelized_file &f) - { attach(f); } + levelized_file_writer(levelized_file& f) + { + attach(f); + } //////////////////////////////////////////////////////////////////////////// /// \brief Construct attached to a given shared levelized file. @@ -66,13 +70,15 @@ namespace adiar::internal /// \pre No file stream or other writer is currently attached to this file. //////////////////////////////////////////////////////////////////////////// levelized_file_writer(adiar::shared_ptr> f) - { attach(f); } + { + attach(f); + } //////////////////////////////////////////////////////////////////////////// /// \brief Detaches and cleans up when destructed. //////////////////////////////////////////////////////////////////////////// ~levelized_file_writer() - { } // <-- detach within `~file_writer<...>()` + {} // <-- detach within `~file_writer<...>()` public: //////////////////////////////////////////////////////////////////////////// @@ -82,14 +88,15 @@ namespace adiar::internal /// ensure, that the file in question is not destructed before /// `.detach()` is called. //////////////////////////////////////////////////////////////////////////// - void attach(levelized_file &f) + void + attach(levelized_file& f) { if (attached()) { detach(); } // The stack variable is made accessible in '_file_ptr', but it should not // be garbage collected. Hence, we provide a do-nothing deleter to the // 'std::shared_ptr' directly. - _file_ptr = std::shared_ptr>(&f, [](void *) {}); + _file_ptr = std::shared_ptr>(&f, [](void*) {}); _level_writer.attach(f._level_info_file, nullptr); for (size_t s_idx = 0; s_idx < file_traits::files; s_idx++) @@ -99,7 +106,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Attach to a shared file. //////////////////////////////////////////////////////////////////////////// - void attach(adiar::shared_ptr> f) + void + attach(adiar::shared_ptr> f) { if (attached()) { detach(); } @@ -113,7 +121,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether the writer currently is attached to a levelized file. //////////////////////////////////////////////////////////////////////////// - bool attached() const + bool + attached() const { const bool res = _level_writer.attached(); #ifndef NDEBUG @@ -128,11 +137,11 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Detach from a levelized file (if need be) //////////////////////////////////////////////////////////////////////////// - void detach() + void + detach() { _level_writer.detach(); - for (size_t s_idx = 0; s_idx < elem_writers; s_idx++) - _elem_writers[s_idx].detach(); + for (size_t s_idx = 0; s_idx < elem_writers; s_idx++) _elem_writers[s_idx].detach(); _file_ptr.reset(); } @@ -143,7 +152,8 @@ namespace adiar::internal /// /// \pre `attached() == true`. //////////////////////////////////////////////////////////////////////////// - void push(const level_info &li) + void + push(const level_info& li) { _level_writer.push(li); } @@ -155,7 +165,8 @@ namespace adiar::internal /// /// \pre `attached() == true`. //////////////////////////////////////////////////////////////////////////// - levelized_file_writer& operator<< (const level_info& li) + levelized_file_writer& + operator<<(const level_info& li) { this->push(li); return *this; @@ -167,11 +178,11 @@ namespace adiar::internal /// \tparam s_idx File index to push to. /// \param e Element to push. //////////////////////////////////////////////////////////////////////////// - template - void push(const value_type &e) + template + void + push(const value_type& e) { - static_assert(s_idx < elem_writers, - "Sub-stream index must be within [0; elem_writers)."); + static_assert(s_idx < elem_writers, "Sub-stream index must be within [0; elem_writers)."); _elem_writers[s_idx].push(e); } @@ -180,10 +191,10 @@ namespace adiar::internal /// \brief Number of elements written to the underlying files (excluding the /// level info file). //////////////////////////////////////////////////////////////////////////// - size_t size(const size_t s_idx) const + size_t + size(const size_t s_idx) const { - adiar_assert(s_idx < elem_writers, - "Sub-stream index must be within [0; elem_writers)."); + adiar_assert(s_idx < elem_writers, "Sub-stream index must be within [0; elem_writers)."); return _elem_writers[s_idx].size(); } @@ -191,25 +202,28 @@ namespace adiar::internal /// \brief Number of elements written to the underlying files (excluding the /// level info file). //////////////////////////////////////////////////////////////////////////// - size_t size() const + size_t + size() const { size_t acc = 0u; - for (size_t s_idx = 0; s_idx < elem_writers; s_idx++) { - acc += size(s_idx); - } + for (size_t s_idx = 0; s_idx < elem_writers; s_idx++) { acc += size(s_idx); } return acc; } //////////////////////////////////////////////////////////////////////////// /// \brief Number of elements in the level info file. //////////////////////////////////////////////////////////////////////////// - size_t levels() const - { return _level_writer.size(); } + size_t + levels() const + { + return _level_writer.size(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Whether anything has been pushed to any of the underlying files. //////////////////////////////////////////////////////////////////////////// - bool has_pushed() const + bool + has_pushed() const { for (size_t s_idx = 0; s_idx < elem_writers; s_idx++) { if (size(s_idx) > 0) { return true; } @@ -220,8 +234,11 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether the underlying file is empty. //////////////////////////////////////////////////////////////////////////// - bool empty() const - { return !has_pushed(); } + bool + empty() const + { + return !has_pushed(); + } }; } diff --git a/src/adiar/internal/io/node_arc_stream.h b/src/adiar/internal/io/node_arc_stream.h index fc578cf26..6ef6d4dd8 100644 --- a/src/adiar/internal/io/node_arc_stream.h +++ b/src/adiar/internal/io/node_arc_stream.h @@ -4,9 +4,9 @@ #include #include #include +#include #include #include -#include namespace adiar::internal { @@ -18,25 +18,23 @@ namespace adiar::internal /// /// \see shared_levelized_file ////////////////////////////////////////////////////////////////////////////// - template - class node_arc_stream - : protected arc_stream + template + class node_arc_stream : protected arc_stream { private: using parent_t = arc_stream; public: - static size_t memory_usage() + static size_t + memory_usage() { return parent_t::memory_usage(); } private: - static constexpr size_t idx__internal = - file_traits::idx__internal; + static constexpr size_t idx__internal = file_traits::idx__internal; - static constexpr size_t idx__terminals__in_order = - file_traits::idx__terminals__in_order; + static constexpr size_t idx__terminals__in_order = file_traits::idx__terminals__in_order; static constexpr size_t idx__terminals__out_of_order = file_traits::idx__terminals__out_of_order; @@ -48,13 +46,13 @@ namespace adiar::internal node_arc_stream() = default; //////////////////////////////////////////////////////////////////////////// - node_arc_stream(const node_stream &) = delete; - node_arc_stream(node_stream &&) = delete; + node_arc_stream(const node_stream&) = delete; + node_arc_stream(node_stream&&) = delete; //////////////////////////////////////////////////////////////////////////// /// \brief Create attached to an arc file. //////////////////////////////////////////////////////////////////////////// - node_arc_stream(levelized_file &file, const bool negate = false) + node_arc_stream(levelized_file& file, const bool negate = false) : parent_t(/*need to sort before attach*/) { attach(file, negate); @@ -63,20 +61,18 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Create attached to a shared arc file. //////////////////////////////////////////////////////////////////////////// - node_arc_stream(shared_ptr> &file, - const bool negate = false) + node_arc_stream(shared_ptr>& file, const bool negate = false) : parent_t(/*need to sort before attach*/) { attach(file, negate); } - //////////////////////////////////////////////////////////////////////////// /// \brief Create attached to an Decision Diagram. /// /// \pre The given diagram should contain an unreduced diagram. //////////////////////////////////////////////////////////////////////////// - node_arc_stream(const __dd &diagram) + node_arc_stream(const __dd& diagram) : parent_t(/*need to sort before attach*/) { adiar_assert(diagram.template has<__dd::shared_arc_file_type>()); @@ -88,7 +84,8 @@ namespace adiar::internal /// /// \remark This sorts the internal arcs of the file. //////////////////////////////////////////////////////////////////////////// - void attach(levelized_file &file, const bool negate = false) + void + attach(levelized_file& file, const bool negate = false) { if (file.semi_transposed) { file.sort(idx__internal); @@ -102,8 +99,8 @@ namespace adiar::internal /// /// \remark This sorts the internal arcs of the file. //////////////////////////////////////////////////////////////////////////// - void attach(const shared_ptr> &file, - const bool negate = false) + void + attach(const shared_ptr>& file, const bool negate = false) { if (file->semi_transposed) { file->sort(idx__internal); @@ -115,7 +112,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether the stream contains more elements. //////////////////////////////////////////////////////////////////////////// - bool can_pull() const + bool + can_pull() const { return parent_t::can_pull_internal() || parent_t::can_pull_terminal(); } @@ -125,12 +123,11 @@ namespace adiar::internal /// /// \pre `can_pull() == true`. //////////////////////////////////////////////////////////////////////////// - const node pull() + const node + pull() { - const arc a_first = - take_internal() ? parent_t::pull_internal() : parent_t::pull_terminal(); - const arc a_second = - take_internal() ? parent_t::pull_internal() : parent_t::pull_terminal(); + const arc a_first = take_internal() ? parent_t::pull_internal() : parent_t::pull_terminal(); + const arc a_second = take_internal() ? parent_t::pull_internal() : parent_t::pull_terminal(); // Merge into a node (providing low arc first) if constexpr (Reverse) { @@ -145,12 +142,11 @@ namespace adiar::internal /// /// \pre `can_pull() == true`. //////////////////////////////////////////////////////////////////////////// - const node peek() + const node + peek() { - const arc a_first = - take_internal() ? parent_t::peek_internal() : parent_t::peek_terminal(); - const arc a_second = - take_internal() ? parent_t::peek_internal() : parent_t::peek_terminal(); + const arc a_first = take_internal() ? parent_t::peek_internal() : parent_t::peek_terminal(); + const arc a_second = take_internal() ? parent_t::peek_internal() : parent_t::peek_terminal(); // Merge into a node (providing low arc first) if constexpr (Reverse) { @@ -167,14 +163,16 @@ namespace adiar::internal /// /// \pre `can_pull() == true`. //////////////////////////////////////////////////////////////////////////// - const node seek(const node::uid_type &u); + const node + seek(const node::uid_type& u); // TODO private: - bool take_internal() + bool + take_internal() { if constexpr (Reverse) { - if (!parent_t::can_pull_terminal()) { return true; } + if (!parent_t::can_pull_terminal()) { return true; } if (!parent_t::can_pull_internal()) { return false; } } else { adiar_assert(parent_t::can_pull_terminal(), diff --git a/src/adiar/internal/io/node_file.h b/src/adiar/internal/io/node_file.h index 78adbcc5c..ab3a7c91c 100644 --- a/src/adiar/internal/io/node_file.h +++ b/src/adiar/internal/io/node_file.h @@ -2,6 +2,7 @@ #define ADIAR_INTERNAL_IO_NODE_FILE_H #include + #include #include #include @@ -62,8 +63,7 @@ namespace adiar::internal /// /// \see cut ////////////////////////////////////////////////////////////////////////// - cuts_t max_1level_cut = - { cut::max, cut::max, cut::max, cut::max }; + cuts_t max_1level_cut = { cut::max, cut::max, cut::max, cut::max }; ////////////////////////////////////////////////////////////////////////// /// \brief An upper bound for the maximum 2-level cut of the DAG (with or @@ -72,8 +72,7 @@ namespace adiar::internal /// /// \see cut ////////////////////////////////////////////////////////////////////////// - cuts_t max_2level_cut = - { cut::max, cut::max, cut::max, cut::max }; + cuts_t max_2level_cut = { cut::max, cut::max, cut::max, cut::max }; ////////////////////////////////////////////////////////////////////////// /// \brief The number of false and true terminals in the file. Index 0 @@ -87,7 +86,8 @@ namespace adiar::internal /// /// \param file The shared_levelized_file to check its content. ////////////////////////////////////////////////////////////////////////// - inline bool is_terminal() const + inline bool + is_terminal() const { // A shared_levelized_file only contains a terminal iff the number // of arcs to a terminal value in its meta information is exactly one. @@ -101,7 +101,8 @@ namespace adiar::internal /// /// \pre `is_terminal() == true` ////////////////////////////////////////////////////////////////////////// - inline bool value() const + inline bool + value() const { adiar_assert(this->is_terminal()); @@ -114,7 +115,8 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////// /// \brief Whether this DAG is the false terminal only. ////////////////////////////////////////////////////////////////////////// - inline bool is_false() const + inline bool + is_false() const { return this->is_terminal() && !this->value(); } @@ -122,7 +124,8 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////// /// \brief Whether this DAG is the true terminal only. ////////////////////////////////////////////////////////////////////////// - inline bool is_true() const + inline bool + is_true() const { return this->is_terminal() && this->value(); } diff --git a/src/adiar/internal/io/node_random_access.h b/src/adiar/internal/io/node_random_access.h index 0ce80f2f9..40370a442 100644 --- a/src/adiar/internal/io/node_random_access.h +++ b/src/adiar/internal/io/node_random_access.h @@ -14,7 +14,7 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Random-access to the contents of a levelized file of node. ////////////////////////////////////////////////////////////////////////////// - template + template class node_random_access { using value_type = T; @@ -26,13 +26,15 @@ namespace adiar::internal using id_type = typename value_type::id_type; public: - static size_t memory_usage(tpie::memory_size_type max_width) + static size_t + memory_usage(tpie::memory_size_type max_width) { return node_stream::memory_usage() - + tpie::array::memory_usage(max_width); + + tpie::array::memory_usage(max_width); } - static size_t memory_usage(const dd &diagram) + static size_t + memory_usage(const dd& diagram) { return node_stream::memory_usage() + tpie::array::memory_usage(diagram->width); @@ -44,8 +46,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// static constexpr label_type no_level = -1; - static_assert(uid_type::max_label < no_level, - "'no_level' should be an invalid label value"); + static_assert(uid_type::max_label < no_level, "'no_level' should be an invalid label value"); private: //////////////////////////////////////////////////////////////////////////// @@ -94,9 +95,10 @@ namespace adiar::internal /// /// \pre The given levelized file is canonical. //////////////////////////////////////////////////////////////////////////// - node_random_access(const levelized_file &f, - const bool negate = false) - : _ns(f, negate), _max_width(f.width), _level_buffer(f.width) + node_random_access(const levelized_file& f, const bool negate = false) + : _ns(f, negate) + , _max_width(f.width) + , _level_buffer(f.width) { adiar_assert(f.canonical); init(); @@ -107,9 +109,10 @@ namespace adiar::internal /// /// \pre The given shared levelized file is canonical. //////////////////////////////////////////////////////////////////////////// - node_random_access(const shared_ptr> &f, - const bool negate = false) - : _ns(f, negate), _max_width(f->width), _level_buffer(f->width) + node_random_access(const shared_ptr>& f, const bool negate = false) + : _ns(f, negate) + , _max_width(f->width) + , _level_buffer(f->width) { adiar_assert(f->canonical); init(); @@ -120,45 +123,55 @@ namespace adiar::internal /// /// \pre The given decision diagram is canonical. //////////////////////////////////////////////////////////////////////////// - node_random_access(const dd &diagram) - : _ns(diagram), _max_width(diagram->width), _level_buffer(diagram->width) + node_random_access(const dd& diagram) + : _ns(diagram) + , _max_width(diagram->width) + , _level_buffer(diagram->width) { adiar_assert(diagram->canonical); init(); } private: - void init() + void + init() { adiar_assert(_ns.can_pull(), "given file should be non-empty"); // Skip the terminal node for terminal only BDDs. _root = _ns.peek().uid(); - if (_root.is_terminal()) { - _ns.pull(); - } + if (_root.is_terminal()) { _ns.pull(); } } public: //////////////////////////////////////////////////////////////////////////// /// \brief Return root of the diagram. //////////////////////////////////////////////////////////////////////////// - uid_type root() const - { return _root; } + uid_type + root() const + { + return _root; + } //////////////////////////////////////////////////////////////////////////// /// \brief Whether there are any more levels. //////////////////////////////////////////////////////////////////////////// - bool has_next_level() const - { return _ns.can_pull(); } + bool + has_next_level() const + { + return _ns.can_pull(); + } //////////////////////////////////////////////////////////////////////////// /// \brief The immediate next available non-empty level. /// /// \pre `has_next_level() == true` //////////////////////////////////////////////////////////////////////////// - label_type next_level() - { return _ns.peek().uid().label(); } + label_type + next_level() + { + return _ns.peek().uid().label(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Sets up the random access buffer for the specified level. @@ -168,7 +181,8 @@ namespace adiar::internal /// /// \pre `has_current_level() == false` or `current_level() < level` //////////////////////////////////////////////////////////////////////////// - void setup_next_level(const label_type level) + void + setup_next_level(const label_type level) { adiar_assert(!has_current_level() || current_level() < level); @@ -180,9 +194,7 @@ namespace adiar::internal if (!has_next_level()) { return; } // Skip all levels not of interest - while (_ns.can_pull() && _ns.peek().uid().label() < level) { - _ns.pull(); - } + while (_ns.can_pull() && _ns.peek().uid().label() < level) { _ns.pull(); } // Copy over all elements from the requested level while (_ns.can_pull() && _ns.peek().uid().label() == level) { @@ -194,34 +206,49 @@ namespace adiar::internal /// \brief Sets up the random access buffer for the immediate next available /// non-empty level. //////////////////////////////////////////////////////////////////////////// - void setup_next_level() - { setup_next_level(next_level()); } + void + setup_next_level() + { + setup_next_level(next_level()); + } public: //////////////////////////////////////////////////////////////////////////// /// \brief Whether there is any current level to access elements from. //////////////////////////////////////////////////////////////////////////// - bool has_current_level() const - { return _curr_level != no_level; } + bool + has_current_level() const + { + return _curr_level != no_level; + } //////////////////////////////////////////////////////////////////////////// /// \brief The label of the current level. //////////////////////////////////////////////////////////////////////////// - label_type current_level() const - { return _curr_level; } + label_type + current_level() const + { + return _curr_level; + } //////////////////////////////////////////////////////////////////////////// /// \brief The width of the current level, i.e. the number of elements one /// can access to. //////////////////////////////////////////////////////////////////////////// - label_type current_width() const - { return _curr_width; } + label_type + current_width() const + { + return _curr_width; + } //////////////////////////////////////////////////////////////////////////// /// \brief Whether the current level is empty. //////////////////////////////////////////////////////////////////////////// - bool empty_level() const - { return _curr_width == 0u; } + bool + empty_level() const + { + return _curr_width == 0u; + } public: //////////////////////////////////////////////////////////////////////////// @@ -229,7 +256,8 @@ namespace adiar::internal /// /// \pre `idx < current_width()` //////////////////////////////////////////////////////////////////////////// - const value_type& at(id_type idx) const + const value_type& + at(id_type idx) const { adiar_assert(idx < current_width()); return _level_buffer[idx]; @@ -238,7 +266,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the node with the given uid. //////////////////////////////////////////////////////////////////////////// - const value_type& at(uid_type u) const + const value_type& + at(uid_type u) const { adiar_assert(u.label() == current_level()); diff --git a/src/adiar/internal/io/node_stream.h b/src/adiar/internal/io/node_stream.h index f70e40f92..8f037198d 100644 --- a/src/adiar/internal/io/node_stream.h +++ b/src/adiar/internal/io/node_stream.h @@ -1,8 +1,8 @@ #ifndef ADIAR_INTERNAL_IO_NODE_STREAM_H #define ADIAR_INTERNAL_IO_NODE_STREAM_H -#include #include +#include #include #include @@ -16,9 +16,8 @@ namespace adiar::internal /// /// \see shared_levelized_file ////////////////////////////////////////////////////////////////////////////// - template - class node_stream - : public levelized_file_stream + template + class node_stream : public levelized_file_stream { using parent_t = levelized_file_stream; @@ -29,53 +28,60 @@ namespace adiar::internal node_stream() = default; //////////////////////////////////////////////////////////////////////////// - node_stream(const node_stream &) = delete; - node_stream(node_stream &&) = delete; + node_stream(const node_stream&) = delete; + node_stream(node_stream&&) = delete; //////////////////////////////////////////////////////////////////////////// /// \brief Create attached to a node file. //////////////////////////////////////////////////////////////////////////// - node_stream(const levelized_file &file, - const bool negate = false) + node_stream(const levelized_file& file, const bool negate = false) : parent_t(file, negate) - { } + {} //////////////////////////////////////////////////////////////////////////// /// \brief Create attached to a shared node file. //////////////////////////////////////////////////////////////////////////// - node_stream(const shared_ptr> &file, - const bool negate = false) + node_stream(const shared_ptr>& file, const bool negate = false) : parent_t(file, negate) - { } + {} //////////////////////////////////////////////////////////////////////////// /// \brief Create attached to a Decision Diagram. //////////////////////////////////////////////////////////////////////////// - node_stream(const dd &diagram) + node_stream(const dd& diagram) : parent_t(diagram.file, diagram.negate) - { } + {} //////////////////////////////////////////////////////////////////////////// /// \brief Whether the stream contains more elements. //////////////////////////////////////////////////////////////////////////// - bool can_pull() const - { return parent_t::template can_pull<0>(); } + bool + can_pull() const + { + return parent_t::template can_pull<0>(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain next element (and move the read head). /// /// \pre `can_pull() == true`. //////////////////////////////////////////////////////////////////////////// - const node pull() - { return parent_t::template pull<0>(); } + const node + pull() + { + return parent_t::template pull<0>(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the next element (but do not move the read head). /// /// \pre `can_pull() == true`. //////////////////////////////////////////////////////////////////////////// - const node peek() - { return parent_t::template peek<0>(); } + const node + peek() + { + return parent_t::template peek<0>(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the first node past the seeked value. @@ -84,8 +90,11 @@ namespace adiar::internal /// /// \pre `can_pull() == true`. //////////////////////////////////////////////////////////////////////////// - const node seek(const node::uid_type &u) - { return parent_t::_streams[0].seek(u); } + const node + seek(const node::uid_type& u) + { + return parent_t::_streams[0].seek(u); + } }; } diff --git a/src/adiar/internal/io/node_writer.h b/src/adiar/internal/io/node_writer.h index 50524c54c..de012a61f 100644 --- a/src/adiar/internal/io/node_writer.h +++ b/src/adiar/internal/io/node_writer.h @@ -2,10 +2,11 @@ #define ADIAR_INTERNAL_IO_NODE_WRITER_H #include + #include #include -#include #include +#include #include #include @@ -17,20 +18,18 @@ namespace adiar::internal /// /// \see shared_levelized_file ////////////////////////////////////////////////////////////////////////////// - class node_writer - : public levelized_file_writer + class node_writer : public levelized_file_writer { private: //////////////////////////////////////////////////////////////////////////// /// Construct a dummy node, that is invalid within a decision diagram and /// hence easy to recognise. //////////////////////////////////////////////////////////////////////////// - node dummy() + node + dummy() { // Notice, this goes around any of the consistency checks of 'node'! - return node(node::uid_type(0, 0), - node::pointer_type::nil(), - node::pointer_type::nil()); + return node(node::uid_type(0, 0), node::pointer_type::nil(), node::pointer_type::nil()); } //////////////////////////////////////////////////////////////////////////// @@ -59,48 +58,53 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// size_t _terminals_at_bottom[2] = { 0u, 0u }; - cut::size_type _max_1level_short_internal = 0u; + cut::size_type _max_1level_short_internal = 0u; cut::size_type _curr_1level_short_internal = 0u; - node::pointer_type _long_internal_ptr = node::pointer_type::nil(); + node::pointer_type _long_internal_ptr = node::pointer_type::nil(); cut::size_type _number_of_long_internal_arcs = 0u; public: //////////////////////////////////////////////////////////////////////////// /// \brief Construct unattached to any levelized node file. //////////////////////////////////////////////////////////////////////////// - node_writer(): levelized_file_writer() - { } + node_writer() + : levelized_file_writer() + {} //////////////////////////////////////////////////////////////////////////// /// \brief Construct attached to a levelized node file. //////////////////////////////////////////////////////////////////////////// - node_writer(levelized_file &nf) + node_writer(levelized_file& nf) : levelized_file_writer(nf) , _canonical(!levelized_file_writer::has_pushed() || nf.canonical) - { } + {} //////////////////////////////////////////////////////////////////////////// /// \brief Construct attached to a shared levelized node file. //////////////////////////////////////////////////////////////////////////// node_writer(adiar::shared_ptr> nf) : levelized_file_writer(nf) - , _canonical(!levelized_file_writer::has_pushed()|| nf->canonical) - { } + , _canonical(!levelized_file_writer::has_pushed() || nf->canonical) + {} //////////////////////////////////////////////////////////////////////////// /// \brief Detaches and cleans up from the levelized file (if need be). //////////////////////////////////////////////////////////////////////////// ~node_writer() - { detach(); } + { + detach(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Attach to a file //////////////////////////////////////////////////////////////////////////// - void attach(adiar::shared_ptr> &f) { + void + attach(adiar::shared_ptr>& f) + { levelized_file_writer::attach(f); - //Reset all meta-data + // Reset all meta-data _latest_node = dummy(); _canonical = true; @@ -110,23 +114,27 @@ namespace adiar::internal _terminals_at_bottom[0] = 0u; _terminals_at_bottom[1] = 0u; - _max_1level_short_internal = 0u; + _max_1level_short_internal = 0u; _curr_1level_short_internal = 0u; - _long_internal_ptr = node::pointer_type::nil(); + _long_internal_ptr = node::pointer_type::nil(); _number_of_long_internal_arcs = 0u; } //////////////////////////////////////////////////////////////////////////// /// \brief Whether the writer currently is attached. //////////////////////////////////////////////////////////////////////////// - bool attached() const - { return levelized_file_writer::attached(); } + bool + attached() const + { + return levelized_file_writer::attached(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Detach from a file (if need be) //////////////////////////////////////////////////////////////////////////// - void detach() + void + detach() { if (!attached()) { return; } @@ -142,8 +150,8 @@ namespace adiar::internal _level_size = 0u; // TODO: remove? // 1-level cut - _max_1level_short_internal = std::max(_max_1level_short_internal, - _curr_1level_short_internal); + _max_1level_short_internal = + std::max(_max_1level_short_internal, _curr_1level_short_internal); const cut::size_type max_1level_internal_cut = _max_1level_short_internal + _number_of_long_internal_arcs; @@ -152,7 +160,7 @@ namespace adiar::internal const size_t terminals_above_bottom[2] = { _file_ptr->number_of_terminals[false] - _terminals_at_bottom[false], - _file_ptr->number_of_terminals[true] - _terminals_at_bottom[true] + _file_ptr->number_of_terminals[true] - _terminals_at_bottom[true] }; _file_ptr->max_1level_cut[cut::Internal_False] = @@ -163,9 +171,9 @@ namespace adiar::internal std::max(max_1level_internal_cut + terminals_above_bottom[true], _file_ptr->number_of_terminals[true]); - _file_ptr->max_1level_cut[cut::All] = - std::max(max_1level_internal_cut + terminals_above_bottom[false] + terminals_above_bottom[true], - _file_ptr->number_of_terminals[false] + _file_ptr->number_of_terminals[true]); + _file_ptr->max_1level_cut[cut::All] = std::max( + max_1level_internal_cut + terminals_above_bottom[false] + terminals_above_bottom[true], + _file_ptr->number_of_terminals[false] + _file_ptr->number_of_terminals[true]); } // Run final i-level cut computations @@ -185,7 +193,8 @@ namespace adiar::internal /// /// \throws domain_error If the writer is yet not attached. //////////////////////////////////////////////////////////////////////////// - void push(const node &n) + void + push(const node& n) { if (!attached()) { throw domain_error("node_writer is not yet attached to any levelized_file"); @@ -193,26 +202,23 @@ namespace adiar::internal if (_latest_node == dummy()) { // First node pushed _canonical = n.is_terminal() || n.id() == node::max_id; - if (n.is_terminal()) { - _file_ptr->number_of_terminals[n.uid().value()]++; - } + if (n.is_terminal()) { _file_ptr->number_of_terminals[n.uid().value()]++; } } else { // Check validity of input based on prior written node adiar_assert(!_latest_node.is_terminal(), "Cannot push a node after having pushed a terminal"); - adiar_assert(!n.is_terminal(), - "Cannot push a terminal into non-empty file"); + adiar_assert(!n.is_terminal(), "Cannot push a terminal into non-empty file"); // Check it is canonically sorted if (_canonical) { if (_latest_node.label() == n.label()) { - const bool id_diff = n.uid().id() == _latest_node.id() - 1u; + const bool id_diff = n.uid().id() == _latest_node.id() - 1u; const bool children_ordered = n.high() < _latest_node.high() || (n.high() == _latest_node.high() && n.low() < _latest_node.low()); _canonical = id_diff && children_ordered; } else { const bool id_reset = n.id() == node::max_id; - _canonical = id_reset; + _canonical = id_reset; } } @@ -223,11 +229,11 @@ namespace adiar::internal _level_size = 0u; // Update 1-level cut information - _max_1level_short_internal = std::max(_max_1level_short_internal, - _curr_1level_short_internal); + _max_1level_short_internal = + std::max(_max_1level_short_internal, _curr_1level_short_internal); _curr_1level_short_internal = 0u; - _long_internal_ptr = node::uid_type(_latest_node.label(), node::max_id); + _long_internal_ptr = node::uid_type(_latest_node.label(), node::max_id); } } @@ -239,13 +245,19 @@ namespace adiar::internal } if (n.low().is_node()) { - if (n.low() > _long_internal_ptr) { _number_of_long_internal_arcs++; } - else { _curr_1level_short_internal++; } + if (n.low() > _long_internal_ptr) { + _number_of_long_internal_arcs++; + } else { + _curr_1level_short_internal++; + } } if (n.high().is_node()) { - if (n.high() > _long_internal_ptr) { _number_of_long_internal_arcs++; } - else { _curr_1level_short_internal++; } + if (n.high() > _long_internal_ptr) { + _number_of_long_internal_arcs++; + } else { + _curr_1level_short_internal++; + } } // Write node to file @@ -255,7 +267,8 @@ namespace adiar::internal unsafe_push(n); } - node_writer& operator<< (const node& n) + node_writer& + operator<<(const node& n) { this->push(n); return *this; @@ -264,7 +277,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Write directly to level information file without any checks. //////////////////////////////////////////////////////////////////////////// - void unsafe_push(const level_info &m) + void + unsafe_push(const level_info& m) { #ifdef ADIAR_STATS stats_node_file.push_level += 1; @@ -276,12 +290,13 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Write directly to the underlying node file without any checks. //////////////////////////////////////////////////////////////////////////// - void unsafe_push(const node &n) + void + unsafe_push(const node& n) { #ifdef ADIAR_STATS stats_node_file.push_node += 1; #endif - if (n.low().is_terminal()) { _file_ptr->number_of_terminals[n.low().value()]++; } + if (n.low().is_terminal()) { _file_ptr->number_of_terminals[n.low().value()]++; } if (n.high().is_terminal()) { _file_ptr->number_of_terminals[n.high().value()]++; } levelized_file_writer::template push<0>(n); @@ -291,7 +306,8 @@ namespace adiar::internal /// \brief Change the 1-level cut size to the maximum of the current or the /// given cuts. //////////////////////////////////////////////////////////////////////////// - void unsafe_max_1level_cut(const cuts_t &o) + void + unsafe_max_1level_cut(const cuts_t& o) { max_cut(_file_ptr->max_1level_cut, o); } @@ -299,7 +315,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Increase the current maximum 1-level cut size by the given cut. //////////////////////////////////////////////////////////////////////////// - void unsafe_inc_1level_cut(const cuts_t &o) + void + unsafe_inc_1level_cut(const cuts_t& o) { inc_cut(_file_ptr->max_1level_cut, o); } @@ -307,8 +324,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Overwrite the number of false and true arcs. //////////////////////////////////////////////////////////////////////////// - void unsafe_set_number_of_terminals(const size_t number_of_false, - const size_t number_of_true) + void + unsafe_set_number_of_terminals(const size_t number_of_false, const size_t number_of_true) { _file_ptr->number_of_terminals[false] = number_of_false; _file_ptr->number_of_terminals[true] = number_of_true; @@ -317,7 +334,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Overwrite the canonicity flag. //////////////////////////////////////////////////////////////////////////// - void unsafe_set_canonical(const bool canonical) + void + unsafe_set_canonical(const bool canonical) { _file_ptr->canonical = canonical; } @@ -325,21 +343,28 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// /// \brief Whether anything has been pushed to any of the underlying files. //////////////////////////////////////////////////////////////////////////// - bool has_pushed() - { return levelized_file_writer::has_pushed(); } + bool + has_pushed() + { + return levelized_file_writer::has_pushed(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Whether the underlying file is empty. //////////////////////////////////////////////////////////////////////////// - bool empty() - { return levelized_file_writer::empty(); } + bool + empty() + { + return levelized_file_writer::empty(); + } private: //////////////////////////////////////////////////////////////////////////// /// \brief Helper function to bound derived 1-level and 2-level cuts with /// their trivial upper bounds (assuming nothing is pushed later). //////////////////////////////////////////////////////////////////////////// - void fixup_ilevel_cuts() + void + fixup_ilevel_cuts() { const size_t number_of_nodes = levelized_file_writer::size(); const size_t number_of_false = _file_ptr->number_of_terminals[false]; @@ -355,14 +380,14 @@ namespace adiar::internal // Upper bound on just 'all arcs'. This is better than 'max_cut' above, if // there are 'number_of_nodes' or more arcs to terminals. const bool noa_overflow_safe = number_of_nodes <= cut::max / 2u; - const size_t number_of_arcs = 2u * number_of_nodes; + const size_t number_of_arcs = 2u * number_of_nodes; - const cuts_t all_arcs_cut = {{ - noa_overflow_safe ? number_of_arcs - number_of_false - number_of_true : cut::max, - noa_overflow_safe ? number_of_arcs - number_of_true : cut::max, - noa_overflow_safe ? number_of_arcs - number_of_false : cut::max, - noa_overflow_safe ? number_of_arcs : cut::max - }}; + const cuts_t all_arcs_cut = { + { noa_overflow_safe ? number_of_arcs - number_of_false - number_of_true : cut::max, + noa_overflow_safe ? number_of_arcs - number_of_true : cut::max, + noa_overflow_safe ? number_of_arcs - number_of_false : cut::max, + noa_overflow_safe ? number_of_arcs : cut::max } + }; // ----------------------------------------------------------------------- // Maximum 1-level cuts @@ -374,14 +399,12 @@ namespace adiar::internal _file_ptr->max_1level_cut[cut::Internal_True] = number_of_true; _file_ptr->max_1level_cut[cut::All] = 1u; } else { - for(size_t ct = 0u; ct < cut::size; ct++) { + for (size_t ct = 0u; ct < cut::size; ct++) { // Use smallest sound upper bound. Since it is not a terminal, then there // must be at least one in-going arc to the root. - _file_ptr->max_1level_cut[ct] = std::max(1lu, std::min({ - _file_ptr->max_1level_cut[ct], - max_cut, - all_arcs_cut[ct] - })); + _file_ptr->max_1level_cut[ct] = std::max( + 1lu, + std::min({ _file_ptr->max_1level_cut[ct], max_cut, all_arcs_cut[ct] })); } } @@ -390,41 +413,34 @@ namespace adiar::internal const size_t number_of_levels = levelized_file_writer::levels(); if (is_terminal || number_of_nodes == number_of_levels) { - for(size_t ct = 0u; ct < cut::size; ct++) { + for (size_t ct = 0u; ct < cut::size; ct++) { _file_ptr->max_2level_cut[ct] = _file_ptr->max_1level_cut[ct]; } } else { // General case - for(size_t ct = 0u; ct < cut::size; ct++) { + for (size_t ct = 0u; ct < cut::size; ct++) { // Upper bound based on 1-level cut - const cut::size_type ub_from_1level_cut = - _file_ptr->max_1level_cut[ct] < cut::max / 3u + const cut::size_type ub_from_1level_cut = _file_ptr->max_1level_cut[ct] < cut::max / 3u ? ((_file_ptr->max_1level_cut[cut::Internal] * 3u) / 2u + (_file_ptr->max_1level_cut[ct] - _file_ptr->max_1level_cut[cut::Internal])) : cut::max; // Use smallest sound upper bound. - _file_ptr->max_2level_cut[ct] = std::min({ - _file_ptr->max_2level_cut[ct], - ub_from_1level_cut, - max_cut, - all_arcs_cut[ct] - }); + _file_ptr->max_2level_cut[ct] = std::min( + { _file_ptr->max_2level_cut[ct], ub_from_1level_cut, max_cut, all_arcs_cut[ct] }); } } } - void max_cut(cuts_t &c, const cuts_t &o) + void + max_cut(cuts_t& c, const cuts_t& o) { - for(size_t ct = 0u; ct < cut::size; ct++) { - c[ct] = std::max(c[ct], o[ct]); - } + for (size_t ct = 0u; ct < cut::size; ct++) { c[ct] = std::max(c[ct], o[ct]); } } - void inc_cut(cuts_t &c, const cuts_t &o) + void + inc_cut(cuts_t& c, const cuts_t& o) { - for(size_t ct = 0u; ct < cut::size; ct++) { - c[ct] += o[ct]; - } + for (size_t ct = 0u; ct < cut::size; ct++) { c[ct] += o[ct]; } } }; } diff --git a/src/adiar/internal/io/shared_file_ptr.h b/src/adiar/internal/io/shared_file_ptr.h index 37b7d4841..a85cad0f0 100644 --- a/src/adiar/internal/io/shared_file_ptr.h +++ b/src/adiar/internal/io/shared_file_ptr.h @@ -3,10 +3,9 @@ #include -#include - #include #include +#include namespace adiar::internal { @@ -25,8 +24,7 @@ namespace adiar::internal /// \tparam File Type of the underlying file ////////////////////////////////////////////////////////////////////////////// template - class shared_file_ptr - : public shared_ptr + class shared_file_ptr : public shared_ptr { public: //////////////////////////////////////////////////////////////////////////// @@ -55,7 +53,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// shared_file_ptr() : shared_ptr(adiar::make_shared()) - { } + {} //////////////////////////////////////////////////////////////////////////// /// \brief Constructor to reload a persisted file. @@ -64,67 +62,88 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// shared_file_ptr(const std::string p) : shared_ptr(adiar::make_shared(p)) - { } + {} //////////////////////////////////////////////////////////////////////////// /// \brief Conversion-constructor from raw `shared_ptr`. //////////////////////////////////////////////////////////////////////////// - shared_file_ptr(const shared_ptr &other) : shared_ptr(other) - { } + shared_file_ptr(const shared_ptr& other) + : shared_ptr(other) + {} //////////////////////////////////////////////////////////////////////////// /// \brief Copy-constructor. //////////////////////////////////////////////////////////////////////////// - shared_file_ptr(const shared_file_ptr &other) = default; + shared_file_ptr(const shared_file_ptr& other) = default; //////////////////////////////////////////////////////////////////////////// /// \brief Move-constructor. //////////////////////////////////////////////////////////////////////////// - shared_file_ptr(shared_file_ptr &&other) = default; + shared_file_ptr(shared_file_ptr&& other) = default; public: //////////////////////////////////////////////////////////////////////////// - shared_file_ptr& operator= (const shared_file_ptr &o) = default; + shared_file_ptr& + operator=(const shared_file_ptr& o) = default; //////////////////////////////////////////////////////////////////////////// - shared_file_ptr& operator= (shared_file_ptr &&o) = default; + shared_file_ptr& + operator=(shared_file_ptr&& o) = default; public: //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the raw pointer (read-only). //////////////////////////////////////////////////////////////////////////// - const File* get() const - { return shared_ptr::get(); } + const File* + get() const + { + return shared_ptr::get(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Obtain the raw pointer. //////////////////////////////////////////////////////////////////////////// - File* get() - { return shared_ptr::get(); } + File* + get() + { + return shared_ptr::get(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Dereference the pointer to obtain the file (read-only). //////////////////////////////////////////////////////////////////////////// - const File& operator*() const - { return *get(); } + const File& + operator*() const + { + return *get(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Dereference the pointer to obtain the file. //////////////////////////////////////////////////////////////////////////// - File& operator*() - { return *get(); } + File& + operator*() + { + return *get(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Member access (read-only) to the file. //////////////////////////////////////////////////////////////////////////// - const File* operator->() const - { return get(); } + const File* + operator->() const + { + return get(); + } //////////////////////////////////////////////////////////////////////////// /// \brief Member access for the underlying file. //////////////////////////////////////////////////////////////////////////// - File* operator->() - { return get(); } + File* + operator->() + { + return get(); + } public: //////////////////////////////////////////////////////////////////////////// @@ -133,7 +152,8 @@ namespace adiar::internal /// \remark This new file is a temporary file and must be marked persisted /// to be kept existing beyond the last reference to it is gone. //////////////////////////////////////////////////////////////////////////// - static shared_file_ptr copy(const shared_file_ptr &f) + static shared_file_ptr + copy(const shared_file_ptr& f) { return make_shared(File::copy(*f)); } @@ -149,7 +169,9 @@ namespace adiar::internal /// \brief Creates a new (temporary) file with shared ownership. ////////////////////////////////////////////////////////////////////////////// template - inline shared_file make_shared_file() { + inline shared_file + make_shared_file() + { return adiar::make_shared>(); } @@ -157,7 +179,9 @@ namespace adiar::internal /// \brief Open a persisted file with shared ownership. ////////////////////////////////////////////////////////////////////////////// template - inline shared_file make_shared_file(const std::string &p) { + inline shared_file + make_shared_file(const std::string& p) + { return adiar::make_shared>(p); } @@ -172,7 +196,8 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// template inline shared_levelized_file - make_shared_levelized_file() { + make_shared_levelized_file() + { return adiar::make_shared>(); } @@ -181,7 +206,8 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// template inline shared_levelized_file - make_shared_levelized_file(const std::string &p) { + make_shared_levelized_file(const std::string& p) + { return adiar::make_shared>(p); } } diff --git a/src/adiar/internal/memory.h b/src/adiar/internal/memory.h index fb517333d..4c6c90df6 100644 --- a/src/adiar/internal/memory.h +++ b/src/adiar/internal/memory.h @@ -3,8 +3,8 @@ #include -#include #include +#include #include @@ -13,7 +13,8 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// /// \brief Obtain from TPIE the amount of available memory. ////////////////////////////////////////////////////////////////////////////// - inline size_t memory_available() + inline size_t + memory_available() { return tpie::get_memory_manager().available(); } @@ -26,7 +27,11 @@ namespace adiar::internal /// using the external memory (the disk) and (2) an implementation /// that is much faster but is limited to internal memory (the RAM). ////////////////////////////////////////////////////////////////////////////// - enum class memory_mode { Internal, External }; + enum class memory_mode + { + Internal, + External + }; } namespace adiar @@ -49,8 +54,9 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// /// \brief Creates a new object on the heap with shared ownership. ////////////////////////////////////////////////////////////////////////////// - template - inline shared_ptr make_shared(TT && ... tt) + template + inline shared_ptr + make_shared(TT&&... tt) { return std::make_shared(std::forward(tt)...); } @@ -66,8 +72,9 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// /// \brief Creates a new object on the heap with unique ownership. ////////////////////////////////////////////////////////////////////////////// - template - inline unique_ptr make_unique(TT && ... tt) + template + inline unique_ptr + make_unique(TT&&... tt) { return std::make_unique(std::forward(tt)...); } diff --git a/src/adiar/internal/unreachable.h b/src/adiar/internal/unreachable.h index 955981e8c..e1d2b2ec7 100644 --- a/src/adiar/internal/unreachable.h +++ b/src/adiar/internal/unreachable.h @@ -6,12 +6,23 @@ namespace adiar // LCOV_EXCL_START // From: https://stackoverflow.com/a/65258501/13300643 -#ifdef __GNUC__ // GCC 4.8+, Clang, Intel and other compilers compatible with GCC (-std=c++0x or above) - [[noreturn]] inline __attribute__((always_inline)) void adiar_unreachable() {__builtin_unreachable();} +#ifdef __GNUC__ // GCC 4.8+, Clang, Intel and other compilers compatible with GCC (-std=c++0x or + // above) + [[noreturn]] inline __attribute__((always_inline)) void + adiar_unreachable() + { + __builtin_unreachable(); + } #elif defined(_MSC_VER) // MSVC - [[noreturn]] __forceinline void adiar_unreachable() {__assume(false);} -#else // ??? - inline void adiar_unreachable() {} + [[noreturn]] __forceinline void + adiar_unreachable() + { + __assume(false); + } +#else // ??? + inline void + adiar_unreachable() + {} #endif // LCOV_EXCL_STOP diff --git a/src/adiar/internal/util.h b/src/adiar/internal/util.h index 1577ffdef..d49d4717d 100644 --- a/src/adiar/internal/util.h +++ b/src/adiar/internal/util.h @@ -7,23 +7,23 @@ #include #include -#include #include #include +#include +#include +#include #include -#include #include #include -#include -#include #include +#include namespace adiar::internal { //////////////////////////////////////////////////////////////////////////// /// \brief Template to hide how to obtain the level from a data type. //////////////////////////////////////////////////////////////////////////// - template + template inline ptr_uint64::label_type level_of(const T& t) { @@ -38,24 +38,24 @@ namespace adiar::internal /// \brief Defines at compile time the type of the file stream to use for /// reading the levels from some file(s). ////////////////////////////////////////////////////////////////////////////// - template + template struct level_stream_t { - template + template using stream_t = level_info_stream; }; - template<> + template <> struct level_stream_t> { - template + template using stream_t = file_stream; }; - template<> + template <> struct level_stream_t> { - template + template using stream_t = file_stream; }; @@ -63,9 +63,9 @@ namespace adiar::internal /// \brief Obtain whether the levels in two files are disjoint. //////////////////////////////////////////////////////////////////////////// // TODO: Move to dd_func? - template + template bool - disjoint_levels(const A &a, const B &b) + disjoint_levels(const A& a, const B& b) { using stream1_t = typename level_stream_t::template stream_t; stream1_t sa(a); @@ -73,7 +73,7 @@ namespace adiar::internal using stream2_t = typename level_stream_t::template stream_t; stream2_t sb(b); - while(sa.can_pull() && sb.can_pull()) { + while (sa.can_pull() && sb.can_pull()) { if (level_of(sa.peek()) == level_of(sb.peek())) { return false; } else if (level_of(sa.peek()) < level_of(sb.peek())) { @@ -89,16 +89,16 @@ namespace adiar::internal /// \brief Whether a certain level exists in a file. //////////////////////////////////////////////////////////////////////////// // TODO: Move to dd_func? - template + template bool - has_level(const DD &d, const typename DD::label_type x) + has_level(const DD& d, const typename DD::label_type x) { level_info_stream<> in_meta(d); - while(in_meta.can_pull()) { + while (in_meta.can_pull()) { level_info m = in_meta.pull(); // Are we already past where it should be? - if (x < m.label()) { return false; } + if (x < m.label()) { return false; } // Did we find it? if (m.label() == x) { return true; } @@ -121,14 +121,15 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////// template shared_levelized_file - transpose(const DD &d) + transpose(const DD& d) { adiar_assert(!d->is_terminal()); shared_levelized_file af; // Create the contents of 'af' - { arc_writer aw(af); + { + arc_writer aw(af); { // Split every node into their arcs. node_stream ns(d); while (ns.can_pull()) { @@ -143,9 +144,7 @@ namespace adiar::internal af->max_1level_cut = d->max_1level_cut[cut::Internal]; level_info_stream<> lis(d); - while (lis.can_pull()) { - aw << lis.pull(); - } + while (lis.can_pull()) { aw << lis.pull(); } } } diff --git a/src/adiar/statistics.cpp b/src/adiar/statistics.cpp index abb07d02d..0e6071004 100644 --- a/src/adiar/statistics.cpp +++ b/src/adiar/statistics.cpp @@ -3,13 +3,14 @@ #include #include + #include -#include #include #include #include #include #include +#include #include #include #include @@ -21,60 +22,61 @@ namespace adiar // statistics do not need to be recompiled every time an algorithm is // changed. - statistics statistics_get() + statistics + statistics_get() { #ifndef ADIAR_STATS std::cerr << "Statistics not gathered. Please compile with 'ADIAR_STATS'" << std::endl; #endif - return { - // i/o - internal::stats_arc_file, - internal::stats_node_file, + return { // i/o + internal::stats_arc_file, + internal::stats_node_file, - // data structures - internal::stats_levelized_priority_queue, + // data structures + internal::stats_levelized_priority_queue, - // top-down sweeps - internal::stats_count, - internal::stats_equality, - internal::stats_intercut, - internal::stats_prod2, - stats_prod3, - internal::stats_quantify, - internal::stats_select, + // top-down sweeps + internal::stats_count, + internal::stats_equality, + internal::stats_intercut, + internal::stats_prod2, + stats_prod3, + internal::stats_quantify, + internal::stats_select, - // bottom-up sweeps - internal::stats_reduce, + // bottom-up sweeps + internal::stats_reduce, - // other algorithms - internal::nested_sweeping::stats + // other algorithms + internal::nested_sweeping::stats }; } - void statistics_reset() + void + statistics_reset() { // i/o - internal::stats_arc_file = {}; - internal::stats_node_file = {}; + internal::stats_arc_file = {}; + internal::stats_node_file = {}; // data structures internal::stats_levelized_priority_queue = {}; // top-down sweeps - internal::stats_count = {}; - internal::stats_equality = {}; - internal::stats_intercut = {}; - internal::stats_prod2 = {}; - stats_prod3 = {}; - internal::stats_quantify = {}; - internal::stats_select = {}; + internal::stats_count = {}; + internal::stats_equality = {}; + internal::stats_intercut = {}; + internal::stats_prod2 = {}; + stats_prod3 = {}; + internal::stats_quantify = {}; + internal::stats_select = {}; // bottom-up sweeps - internal::stats_reduce = {}; + internal::stats_reduce = {}; // other algorithms - internal::nested_sweeping::stats = {}; + internal::nested_sweeping::stats = {}; } ////////////////////////////////////////////////////////////////////////////// @@ -87,17 +89,24 @@ namespace adiar const std::string bold_off = "\033[0m"; const std::string percent = "%"; - inline std::ostream& indent(std::ostream &os) - { return os << "| " << std::left << std::setw(2*indent_level) << ""; } + inline std::ostream& + indent(std::ostream& os) + { + return os << "| " << std::left << std::setw(2 * indent_level) << ""; + } - inline std::ostream& label(std::ostream &os) + inline std::ostream& + label(std::ostream& os) { constexpr int cell1_indent_level = 38; - return os << std::left << std::setw(cell1_indent_level - 2*indent_level); + return os << std::left << std::setw(cell1_indent_level - 2 * indent_level); } - inline std::ostream& endl(std::ostream &os) - { return os << '\n'; } + inline std::ostream& + endl(std::ostream& os) + { + return os << '\n'; + } ////////////////////////////////////////////////////////////////////////////// /// \brief Convert a wide integer to a string and push it to an output stream. @@ -108,20 +117,21 @@ namespace adiar /// of only this file until we have added `to_string()` functions to /// all basic data types. ////////////////////////////////////////////////////////////////////////////// - inline std::ostream& operator<< (std::ostream& os, const uintwide &s) + inline std::ostream& + operator<<(std::ostream& os, const uintwide& s) { return os << internal::to_string(s); } - void __printstat_arc_file(std::ostream &o) + void + __printstat_arc_file(std::ostream& o) { o << indent << bold_on << "Arc Files" << bold_off << endl; indent_level++; uintwide total_pushes = internal::stats_arc_file.push_internal - + internal::stats_arc_file.push_in_order - + internal::stats_arc_file.push_out_of_order; + + internal::stats_arc_file.push_in_order + internal::stats_arc_file.push_out_of_order; if (total_pushes == 0u) { o << indent << "No writes" << endl; @@ -132,22 +142,28 @@ namespace adiar o << indent << bold_on << label << "unsafe_push(arc ...)" << bold_off << total_pushes << endl; indent_level++; - o << indent << label << "internal" << internal::stats_arc_file.push_internal - << " = " << internal::percent_frac(internal::stats_arc_file.push_internal, total_pushes) << percent << endl; + o << indent << label << "internal" << internal::stats_arc_file.push_internal << " = " + << internal::percent_frac(internal::stats_arc_file.push_internal, total_pushes) << percent + << endl; o << indent << label << "terminals (in-order)" << internal::stats_arc_file.push_in_order - << " = " << internal::percent_frac(internal::stats_arc_file.push_in_order, total_pushes) << percent << endl; + << " = " << internal::percent_frac(internal::stats_arc_file.push_in_order, total_pushes) + << percent << endl; o << indent << label << "terminals (out-of-order)" << internal::stats_arc_file.push_out_of_order - << " = " << internal::percent_frac(internal::stats_arc_file.push_out_of_order, total_pushes) << percent << endl; + << " = " << internal::percent_frac(internal::stats_arc_file.push_out_of_order, total_pushes) + << percent << endl; indent_level--; - o << indent << bold_on << label << "push(level_info ...)" << bold_off << internal::stats_arc_file.push_level << endl; + o << indent << bold_on << label << "push(level_info ...)" << bold_off + << internal::stats_arc_file.push_level << endl; - o << indent << bold_on << label << "out-of-order sortings" << bold_off << internal::stats_arc_file.sort_out_of_order << endl; + o << indent << bold_on << label << "out-of-order sortings" << bold_off + << internal::stats_arc_file.sort_out_of_order << endl; indent_level--; } - void __printstat_node_file(std::ostream &o) + void + __printstat_node_file(std::ostream& o) { o << indent << bold_on << "Node Files" << bold_off << endl; @@ -169,7 +185,8 @@ namespace adiar indent_level--; } - void __printstat_lpq(std::ostream &o, const statistics::levelized_priority_queue_t& stats) + void + __printstat_lpq(std::ostream& o, const statistics::levelized_priority_queue_t& stats) { if (indent_level == 0) { o << indent << bold_on << "Levelized Priority Queue" << bold_off << endl; @@ -187,11 +204,10 @@ namespace adiar o << indent << bold_on << label << "push(...)" << bold_off << total_pushes << endl; indent_level++; - o << indent << label << "hit bucket" << stats.push_bucket - << " = " << internal::percent_frac(stats.push_bucket, total_pushes) << percent - << endl; - o << indent << label << "hit overflow" << stats.push_overflow - << " = " << internal::percent_frac(stats.push_overflow, total_pushes) << percent << endl; + o << indent << label << "hit bucket" << stats.push_bucket << " = " + << internal::percent_frac(stats.push_bucket, total_pushes) << percent << endl; + o << indent << label << "hit overflow" << stats.push_overflow << " = " + << internal::percent_frac(stats.push_overflow, total_pushes) << percent << endl; indent_level--; o << indent << endl; @@ -199,36 +215,35 @@ namespace adiar o << indent << bold_on << "prediction precision ratio" << bold_off << endl; indent_level++; - o << indent << label << "unweighted" - << stats.sum_max_size_ratio << " / " << stats.sum_destructors - << " = " << 100.0 * stats.sum_max_size_ratio / stats.sum_destructors << percent - << endl; + o << indent << label << "unweighted" << stats.sum_max_size_ratio << " / " + << stats.sum_destructors << " = " << 100.0 * stats.sum_max_size_ratio / stats.sum_destructors + << percent << endl; - o << indent << label << "weighted" - << stats.sum_actual_max_size << " / " << stats.sum_predicted_max_size - << " = " << internal::percent_frac(stats.sum_actual_max_size, stats.sum_predicted_max_size) << percent + o << indent << label << "weighted" << stats.sum_actual_max_size << " / " + << stats.sum_predicted_max_size << " = " + << internal::percent_frac(stats.sum_actual_max_size, stats.sum_predicted_max_size) << percent << endl; indent_level -= 2; } - - void __printstat_alg_base(std::ostream &o, const statistics::__alg_base& stats) + void + __printstat_alg_base(std::ostream& o, const statistics::__alg_base& stats) { o << indent << bold_on << "levelized priority queue" << bold_off << endl; - const uintwide total_lpqs = stats.lpq.total(); + const uintwide total_lpqs = stats.lpq.total(); const uintwide total_internal_lpqs = stats.lpq.unbucketed + stats.lpq.internal; indent_level++; - o << indent << label << "external memory" - << stats.lpq.external << " = " << internal::percent_frac(stats.lpq.external, total_lpqs) << percent << endl; + o << indent << label << "external memory" << stats.lpq.external << " = " + << internal::percent_frac(stats.lpq.external, total_lpqs) << percent << endl; - o << indent << label << "internal memory" - << total_internal_lpqs << " = " << internal::percent_frac(total_internal_lpqs, total_lpqs) << percent << endl; + o << indent << label << "internal memory" << total_internal_lpqs << " = " + << internal::percent_frac(total_internal_lpqs, total_lpqs) << percent << endl; - o << indent << label << " unbucketed" - << stats.lpq.unbucketed << " = " << internal::percent_frac(stats.lpq.unbucketed, total_internal_lpqs) << percent << endl; + o << indent << label << " unbucketed" << stats.lpq.unbucketed << " = " + << internal::percent_frac(stats.lpq.unbucketed, total_internal_lpqs) << percent << endl; indent_level--; @@ -237,8 +252,8 @@ namespace adiar __printstat_lpq(o, stats.lpq); } - - void __printstat_count(std::ostream &o) + void + __printstat_count(std::ostream& o) { uintwide total_runs = internal::stats_count.lpq.total(); o << indent << bold_on << label << "Count" << bold_off << total_runs << endl; @@ -254,8 +269,8 @@ namespace adiar indent_level--; } - - void __printstat_comparison_check(std::ostream &o) + void + __printstat_comparison_check(std::ostream& o) { uintwide total_runs = internal::stats_equality.lpq.total(); o << indent << bold_on << label << "Comparison Check" << bold_off << total_runs << endl; @@ -271,8 +286,8 @@ namespace adiar indent_level--; } - - void __printstat_intercut(std::ostream &o) + void + __printstat_intercut(std::ostream& o) { uintwide total_runs = internal::stats_intercut.lpq.total(); o << indent << bold_on << label << "Intercut" << bold_off << total_runs << endl; @@ -288,17 +303,14 @@ namespace adiar indent_level--; } - - void __printstat_isomorphism(std::ostream &o) + void + __printstat_isomorphism(std::ostream& o) { const uintwide total_runs = internal::stats_equality.exit_on_same_file - + internal::stats_equality.exit_on_nodecount - + internal::stats_equality.exit_on_varcount - + internal::stats_equality.exit_on_width - + internal::stats_equality.exit_on_terminalcount - + internal::stats_equality.exit_on_levels_mismatch - + internal::stats_equality.slow_check.runs - + internal::stats_equality.fast_check.runs; + + internal::stats_equality.exit_on_nodecount + internal::stats_equality.exit_on_varcount + + internal::stats_equality.exit_on_width + internal::stats_equality.exit_on_terminalcount + + internal::stats_equality.exit_on_levels_mismatch + internal::stats_equality.slow_check.runs + + internal::stats_equality.fast_check.runs; o << indent << bold_on << label << "Isomorphism Check" << bold_off << total_runs << endl; @@ -309,19 +321,17 @@ namespace adiar return; } - o << indent << bold_on << "execution trace" << bold_off << endl; + o << indent << bold_on << "execution trace" << bold_off << endl; indent_level++; o << indent << "O(1) termination cases" << endl; indent_level++; - o << indent << label << "same file" - << internal::stats_equality.exit_on_same_file << endl; - o << indent << label << "node count mismatch" - << internal::stats_equality.exit_on_nodecount << endl; - o << indent << label << "var count mismatch" - << internal::stats_equality.exit_on_varcount << endl; - o << indent << label << "width mismatch" - << internal::stats_equality.exit_on_width << endl; + o << indent << label << "same file" << internal::stats_equality.exit_on_same_file << endl; + o << indent << label << "node count mismatch" << internal::stats_equality.exit_on_nodecount + << endl; + o << indent << label << "var count mismatch" << internal::stats_equality.exit_on_varcount + << endl; + o << indent << label << "width mismatch" << internal::stats_equality.exit_on_width << endl; o << indent << label << "terminal count mismatch" << internal::stats_equality.exit_on_terminalcount << endl; indent_level--; @@ -336,8 +346,8 @@ namespace adiar o << indent << endl; - o << indent << label << "O(sort(N)) algorithm" - << internal::stats_equality.slow_check.runs << endl; + o << indent << label << "O(sort(N)) algorithm" << internal::stats_equality.slow_check.runs + << endl; indent_level++; o << indent << label << "local violation (root)" << internal::stats_equality.slow_check.exit_on_root << endl; @@ -349,11 +359,10 @@ namespace adiar o << indent << endl; - o << indent << label << "O(N/B) algorithm" - << internal::stats_equality.fast_check.runs << endl; + o << indent << label << "O(N/B) algorithm" << internal::stats_equality.fast_check.runs << endl; indent_level++; - o << indent << label << "node mismatch" - << internal::stats_equality.fast_check.exit_on_mismatch << endl; + o << indent << label << "node mismatch" << internal::stats_equality.fast_check.exit_on_mismatch + << endl; indent_level -= 2; @@ -366,15 +375,15 @@ namespace adiar indent_level -= 2; } - - void __printstat_prod2(std::ostream &o) + void + __printstat_prod2(std::ostream& o) { uintwide total_runs = internal::stats_prod2.trivial_file - + internal::stats_prod2.trivial_terminal - + internal::stats_prod2.ra.runs - + internal::stats_prod2.pq.runs; + + internal::stats_prod2.trivial_terminal + internal::stats_prod2.ra.runs + + internal::stats_prod2.pq.runs; - o << indent << bold_on << label << "Product Construction (2-ary)" << bold_off << total_runs << endl; + o << indent << bold_on << label << "Product Construction (2-ary)" << bold_off << total_runs + << endl; indent_level++; if (total_runs == 0u) { @@ -384,46 +393,39 @@ namespace adiar } o << indent << bold_on << label << "case [same file]" << bold_off - << internal::stats_prod2.trivial_file - << " = " << internal::percent_frac(internal::stats_prod2.trivial_file, total_runs) << percent - << endl; + << internal::stats_prod2.trivial_file << " = " + << internal::percent_frac(internal::stats_prod2.trivial_file, total_runs) << percent << endl; o << indent << endl; o << indent << bold_on << label << "case [terminal]" << bold_off - << internal::stats_prod2.trivial_terminal - << " = " << internal::percent_frac(internal::stats_prod2.trivial_terminal, total_runs) << percent + << internal::stats_prod2.trivial_terminal << " = " + << internal::percent_frac(internal::stats_prod2.trivial_terminal, total_runs) << percent << endl; o << indent << endl; o << indent << bold_on << label << "case [random access]" << bold_off - << internal::stats_prod2.ra.runs - << " = " << internal::percent_frac(internal::stats_prod2.ra.runs, total_runs) << percent - << endl; + << internal::stats_prod2.ra.runs << " = " + << internal::percent_frac(internal::stats_prod2.ra.runs, total_runs) << percent << endl; if (internal::stats_prod2.ra.runs > 0u) { indent_level++; - o << indent << label << "used narrowest:" - << internal::stats_prod2.ra.used_narrowest - << " = " << internal::percent_frac(internal::stats_prod2.ra.used_narrowest, internal::stats_prod2.ra.runs) << percent - << endl; + o << indent << label << "used narrowest:" << internal::stats_prod2.ra.used_narrowest << " = " + << internal::percent_frac(internal::stats_prod2.ra.used_narrowest, + internal::stats_prod2.ra.runs) + << percent << endl; o << indent << endl; o << indent << bold_on << label << "width:" << bold_off << endl; indent_level++; - o << indent << label << "minimum:" - << internal::stats_prod2.ra.min_width - << endl; + o << indent << label << "minimum:" << internal::stats_prod2.ra.min_width << endl; - o << indent << label << "maximum:" - << internal::stats_prod2.ra.max_width - << endl; + o << indent << label << "maximum:" << internal::stats_prod2.ra.max_width << endl; - o << indent << label << "accumulated:" - << internal::stats_prod2.ra.acc_width - << " (avg = " << internal::frac(internal::stats_prod2.ra.acc_width, internal::stats_prod2.ra.runs) << ")" + o << indent << label << "accumulated:" << internal::stats_prod2.ra.acc_width << " (avg = " + << internal::frac(internal::stats_prod2.ra.acc_width, internal::stats_prod2.ra.runs) << ")" << endl; indent_level -= 2; @@ -432,29 +434,26 @@ namespace adiar o << indent << endl; o << indent << bold_on << label << "case [priority queue]" << bold_off - << internal::stats_prod2.pq.runs - << " = " << internal::percent_frac(internal::stats_prod2.pq.runs, total_runs) << percent - << endl; + << internal::stats_prod2.pq.runs << " = " + << internal::percent_frac(internal::stats_prod2.pq.runs, total_runs) << percent << endl; if (internal::stats_prod2.pq.runs > 0u) { indent_level++; - o << indent << label << "pq2 elements:" - << internal::stats_prod2.pq.pq_2_elems - << endl; + o << indent << label << "pq2 elements:" << internal::stats_prod2.pq.pq_2_elems << endl; indent_level--; } - o << indent << endl; __printstat_alg_base(o, internal::stats_prod2); indent_level--; } - - void __printstat_prod3(std::ostream &o) + void + __printstat_prod3(std::ostream& o) { uintwide total_runs = stats_prod3.lpq.total(); - o << indent << bold_on << label << "Product Construction (3-ary)" << bold_off << total_runs << endl; + o << indent << bold_on << label << "Product Construction (3-ary)" << bold_off << total_runs + << endl; indent_level++; if (total_runs == 0u) { @@ -467,17 +466,14 @@ namespace adiar indent_level--; } - - void __printstat_quantify(std::ostream &o) + void + __printstat_quantify(std::ostream& o) { const uintwide total_runs = internal::stats_quantify.skipped - + internal::stats_quantify.singleton_sweeps - + internal::stats_quantify.partial_sweeps - + internal::stats_quantify.nested_sweeps; + + internal::stats_quantify.singleton_sweeps + internal::stats_quantify.partial_sweeps + + internal::stats_quantify.nested_sweeps; - o << indent << bold_on << label << "Quantification" << bold_off - << total_runs - << endl; + o << indent << bold_on << label << "Quantification" << bold_off << total_runs << endl; indent_level++; if (total_runs == 0u) { @@ -488,17 +484,16 @@ namespace adiar { o << indent << bold_on << label << "case [skipped]" << bold_off - << internal::stats_quantify.skipped - << " = " << internal::percent_frac(internal::stats_quantify.skipped, total_runs) << percent - << endl; + << internal::stats_quantify.skipped << " = " + << internal::percent_frac(internal::stats_quantify.skipped, total_runs) << percent << endl; } { o << indent << endl; o << indent << bold_on << label << "case [singleton sweep]" << bold_off - << internal::stats_quantify.singleton_sweeps - << " = " << internal::percent_frac(internal::stats_quantify.singleton_sweeps, total_runs) << percent + << internal::stats_quantify.singleton_sweeps << " = " + << internal::percent_frac(internal::stats_quantify.singleton_sweeps, total_runs) << percent << endl; } @@ -506,15 +501,13 @@ namespace adiar o << indent << endl; o << indent << bold_on << label << "case [partial sweep]" << bold_off - << internal::stats_quantify.partial_sweeps - << " = " << internal::percent_frac(internal::stats_quantify.partial_sweeps, total_runs) << percent + << internal::stats_quantify.partial_sweeps << " = " + << internal::percent_frac(internal::stats_quantify.partial_sweeps, total_runs) << percent << endl; indent_level++; - o << indent << label << "termination" - << internal::stats_quantify.partial_termination - << endl; + o << indent << label << "termination" << internal::stats_quantify.partial_termination << endl; indent_level--; } @@ -523,36 +516,34 @@ namespace adiar o << indent << endl; o << indent << bold_on << label << "case [nested sweep]" << bold_off - << internal::stats_quantify.nested_sweeps - << " = " << internal::percent_frac(internal::stats_quantify.nested_sweeps, total_runs) << percent + << internal::stats_quantify.nested_sweeps << " = " + << internal::percent_frac(internal::stats_quantify.nested_sweeps, total_runs) << percent << endl; indent_level++; const uintwide total_roots = internal::stats_quantify.nested_policy.shortcut_terminal - + internal::stats_quantify.nested_policy.shortcut_node - + internal::stats_quantify.nested_policy.products; + + internal::stats_quantify.nested_policy.shortcut_node + + internal::stats_quantify.nested_policy.products; - o << indent << label << "root requests" - << total_roots - << endl; + o << indent << label << "root requests" << total_roots << endl; indent_level++; o << indent << label << "shortcut (terminal)" - << internal::stats_quantify.nested_policy.shortcut_terminal - << " = " << internal::percent_frac(internal::stats_quantify.nested_policy.shortcut_terminal, total_roots) << percent - << endl; + << internal::stats_quantify.nested_policy.shortcut_terminal << " = " + << internal::percent_frac(internal::stats_quantify.nested_policy.shortcut_terminal, + total_roots) + << percent << endl; o << indent << label << "shortcut (node)" - << internal::stats_quantify.nested_policy.shortcut_node - << " = " << internal::percent_frac(internal::stats_quantify.nested_policy.shortcut_node, total_roots) << percent - << endl; + << internal::stats_quantify.nested_policy.shortcut_node << " = " + << internal::percent_frac(internal::stats_quantify.nested_policy.shortcut_node, total_roots) + << percent << endl; - o << indent << label << "products" - << internal::stats_quantify.nested_policy.products - << " = " << internal::percent_frac(internal::stats_quantify.nested_policy.products, total_roots) << percent - << endl; + o << indent << label << "products" << internal::stats_quantify.nested_policy.products << " = " + << internal::percent_frac(internal::stats_quantify.nested_policy.products, total_roots) + << percent << endl; indent_level -= 2; } @@ -562,28 +553,24 @@ namespace adiar o << indent << endl; { - o << indent << bold_on << label << "requests (excluding roots)" << bold_off - << endl; + o << indent << bold_on << label << "requests (excluding roots)" << bold_off << endl; indent_level++; { - const uintwide total_requests = internal::stats_quantify.requests[0] - + internal::stats_quantify.requests[1]; + const uintwide total_requests = + internal::stats_quantify.requests[0] + internal::stats_quantify.requests[1]; - o << indent << label << "incl. duplicates" - << total_requests - << endl; + o << indent << label << "incl. duplicates" << total_requests << endl; indent_level++; for (int arity_idx = 0; arity_idx < 2; ++arity_idx) { std::string t; - t += static_cast('1'+arity_idx); + t += static_cast('1' + arity_idx); t += "-ary"; - o << indent << label << t - << internal::stats_quantify.requests[arity_idx] - << " = " << internal::percent_frac(internal::stats_quantify.requests[arity_idx], total_requests) << percent - << endl; + o << indent << label << t << internal::stats_quantify.requests[arity_idx] << " = " + << internal::percent_frac(internal::stats_quantify.requests[arity_idx], total_requests) + << percent << endl; } indent_level--; } @@ -591,23 +578,21 @@ namespace adiar o << indent << endl; { - const uintwide total_unique = internal::stats_quantify.requests_unique[0] - + internal::stats_quantify.requests_unique[1]; + const uintwide total_unique = + internal::stats_quantify.requests_unique[0] + internal::stats_quantify.requests_unique[1]; - o << indent << label << "excl. duplicates" - << total_unique - << endl; + o << indent << label << "excl. duplicates" << total_unique << endl; indent_level++; for (int arity_idx = 0; arity_idx < 2; ++arity_idx) { std::string t; - t += static_cast('1'+arity_idx); + t += static_cast('1' + arity_idx); t += "-ary"; - o << indent << label << t - << internal::stats_quantify.requests_unique[arity_idx] - << " = " << internal::percent_frac(internal::stats_quantify.requests_unique[arity_idx], total_unique) << percent - << endl; + o << indent << label << t << internal::stats_quantify.requests_unique[arity_idx] << " = " + << internal::percent_frac(internal::stats_quantify.requests_unique[arity_idx], + total_unique) + << percent << endl; } indent_level--; } @@ -616,8 +601,8 @@ namespace adiar indent_level--; } - - void __printstat_select(std::ostream &o) + void + __printstat_select(std::ostream& o) { uintwide total_runs = internal::stats_select.lpq.total(); o << indent << bold_on << label << "Selection" << bold_off << total_runs << endl; @@ -633,8 +618,8 @@ namespace adiar indent_level--; } - - void __printstat_reduce(std::ostream &o, statistics::reduce_t &stats_struct = internal::stats_reduce) + void + __printstat_reduce(std::ostream& o, statistics::reduce_t& stats_struct = internal::stats_reduce) { const bool is_outer = indent_level == 0; if (is_outer) { @@ -651,36 +636,29 @@ namespace adiar } uintwide total_arcs = stats_struct.sum_node_arcs + stats_struct.sum_terminal_arcs; - o << indent << bold_on << label << "inputs size" << bold_off - << total_arcs << " arcs = " << total_arcs / 2 << " nodes" << endl; + o << indent << bold_on << label << "inputs size" << bold_off << total_arcs + << " arcs = " << total_arcs / 2 << " nodes" << endl; indent_level++; - o << indent << label << "node arcs:" - << stats_struct.sum_node_arcs - << " = " << internal::percent_frac(stats_struct.sum_node_arcs, total_arcs) << percent - << endl; + o << indent << label << "node arcs:" << stats_struct.sum_node_arcs << " = " + << internal::percent_frac(stats_struct.sum_node_arcs, total_arcs) << percent << endl; - o << indent << label << "terminal arcs:" - << stats_struct.sum_terminal_arcs - << " = " << internal::percent_frac(stats_struct.sum_terminal_arcs, total_arcs) << percent - << endl; + o << indent << label << "terminal arcs:" << stats_struct.sum_terminal_arcs << " = " + << internal::percent_frac(stats_struct.sum_terminal_arcs, total_arcs) << percent << endl; indent_level--; o << indent << endl; uintwide total_removed = stats_struct.removed_by_rule_1 + stats_struct.removed_by_rule_2; o << indent << bold_on << label << "nodes removed" << bold_off; if (total_removed > 0u) { - o << total_removed << " = " << internal::percent_frac(total_removed, total_arcs) << percent << endl; - indent_level++; - o << indent << label << "rule 1:" - << stats_struct.removed_by_rule_1 - << " = " << internal::percent_frac(stats_struct.removed_by_rule_1, total_removed) << percent + o << total_removed << " = " << internal::percent_frac(total_removed, total_arcs) << percent << endl; + indent_level++; + o << indent << label << "rule 1:" << stats_struct.removed_by_rule_1 << " = " + << internal::percent_frac(stats_struct.removed_by_rule_1, total_removed) << percent << endl; - o << indent << label << "rule 2:" - << stats_struct.removed_by_rule_2 - << " = " << internal::percent_frac(stats_struct.removed_by_rule_2, total_removed) << percent - << endl; + o << indent << label << "rule 2:" << stats_struct.removed_by_rule_2 << " = " + << internal::percent_frac(stats_struct.removed_by_rule_2, total_removed) << percent << endl; indent_level--; } else { o << "none" << endl; @@ -689,16 +667,14 @@ namespace adiar o << indent << endl; __printstat_alg_base(o, stats_struct); - if (is_outer) { - indent_level--; - } + if (is_outer) { indent_level--; } } - - void __printstat_nested_sweeping(std::ostream &o) + void + __printstat_nested_sweeping(std::ostream& o) { - const uintwide total_runs = internal::nested_sweeping::stats.skips - + internal::nested_sweeping::stats.runs; + const uintwide total_runs = + internal::nested_sweeping::stats.skips + internal::nested_sweeping::stats.runs; if (total_runs == 0u) { o << indent << "Not used" << endl; @@ -706,7 +682,7 @@ namespace adiar } o << indent << label << "skips" << internal::nested_sweeping::stats.skips << endl - << indent << label << "runs" << internal::nested_sweeping::stats.runs << endl; + << indent << label << "runs" << internal::nested_sweeping::stats.runs << endl; o << indent << endl; @@ -716,58 +692,57 @@ namespace adiar indent_level++; const uintwide total_nested = internal::nested_sweeping::stats.outer_up.nested_levels - + internal::nested_sweeping::stats.outer_up.skipped_nested_levels; + + internal::nested_sweeping::stats.outer_up.skipped_nested_levels; o << indent << bold_on << label << "nested levels" << bold_off << total_nested << endl; indent_level++; - o << indent << label << "executed" - << internal::nested_sweeping::stats.outer_up.nested_levels - << " = " << internal::percent_frac(internal::nested_sweeping::stats.outer_up.nested_levels, total_nested) << percent - << endl; + o << indent << label << "executed" << internal::nested_sweeping::stats.outer_up.nested_levels + << " = " + << internal::percent_frac(internal::nested_sweeping::stats.outer_up.nested_levels, + total_nested) + << percent << endl; - const uintwide unpruned_skipped = internal::nested_sweeping::stats.outer_up.skipped_nested_levels - - internal::nested_sweeping::stats.outer_up.skipped_nested_levels__prune; + const uintwide unpruned_skipped = + internal::nested_sweeping::stats.outer_up.skipped_nested_levels + - internal::nested_sweeping::stats.outer_up.skipped_nested_levels__prune; - o << indent << label << "skipped (non-pruning)" - << unpruned_skipped - << " = " << internal::percent_frac(unpruned_skipped, total_nested) << percent - << endl; + o << indent << label << "skipped (non-pruning)" << unpruned_skipped << " = " + << internal::percent_frac(unpruned_skipped, total_nested) << percent << endl; o << indent << label << "skipped (pruning)" - << internal::nested_sweeping::stats.outer_up.skipped_nested_levels__prune - << " = " << internal::percent_frac(internal::nested_sweeping::stats.outer_up.skipped_nested_levels__prune, total_nested) << percent - << endl; + << internal::nested_sweeping::stats.outer_up.skipped_nested_levels__prune << " = " + << internal::percent_frac( + internal::nested_sweeping::stats.outer_up.skipped_nested_levels__prune, total_nested) + << percent << endl; indent_level--; o << indent << endl; o << indent << bold_on << label << "collapse to terminal" << bold_off - << internal::nested_sweeping::stats.outer_up.collapse_to_terminal - << endl; + << internal::nested_sweeping::stats.outer_up.collapse_to_terminal << endl; o << indent << endl; o << indent << bold_on << label << "reduced levels" << bold_off - << internal::nested_sweeping::stats.outer_up.reduced_levels - << endl; + << internal::nested_sweeping::stats.outer_up.reduced_levels << endl; indent_level++; const uintwide canonical_levels = internal::nested_sweeping::stats.outer_up.reduced_levels - - internal::nested_sweeping::stats.outer_up.reduced_levels__fast; + - internal::nested_sweeping::stats.outer_up.reduced_levels__fast; o << indent << label << "canonical" - << internal::nested_sweeping::stats.outer_up.reduced_levels - << " = " << internal::percent_frac(canonical_levels, - internal::nested_sweeping::stats.outer_up.reduced_levels) << percent - << endl; + << internal::nested_sweeping::stats.outer_up.reduced_levels << " = " + << internal::percent_frac(canonical_levels, + internal::nested_sweeping::stats.outer_up.reduced_levels) + << percent << endl; o << indent << label << "fast" - << internal::nested_sweeping::stats.outer_up.reduced_levels__fast - << " = " << internal::percent_frac(internal::nested_sweeping::stats.outer_up.reduced_levels__fast, - internal::nested_sweeping::stats.outer_up.reduced_levels) << percent - << endl; + << internal::nested_sweeping::stats.outer_up.reduced_levels__fast << " = " + << internal::percent_frac(internal::nested_sweeping::stats.outer_up.reduced_levels__fast, + internal::nested_sweeping::stats.outer_up.reduced_levels) + << percent << endl; indent_level--; o << indent << endl; @@ -821,62 +796,56 @@ namespace adiar const uintwide total_arcs = internal::nested_sweeping::stats.inner_up.outer_arcs + internal::nested_sweeping::stats.inner_up.inner_arcs; - o << indent << bold_on << label << "output origin (arcs)" << bold_off - << total_arcs - << endl; + o << indent << bold_on << label << "output origin (arcs)" << bold_off << total_arcs << endl; indent_level++; - o << indent << label << "outer sweep" - << internal::nested_sweeping::stats.inner_up.outer_arcs - << " = " << internal::percent_frac(internal::nested_sweeping::stats.inner_up.outer_arcs, - total_arcs) << percent - << endl; + o << indent << label << "outer sweep" << internal::nested_sweeping::stats.inner_up.outer_arcs + << " = " + << internal::percent_frac(internal::nested_sweeping::stats.inner_up.outer_arcs, total_arcs) + << percent << endl; - o << indent << label << "inner sweep" - << internal::nested_sweeping::stats.inner_up.inner_arcs - << " = " << internal::percent_frac(internal::nested_sweeping::stats.inner_up.inner_arcs, - total_arcs) << percent - << endl; + o << indent << label << "inner sweep" << internal::nested_sweeping::stats.inner_up.inner_arcs + << " = " + << internal::percent_frac(internal::nested_sweeping::stats.inner_up.inner_arcs, total_arcs) + << percent << endl; indent_level--; o << indent << endl; const uintwide total_requests = internal::nested_sweeping::stats.inner_down.requests.terminals - + internal::nested_sweeping::stats.inner_down.requests.preserving - + internal::nested_sweeping::stats.inner_down.requests.modifying; + + internal::nested_sweeping::stats.inner_down.requests.preserving + + internal::nested_sweeping::stats.inner_down.requests.modifying; - o << indent << bold_on << label << "root requests" << bold_off - << total_requests - << endl; + o << indent << bold_on << label << "root requests" << bold_off << total_requests << endl; indent_level++; o << indent << label << "reduce rule 1" - << internal::nested_sweeping::stats.inner_down.removed_by_rule_1 - << " = " << internal::percent_frac(internal::nested_sweeping::stats.inner_down.removed_by_rule_1, - total_requests) << percent - << endl; + << internal::nested_sweeping::stats.inner_down.removed_by_rule_1 << " = " + << internal::percent_frac(internal::nested_sweeping::stats.inner_down.removed_by_rule_1, + total_requests) + << percent << endl; o << indent << endl; o << indent << label << "terminals" - << internal::nested_sweeping::stats.inner_down.requests.terminals - << " = " << internal::percent_frac(internal::nested_sweeping::stats.inner_down.requests.terminals, - total_requests) << percent - << endl; + << internal::nested_sweeping::stats.inner_down.requests.terminals << " = " + << internal::percent_frac(internal::nested_sweeping::stats.inner_down.requests.terminals, + total_requests) + << percent << endl; o << indent << label << "modifying" - << internal::nested_sweeping::stats.inner_down.requests.modifying - << " = " << internal::percent_frac(internal::nested_sweeping::stats.inner_down.requests.modifying, - total_requests) << percent - << endl; + << internal::nested_sweeping::stats.inner_down.requests.modifying << " = " + << internal::percent_frac(internal::nested_sweeping::stats.inner_down.requests.modifying, + total_requests) + << percent << endl; o << indent << label << "preserving" - << internal::nested_sweeping::stats.inner_down.requests.preserving - << " = " << internal::percent_frac(internal::nested_sweeping::stats.inner_down.requests.preserving, - total_requests) << percent - << endl; + << internal::nested_sweeping::stats.inner_down.requests.preserving << " = " + << internal::percent_frac(internal::nested_sweeping::stats.inner_down.requests.preserving, + total_requests) + << percent << endl; indent_level -= 2; } @@ -889,24 +858,23 @@ namespace adiar indent_level++; o << indent << bold_on << label << "reduced levels" << bold_off - << internal::nested_sweeping::stats.inner_up.reduced_levels - << endl; + << internal::nested_sweeping::stats.inner_up.reduced_levels << endl; indent_level++; const uintwide canonical_levels = internal::nested_sweeping::stats.inner_up.reduced_levels - - internal::nested_sweeping::stats.inner_up.reduced_levels__fast; + - internal::nested_sweeping::stats.inner_up.reduced_levels__fast; - o << indent << label << "canonical" - << canonical_levels - << " = " << internal::percent_frac(canonical_levels, internal::nested_sweeping::stats.inner_up.reduced_levels) << percent - << endl; + o << indent << label << "canonical" << canonical_levels << " = " + << internal::percent_frac(canonical_levels, + internal::nested_sweeping::stats.inner_up.reduced_levels) + << percent << endl; o << indent << label << "fast" - << internal::nested_sweeping::stats.inner_up.reduced_levels__fast - << " = " << internal::percent_frac(internal::nested_sweeping::stats.inner_up.reduced_levels__fast, - internal::nested_sweeping::stats.inner_up.reduced_levels) << percent - << endl; + << internal::nested_sweeping::stats.inner_up.reduced_levels__fast << " = " + << internal::percent_frac(internal::nested_sweeping::stats.inner_up.reduced_levels__fast, + internal::nested_sweeping::stats.inner_up.reduced_levels) + << percent << endl; indent_level--; @@ -918,8 +886,8 @@ namespace adiar } } - - void statistics_print(std::ostream &o) + void + statistics_print(std::ostream& o) { o << bold_on << "Adiar statistics" << bold_off << endl; o << endl; diff --git a/src/adiar/statistics.h b/src/adiar/statistics.h index c085d6db1..50bd840fb 100644 --- a/src/adiar/statistics.h +++ b/src/adiar/statistics.h @@ -12,8 +12,8 @@ /// `ON`. //////////////////////////////////////////////////////////////////////////////// -#include #include +#include #include @@ -171,7 +171,8 @@ namespace adiar //////////////////////////////////////////////////////////////////////// /// \brief Total number of levelized priority queues. //////////////////////////////////////////////////////////////////////// - uintwide total() const + uintwide + total() const { return unbucketed + internal + external; } @@ -189,7 +190,8 @@ namespace adiar /// \see bdd_satcount bdd_pathcount zdd_size //////////////////////////////////////////////////////////////////////////// struct count_t : public __alg_base - { } + { + } /// \copydoc count_t count; @@ -294,7 +296,8 @@ namespace adiar /// \see bdd_from zdd_change zdd_complement zdd_expand zdd_from //////////////////////////////////////////////////////////////////////////// struct intercut_t : public __alg_base - { } + { + } /// \copydoc intercut_t intercut; @@ -377,7 +380,8 @@ namespace adiar /// \see bdd_ite //////////////////////////////////////////////////////////////////////////// struct prod3_t : public __alg_base - { } + { + } /// \copydoc prod3_t prod3; @@ -432,8 +436,7 @@ namespace adiar /// \brief Number of recursions left for a product construction. //////////////////////////////////////////////////////////////////////// uintwide products = 0; - } - nested_policy; + } nested_policy; ////////////////////////////////////////////////////////////////////////// /// \brief Number of requests of arity 1 and 2. @@ -454,7 +457,8 @@ namespace adiar /// \see bdd_restrict zdd_onset zdd_offset //////////////////////////////////////////////////////////////////////////// struct select_t : public __alg_base - { } + { + } /// \copydoc select_t select; @@ -665,21 +669,24 @@ namespace adiar /// /// \copydoc statistics ////////////////////////////////////////////////////////////////////////////// - statistics statistics_get(); + statistics + statistics_get(); ////////////////////////////////////////////////////////////////////////////// /// \brief Print statistics to an output stream (default `std::cout`). /// /// \copydoc statistics ////////////////////////////////////////////////////////////////////////////// - void statistics_print(std::ostream &o = std::cout); + void + statistics_print(std::ostream& o = std::cout); ////////////////////////////////////////////////////////////////////////////// /// \brief Resets all statistics to default value. /// /// \see statistics ////////////////////////////////////////////////////////////////////////////// - void statistics_reset(); + void + statistics_reset(); /// \} ////////////////////////////////////////////////////////////////////////////// diff --git a/src/adiar/types.h b/src/adiar/types.h index 7c06f53b3..77b522297 100644 --- a/src/adiar/types.h +++ b/src/adiar/types.h @@ -19,17 +19,19 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// /// \brief A pair of values. ////////////////////////////////////////////////////////////////////////////// - template + template using pair = std::pair; ////////////////////////////////////////////////////////////////////////////// /// \brief Create an `adiar::pair`, deducing the target type based on the /// types of the arguments. ////////////////////////////////////////////////////////////////////////////// - template + template constexpr pair - make_pair(const T1 &t1, const T2 &t2) - { return std::make_pair(t1, t2); } + make_pair(const T1& t1, const T2& t2) + { + return std::make_pair(t1, t2); + } /* ////////////////////////////////////////////////////////////////////////////// @@ -48,24 +50,28 @@ namespace adiar /// \details Not having a value is for example used to indicate the end of /// streams and generators. ////////////////////////////////////////////////////////////////////////////// - template + template using optional = std::optional; ////////////////////////////////////////////////////////////////////////////// /// \brief Create an empty `adiar::optional`, i.e. *None*. ////////////////////////////////////////////////////////////////////////////// - template + template constexpr optional make_optional() - { return optional(); } + { + return optional(); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Create an `adiar::optional` with *Some* value. ////////////////////////////////////////////////////////////////////////////// - template + template constexpr optional - make_optional(const T &t) - { return std::make_optional(t); } + make_optional(const T& t) + { + return std::make_optional(t); + } /* ////////////////////////////////////////////////////////////////////////////// diff --git a/src/adiar/zdd.h b/src/adiar/zdd.h index 5ad9a5b15..48dec9881 100644 --- a/src/adiar/zdd.h +++ b/src/adiar/zdd.h @@ -16,12 +16,11 @@ #include #include +#include #include #include #include - #include -#include namespace adiar { @@ -45,17 +44,20 @@ namespace adiar /// /// \see zdd_empty zdd_null ////////////////////////////////////////////////////////////////////////////// - zdd zdd_terminal(bool value); + zdd + zdd_terminal(bool value); ////////////////////////////////////////////////////////////////////////////// /// \brief The empty family, i.e. Ø . ////////////////////////////////////////////////////////////////////////////// - zdd zdd_empty(); + zdd + zdd_empty(); ////////////////////////////////////////////////////////////////////////////// /// \brief The family only with the empty set, i.e. { Ø } . ////////////////////////////////////////////////////////////////////////////// - zdd zdd_null(); + zdd + zdd_null(); ////////////////////////////////////////////////////////////////////////////// /// \brief The set of bitvectors over a given domain where *var* is set to @@ -74,7 +76,8 @@ namespace adiar /// /// \throws invalid_argument If `dom` is not in \em descending order. ////////////////////////////////////////////////////////////////////////////// - zdd zdd_ithvar(zdd::label_type var, const generator &dom); + zdd + zdd_ithvar(zdd::label_type var, const generator& dom); ////////////////////////////////////////////////////////////////////////////// /// \brief The set of bitvectors over a given domain where *var* is set @@ -93,9 +96,12 @@ namespace adiar /// \throws invalid_argument If the iterator does not provide values in /// \em descending order. ////////////////////////////////////////////////////////////////////////////// - template - zdd zdd_ithvar(zdd::label_type var, ForwardIt begin, ForwardIt end) - { return zdd_ithvar(var, make_generator(begin, end)); } + template + zdd + zdd_ithvar(zdd::label_type var, ForwardIt begin, ForwardIt end) + { + return zdd_ithvar(var, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief The set of bitvectors over the globally set domain where *var* @@ -106,7 +112,8 @@ namespace adiar /// \pre `domain_isset() == true` and the variable `var` should /// occur in the global domain. ////////////////////////////////////////////////////////////////////////////// - zdd zdd_ithvar(zdd::label_type var); + zdd + zdd_ithvar(zdd::label_type var); ////////////////////////////////////////////////////////////////////////////// /// \brief The set of bitvectors over a given domain where *var* is set to @@ -125,7 +132,8 @@ namespace adiar /// /// \throws invalid_argument If `dom` is not in \em descending order. ////////////////////////////////////////////////////////////////////////////// - zdd zdd_nithvar(zdd::label_type var, const generator &dom); + zdd + zdd_nithvar(zdd::label_type var, const generator& dom); ////////////////////////////////////////////////////////////////////////////// /// \brief The set of bitvectors over a given domain where *var* is set @@ -144,9 +152,12 @@ namespace adiar /// \throws invalid_argument If the iterator does not provide values in /// \em descending order. ////////////////////////////////////////////////////////////////////////////// - template - zdd zdd_nithvar(zdd::label_type var, ForwardIt begin, ForwardIt end) - { return zdd_nithvar(var, make_generator(begin, end)); } + template + zdd + zdd_nithvar(zdd::label_type var, ForwardIt begin, ForwardIt end) + { + return zdd_nithvar(var, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief The set of bitvectors over the globally set domain where *var* @@ -157,7 +168,8 @@ namespace adiar /// \pre `domain_isset() == true` and the variable `var` should /// occur in the global domain. ////////////////////////////////////////////////////////////////////////////// - zdd zdd_nithvar(zdd::label_type var); + zdd + zdd_nithvar(zdd::label_type var); ////////////////////////////////////////////////////////////////////////////// /// \brief The family { { 1, 2, ..., k } }. @@ -170,7 +182,8 @@ namespace adiar /// /// \throws invalid_argument If `vars` are not in \em descending order. ////////////////////////////////////////////////////////////////////////////// - zdd zdd_vars(const generator &vars); + zdd + zdd_vars(const generator& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief The family { { 1, 2, ..., k } }. @@ -184,9 +197,12 @@ namespace adiar /// \throws invalid_argument If the iterator does not provide values in /// \em descending order. ////////////////////////////////////////////////////////////////////////////// - template - zdd zdd_vars(ForwardIt begin, ForwardIt end) - { return zdd_vars(make_generator(begin, end)); } + template + zdd + zdd_vars(ForwardIt begin, ForwardIt end) + { + return zdd_vars(make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief The family { { 1, 2, ..., k } } with a single bit-vector. @@ -199,7 +215,8 @@ namespace adiar /// /// \throws invalid_argument If `vars` are not in \em descending order. ////////////////////////////////////////////////////////////////////////////// - zdd zdd_point(const generator &vars); + zdd + zdd_point(const generator& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief The family { { 1, 2, ..., k } } with a single bit-vector. @@ -213,9 +230,12 @@ namespace adiar /// \throws invalid_argument If the iterator does not provide values in /// \em descending order. ////////////////////////////////////////////////////////////////////////////// - template - zdd zdd_point(ForwardIt begin, ForwardIt end) - { return zdd_point(make_generator(begin, end)); } + template + zdd + zdd_point(ForwardIt begin, ForwardIt end) + { + return zdd_point(make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief The family { {i} } . @@ -228,7 +248,8 @@ namespace adiar /// /// \throws invalid_argument If `var` is a too large value. ////////////////////////////////////////////////////////////////////////////// - zdd zdd_singleton(zdd::label_type var); + zdd + zdd_singleton(zdd::label_type var); ////////////////////////////////////////////////////////////////////////////// /// \brief The family { {1}, {2}, ..., {k} }. @@ -241,7 +262,8 @@ namespace adiar /// /// \throws invalid_argument If `vars` are not in \em descending order. ////////////////////////////////////////////////////////////////////////////// - zdd zdd_singletons(const generator &vars); + zdd + zdd_singletons(const generator& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief The family { {1}, {2}, ..., {k} }. @@ -255,9 +277,12 @@ namespace adiar /// \throws invalid_argument If the iterator does not provide values in /// \em descending order. ////////////////////////////////////////////////////////////////////////////// - template - zdd zdd_singletons(ForwardIt begin, ForwardIt end) - { return zdd_singletons(make_generator(begin, end)); } + template + zdd + zdd_singletons(ForwardIt begin, ForwardIt end) + { + return zdd_singletons(make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief The powerset of all given variables. @@ -270,7 +295,8 @@ namespace adiar /// /// \throws invalid_argument If `vars` are not in \em ascending order. ////////////////////////////////////////////////////////////////////////////// - zdd zdd_powerset(const generator &vars); + zdd + zdd_powerset(const generator& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief The powerset of all given variables. @@ -284,9 +310,12 @@ namespace adiar /// \throws invalid_argument If the iterator does not provide values in /// \em descending order. ////////////////////////////////////////////////////////////////////////////// - template - zdd zdd_powerset(ForwardIt begin, ForwardIt end) - { return zdd_powerset(make_generator(begin, end)); } + template + zdd + zdd_powerset(ForwardIt begin, ForwardIt end) + { + return zdd_powerset(make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Bottom of the powerset lattice. @@ -296,7 +325,8 @@ namespace adiar /// /// \see zdd_empty ////////////////////////////////////////////////////////////////////////////// - zdd zdd_bot(const generator &dom); + zdd + zdd_bot(const generator& dom); ////////////////////////////////////////////////////////////////////////////// /// \brief Bottom of the powerset lattice. @@ -309,16 +339,20 @@ namespace adiar /// /// \see zdd_empty ////////////////////////////////////////////////////////////////////////////// - template - inline zdd zdd_bot(ForwardIt begin, ForwardIt end) - { return zdd_bot(make_generator(begin, end)); } + template + inline zdd + zdd_bot(ForwardIt begin, ForwardIt end) + { + return zdd_bot(make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Bottom of the powerset lattice. /// /// \see zdd_empty ////////////////////////////////////////////////////////////////////////////// - zdd zdd_bot(); + zdd + zdd_bot(); ////////////////////////////////////////////////////////////////////////////// /// \brief Top of the powerset lattice. @@ -328,7 +362,8 @@ namespace adiar /// /// \see zdd_powerset, zdd_null ////////////////////////////////////////////////////////////////////////////// - zdd zdd_top(const generator &dom); + zdd + zdd_top(const generator& dom); ////////////////////////////////////////////////////////////////////////////// /// \brief Top of the powerset lattice. @@ -341,9 +376,12 @@ namespace adiar /// /// \see zdd_empty ////////////////////////////////////////////////////////////////////////////// - template - inline zdd zdd_top(ForwardIt begin, ForwardIt end) - { return zdd_top(make_generator(begin, end)); } + template + inline zdd + zdd_top(ForwardIt begin, ForwardIt end) + { + return zdd_top(make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Top of the powerset lattice. @@ -353,7 +391,8 @@ namespace adiar /// /// \see zdd_powerset, zdd_null ////////////////////////////////////////////////////////////////////////////// - zdd zdd_top(); + zdd + zdd_top(); /// \} ////////////////////////////////////////////////////////////////////////////// @@ -374,15 +413,14 @@ namespace adiar /// \return Product construction of the two that represents the boolean /// operator applied to the two family of sets. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_binop(const zdd &A, const zdd &B, const bool_op &op); + __zdd + zdd_binop(const zdd& A, const zdd& B, const bool_op& op); ////////////////////////////////////////////////////////////////////////////// /// \brief Apply a binary operator between the sets of two families. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_binop(const exec_policy &ep, - const zdd &A, - const zdd &B, - const bool_op &op); + __zdd + zdd_binop(const exec_policy& ep, const zdd& A, const zdd& B, const bool_op& op); ////////////////////////////////////////////////////////////////////////////// /// \brief The union of two families of sets. @@ -390,22 +428,28 @@ namespace adiar /// \returns /// \f$ A \cup B \f$ ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_union(const zdd &A, const zdd &B); + __zdd + zdd_union(const zdd& A, const zdd& B); ////////////////////////////////////////////////////////////////////////////// /// \brief The union of two families of sets. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_union(const exec_policy &ep, const zdd &A, const zdd &B); + __zdd + zdd_union(const exec_policy& ep, const zdd& A, const zdd& B); ////////////////////////////////////////////////////////////////////////////// /// \see zdd_union ////////////////////////////////////////////////////////////////////////////// - __zdd operator| (const zdd &lhs, const zdd &rhs); + __zdd + operator|(const zdd& lhs, const zdd& rhs); /// \cond - __zdd operator| (__zdd &&, __zdd &&); - __zdd operator| (const zdd &, __zdd &&); - __zdd operator| (__zdd &&, const zdd &); + __zdd + operator|(__zdd&&, __zdd&&); + __zdd + operator|(const zdd&, __zdd&&); + __zdd + operator|(__zdd&&, const zdd&); /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -414,22 +458,28 @@ namespace adiar /// \returns /// \f$ A \cap B \f$ ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_intsec(const zdd &A, const zdd &B); + __zdd + zdd_intsec(const zdd& A, const zdd& B); ////////////////////////////////////////////////////////////////////////////// /// \brief The intersection of two families of sets. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_intsec(const exec_policy &ep, const zdd &A, const zdd &B); + __zdd + zdd_intsec(const exec_policy& ep, const zdd& A, const zdd& B); ////////////////////////////////////////////////////////////////////////////// /// \see zdd_intsec ////////////////////////////////////////////////////////////////////////////// - __zdd operator& (const zdd &lhs, const zdd &rhs); + __zdd + operator&(const zdd& lhs, const zdd& rhs); /// \cond - __zdd operator& (__zdd &&, __zdd &&); - __zdd operator& (const zdd &, __zdd &&); - __zdd operator& (__zdd &&, const __zdd &); + __zdd + operator&(__zdd&&, __zdd&&); + __zdd + operator&(const zdd&, __zdd&&); + __zdd + operator&(__zdd&&, const __zdd&); /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -438,22 +488,28 @@ namespace adiar /// \returns /// \f$ A \setminus B \f$ ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_diff(const zdd &A, const zdd &B); + __zdd + zdd_diff(const zdd& A, const zdd& B); ////////////////////////////////////////////////////////////////////////////// /// \brief The set difference of two families of sets. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_diff(const exec_policy &ep, const zdd &A, const zdd &B); + __zdd + zdd_diff(const exec_policy& ep, const zdd& A, const zdd& B); ////////////////////////////////////////////////////////////////////////////// /// \see zdd_diff ////////////////////////////////////////////////////////////////////////////// - __zdd operator- (const zdd &lhs, const zdd &rhs); + __zdd + operator-(const zdd& lhs, const zdd& rhs); /// \cond - __zdd operator- (__zdd &&, __zdd &&); - __zdd operator- (const zdd &, __zdd &&); - __zdd operator- (__zdd &&, const zdd &); + __zdd + operator-(__zdd&&, __zdd&&); + __zdd + operator-(const zdd&, __zdd&&); + __zdd + operator-(__zdd&&, const zdd&); /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -468,15 +524,15 @@ namespace adiar /// \returns /// \f$ \{ \mathit{vars} \Delta a \mid a \in A \} \f$ ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_change(const zdd &A, const generator &vars); + __zdd + zdd_change(const zdd& A, const generator& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief The symmetric difference between each set in the family and the /// given set of variables. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_change(const exec_policy &ep, - const zdd &A, - const generator &vars); + __zdd + zdd_change(const exec_policy& ep, const zdd& A, const generator& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief The symmetric difference between each set in the family and @@ -493,20 +549,23 @@ namespace adiar /// \returns /// \f$ \{ \mathit{vars} \Delta a \mid a \in A \} \f$ ////////////////////////////////////////////////////////////////////////////// - template - __zdd zdd_change(const zdd &A, ForwardIt begin, ForwardIt end) - { return zdd_change(A, make_generator(begin, end)); } + template + __zdd + zdd_change(const zdd& A, ForwardIt begin, ForwardIt end) + { + return zdd_change(A, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief The symmetric difference between each set in the family and the /// given set of variables. ////////////////////////////////////////////////////////////////////////////// - template - __zdd zdd_change(const exec_policy &ep, - const zdd &A, - ForwardIt begin, - ForwardIt end) - { return zdd_change(ep, A, make_generator(begin, end)); } + template + __zdd + zdd_change(const exec_policy& ep, const zdd& A, ForwardIt begin, ForwardIt end) + { + return zdd_change(ep, A, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Complement of A within the given domain. @@ -517,14 +576,14 @@ namespace adiar /// /// \returns \f$ 2^{\mathit{dom}} \setminus A \f$ ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_complement(const zdd &A, const generator &dom); + __zdd + zdd_complement(const zdd& A, const generator& dom); ////////////////////////////////////////////////////////////////////////////// /// \brief Complement of A within the given domain. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_complement(const exec_policy& ep, - const zdd &A, - const generator &dom); + __zdd + zdd_complement(const exec_policy& ep, const zdd& A, const generator& dom); ////////////////////////////////////////////////////////////////////////////// /// \brief Complement of A within the given domain. @@ -539,19 +598,22 @@ namespace adiar /// /// \returns \f$ 2^{\mathit{dom}} \setminus A \f$ ////////////////////////////////////////////////////////////////////////////// - template - __zdd zdd_complement(const zdd &A, ForwardIt begin, ForwardIt end) - { return zdd_complement(A, make_generator(begin, end)); } + template + __zdd + zdd_complement(const zdd& A, ForwardIt begin, ForwardIt end) + { + return zdd_complement(A, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Complement of A within the given domain. ////////////////////////////////////////////////////////////////////////////// - template - __zdd zdd_complement(const exec_policy &ep, - const zdd &A, - ForwardIt begin, - ForwardIt end) - { return zdd_complement(ep, A, make_generator(begin, end)); } + template + __zdd + zdd_complement(const exec_policy& ep, const zdd& A, ForwardIt begin, ForwardIt end) + { + return zdd_complement(ep, A, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Complement of A within the global \ref module__domain @@ -565,20 +627,24 @@ namespace adiar /// \pre The global \ref module__domain is set to a set of variables /// that is equals to or a superset of the variables in `A`. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_complement(const zdd &A); + __zdd + zdd_complement(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Complement of A within the global \ref module__domain ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_complement(const exec_policy& ep, const zdd &A); + __zdd + zdd_complement(const exec_policy& ep, const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \see zdd_complement ////////////////////////////////////////////////////////////////////////////// - __zdd operator~ (const zdd& A); + __zdd + operator~(const zdd& A); /// \cond - __zdd operator~ (__zdd&& A); + __zdd + operator~(__zdd&& A); /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -598,15 +664,15 @@ namespace adiar /// \returns /// \f$ \bigcup_{a \in A, i \in 2^{vars}} (a \cup i) \f$ ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_expand(const zdd &A, const generator &vars); + __zdd + zdd_expand(const zdd& A, const generator& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief Expands the domain of the given ZDD to also include the given set /// of labels. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_expand(const exec_policy &ep, - const zdd &A, - const generator &vars); + __zdd + zdd_expand(const exec_policy& ep, const zdd& A, const generator& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief Expands the domain of the given ZDD to also include the given @@ -627,19 +693,23 @@ namespace adiar /// /// \see zdd_project ////////////////////////////////////////////////////////////////////////////// - template - __zdd zdd_expand(const zdd &A, ForwardIt begin, ForwardIt end) - { return zdd_expand(A, make_generator(begin, end)); } + template + __zdd + zdd_expand(const zdd& A, ForwardIt begin, ForwardIt end) + { + return zdd_expand(A, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Expands the domain of the given ZDD to also include the given set /// of labels. ////////////////////////////////////////////////////////////////////////////// - template - __zdd zdd_expand(const exec_policy &ep, - const zdd &A, - ForwardIt begin, ForwardIt end) - { return zdd_expand(ep, A, make_generator(begin, end)); } + template + __zdd + zdd_expand(const exec_policy& ep, const zdd& A, ForwardIt begin, ForwardIt end) + { + return zdd_expand(ep, A, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Subset that do \em not include the given element. @@ -651,12 +721,14 @@ namespace adiar /// \returns /// \f$ \{ a \in A \mid \mathit{var} \not\in a \} \f$ ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_offset(const zdd &A, zdd::label_type var); + __zdd + zdd_offset(const zdd& A, zdd::label_type var); ////////////////////////////////////////////////////////////////////////////// /// \brief Subset that do \em not include the given element. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_offset(const exec_policy &ep, const zdd &A, zdd::label_type var); + __zdd + zdd_offset(const exec_policy& ep, const zdd& A, zdd::label_type var); ////////////////////////////////////////////////////////////////////////////// /// \brief Subset that do \em not include the top variable. @@ -669,12 +741,14 @@ namespace adiar /// /// \throws invalid_argument If `A` is a terminal. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_offset(const zdd &A); + __zdd + zdd_offset(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Subset that do \em not include the top variable. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_offset(const exec_policy &ep, const zdd &A); + __zdd + zdd_offset(const exec_policy& ep, const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Subset that do \em not include the given set of variables. @@ -688,14 +762,14 @@ namespace adiar /// \returns /// \f$ \{ a \in A \mid \forall i \in \mathit{vars} : i \not\in a \} \f$ ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_offset(const zdd &A, const generator &vars); + __zdd + zdd_offset(const zdd& A, const generator& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief Subset that do \em not include the given set of variables. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_offset(const exec_policy &ep, - const zdd &A, - const generator &vars); + __zdd + zdd_offset(const exec_policy& ep, const zdd& A, const generator& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief Subset that do \em not include the given set of variables. @@ -711,19 +785,22 @@ namespace adiar /// \returns /// \f$ \{ a \in A \mid \forall i \in \mathit{vars} : i \not\in a \} \f$ ////////////////////////////////////////////////////////////////////////////// - template - __zdd zdd_offset(const zdd &A, ForwardIt begin, ForwardIt end) - { return zdd_offset(A, make_generator(begin, end)); } + template + __zdd + zdd_offset(const zdd& A, ForwardIt begin, ForwardIt end) + { + return zdd_offset(A, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Subset that do \em not include the given set of variables. ////////////////////////////////////////////////////////////////////////////// - template - __zdd zdd_offset(const exec_policy &ep, - const zdd &A, - ForwardIt begin, - ForwardIt end) - { return zdd_offset(ep, A, make_generator(begin, end)); } + template + __zdd + zdd_offset(const exec_policy& ep, const zdd& A, ForwardIt begin, ForwardIt end) + { + return zdd_offset(ep, A, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Subset that \em do include the given element. @@ -734,12 +811,14 @@ namespace adiar /// \returns /// \f$ \{ a \in A \mid \mathit{var} \in a \} \f$ ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_onset(const zdd &A, zdd::label_type var); + __zdd + zdd_onset(const zdd& A, zdd::label_type var); ////////////////////////////////////////////////////////////////////////////// /// \brief Subset that \em do include the given element. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_onset(const exec_policy &ep, const zdd &A, zdd::label_type var); + __zdd + zdd_onset(const exec_policy& ep, const zdd& A, zdd::label_type var); ////////////////////////////////////////////////////////////////////////////// /// \brief Subset that \em do include the top variable. @@ -752,12 +831,14 @@ namespace adiar /// /// \throws invalid_argument If `A` is a terminal. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_onset(const zdd &A); + __zdd + zdd_onset(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Subset that \em do include the top variable. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_onset(const exec_policy &ep, const zdd &A); + __zdd + zdd_onset(const exec_policy& ep, const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Subset that \em do include the given set of variables. @@ -771,14 +852,14 @@ namespace adiar /// \returns /// \f$ \{ a \in A \mid \forall i \in \mathit{vars} : i \in a \} \f$ ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_onset(const zdd &A, const generator &vars); + __zdd + zdd_onset(const zdd& A, const generator& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief Subset that \em do include the given set of variables. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_onset(const exec_policy &ep, - const zdd &A, - const generator &vars); + __zdd + zdd_onset(const exec_policy& ep, const zdd& A, const generator& vars); ////////////////////////////////////////////////////////////////////////////// /// \brief Subset that \em do include the given set of variables. @@ -794,19 +875,22 @@ namespace adiar /// \returns /// \f$ \{ a \in A \mid \forall i \in \mathit{vars} : i \in a \} \f$ ////////////////////////////////////////////////////////////////////////////// - template - __zdd zdd_onset(const zdd &A, ForwardIt begin, ForwardIt end) - { return zdd_onset(A, make_generator(begin, end)); } + template + __zdd + zdd_onset(const zdd& A, ForwardIt begin, ForwardIt end) + { + return zdd_onset(A, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Subset that \em do include the given set of variables. ////////////////////////////////////////////////////////////////////////////// - template - __zdd zdd_onset(const exec_policy &ep, - const zdd &A, - ForwardIt begin, - ForwardIt end) - { return zdd_onset(ep, A, make_generator(begin, end)); } + template + __zdd + zdd_onset(const exec_policy& ep, const zdd& A, ForwardIt begin, ForwardIt end) + { + return zdd_onset(ep, A, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Project family of sets onto a domain, i.e. remove from every @@ -821,24 +905,24 @@ namespace adiar /// /// \see zdd_expand ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_project(const zdd &A, const predicate &dom); + __zdd + zdd_project(const zdd& A, const predicate& dom); /// \cond - __zdd zdd_project(zdd &&A, const predicate &dom); + __zdd + zdd_project(zdd&& A, const predicate& dom); /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \brief Project family of sets onto a domain, i.e. remove from every /// set all variables not within the domain. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_project(const exec_policy &ep, - const zdd &A, - const predicate &dom); + __zdd + zdd_project(const exec_policy& ep, const zdd& A, const predicate& dom); /// \cond - __zdd zdd_project(const exec_policy &ep, - zdd &&A, - const predicate &dom); + __zdd + zdd_project(const exec_policy& ep, zdd&& A, const predicate& dom); /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -855,24 +939,25 @@ namespace adiar /// /// \see zdd_expand ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_project(const zdd &A, const generator &dom); + __zdd + zdd_project(const zdd& A, const generator& dom); /// \cond - __zdd zdd_project(zdd &&A, const generator &dom); + __zdd + zdd_project(zdd&& A, const generator& dom); /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \brief Project family of sets onto a domain, i.e. remove from every /// set all variables not within the domain. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_project(const exec_policy &ep, - const zdd &A, - const generator &dom); + __zdd + zdd_project(const exec_policy& ep, const zdd& A, const generator& dom); /// \cond - __zdd zdd_project(const exec_policy &ep, - zdd &&A, - const generator &dom); + __zdd + zdd_project(const exec_policy& ep, zdd&& A, const generator& dom); + /// \endcond ////////////////////////////////////////////////////////////////////////////// @@ -892,34 +977,42 @@ namespace adiar /// /// \see zdd_expand ////////////////////////////////////////////////////////////////////////////// - template - __zdd zdd_project(const zdd &A, ForwardIt begin, ForwardIt end) - { return zdd_project(A, make_generator(begin, end)); } + template + __zdd + zdd_project(const zdd& A, ForwardIt begin, ForwardIt end) + { + return zdd_project(A, make_generator(begin, end)); + } /// \cond - template - __zdd zdd_project(zdd &&A, ForwardIt begin, ForwardIt end) - { return zdd_project(std::forward(A), make_generator(begin, end)); } + template + __zdd + zdd_project(zdd&& A, ForwardIt begin, ForwardIt end) + { + return zdd_project(std::forward(A), make_generator(begin, end)); + } + /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \brief Project family of sets onto a domain, i.e. remove from every /// set all variables not within the domain. ////////////////////////////////////////////////////////////////////////////// - template - __zdd zdd_project(const exec_policy &ep, - const zdd &A, - ForwardIt begin, - ForwardIt end) - { return zdd_project(ep, A, make_generator(begin, end)); } + template + __zdd + zdd_project(const exec_policy& ep, const zdd& A, ForwardIt begin, ForwardIt end) + { + return zdd_project(ep, A, make_generator(begin, end)); + } /// \cond - template - __zdd zdd_project(const exec_policy &ep, - zdd &&A, - ForwardIt begin, - ForwardIt end) - { return zdd_project(ep, std::forward(A), make_generator(begin, end)); } + template + __zdd + zdd_project(const exec_policy& ep, zdd&& A, ForwardIt begin, ForwardIt end) + { + return zdd_project(ep, std::forward(A), make_generator(begin, end)); + } + /// \endcond /// \} @@ -935,153 +1028,194 @@ namespace adiar /// /// \copydetails adiar::internal::dd_iscanonical ////////////////////////////////////////////////////////////////////////////// - bool zdd_iscanonical(const zdd& A); + bool + zdd_iscanonical(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether this ZDD represents a terminal. ////////////////////////////////////////////////////////////////////////////// - bool zdd_isterminal(const zdd& A); + bool + zdd_isterminal(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether this ZDD represents false terminal. ////////////////////////////////////////////////////////////////////////////// - bool zdd_isfalse(const zdd& A); + bool + zdd_isfalse(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether it is the empty family, i.e. Ø . ////////////////////////////////////////////////////////////////////////////// - bool zdd_isempty(const zdd &A); + bool + zdd_isempty(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether this BDD represents true terminal. ////////////////////////////////////////////////////////////////////////////// - bool zdd_istrue(const zdd& A); + bool + zdd_istrue(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether it is the null family, i.e. { Ø } . ////////////////////////////////////////////////////////////////////////////// - bool zdd_isnull(const zdd &A); + bool + zdd_isnull(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether it contains a single bit-vector `a`, i.e. A = { a }. ////////////////////////////////////////////////////////////////////////////// - bool zdd_ispoint(const zdd &A); + bool + zdd_ispoint(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether they represent the same family. ////////////////////////////////////////////////////////////////////////////// - bool zdd_equal(const zdd &A, const zdd &B); + bool + zdd_equal(const zdd& A, const zdd& B); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether they represent the same family. ////////////////////////////////////////////////////////////////////////////// - bool zdd_equal(const exec_policy &ep, const zdd &A, const zdd &B); + bool + zdd_equal(const exec_policy& ep, const zdd& A, const zdd& B); ////////////////////////////////////////////////////////////////////////////// /// \see zdd_equal ////////////////////////////////////////////////////////////////////////////// - bool operator== (const zdd& lhs, const zdd& rhs); + bool + operator==(const zdd& lhs, const zdd& rhs); /// \cond - bool operator== (__zdd &&, __zdd &&); - bool operator== (const zdd &, __zdd &&); - bool operator== (__zdd &&, const zdd &); + bool + operator==(__zdd&&, __zdd&&); + bool + operator==(const zdd&, __zdd&&); + bool + operator==(__zdd&&, const zdd&); /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \brief Whether they represent two different families. ////////////////////////////////////////////////////////////////////////////// - bool zdd_unequal(const zdd &A, const zdd &B); + bool + zdd_unequal(const zdd& A, const zdd& B); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether they represent two different families. ////////////////////////////////////////////////////////////////////////////// - bool zdd_unequal(const exec_policy &ep, const zdd &A, const zdd &B); + bool + zdd_unequal(const exec_policy& ep, const zdd& A, const zdd& B); ////////////////////////////////////////////////////////////////////////////// /// \see zdd_unequal ////////////////////////////////////////////////////////////////////////////// - bool operator!= (const zdd& lhs, const zdd& rhs); + bool + operator!=(const zdd& lhs, const zdd& rhs); /// \cond - bool operator!= (__zdd &&, __zdd &&); - bool operator!= (const zdd &, __zdd &&); - bool operator!= (__zdd &&, const zdd &); + bool + operator!=(__zdd&&, __zdd&&); + bool + operator!=(const zdd&, __zdd&&); + bool + operator!=(__zdd&&, const zdd&); /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \brief Whether one family is a subset or equal to the other. ////////////////////////////////////////////////////////////////////////////// - bool zdd_subseteq(const zdd &A, const zdd &B); + bool + zdd_subseteq(const zdd& A, const zdd& B); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether one family is a subset or equal to the other. ////////////////////////////////////////////////////////////////////////////// - bool zdd_subseteq(const exec_policy &ep, const zdd &A, const zdd &B); + bool + zdd_subseteq(const exec_policy& ep, const zdd& A, const zdd& B); ////////////////////////////////////////////////////////////////////////////// /// \see zdd_subseteq ////////////////////////////////////////////////////////////////////////////// - bool operator<= (const zdd& lhs, const zdd& rhs); + bool + operator<=(const zdd& lhs, const zdd& rhs); /// \cond - bool operator<= (__zdd &&, __zdd &&); - bool operator<= (const zdd &, __zdd &&); - bool operator<= (__zdd &&, const zdd &); + bool + operator<=(__zdd&&, __zdd&&); + bool + operator<=(const zdd&, __zdd&&); + bool + operator<=(__zdd&&, const zdd&); /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \see zdd_subseteq ////////////////////////////////////////////////////////////////////////////// - bool operator>= (const zdd& lhs, const zdd& rhs); + bool + operator>=(const zdd& lhs, const zdd& rhs); /// \cond - bool operator>= (__zdd &&, __zdd &&); - bool operator>= (const zdd &, __zdd &&); - bool operator>= (__zdd &&, const zdd &); + bool + operator>=(__zdd&&, __zdd&&); + bool + operator>=(const zdd&, __zdd&&); + bool + operator>=(__zdd&&, const zdd&); /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \brief Whether one family is a strict subset of the other. ////////////////////////////////////////////////////////////////////////////// - bool zdd_subset(const zdd &A, const zdd &B); + bool + zdd_subset(const zdd& A, const zdd& B); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether one family is a strict subset of the other. ////////////////////////////////////////////////////////////////////////////// - bool zdd_subset(const exec_policy &ep, const zdd &A, const zdd &B); + bool + zdd_subset(const exec_policy& ep, const zdd& A, const zdd& B); ////////////////////////////////////////////////////////////////////////////// /// \see zdd_subset ////////////////////////////////////////////////////////////////////////////// - bool operator< (const zdd& lhs, const zdd& rhs); + bool + operator<(const zdd& lhs, const zdd& rhs); /// \cond - bool operator< (__zdd &&, __zdd &&); - bool operator< (const zdd &, __zdd &&); - bool operator< (__zdd &&, const zdd &); + bool + operator<(__zdd&&, __zdd&&); + bool + operator<(const zdd&, __zdd&&); + bool + operator<(__zdd&&, const zdd&); /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \see zdd_subset ////////////////////////////////////////////////////////////////////////////// - bool operator> (const zdd& lhs, const zdd& rhs); + bool + operator>(const zdd& lhs, const zdd& rhs); /// \cond - bool operator> (__zdd &&, __zdd &&); - bool operator> (const zdd &, __zdd &&); - bool operator> (__zdd &&, const zdd &); + bool + operator>(__zdd&&, __zdd&&); + bool + operator>(const zdd&, __zdd&&); + bool + operator>(__zdd&&, const zdd&); /// \endcond ////////////////////////////////////////////////////////////////////////////// /// \brief Whether the two families are disjoint. ////////////////////////////////////////////////////////////////////////////// - bool zdd_disjoint(const zdd &A, const zdd &B); + bool + zdd_disjoint(const zdd& A, const zdd& B); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether the two families are disjoint. ////////////////////////////////////////////////////////////////////////////// - bool zdd_disjoint(const exec_policy &ep, const zdd &A, const zdd &B); + bool + zdd_disjoint(const exec_policy& ep, const zdd& A, const zdd& B); /// \} ////////////////////////////////////////////////////////////////////////////// @@ -1095,23 +1229,27 @@ namespace adiar /// \brief The number of (internal) nodes used to represent the family of /// sets. ////////////////////////////////////////////////////////////////////////////// - size_t zdd_nodecount(const zdd &A); + size_t + zdd_nodecount(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief The number of variables that exist in the family of sets, i.e. the /// number of levels in the ZDD. ////////////////////////////////////////////////////////////////////////////// - zdd::label_type zdd_varcount(const zdd &A); + zdd::label_type + zdd_varcount(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief The number of sets in the family of sets. ////////////////////////////////////////////////////////////////////////////// - uint64_t zdd_size(const zdd &A); + uint64_t + zdd_size(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief The number of sets in the family of sets. ////////////////////////////////////////////////////////////////////////////// - uint64_t zdd_size(const exec_policy &ep, const zdd &A); + uint64_t + zdd_size(const exec_policy& ep, const zdd& A); /// \} ////////////////////////////////////////////////////////////////////////////// @@ -1129,7 +1267,8 @@ namespace adiar /// /// \param cb Callback function that consumes the variable labels. ////////////////////////////////////////////////////////////////////////////// - void zdd_support(const zdd &A, const consumer &cb); + void + zdd_support(const zdd& A, const consumer& cb); ////////////////////////////////////////////////////////////////////////////// /// \brief Copy all of the variable labels (in \em ascending order) that occur @@ -1146,8 +1285,9 @@ namespace adiar /// \throws out_of_range If the distance between `begin` and `end` is not big /// enough to contain all variables in `f`. ////////////////////////////////////////////////////////////////////////////// - template - ForwardIt zdd_support(const zdd &A, ForwardIt begin, ForwardIt end) + template + ForwardIt + zdd_support(const zdd& A, ForwardIt begin, ForwardIt end) { zdd_support(A, make_consumer(begin, end)); return begin; @@ -1158,21 +1298,24 @@ namespace adiar /// /// \throws invalid_argument If `A` is a terminal. ////////////////////////////////////////////////////////////////////////////// - zdd::label_type zdd_topvar(const zdd &f); + zdd::label_type + zdd_topvar(const zdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Get the minimal occurring variable in the family. /// /// \throws invalid_argument If `A` is a terminal. ////////////////////////////////////////////////////////////////////////////// - zdd::label_type zdd_minvar(const zdd &A); + zdd::label_type + zdd_minvar(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Get the maximal occurring variable in the family. /// /// \throws invalid_argument If `A` is a terminal. ////////////////////////////////////////////////////////////////////////////// - zdd::label_type zdd_maxvar(const zdd &A); + zdd::label_type + zdd_maxvar(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether the family includes the given set of labels. @@ -1184,7 +1327,8 @@ namespace adiar /// /// \returns Whether \f$ a \in A \f$ ////////////////////////////////////////////////////////////////////////////// - bool zdd_contains(const zdd &A, const generator &a); + bool + zdd_contains(const zdd& A, const generator& a); ////////////////////////////////////////////////////////////////////////////// /// \brief Whether the family includes the given set of labels. @@ -1199,9 +1343,12 @@ namespace adiar /// /// \returns Whether \f$ \{\mathit{begin}, \dots, \mathit{end}\} \in A \f$ ////////////////////////////////////////////////////////////////////////////// - template - bool zdd_contains(const zdd &A, ForwardIt begin, ForwardIt end) - { return zdd_contains(A, make_generator(begin, end)); } + template + bool + zdd_contains(const zdd& A, ForwardIt begin, ForwardIt end) + { + return zdd_contains(A, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Retrieves the lexicographically smallest set a in A. @@ -1212,7 +1359,8 @@ namespace adiar /// resulting assignment is lexicographically smallest, where every /// variable is treated as a digit and \f$ x_0 > x_1 > \dots \f$. ////////////////////////////////////////////////////////////////////////////// - zdd zdd_minelem(const zdd &A); + zdd + zdd_minelem(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Retrieves the lexicographically smallest set a in A. @@ -1224,7 +1372,8 @@ namespace adiar /// /// \pre `A != zdd_empty()` ////////////////////////////////////////////////////////////////////////////// - void zdd_minelem(const zdd &A, const consumer &cb); + void + zdd_minelem(const zdd& A, const consumer& cb); ////////////////////////////////////////////////////////////////////////////// /// \brief Retrieves the lexicographically smallest set a in A. @@ -1240,8 +1389,9 @@ namespace adiar /// \throws out_of_range If the distance between `begin` and `end` is not big /// enough to contain all variables in `f`. ////////////////////////////////////////////////////////////////////////////// - template - ForwardIt zdd_minelem(const zdd &A, ForwardIt begin, ForwardIt end) + template + ForwardIt + zdd_minelem(const zdd& A, ForwardIt begin, ForwardIt end) { zdd_minelem(A, make_consumer(begin, end)); return begin; @@ -1256,7 +1406,8 @@ namespace adiar /// resulting assignment is lexicographically largest, where every /// variable is treated as a digit and \f$ x_0 > x_1 > \dots \f$. ////////////////////////////////////////////////////////////////////////////// - zdd zdd_maxelem(const zdd &A); + zdd + zdd_maxelem(const zdd& A); ////////////////////////////////////////////////////////////////////////////// /// \brief Retrieves the lexicographically largest set a in A. @@ -1268,7 +1419,8 @@ namespace adiar /// /// \pre `A != zdd_empty()` ////////////////////////////////////////////////////////////////////////////// - void zdd_maxelem(const zdd &A, const consumer &cb); + void + zdd_maxelem(const zdd& A, const consumer& cb); ////////////////////////////////////////////////////////////////////////////// /// \brief Retrieves the lexicographically largest set a in A. @@ -1284,8 +1436,9 @@ namespace adiar /// \throws out_of_range If the distance between `begin` and `end` is not big /// enough to contain all variables in `f`. ////////////////////////////////////////////////////////////////////////////// - template - ForwardIt zdd_maxelem(const zdd &A, ForwardIt begin, ForwardIt end) + template + ForwardIt + zdd_maxelem(const zdd& A, ForwardIt begin, ForwardIt end) { zdd_maxelem(A, make_consumer(begin, end)); return begin; @@ -1311,15 +1464,15 @@ namespace adiar /// \returns ZDD that is true for the exact same assignments to variables in /// the given domain. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_from(const bdd &f, const generator &dom); + __zdd + zdd_from(const bdd& f, const generator& dom); ////////////////////////////////////////////////////////////////////////////// /// \brief Obtains the ZDD that represents the same function/set as the given /// BDD within the given domain. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_from(const exec_policy &ep, - const bdd &f, - const generator &dom); + __zdd + zdd_from(const exec_policy& ep, const bdd& f, const generator& dom); ////////////////////////////////////////////////////////////////////////////// /// \brief Obtains the ZDD that represents the same function/set as the @@ -1336,20 +1489,23 @@ namespace adiar /// \returns ZDD that is true for the exact same assignments to variables /// in the given domain. ////////////////////////////////////////////////////////////////////////////// - template - __zdd zdd_from(const bdd &f, ForwardIt begin, ForwardIt end) - { return zdd_from(f, make_generator(begin, end)); } + template + __zdd + zdd_from(const bdd& f, ForwardIt begin, ForwardIt end) + { + return zdd_from(f, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Obtains the ZDD that represents the same function/set as the given /// BDD within the given domain. ////////////////////////////////////////////////////////////////////////////// - template - __zdd zdd_from(const exec_policy &ep, - const bdd &f, - ForwardIt begin, - ForwardIt end) - { return bdd_from(ep, f, make_generator(begin, end)); } + template + __zdd + zdd_from(const exec_policy& ep, const bdd& f, ForwardIt begin, ForwardIt end) + { + return bdd_from(ep, f, make_generator(begin, end)); + } ////////////////////////////////////////////////////////////////////////////// /// \brief Obtains the ZDD that represents the same function/set as the @@ -1363,13 +1519,15 @@ namespace adiar /// \pre The global \ref module__domain is set to a set of variables /// that is equals to or a superset of the variables in `A`. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_from(const bdd &f); + __zdd + zdd_from(const bdd& f); ////////////////////////////////////////////////////////////////////////////// /// \brief Obtains the BDD that represents the same function/set as the given /// ZDD within the global domain. ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_from(const exec_policy &ep, const bdd &f); + __zdd + zdd_from(const exec_policy& ep, const bdd& f); /// \} ////////////////////////////////////////////////////////////////////////////// @@ -1382,16 +1540,14 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// /// \brief Output a DOT drawing of a ZDD to the given output stream. ////////////////////////////////////////////////////////////////////////////// - void zdd_printdot(const zdd &A, - std::ostream &out = std::cout, - bool include_id = false); + void + zdd_printdot(const zdd& A, std::ostream& out = std::cout, bool include_id = false); ////////////////////////////////////////////////////////////////////////////// /// \brief Output a DOT drawing of a ZDD to the file with the given name. ////////////////////////////////////////////////////////////////////////////// - void zdd_printdot(const zdd &A, - const std::string &file_name, - bool include_id = false); + void + zdd_printdot(const zdd& A, const std::string& file_name, bool include_id = false); /// \} ////////////////////////////////////////////////////////////////////////////// diff --git a/src/adiar/zdd/binop.cpp b/src/adiar/zdd/binop.cpp index c57a55365..343758cf6 100644 --- a/src/adiar/zdd/binop.cpp +++ b/src/adiar/zdd/binop.cpp @@ -3,42 +3,47 @@ #include #include -#include -#include #include +#include #include +#include namespace adiar { - bool can_left_shortcut_zdd(const bool_op &op, const zdd::pointer_type &terminal) + bool + can_left_shortcut_zdd(const bool_op& op, const zdd::pointer_type& terminal) { zdd::pointer_type terminal_F = zdd::pointer_type(false); zdd::pointer_type terminal_T = zdd::pointer_type(true); return // Does it shortcut on this level? - op(terminal, terminal_F) == terminal_F && op(terminal, terminal_T) == terminal_F + op(terminal, terminal_F) == terminal_F + && op(terminal, terminal_T) == terminal_F // Does it shortcut on all other levels below? - && op(terminal_F, terminal_F) == terminal_F && op(terminal_F, terminal_T) == terminal_F; + && op(terminal_F, terminal_F) == terminal_F && op(terminal_F, terminal_T) == terminal_F; } - bool can_right_shortcut_zdd(const bool_op &op, const zdd::pointer_type &terminal) + bool + can_right_shortcut_zdd(const bool_op& op, const zdd::pointer_type& terminal) { zdd::pointer_type terminal_F = zdd::pointer_type(false); zdd::pointer_type terminal_T = zdd::pointer_type(true); return // Does it shortcut on this level? - op(terminal_F, terminal) == terminal_F && op(terminal_T, terminal) == terminal_F + op(terminal_F, terminal) == terminal_F + && op(terminal_T, terminal) == terminal_F // Does it shortcut on all other levels below? - && op(terminal_F, terminal_F) == terminal_F && op(terminal_T, terminal_F) == terminal_F; + && op(terminal_F, terminal_F) == terminal_F && op(terminal_T, terminal_F) == terminal_F; } - bool zdd_skippable(const bool_op &op, const zdd::node_type::children_type &r_high) + bool + zdd_skippable(const bool_op& op, const zdd::node_type::children_type& r_high) { return (r_high[0].is_terminal() && r_high[1].is_terminal() && op(r_high[0], r_high[1]) == zdd::pointer_type(false)) || (r_high[0].is_terminal() && can_left_shortcut_zdd(op, r_high[0])) || (r_high[1].is_terminal() && can_right_shortcut_zdd(op, r_high[1])); - } + } ////////////////////////////////////////////////////////////////////////////// // ZDD product construction policy @@ -47,25 +52,22 @@ namespace adiar , public internal::prod2_mixed_level_merger { public: - static __zdd resolve_same_file(const zdd &zdd_1, const zdd &/* zdd_2 */, - const bool_op &op) + static __zdd + resolve_same_file(const zdd& zdd_1, const zdd& /* zdd_2 */, const bool_op& op) { // Compute the results on all children. zdd::pointer_type op_F = op(zdd::pointer_type(false), zdd::pointer_type(false)); zdd::pointer_type op_T = op(zdd::pointer_type(true), zdd::pointer_type(true)); // Does it collapse to a terminal? - if (op_F == op_T) { - return zdd_terminal(op_F.value()); - } + if (op_F == op_T) { return zdd_terminal(op_F.value()); } return zdd_1; } public: - static __zdd resolve_terminal_root(const zdd& zdd_1, - const zdd& zdd_2, - const bool_op &op) + static __zdd + resolve_terminal_root(const zdd& zdd_1, const zdd& zdd_2, const bool_op& op) { adiar_assert(zdd_isterminal(zdd_1) || zdd_isterminal(zdd_2)); @@ -79,7 +81,7 @@ namespace adiar } else if (zdd_isterminal(zdd_1)) { const zdd::pointer_type p1 = dd_valueof(zdd_1); - if (can_left_shortcut_zdd(op, p1)) { + if (can_left_shortcut_zdd(op, p1)) { // Shortcuts the left-most path to {Ø} and all others to Ø return zdd_terminal(false); } else if (is_left_irrelevant(op, p1) && is_left_irrelevant(op, terminal_F)) { @@ -101,26 +103,27 @@ namespace adiar } public: - static internal::cut left_cut(const bool_op &op) + static internal::cut + left_cut(const bool_op& op) { const bool incl_false = !can_left_shortcut_zdd(op, zdd::pointer_type(false)); - const bool incl_true = !can_left_shortcut_zdd(op, zdd::pointer_type(true)); + const bool incl_true = !can_left_shortcut_zdd(op, zdd::pointer_type(true)); return internal::cut(incl_false, incl_true); } - static internal::cut right_cut(const bool_op &op) + static internal::cut + right_cut(const bool_op& op) { const bool incl_false = !can_right_shortcut_zdd(op, zdd::pointer_type(false)); - const bool incl_true = !can_right_shortcut_zdd(op, zdd::pointer_type(true)); + const bool incl_true = !can_right_shortcut_zdd(op, zdd::pointer_type(true)); return internal::cut(incl_false, incl_true); } private: static internal::tuple - __resolve_request(const bool_op &op, - const internal::tuple &r) + __resolve_request(const bool_op& op, const internal::tuple& r) { if (r[0].is_terminal() && can_left_shortcut_zdd(op, r[0])) { return { r[0], zdd::pointer_type(true) }; @@ -133,9 +136,9 @@ namespace adiar public: static internal::prod2_rec - resolve_request(const bool_op &op, - const internal::tuple &r_low, - const internal::tuple &r_high) + resolve_request(const bool_op& op, + const internal::tuple& r_low, + const internal::tuple& r_high) { // If r_high surely suppresses the node during the ZDD Reduce, then skip // creating it in the first place and just forward the edge to r_low. @@ -145,55 +148,58 @@ namespace adiar } // Otherwise, create a node with children r_low and r_high - return internal::prod2_rec_output { - __resolve_request(op, r_low), - __resolve_request(op, r_high) - }; + return internal::prod2_rec_output{ __resolve_request(op, r_low), + __resolve_request(op, r_high) }; } static constexpr bool no_skip = false; }; ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_binop(const exec_policy &ep, - const zdd &A, - const zdd &B, - const bool_op &op) + __zdd + zdd_binop(const exec_policy& ep, const zdd& A, const zdd& B, const bool_op& op) { return internal::prod2(ep, A, B, op); } - __zdd zdd_binop(const zdd &A, const zdd &B, const bool_op &op) + __zdd + zdd_binop(const zdd& A, const zdd& B, const bool_op& op) { return zdd_binop(exec_policy(), A, B, op); } - __zdd zdd_union(const exec_policy &ep, const zdd &A, const zdd &B) + __zdd + zdd_union(const exec_policy& ep, const zdd& A, const zdd& B) { return zdd_binop(ep, A, B, or_op); } - __zdd zdd_union(const zdd &A, const zdd &B) + __zdd + zdd_union(const zdd& A, const zdd& B) { return zdd_union(exec_policy(), A, B); } - __zdd zdd_intsec(const exec_policy &ep, const zdd &A, const zdd &B) + __zdd + zdd_intsec(const exec_policy& ep, const zdd& A, const zdd& B) { return zdd_binop(ep, A, B, and_op); } - __zdd zdd_intsec(const zdd &A, const zdd &B) + __zdd + zdd_intsec(const zdd& A, const zdd& B) { return zdd_intsec(exec_policy(), A, B); } - __zdd zdd_diff(const exec_policy &ep, const zdd &A, const zdd &B) + __zdd + zdd_diff(const exec_policy& ep, const zdd& A, const zdd& B) { return zdd_binop(ep, A, B, diff_op); } - __zdd zdd_diff(const zdd &A, const zdd &B) + __zdd + zdd_diff(const zdd& A, const zdd& B) { return zdd_diff(exec_policy(), A, B); } diff --git a/src/adiar/zdd/build.cpp b/src/adiar/zdd/build.cpp index 4efd919b1..9399a4b9c 100644 --- a/src/adiar/zdd/build.cpp +++ b/src/adiar/zdd/build.cpp @@ -1,29 +1,31 @@ -#include - #include -#include #include +#include +#include -#include #include +#include namespace adiar { using zdd_chain_converter = internal::chain_converter>; ////////////////////////////////////////////////////////////////////////////// - zdd zdd_terminal(bool value) + zdd + zdd_terminal(bool value) { return internal::build_terminal(value); } - zdd zdd_empty() + zdd + zdd_empty() { return internal::build_terminal(false); } - zdd zdd_null() + zdd + zdd_null() { return internal::build_terminal(true); } @@ -35,20 +37,23 @@ namespace adiar const zdd::label_type var; public: - zdd_ithvar_policy(zdd::label_type v) : var(v) - { } + zdd_ithvar_policy(zdd::label_type v) + : var(v) + {} public: static constexpr bool init_terminal = true; constexpr bool - skip(const zdd_policy::label_type &) const - { return false; } + skip(const zdd_policy::label_type&) const + { + return false; + } inline zdd_policy::node_type - make_node(const zdd_policy::label_type &l, - const zdd_policy::pointer_type &r, - const bool/*negated*/) const + make_node(const zdd_policy::label_type& l, + const zdd_policy::pointer_type& r, + const bool /*negated*/) const { if (l == var) { return zdd_policy::node_type(l, zdd_policy::max_id, zdd_policy::pointer_type(false), r); @@ -57,7 +62,8 @@ namespace adiar } }; - zdd zdd_ithvar(const zdd::label_type var, const generator &dom) + zdd + zdd_ithvar(const zdd::label_type var, const generator& dom) { // TODO: Move empty dom edge-case inside of `internal::build_chain<>`? @@ -69,7 +75,8 @@ namespace adiar return zdd_isnull(res) ? zdd_empty() : res; } - zdd zdd_ithvar(const zdd::label_type var) + zdd + zdd_ithvar(const zdd::label_type var) { const internal::shared_file dom = domain_get(); internal::file_stream ds(dom); @@ -84,24 +91,30 @@ namespace adiar const zdd::label_type var; public: - zdd_nithvar_policy(zdd::label_type v) : var(v) - { } + zdd_nithvar_policy(zdd::label_type v) + : var(v) + {} public: static constexpr bool init_terminal = true; inline bool - skip(const zdd_policy::label_type &l) const - { return l == var; } + skip(const zdd_policy::label_type& l) const + { + return l == var; + } inline zdd_policy::node_type - make_node(const zdd_policy::label_type &l, - const zdd_policy::pointer_type &r, - const bool/*negated*/) const - { return zdd_policy::node_type(l, zdd_policy::max_id, r, r); } + make_node(const zdd_policy::label_type& l, + const zdd_policy::pointer_type& r, + const bool /*negated*/) const + { + return zdd_policy::node_type(l, zdd_policy::max_id, r, r); + } }; - zdd zdd_nithvar(const zdd::label_type var, const generator &dom) + zdd + zdd_nithvar(const zdd::label_type var, const generator& dom) { const zdd_nithvar_policy p(var); const zdd_chain_converter dom_wrapper(dom); @@ -109,7 +122,8 @@ namespace adiar return internal::build_chain<>(p, dom_wrapper); } - zdd zdd_nithvar(const zdd::label_type var) + zdd + zdd_nithvar(const zdd::label_type var) { const internal::shared_file dom = domain_get(); internal::file_stream ds(dom); @@ -118,7 +132,8 @@ namespace adiar } ////////////////////////////////////////////////////////////////////////////// - zdd zdd_vars(const generator &vars) + zdd + zdd_vars(const generator& vars) { const internal::chain_high p; const zdd_chain_converter vars_wrapper(vars); @@ -127,19 +142,22 @@ namespace adiar } ////////////////////////////////////////////////////////////////////////////// - zdd zdd_point(const generator &vars) + zdd + zdd_point(const generator& vars) { return zdd_vars(vars); } ////////////////////////////////////////////////////////////////////////////// - zdd zdd_singleton(const zdd::label_type label) + zdd + zdd_singleton(const zdd::label_type label) { return internal::build_ithvar(label); } ////////////////////////////////////////////////////////////////////////////// - zdd zdd_singletons(const generator &vars) + zdd + zdd_singletons(const generator& vars) { internal::chain_low p; zdd_chain_converter vars_wrapper(vars); @@ -148,7 +166,8 @@ namespace adiar } ////////////////////////////////////////////////////////////////////////////// - zdd zdd_powerset(const generator &vars) + zdd + zdd_powerset(const generator& vars) { const internal::chain_both p; const zdd_chain_converter vars_wrapper(vars); @@ -157,26 +176,28 @@ namespace adiar } ////////////////////////////////////////////////////////////////////////////// - zdd zdd_bot(const generator &/*dom*/) + zdd + zdd_bot(const generator& /*dom*/) { return zdd_empty(); } - zdd zdd_bot() + zdd + zdd_bot() { return zdd_empty(); } - zdd zdd_top(const generator &dom) + zdd + zdd_top(const generator& dom) { return zdd_powerset(dom); } - zdd zdd_top() + zdd + zdd_top() { - if (!domain_isset()) { - return zdd_null(); - } + if (!domain_isset()) { return zdd_null(); } const internal::shared_file dom = domain_get(); internal::file_stream ds(dom); diff --git a/src/adiar/zdd/change.cpp b/src/adiar/zdd/change.cpp index 681c239c2..13a0a71eb 100644 --- a/src/adiar/zdd/change.cpp +++ b/src/adiar/zdd/change.cpp @@ -1,8 +1,7 @@ +#include #include #include -#include - #include #include #include @@ -15,20 +14,22 @@ namespace adiar public: static constexpr bool may_skip = true; - static constexpr bool cut_true_terminal = true; + static constexpr bool cut_true_terminal = true; static constexpr bool cut_false_terminal = false; static constexpr size_t mult_factor = 1u; public: - static zdd on_empty_labels(const zdd& dd) + static zdd + on_empty_labels(const zdd& dd) { return dd; } - static zdd on_terminal_input(const bool terminal_value, - const zdd& dd, - const internal::shared_file &vars) + static zdd + on_terminal_input(const bool terminal_value, + const zdd& dd, + const internal::shared_file& vars) { // TODO: simplify with generator function as input if (terminal_value) { @@ -39,39 +40,41 @@ namespace adiar } } - static zdd terminal(const bool terminal_value) + static zdd + terminal(const bool terminal_value) { return zdd_terminal(terminal_value); } - static internal::intercut_rec hit_existing(const zdd::node_type &n) + static internal::intercut_rec + hit_existing(const zdd::node_type& n) { - if (n.low().is_false()) { - return internal::intercut_rec_skipto { n.high() }; - } + if (n.low().is_false()) { return internal::intercut_rec_skipto{ n.high() }; } - return internal::intercut_rec_output { n.high(), n.low() }; + return internal::intercut_rec_output{ n.high(), n.low() }; } - static internal::intercut_rec_output hit_cut(const zdd::pointer_type &target) + static internal::intercut_rec_output + hit_cut(const zdd::pointer_type& target) { - return internal::intercut_rec_output { zdd::pointer_type(false), target }; + return internal::intercut_rec_output{ zdd::pointer_type(false), target }; } - static internal::intercut_rec_output miss_existing(const zdd::node_type &n) + static internal::intercut_rec_output + miss_existing(const zdd::node_type& n) { - return internal::intercut_rec_output { n.low(), n.high() }; + return internal::intercut_rec_output{ n.low(), n.high() }; } }; - __zdd zdd_change(const exec_policy &ep, - const zdd &A, - const generator &vars) + __zdd + zdd_change(const exec_policy& ep, const zdd& A, const generator& vars) { return internal::intercut(ep, A, vars); } - __zdd zdd_change(const zdd &A, const generator &vars) + __zdd + zdd_change(const zdd& A, const generator& vars) { return zdd_change(exec_policy(), A, vars); } diff --git a/src/adiar/zdd/complement.cpp b/src/adiar/zdd/complement.cpp index 58ec344ef..13d724339 100644 --- a/src/adiar/zdd/complement.cpp +++ b/src/adiar/zdd/complement.cpp @@ -1,13 +1,12 @@ +#include #include #include -#include - -#include -#include #include #include +#include #include +#include namespace adiar { @@ -16,7 +15,7 @@ namespace adiar public: static constexpr bool may_skip = false; - static constexpr bool cut_true_terminal = true; + static constexpr bool cut_true_terminal = true; static constexpr bool cut_false_terminal = true; static constexpr size_t mult_factor = 2u; @@ -28,14 +27,13 @@ namespace adiar static constexpr bool init_terminal = false; constexpr bool - skip(const typename dd_policy::label_type &) const - { return false; } - - inline - bdd::node_type - make_node(const zdd::label_type &l, - const zdd::pointer_type &r, - const bool/*negated*/) const + skip(const typename dd_policy::label_type&) const + { + return false; + } + + inline bdd::node_type + make_node(const zdd::label_type& l, const zdd::pointer_type& r, const bool /*negated*/) const { if (r.is_terminal()) { adiar_assert(r.value() == false, "Root should be Ø"); @@ -45,18 +43,21 @@ namespace adiar } } - static constexpr bool link[2] = {true, true}; - static constexpr bool terminal_value[2] = {true, true}; + static constexpr bool link[2] = { true, true }; + static constexpr bool terminal_value[2] = { true, true }; }; public: - static zdd on_empty_labels(const zdd& dd) + static zdd + on_empty_labels(const zdd& dd) { return dd; } - static zdd on_terminal_input(const bool terminal_value, const zdd& /*dd*/, - const internal::shared_file &universe) + static zdd + on_terminal_input(const bool terminal_value, + const zdd& /*dd*/, + const internal::shared_file& universe) { // TODO: remove internal::file_stream ls(universe); @@ -79,8 +80,12 @@ namespace adiar } // LCOV_EXCL_START - static zdd terminal(const bool /*terminal_value*/) - { adiar_unreachable(); } + static zdd + terminal(const bool /*terminal_value*/) + { + adiar_unreachable(); + } + // LCOV_EXCL_STOP // We can improve this by knowing whether we are at the very last label. If @@ -89,44 +94,49 @@ namespace adiar // Yet, this is only 2 nodes that we can kill; that is 4 arcs. This is 32 // bytes of data and very few computation cycles. For very large cases the // shortcutting in branch-prediction probably offsets this? - static internal::intercut_rec_output hit_existing(const zdd::node_type &n) + static internal::intercut_rec_output + hit_existing(const zdd::node_type& n) { - const zdd::pointer_type low = n.low().is_terminal() ? !n.low() : n.low(); + const zdd::pointer_type low = n.low().is_terminal() ? !n.low() : n.low(); const zdd::pointer_type high = n.high().is_terminal() ? !n.high() : n.high(); - return internal::intercut_rec_output { low, high }; + return internal::intercut_rec_output{ low, high }; } - static internal::intercut_rec_output hit_cut(const zdd::pointer_type &target) + static internal::intercut_rec_output + hit_cut(const zdd::pointer_type& target) { // T chain: We are definitely outside of the given set - if (target.is_true()) { - return internal::intercut_rec_output { target, target }; - } + if (target.is_true()) { return internal::intercut_rec_output{ target, target }; } // Otherwise, check whether this variable is true and so we move to the T chain - return internal::intercut_rec_output { target, zdd::pointer_type(true) }; + return internal::intercut_rec_output{ target, zdd::pointer_type(true) }; } // LCOV_EXCL_START - static internal::intercut_rec_output miss_existing(const zdd::node_type &/*n*/) - { adiar_unreachable(); } + static internal::intercut_rec_output + miss_existing(const zdd::node_type& /*n*/) + { + adiar_unreachable(); + } + // LCOV_EXCL_STOP }; - __zdd zdd_complement(const exec_policy &ep, - const zdd &A, - const generator &dom) + __zdd + zdd_complement(const exec_policy& ep, const zdd& A, const generator& dom) { return internal::intercut(ep, A, dom); } - __zdd zdd_complement(const zdd &A, const generator &dom) + __zdd + zdd_complement(const zdd& A, const generator& dom) { return zdd_complement(exec_policy(), A, dom); } - __zdd zdd_complement(const exec_policy &ep, const zdd &A) + __zdd + zdd_complement(const exec_policy& ep, const zdd& A) { const internal::shared_file dom = domain_get(); internal::file_stream ds(dom); @@ -134,7 +144,8 @@ namespace adiar return zdd_complement(ep, A, make_generator(ds)); } - __zdd zdd_complement(const zdd &A) + __zdd + zdd_complement(const zdd& A) { return zdd_complement(exec_policy(), A); } diff --git a/src/adiar/zdd/contains.cpp b/src/adiar/zdd/contains.cpp index 337086cf9..39f029d5b 100644 --- a/src/adiar/zdd/contains.cpp +++ b/src/adiar/zdd/contains.cpp @@ -8,7 +8,7 @@ namespace adiar { class zdd_contains_visitor { - const generator &gen; + const generator& gen; optional l; @@ -21,13 +21,14 @@ namespace adiar bool terminal_val = false; public: - zdd_contains_visitor(const generator &a) + zdd_contains_visitor(const generator& a) : gen(a) { l = gen(); } - inline zdd::pointer_type visit(const zdd::node_type &n) + inline zdd::pointer_type + visit(const zdd::node_type& n) { visited_label = n.label(); @@ -36,19 +37,15 @@ namespace adiar if (l) { // Did we miss a label before the root? - if (is_first_visit && l.value() < visited_label) { - return zdd::pointer_type::nil(); - } + if (is_first_visit && l.value() < visited_label) { return zdd::pointer_type::nil(); } // Forward once (if node was in the set) to hold onto the next to-be // visited level. - if (l.value() == visited_label) { - l = gen(); - } + if (l.value() == visited_label) { l = gen(); } // Will we miss the next to-be visited level? - if (next_ptr.is_node() && l.has_value() - && visited_label < l.value() && l.value() < next_ptr.label()) { + if (next_ptr.is_node() && l.has_value() && visited_label < l.value() + && l.value() < next_ptr.label()) { return zdd::pointer_type::nil(); } } @@ -57,14 +54,21 @@ namespace adiar return next_ptr; } - inline void visit(const bool s) - { terminal_val = s; } + inline void + visit(const bool s) + { + terminal_val = s; + } - inline bool get_result() - { return terminal_val && !l.has_value(); } + inline bool + get_result() + { + return terminal_val && !l.has_value(); + } }; - bool zdd_contains(const zdd &zdd, const generator &a) + bool + zdd_contains(const zdd& zdd, const generator& a) { zdd_contains_visitor v(a); internal::traverse(zdd, v); diff --git a/src/adiar/zdd/convert.cpp b/src/adiar/zdd/convert.cpp index 8b46df0e3..c1720fd48 100644 --- a/src/adiar/zdd/convert.cpp +++ b/src/adiar/zdd/convert.cpp @@ -1,27 +1,27 @@ -#include #include +#include +#include #include -#include #include #include namespace adiar { - __zdd zdd_from(const exec_policy &ep, - const bdd &f, - const generator &dom) + __zdd + zdd_from(const exec_policy& ep, const bdd& f, const generator& dom) { - return internal::intercut> - (ep, f, dom); + return internal::intercut>(ep, f, dom); } - __zdd zdd_from(const bdd &f, const generator &dom) + __zdd + zdd_from(const bdd& f, const generator& dom) { return zdd_from(exec_policy(), f, dom); } - __zdd zdd_from(const exec_policy &ep, const bdd &f) + __zdd + zdd_from(const exec_policy& ep, const bdd& f) { const internal::shared_file dom = domain_get(); internal::file_stream ds(dom); @@ -29,7 +29,8 @@ namespace adiar return zdd_from(ep, f, make_generator(ds)); } - __zdd zdd_from(const bdd &f) + __zdd + zdd_from(const bdd& f) { return zdd_from(exec_policy(), f); } diff --git a/src/adiar/zdd/count.cpp b/src/adiar/zdd/count.cpp index f7a1c92db..669c97a35 100644 --- a/src/adiar/zdd/count.cpp +++ b/src/adiar/zdd/count.cpp @@ -1,29 +1,35 @@ #include #include +#include #include #include -#include namespace adiar { - size_t zdd_nodecount(const zdd &A) + size_t + zdd_nodecount(const zdd& A) { return internal::dd_nodecount(A); } - zdd::label_type zdd_varcount(const zdd &A) + zdd::label_type + zdd_varcount(const zdd& A) { return internal::dd_varcount(A); } - uint64_t zdd_size(const exec_policy &ep, const zdd &A) + uint64_t + zdd_size(const exec_policy& ep, const zdd& A) { return zdd_isterminal(A) ? internal::dd_valueof(A) : internal::count>(ep, A, zdd_varcount(A)); } - uint64_t zdd_size(const zdd &A) - { return zdd_size(exec_policy(), A); } + uint64_t + zdd_size(const zdd& A) + { + return zdd_size(exec_policy(), A); + } } diff --git a/src/adiar/zdd/dot.cpp b/src/adiar/zdd/dot.cpp index 0ed2c53db..f8e008dcf 100644 --- a/src/adiar/zdd/dot.cpp +++ b/src/adiar/zdd/dot.cpp @@ -4,12 +4,14 @@ namespace adiar { - void zdd_printdot(const zdd &A, std::ostream &out, bool include_id) + void + zdd_printdot(const zdd& A, std::ostream& out, bool include_id) { internal::print_dot(A, out, include_id); } - void zdd_printdot(const zdd &A, const std::string &file_name, bool include_id) + void + zdd_printdot(const zdd& A, const std::string& file_name, bool include_id) { internal::print_dot(A, file_name, include_id); } diff --git a/src/adiar/zdd/elem.cpp b/src/adiar/zdd/elem.cpp index f4f28f382..7fe1cad5a 100644 --- a/src/adiar/zdd/elem.cpp +++ b/src/adiar/zdd/elem.cpp @@ -1,12 +1,10 @@ +#include #include - -#include #include +#include -#include - -#include #include +#include #include #include #include @@ -16,9 +14,9 @@ namespace adiar { /// \brief Whether the next choice needs to be output. - template - bool __zdd_Xelem__output(const zdd::node_type &curr, - const zdd::pointer_type &next) + template + bool + __zdd_Xelem__output(const zdd::node_type& curr, const zdd::pointer_type& next) { return /* Ignore everything that definitely did not pick the 'high' arc */ next == curr.high() @@ -28,55 +26,57 @@ namespace adiar } ////////////////////////////////////////////////////////////////////////////// - template + template class __zdd_Xelem__functional { private: Visitor _visitor; - const consumer &_consumer; + const consumer& _consumer; public: - __zdd_Xelem__functional(const consumer &c) + __zdd_Xelem__functional(const consumer& c) : _consumer(c) - { } + {} - zdd::pointer_type visit(const zdd::node_type &n) + zdd::pointer_type + visit(const zdd::node_type& n) { - adiar_assert(!n.high().is_terminal() || n.high().value(), - "high terminals are never false"); + adiar_assert(!n.high().is_terminal() || n.high().value(), "high terminals are never false"); const zdd::pointer_type next = _visitor.visit(n); - if (__zdd_Xelem__output(n, next)) { - _consumer(n.label()); - } + if (__zdd_Xelem__output(n, next)) { _consumer(n.label()); } return next; } - void visit(const bool t) + void + visit(const bool t) { _visitor.visit(t); } }; - template - void __zdd_Xelem(const zdd &A, const consumer &c) + template + void + __zdd_Xelem(const zdd& A, const consumer& c) { __zdd_Xelem__functional v(c); internal::traverse(A, v); } - void zdd_minelem(const zdd &A, const consumer &c) + void + zdd_minelem(const zdd& A, const consumer& c) { return __zdd_Xelem(A, c); } - void zdd_maxelem(const zdd &A, const consumer &c) + void + zdd_maxelem(const zdd& A, const consumer& c) { return __zdd_Xelem(A, c); } ////////////////////////////////////////////////////////////////////////////// - template + template class __zdd_Xelem__stack { private: @@ -92,26 +92,26 @@ namespace adiar public: __zdd_Xelem__stack(size_t max_size) : _stack(max_size) - { } + {} - zdd::pointer_type visit(const zdd::node_type &n) + zdd::pointer_type + visit(const zdd::node_type& n) { - adiar_assert(!n.high().is_terminal() || n.high().value(), - "high terminals are never false"); + adiar_assert(!n.high().is_terminal() || n.high().value(), "high terminals are never false"); const zdd::pointer_type next = _visitor.visit(n); - if (__zdd_Xelem__output(n, next)) { - _stack.push(n.label()); - } + if (__zdd_Xelem__output(n, next)) { _stack.push(n.label()); } return next; } - void visit(const bool t) + void + visit(const bool t) { _visitor.visit(t); } - zdd build_zdd() + zdd + build_zdd() { // TODO (optimisation): Use 'internal::build_chain' directly to inline // popping values from the stack. @@ -125,20 +125,23 @@ namespace adiar } }; - template - zdd __zdd_Xelem(const zdd &A) + template + zdd + __zdd_Xelem(const zdd& A) { __zdd_Xelem__stack v(A->levels()); internal::traverse(A, v); return v.build_zdd(); } - zdd zdd_minelem(const zdd &A) + zdd + zdd_minelem(const zdd& A) { return __zdd_Xelem(A); } - zdd zdd_maxelem(const zdd &A) + zdd + zdd_maxelem(const zdd& A) { return __zdd_Xelem(A); } diff --git a/src/adiar/zdd/expand.cpp b/src/adiar/zdd/expand.cpp index 599e0f001..b251962b5 100644 --- a/src/adiar/zdd/expand.cpp +++ b/src/adiar/zdd/expand.cpp @@ -1,13 +1,12 @@ +#include #include #include -#include - -#include #include #include #include #include +#include namespace adiar { @@ -16,21 +15,22 @@ namespace adiar public: static constexpr bool may_skip = false; - static constexpr bool cut_true_terminal = true; + static constexpr bool cut_true_terminal = true; static constexpr bool cut_false_terminal = false; static constexpr size_t mult_factor = 2u; public: - static zdd on_empty_labels(const zdd& dd) + static zdd + on_empty_labels(const zdd& dd) { return dd; } - - static zdd on_terminal_input(const bool terminal_value, - const zdd& dd, - const internal::shared_file &labels) + static zdd + on_terminal_input(const bool terminal_value, + const zdd& dd, + const internal::shared_file& labels) { // TODO: simplify when labels are a generator if (terminal_value) { @@ -42,37 +42,45 @@ namespace adiar } // LCOV_EXCL_START - static zdd terminal(const bool /*terminal_value*/) - { adiar_unreachable(); } + static zdd + terminal(const bool /*terminal_value*/) + { + adiar_unreachable(); + } + // LCOV_EXCL_STOP // LCOV_EXCL_START - static inline internal::intercut_rec hit_existing(const zdd::node_type &/*n*/) + static inline internal::intercut_rec + hit_existing(const zdd::node_type& /*n*/) { // The user should NOT have supplied a label that hits any existing nodes. adiar_unreachable(); } + // LCOV_EXCL_STOP - static inline internal::intercut_rec_output hit_cut(const zdd::pointer_type &target) + static inline internal::intercut_rec_output + hit_cut(const zdd::pointer_type& target) { - return internal::intercut_rec_output { target, target }; + return internal::intercut_rec_output{ target, target }; } - static inline internal::intercut_rec_output miss_existing(const zdd::node_type &n) + static inline internal::intercut_rec_output + miss_existing(const zdd::node_type& n) { - return internal::intercut_rec_output { n.low(), n.high() }; + return internal::intercut_rec_output{ n.low(), n.high() }; } }; - __zdd zdd_expand(const exec_policy &ep, - const zdd &A, - const generator &vars) + __zdd + zdd_expand(const exec_policy& ep, const zdd& A, const generator& vars) { return internal::intercut(ep, A, vars); } - __zdd zdd_expand(const zdd &A, const generator &vars) + __zdd + zdd_expand(const zdd& A, const generator& vars) { return zdd_expand(exec_policy(), A, vars); } diff --git a/src/adiar/zdd/pred.cpp b/src/adiar/zdd/pred.cpp index ae3695bd8..6bf0f1fb7 100644 --- a/src/adiar/zdd/pred.cpp +++ b/src/adiar/zdd/pred.cpp @@ -1,43 +1,50 @@ #include #include -#include #include #include +#include namespace adiar { - bool zdd_iscanonical(const zdd& A) + bool + zdd_iscanonical(const zdd& A) { return internal::dd_iscanonical(A); } - bool zdd_isterminal(const zdd& A) + bool + zdd_isterminal(const zdd& A) { return internal::dd_isterminal(A); } - bool zdd_isfalse(const zdd& A) + bool + zdd_isfalse(const zdd& A) { return internal::dd_isfalse(A); } - bool zdd_isempty(const zdd &A) + bool + zdd_isempty(const zdd& A) { return zdd_isfalse(A); } - bool zdd_istrue(const zdd& A) + bool + zdd_istrue(const zdd& A) { return internal::dd_istrue(A); } - bool zdd_isnull(const zdd &A) + bool + zdd_isnull(const zdd& A) { return zdd_istrue(A); } - bool zdd_ispoint(const zdd &A) + bool + zdd_ispoint(const zdd& A) { // Assuming the ZDD is fully reduced (which it should be), then it can only // be a point if: @@ -48,33 +55,38 @@ namespace adiar return A.width() <= 1 && A.number_of_terminals(true) == 1u; } - bool zdd_equal(const exec_policy &ep, const zdd &A, const zdd &B) + bool + zdd_equal(const exec_policy& ep, const zdd& A, const zdd& B) { return internal::is_isomorphic(ep, A, B); } - bool zdd_equal(const zdd &A, const zdd &B) + bool + zdd_equal(const zdd& A, const zdd& B) { return zdd_equal(exec_policy(), A, B); } - bool zdd_unequal(const exec_policy &ep, const zdd &A, const zdd &B) + bool + zdd_unequal(const exec_policy& ep, const zdd& A, const zdd& B) { return !zdd_equal(ep, A, B); } - bool zdd_unequal(const zdd &A, const zdd &B) + bool + zdd_unequal(const zdd& A, const zdd& B) { - return zdd_unequal(exec_policy(), A,B); + return zdd_unequal(exec_policy(), A, B); } ////////////////////////////////////////////////////////////////////////////// - template + template class ignore_levels { public: - static size_t pq1_upper_bound(const internal::shared_levelized_file &in_1, - const internal::shared_levelized_file &in_2) + static size_t + pq1_upper_bound(const internal::shared_levelized_file& in_1, + const internal::shared_levelized_file& in_2) { const internal::safe_size_t max_2level_cut_1 = in_1->max_2level_cut[ct_1]; const internal::safe_size_t max_2level_cut_2 = in_2->max_2level_cut[ct_2]; @@ -82,8 +94,9 @@ namespace adiar return internal::to_size(max_2level_cut_1 * max_2level_cut_2); } - static size_t pq2_upper_bound(const internal::shared_levelized_file &in_1, - const internal::shared_levelized_file &in_2) + static size_t + pq2_upper_bound(const internal::shared_levelized_file& in_1, + const internal::shared_levelized_file& in_2) { const internal::safe_size_t max_1level_cut_1 = in_1->max_1level_cut[ct_1]; const internal::safe_size_t max_1level_cut_2 = in_2->max_1level_cut[ct_2]; @@ -91,21 +104,28 @@ namespace adiar return internal::to_size(max_1level_cut_1 * max_1level_cut_2); } - static constexpr size_t memory_usage() + static constexpr size_t + memory_usage() { return 0u; } public: - ignore_levels(const internal::shared_levelized_file &/*f1*/, - const internal::shared_levelized_file &/*f2*/) - { /* do nothing */ } + ignore_levels(const internal::shared_levelized_file& /*f1*/, + const internal::shared_levelized_file& /*f2*/) + { /* do nothing */ + } - void next_level(zdd::label_type /* level */) - { /* do nothing */ } + void + next_level(zdd::label_type /* level */) + { /* do nothing */ + } - bool on_step() - { return false; } + bool + on_step() + { + return false; + } static constexpr bool termination_value = false; }; @@ -118,18 +138,21 @@ namespace adiar using level_check_t = ignore_levels; public: - static constexpr size_t lookahead_bound() + static constexpr size_t + lookahead_bound() { return 1; } public: - static bool resolve_terminals(const zdd::node_type &v1, const zdd::node_type &v2, bool &ret_value) + static bool + resolve_terminals(const zdd::node_type& v1, const zdd::node_type& v2, bool& ret_value) { if (v1.is_terminal() && v2.is_terminal()) { ret_value = !v1.value() || v2.value(); return true; - } if (v1.is_false()) { + } + if (v1.is_false()) { ret_value = true; return true; } else if (v2.is_true()) { @@ -140,15 +163,16 @@ namespace adiar } public: - static bool resolve_singletons(const zdd::node_type &v1, const zdd::node_type &v2) + static bool + resolve_singletons(const zdd::node_type& v1, const zdd::node_type& v2) { - return v1.label() == v2.label() - && v1.low() <= v2.low() && v1.high() <= v2.high(); + return v1.label() == v2.label() && v1.low() <= v2.low() && v1.high() <= v2.high(); } public: - template - static bool resolve_request(pq_1_t &pq, const internal::tuple &rp) + template + static bool + resolve_request(pq_1_t& pq, const internal::tuple& rp) { // Are they both a terminal? If so, check whether the left-hand side is true // and not the right, which would contradict being an implication (i.e. @@ -158,14 +182,10 @@ namespace adiar } // Has the left-hand side fallen out of its set? - if (rp[0].is_false()) { - return false; - } + if (rp[0].is_false()) { return false; } // Has the right-hand side fallen out of its set? - if (rp[1].is_false()) { - return true; - } + if (rp[1].is_false()) { return true; } // Otherwise, recurse pq.push({ rp, {} }); @@ -173,31 +193,33 @@ namespace adiar } public: - static constexpr bool early_return_value = false; + static constexpr bool early_return_value = false; static constexpr bool no_early_return_value = true; }; - bool zdd_subseteq(const exec_policy &ep, const zdd &A, const zdd &B) + bool + zdd_subseteq(const exec_policy& ep, const zdd& A, const zdd& B) { - if (A.file == B.file) { - return true; - } + if (A.file == B.file) { return true; } return internal::comparison_check(ep, A, B); } - bool zdd_subseteq(const zdd &A, const zdd &B) + bool + zdd_subseteq(const zdd& A, const zdd& B) { return zdd_subseteq(exec_policy(), A, B); } ////////////////////////////////////////////////////////////////////////////// - bool zdd_subset(const exec_policy &ep, const zdd &A, const zdd &B) + bool + zdd_subset(const exec_policy& ep, const zdd& A, const zdd& B) { return zdd_subseteq(ep, A, B) && zdd_unequal(ep, A, B); } - bool zdd_subset(const zdd &A, const zdd &B) + bool + zdd_subset(const zdd& A, const zdd& B) { return zdd_subset(exec_policy(), A, B); } @@ -211,46 +233,42 @@ namespace adiar using level_check_t = ignore_levels; public: - static constexpr size_t lookahead_bound() + static constexpr size_t + lookahead_bound() { return 2; } public: - static bool resolve_terminals(const zdd::node_type &v1, const zdd::node_type &v2, bool &ret_value) + static bool + resolve_terminals(const zdd::node_type& v1, const zdd::node_type& v2, bool& ret_value) { ret_value = v1.is_false() || v2.is_false(); return (v1.is_terminal() && v2.is_terminal()) || ret_value; } public: - static bool resolve_singletons(const zdd::node_type &v1, const zdd::node_type &v2) + static bool + resolve_singletons(const zdd::node_type& v1, const zdd::node_type& v2) { - return v1.label() != v2.label() - || v1.low() != v2.low() - || v1.high() != v2.high(); + return v1.label() != v2.label() || v1.low() != v2.low() || v1.high() != v2.high(); } public: - template - static bool resolve_request(pq_1_t &pq, const internal::tuple &rp) + template + static bool + resolve_request(pq_1_t& pq, const internal::tuple& rp) { // Are they both a terminal? If so, check whether they both are true, which // verify there is a satisfiying conjunction (i.e. representing a shared // path/element). - if (rp[0].is_terminal() && rp[1].is_terminal()) { - return rp[0].value() && rp[1].value(); - } + if (rp[0].is_terminal() && rp[1].is_terminal()) { return rp[0].value() && rp[1].value(); } // Has the left-hand side fallen out of its set? - if (rp[0].is_false()) { - return false; - } + if (rp[0].is_false()) { return false; } // Has the right-hand side fallen out of its set? - if (rp[1].is_false()) { - return false; - } + if (rp[1].is_false()) { return false; } // Otherwise, recurse pq.push({ rp, {} }); @@ -258,20 +276,20 @@ namespace adiar } public: - static constexpr bool early_return_value = false; + static constexpr bool early_return_value = false; static constexpr bool no_early_return_value = true; }; - bool zdd_disjoint(const exec_policy &ep, const zdd &A, const zdd &B) + bool + zdd_disjoint(const exec_policy& ep, const zdd& A, const zdd& B) { - if (A.file == B.file) { - return zdd_isfalse(A); - } + if (A.file == B.file) { return zdd_isfalse(A); } return internal::comparison_check(ep, A, B); } - bool zdd_disjoint(const zdd &A, const zdd &B) + bool + zdd_disjoint(const zdd& A, const zdd& B) { return zdd_disjoint(exec_policy(), A, B); } diff --git a/src/adiar/zdd/project.cpp b/src/adiar/zdd/project.cpp index f11d1a286..b943a9660 100644 --- a/src/adiar/zdd/project.cpp +++ b/src/adiar/zdd/project.cpp @@ -1,11 +1,11 @@ +#include + #include #include -#include - +#include #include #include -#include #include #include #include @@ -16,7 +16,7 @@ namespace adiar { public: static inline zdd::pointer_type - resolve_root(const zdd::node_type &r, const bool_op &/*op*/) + resolve_root(const zdd::node_type& r, const bool_op& /*op*/) { // TODO: should all but the last case not have a 'suppression taint'? @@ -29,9 +29,7 @@ namespace adiar } // Will one of the two options "fall out"? - if (r.low().is_terminal() && !r.low().value()) { - return r.high(); - } + if (r.low().is_terminal() && !r.low().value()) { return r.high(); } // if (r.high().is_terminal() && !r.high().value()) { NEVER HAPPENS } // Otherwise return as-is @@ -40,20 +38,20 @@ namespace adiar public: static inline bool - keep_terminal(const bool_op &/*op*/, const zdd::pointer_type &p) + keep_terminal(const bool_op& /*op*/, const zdd::pointer_type& p) { return p.value(); } static constexpr bool - collapse_to_terminal(const bool_op &/*op*/, const zdd::pointer_type &/*p*/) + collapse_to_terminal(const bool_op& /*op*/, const zdd::pointer_type& /*p*/) { return false; } public: static inline internal::cut - cut_with_terminals(const bool_op &/*op*/) + cut_with_terminals(const bool_op& /*op*/) { return internal::cut::All; } @@ -63,50 +61,50 @@ namespace adiar }; ////////////////////////////////////////////////////////////////////////////// - __zdd zdd_project(const exec_policy &ep, - const zdd &A, - const predicate &dom) + __zdd + zdd_project(const exec_policy& ep, const zdd& A, const predicate& dom) { return internal::quantify(ep, A, dom, or_op); } - __zdd zdd_project(const zdd &A, const predicate &dom) + __zdd + zdd_project(const zdd& A, const predicate& dom) { return zdd_project(exec_policy(), A, dom); } - __zdd zdd_project(const exec_policy &ep, - zdd &&A, - const predicate &dom) + __zdd + zdd_project(const exec_policy& ep, zdd&& A, const predicate& dom) { return internal::quantify(ep, std::move(A), dom, or_op); } - __zdd zdd_project(zdd &&A, const predicate &dom) + __zdd + zdd_project(zdd&& A, const predicate& dom) { return zdd_project(exec_policy(), std::move(A), dom); } - __zdd zdd_project(const exec_policy &ep, - const zdd &A, - const generator &dom) + __zdd + zdd_project(const exec_policy& ep, const zdd& A, const generator& dom) { return internal::quantify(ep, A, dom, or_op); } - __zdd zdd_project(const zdd &A, const generator &dom) + __zdd + zdd_project(const zdd& A, const generator& dom) { return zdd_project(exec_policy(), A, dom); } - __zdd zdd_project(const exec_policy &ep, - zdd &&A, - const generator &dom) + __zdd + zdd_project(const exec_policy& ep, zdd&& A, const generator& dom) { return internal::quantify(ep, std::move(A), dom, or_op); } - __zdd zdd_project(zdd &&A, const generator &dom) + __zdd + zdd_project(zdd&& A, const generator& dom) { return zdd_project(exec_policy(), std::move(A), dom); } diff --git a/src/adiar/zdd/subset.cpp b/src/adiar/zdd/subset.cpp index a49180a1f..d38103353 100644 --- a/src/adiar/zdd/subset.cpp +++ b/src/adiar/zdd/subset.cpp @@ -1,17 +1,17 @@ #include #include -#include -#include #include +#include #include +#include namespace adiar { - template + template class zdd_subset_labels { - const generator &gen; + const generator& gen; /// \brief The current level (including the current algorithm level) optional l_incl = make_optional(); @@ -27,7 +27,7 @@ namespace adiar bool l_match = false; public: - zdd_subset_labels(const generator &g) + zdd_subset_labels(const generator& g) : gen(g) { l_incl = gen(); @@ -36,7 +36,8 @@ namespace adiar private: /// \brief Forwards through the input to the given level - inline void forward_to_level(const zdd::label_type new_level) + inline void + forward_to_level(const zdd::label_type new_level) { adiar_assert(alg_level <= new_level, "The algorithm should ask for the levels in increasing order."); @@ -51,7 +52,8 @@ namespace adiar public: /// \brief Obtain the assignment for the current level - assignment assignment_for_level(const zdd::label_type new_level) + assignment + assignment_for_level(const zdd::label_type new_level) { forward_to_level(new_level); @@ -63,26 +65,30 @@ namespace adiar public: /// \brief Whether the manager has a next level (including the current) - bool has_level_incl() + bool + has_level_incl() { return l_incl && alg_level <= l_incl.value(); } /// \brief Get the current level (including the current algorithm level) - zdd::label_type level_incl() + zdd::label_type + level_incl() { adiar_assert(has_level_incl()); return l_incl.value(); } /// \brief Whether the manager has a level ahead of the current - bool has_level_excl() + bool + has_level_excl() { return (l_incl && alg_level < l_incl.value()) || l_excl; } /// \brief Get the next level (excluding the current one) - zdd::label_type level_excl() + zdd::label_type + level_excl() { adiar_assert(has_level_excl()); if (alg_level < l_incl.value()) { return l_incl.value(); } @@ -91,27 +97,41 @@ namespace adiar }; ////////////////////////////////////////////////////////////////////////////// - template + template class zdd_offset_policy : public zdd_policy { public: - static internal::select_rec keep_node(const zdd::node_type &n, assignment_mgr &/*amgr*/) - { return n; } + static internal::select_rec + keep_node(const zdd::node_type& n, assignment_mgr& /*amgr*/) + { + return n; + } - static internal::select_rec fix_false(const zdd::node_type &n, assignment_mgr &/*amgr*/) - { return n.low(); } + static internal::select_rec + fix_false(const zdd::node_type& n, assignment_mgr& /*amgr*/) + { + return n.low(); + } // LCOV_EXCL_START - static internal::select_rec fix_true(const zdd::node_type &/*n*/, assignment_mgr &/*amgr*/) - { adiar_unreachable(); } + static internal::select_rec + fix_true(const zdd::node_type& /*n*/, assignment_mgr& /*amgr*/) + { + adiar_unreachable(); + } + // LCOV_EXCL_STOP public: - static inline zdd terminal(bool terminal_val, assignment_mgr& /*amgr*/) - { return zdd_terminal(terminal_val); } + static inline zdd + terminal(bool terminal_val, assignment_mgr& /*amgr*/) + { + return zdd_terminal(terminal_val); + } }; - __zdd zdd_offset(const exec_policy &ep, const zdd &A, const generator &vars) + __zdd + zdd_offset(const exec_policy& ep, const zdd& A, const generator& vars) { // Both { Ø }, and Ø cannot have more variables removed if (zdd_isterminal(A)) { return A; } @@ -122,70 +142,77 @@ namespace adiar if (!amgr.has_level_incl()) { return A; } // Run select sweep - __zdd res = internal::select>> - (ep, A, amgr); + __zdd res = + internal::select>>(ep, A, amgr); // Skip Reduce if no level of `xs` matched with any in `A`. - if (!amgr.l_match) { - return A; - } + if (!amgr.l_match) { return A; } return res; } - __zdd zdd_offset(const zdd &A, const generator &vars) + __zdd + zdd_offset(const zdd& A, const generator& vars) { return zdd_offset(exec_policy(), A, vars); } - __zdd zdd_offset(const exec_policy &ep, const zdd &A, zdd::label_type var) + __zdd + zdd_offset(const exec_policy& ep, const zdd& A, zdd::label_type var) { return zdd_offset(ep, A, make_generator(var)); } - __zdd zdd_offset(const zdd &A, zdd::label_type var) + __zdd + zdd_offset(const zdd& A, zdd::label_type var) { return zdd_offset(exec_policy(), A, var); } - __zdd zdd_offset(const exec_policy &ep, const zdd &A) + __zdd + zdd_offset(const exec_policy& ep, const zdd& A) { return zdd_offset(ep, A, zdd_topvar(A)); } - __zdd zdd_offset(const zdd &A) + __zdd + zdd_offset(const zdd& A) { return zdd_offset(exec_policy(), A); } ////////////////////////////////////////////////////////////////////////////// - template + template class zdd_onset_policy : public zdd_policy { public: - static internal::select_rec keep_node(const zdd::node_type &n, assignment_mgr &amgr) + static internal::select_rec + keep_node(const zdd::node_type& n, assignment_mgr& amgr) { if (amgr.has_level_incl()) { // If recursion goes past the intended level, then it is replaced with // the false terminal. - const zdd::pointer_type low = n.low().is_terminal() || n.low().label() > amgr.level_incl() + const zdd::pointer_type low = n.low().is_terminal() || n.low().label() > amgr.level_incl() ? zdd::pointer_type(false) : n.low(); // If this applies to high, then the node should be skipped entirely. - if (n.high().is_terminal() || n.high().label() > amgr.level_incl()) { - return low; - } + if (n.high().is_terminal() || n.high().label() > amgr.level_incl()) { return low; } return zdd::node_type(n.uid(), low, n.high()); } return n; } // LCOV_EXCL_START - static internal::select_rec fix_false(const zdd::node_type &/*n*/, assignment_mgr &/*amgr*/) - { adiar_unreachable(); } + static internal::select_rec + fix_false(const zdd::node_type& /*n*/, assignment_mgr& /*amgr*/) + { + adiar_unreachable(); + } + // LCOV_EXCL_STOP - static internal::select_rec fix_true(const zdd::node_type &n, assignment_mgr &amgr) + static internal::select_rec + fix_true(const zdd::node_type& n, assignment_mgr& amgr) { if (amgr.has_level_excl()) { if (n.high().is_terminal() || n.high().label() > amgr.level_excl()) { @@ -197,60 +224,61 @@ namespace adiar } public: - static inline zdd terminal(bool terminal_val, assignment_mgr &amgr) + static inline zdd + terminal(bool terminal_val, assignment_mgr& amgr) { return zdd_terminal(!amgr.has_level_excl() && terminal_val); } }; - __zdd zdd_onset(const exec_policy &ep, const zdd &A, const generator &xs) + __zdd + zdd_onset(const exec_policy& ep, const zdd& A, const generator& xs) { if (zdd_isfalse(A)) { return A; } zdd_subset_labels amgr(xs); // Empty set of variables in `xs`? - if (!amgr.has_level_incl()) { - return A; - } + if (!amgr.has_level_incl()) { return A; } // If `A` is { Ø } and `xs` is non-empty, then it trivially collapses to Ø. - if (zdd_istrue(A)) { - return zdd_empty(); - } + if (zdd_istrue(A)) { return zdd_empty(); } // Run select sweep - __zdd res = internal::select>> - (ep, A, amgr); + __zdd res = + internal::select>>(ep, A, amgr); // Skip Reduce no levels of `xs` matched with one from `A`. - if (!amgr.l_match) { - return zdd_empty(); - } + if (!amgr.l_match) { return zdd_empty(); } return res; } - __zdd zdd_onset(const zdd &A, const generator &xs) + __zdd + zdd_onset(const zdd& A, const generator& xs) { return zdd_onset(exec_policy(), A, xs); } - __zdd zdd_onset(const exec_policy &ep, const zdd &A, zdd::label_type var) + __zdd + zdd_onset(const exec_policy& ep, const zdd& A, zdd::label_type var) { return zdd_onset(ep, A, make_generator(var)); } - __zdd zdd_onset(const zdd &A, zdd::label_type var) + __zdd + zdd_onset(const zdd& A, zdd::label_type var) { return zdd_onset(exec_policy(), A, var); } - __zdd zdd_onset(const exec_policy &ep, const zdd &A) + __zdd + zdd_onset(const exec_policy& ep, const zdd& A) { return zdd_onset(ep, A, zdd_topvar(A)); } - __zdd zdd_onset(const zdd &A) + __zdd + zdd_onset(const zdd& A) { return zdd_onset(exec_policy(), A); } diff --git a/src/adiar/zdd/zdd.cpp b/src/adiar/zdd/zdd.cpp index 9671628bb..6062d7d01 100644 --- a/src/adiar/zdd/zdd.cpp +++ b/src/adiar/zdd/zdd.cpp @@ -1,19 +1,19 @@ #include "zdd.h" -#include - #include +#include #include #include -#include +#include +#include + #include #include #include #include #include -#include -#include +#include namespace adiar { @@ -21,193 +21,215 @@ namespace adiar // '__zdd' Constructors __zdd::__zdd() : internal::__dd() - { } + {} - __zdd::__zdd(const shared_node_file_type &f) + __zdd::__zdd(const shared_node_file_type& f) : internal::__dd(f) - { } + {} - __zdd::__zdd(const shared_arc_file_type &f, const exec_policy &ep) + __zdd::__zdd(const shared_arc_file_type& f, const exec_policy& ep) : internal::__dd(f, ep) - { } + {} - __zdd::__zdd(const zdd &dd) + __zdd::__zdd(const zdd& dd) : internal::__dd(dd) - { } + {} ////////////////////////////////////////////////////////////////////////////// // 'zdd' Constructors zdd::zdd() : zdd(zdd_empty()) - { } + {} zdd::zdd(terminal_type t) : zdd(zdd_terminal(t)) - { } + {} - zdd::zdd(const shared_node_file_type &A, bool negate) + zdd::zdd(const shared_node_file_type& A, bool negate) : internal::dd(A, negate) { if (negate) { throw invalid_argument("ZDDs cannot be negated"); } } - zdd::zdd(const zdd &A) + zdd::zdd(const zdd& A) : internal::dd(A) - { } + {} - zdd::zdd(zdd &&A) + zdd::zdd(zdd&& A) : internal::dd(A) - { } + {} - zdd::zdd(__zdd &&A) + zdd::zdd(__zdd&& A) : internal::dd(internal::reduce(std::move(A))) - { } + {} ////////////////////////////////////////////////////////////////////////////// // Operators -#define __zdd_oper(out_t, op) \ - out_t operator op (__zdd &&lhs, __zdd &&rhs) { \ - return zdd(std::move(lhs)) op zdd(std::move(rhs)); \ - } \ - \ - out_t operator op (const zdd &lhs, __zdd &&rhs) { \ - return lhs op zdd(std::move(rhs)); \ - } \ - \ - out_t operator op (__zdd &&lhs, const zdd &rhs) { \ - return zdd(std::move(lhs)) op rhs; \ - } - - __zdd_oper(__zdd, &) - __zdd_oper(__zdd, |) - __zdd_oper(__zdd, -) - - __zdd_oper(bool, ==) - __zdd_oper(bool, !=) - __zdd_oper(bool, <=) - __zdd_oper(bool, >=) - __zdd_oper(bool, <) - __zdd_oper(bool, >) - - zdd& zdd::operator= (const zdd &other) - { - this -> negate = other.negate; - this -> file = other.file; +#define __zdd_oper(out_t, op) \ + out_t operator op(__zdd&& lhs, __zdd&& rhs) \ + { \ + return zdd(std::move(lhs)) op zdd(std::move(rhs)); \ + } \ + \ + out_t operator op(const zdd& lhs, __zdd&& rhs) \ + { \ + return lhs op zdd(std::move(rhs)); \ + } \ + \ + out_t operator op(__zdd&& lhs, const zdd& rhs) \ + { \ + return zdd(std::move(lhs)) op rhs; \ + } + + __zdd_oper(__zdd, &) __zdd_oper(__zdd, |) __zdd_oper(__zdd, -) + + __zdd_oper(bool, ==) __zdd_oper(bool, !=) __zdd_oper(bool, <=) __zdd_oper(bool, >=) + __zdd_oper(bool, <) __zdd_oper(bool, >) + + zdd& zdd::operator=(const zdd & other) + { + this->negate = other.negate; + this->file = other.file; return *this; } - zdd& zdd::operator= (__zdd &&other) + zdd& + zdd::operator=(__zdd&& other) { deref(); return (*this = internal::reduce(std::move(other))); } - __zdd operator~ (const zdd &A) + __zdd + operator~(const zdd& A) { return zdd_complement(A); } - __zdd operator~ (__zdd &&A) + __zdd + operator~(__zdd&& A) { return ~zdd(std::move(A)); } - __zdd operator& (const zdd& lhs, const zdd& rhs) + __zdd + operator&(const zdd& lhs, const zdd& rhs) { return zdd_intsec(lhs, rhs); } - zdd& zdd::operator&= (const zdd &other) + zdd& + zdd::operator&=(const zdd& other) { return (*this = zdd_intsec(*this, other)); } - zdd& zdd::operator&= (zdd &&other) + zdd& + zdd::operator&=(zdd&& other) { __zdd temp = zdd_intsec(*this, other); other.deref(); return (*this = std::move(temp)); } - __zdd operator| (const zdd& lhs, const zdd& rhs) + __zdd + operator|(const zdd& lhs, const zdd& rhs) { return zdd_union(lhs, rhs); } - zdd& zdd::operator|= (const zdd &other) + zdd& + zdd::operator|=(const zdd& other) { return (*this = zdd_union(*this, other)); } - zdd& zdd::operator|= (zdd &&other) + zdd& + zdd::operator|=(zdd&& other) { __zdd temp = zdd_union(*this, other); other.deref(); return (*this = std::move(temp)); } - __zdd operator- (const zdd& lhs, const zdd& rhs) + __zdd + operator-(const zdd& lhs, const zdd& rhs) { return zdd_diff(lhs, rhs); } - zdd& zdd::operator-= (const zdd &other) + zdd& + zdd::operator-=(const zdd& other) { return (*this = zdd_diff(*this, other)); } - zdd& zdd::operator-= (zdd &&other) + zdd& + zdd::operator-=(zdd&& other) { __zdd temp = zdd_diff(*this, other); other.deref(); return (*this = std::move(temp)); } - bool operator== (const zdd& lhs, const zdd& rhs) + bool + operator==(const zdd& lhs, const zdd& rhs) { return zdd_equal(lhs, rhs); } - bool operator!= (const zdd& lhs, const zdd& rhs) { + bool + operator!=(const zdd& lhs, const zdd& rhs) + { return zdd_unequal(lhs, rhs); } - bool operator<= (const zdd& lhs, const zdd& rhs) + bool + operator<=(const zdd& lhs, const zdd& rhs) { return zdd_subseteq(lhs, rhs); } - bool operator>= (const zdd& lhs, const zdd& rhs) { + bool + operator>=(const zdd& lhs, const zdd& rhs) + { return zdd_subseteq(rhs, lhs); } - bool operator< (const zdd& lhs, const zdd& rhs) + bool + operator<(const zdd& lhs, const zdd& rhs) { return zdd_subset(lhs, rhs); } - bool operator> (const zdd& lhs, const zdd& rhs) { + bool + operator>(const zdd& lhs, const zdd& rhs) + { return zdd_subset(rhs, lhs); } ////////////////////////////////////////////////////////////////////////////// // Input variables - zdd::label_type zdd_topvar(const zdd &A) + zdd::label_type + zdd_topvar(const zdd& A) { return internal::dd_topvar(A); } - zdd::label_type zdd_minvar(const zdd &A) + zdd::label_type + zdd_minvar(const zdd& A) { return internal::dd_minvar(A); } - zdd::label_type zdd_maxvar(const zdd &A) + zdd::label_type + zdd_maxvar(const zdd& A) { return internal::dd_maxvar(A); } - void zdd_support(const zdd &A, const consumer &cb) + void + zdd_support(const zdd& A, const consumer& cb) { return internal::dd_support(A, cb); } diff --git a/src/adiar/zdd/zdd.h b/src/adiar/zdd/zdd.h index d2bc8c3c3..83744f71f 100644 --- a/src/adiar/zdd/zdd.h +++ b/src/adiar/zdd/zdd.h @@ -20,7 +20,8 @@ namespace adiar /// /// \copydetails adiar::internal::__dd ////////////////////////////////////////////////////////////////////////////// - class __zdd : public internal::__dd { + class __zdd : public internal::__dd + { public: //////////////////////////////////////////////////////////////////////////// /// \brief Default constructor with an empty result. @@ -30,17 +31,17 @@ namespace adiar //////////////////////////////////////////////////////////////////////////// /// \brief Wrapper for an algorithm's already reduced output. //////////////////////////////////////////////////////////////////////////// - __zdd(const shared_node_file_type &f); + __zdd(const shared_node_file_type& f); //////////////////////////////////////////////////////////////////////////// /// \brief Wrapper for an algorithm's unreduced output. //////////////////////////////////////////////////////////////////////////// - __zdd(const shared_arc_file_type &f, const exec_policy &ep); + __zdd(const shared_arc_file_type& f, const exec_policy& ep); //////////////////////////////////////////////////////////////////////////// /// \brief Conversion constructor from a `bdd` to pass along a prior value. //////////////////////////////////////////////////////////////////////////// - __zdd(const zdd &zdd); + __zdd(const zdd& zdd); // NOTE: // '__dd' class includes 'max_1level_cut' and 'max_2level_cut' operations. @@ -65,11 +66,15 @@ namespace adiar friend __zdd; // |- functions - friend size_t zdd_nodecount(const zdd&); - friend zdd::label_type zdd_varcount(const zdd&); + friend size_t + zdd_nodecount(const zdd&); + friend zdd::label_type + zdd_varcount(const zdd&); - friend bool zdd_subseteq(const exec_policy &ep, const zdd&, const zdd&); - friend bool zdd_disjoint(const exec_policy &ep, const zdd &, const zdd &); + friend bool + zdd_subseteq(const exec_policy& ep, const zdd&, const zdd&); + friend bool + zdd_disjoint(const exec_policy& ep, const zdd&, const zdd&); public: /// \cond @@ -106,19 +111,19 @@ namespace adiar //////////////////////////////////////////////////////////////////////////// /// \brief Constructor to wrap the node-based result of an algorithm. //////////////////////////////////////////////////////////////////////////// - zdd(const zdd::shared_node_file_type &A, bool negate = false); + zdd(const zdd::shared_node_file_type& A, bool negate = false); /// \endcond //////////////////////////////////////////////////////////////////////////// /// \brief Copy construction, incrementing thre reference count on the file /// underneath. //////////////////////////////////////////////////////////////////////////// - zdd(const zdd &oA); + zdd(const zdd& oA); //////////////////////////////////////////////////////////////////////////// /// \brief Move construction, taking over ownership of the files underneath. //////////////////////////////////////////////////////////////////////////// - zdd(zdd &&A); + zdd(zdd&& A); //////////////////////////////////////////////////////////////////////////// /// \brief Implicit move conversion from a possibly to-be reduced result @@ -131,7 +136,7 @@ namespace adiar /// \remark Since the value `o` is forced to be moved, we force the content /// of `o` to be destructed after finishing the *Reduce* algorithm. //////////////////////////////////////////////////////////////////////////// - zdd(__zdd &&A); + zdd(__zdd&& A); //////////////////////////////////////////////////////////////////////////// // Accessors overwrite @@ -143,7 +148,8 @@ namespace adiar /// /// \param ct The type of the cut to obtain //////////////////////////////////////////////////////////////////////////// - internal::cut::size_type max_1level_cut(const internal::cut ct) const + internal::cut::size_type + max_1level_cut(const internal::cut ct) const { return add_false_cofactor(ct, file->max_1level_cut); } @@ -154,10 +160,12 @@ namespace adiar /// /// \param ct The type of the cut to obtain //////////////////////////////////////////////////////////////////////////// - internal::cut::size_type max_2level_cut(const internal::cut ct) const + internal::cut::size_type + max_2level_cut(const internal::cut ct) const { return add_false_cofactor(ct, file->max_2level_cut); } + /// \endcond private: @@ -165,13 +173,14 @@ namespace adiar //////////////////////////////////////////////////////////////////////////// /// \brief Accounts for the false arc added due to using a co-factor. //////////////////////////////////////////////////////////////////////////// - internal::cut::size_type add_false_cofactor(const internal::cut ct, const internal::cuts_t &ilevel_cuts) const + internal::cut::size_type + add_false_cofactor(const internal::cut ct, const internal::cuts_t& ilevel_cuts) const { const internal::safe_size_t cut_size = ilevel_cuts[ct]; // Bit-mask (allowing implicit conversion to size_t with bit-operators) to // get the cut-type WITHOUT the false arcs. - constexpr size_t bit_mask = internal::cut::Internal_True; + constexpr size_t bit_mask = internal::cut::Internal_True; const internal::cut ct_excl_false = static_cast(ct & bit_mask); // In product construction algorithms we need to take into account the @@ -192,6 +201,7 @@ namespace adiar return internal::to_size(cut_size + add_suppressed); } + /// \endcond //////////////////////////////////////////////////////////////////////////// @@ -200,39 +210,47 @@ namespace adiar //////////////////////////////////////////////////////////////////////////// /// \brief Assigns new `zdd`. //////////////////////////////////////////////////////////////////////////// - zdd& operator= (const zdd &other); + zdd& + operator=(const zdd& other); //////////////////////////////////////////////////////////////////////////// /// \brief Assigns new `zdd` to a variable; the content is derefenced before /// the given `__zdd` is reduced into a `zdd`. //////////////////////////////////////////////////////////////////////////// - zdd& operator= (__zdd &&other); + zdd& + operator=(__zdd&& other); //////////////////////////////////////////////////////////////////////////// /// \see zdd_intsec //////////////////////////////////////////////////////////////////////////// - zdd& operator&= (const zdd &other); + zdd& + operator&=(const zdd& other); /// \cond - zdd& operator&= (zdd &&other); + zdd& + operator&=(zdd&& other); /// \endcond //////////////////////////////////////////////////////////////////////////// /// \see zdd_union //////////////////////////////////////////////////////////////////////////// - zdd& operator|= (const zdd &other); + zdd& + operator|=(const zdd& other); /// \cond - zdd& operator|= (zdd &&other); + zdd& + operator|=(zdd&& other); /// \endcond //////////////////////////////////////////////////////////////////////////// /// \see zdd_diff //////////////////////////////////////////////////////////////////////////// - zdd& operator-= (const zdd &other); + zdd& + operator-=(const zdd& other); /// \cond - zdd& operator-= (zdd &&other); + zdd& + operator-=(zdd&& other); /// \endcond }; } diff --git a/src/adiar/zdd/zdd_policy.h b/src/adiar/zdd/zdd_policy.h index b1eec91e3..9daa39fdd 100644 --- a/src/adiar/zdd/zdd_policy.h +++ b/src/adiar/zdd/zdd_policy.h @@ -14,17 +14,17 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////// using zdd_policy = internal::dd_policy; - template<> + template <> inline zdd::pointer_type - zdd_policy::reduction_rule(const node &n) + zdd_policy::reduction_rule(const node& n) { if (n.high().is_false()) { return n.low(); } return n.uid(); } - template<> + template <> inline zdd::node_type::children_type - zdd_policy::reduction_rule_inv(const zdd::pointer_type &child) + zdd_policy::reduction_rule_inv(const zdd::pointer_type& child) { return { child, zdd::pointer_type(false) }; } diff --git a/src/playground.cpp b/src/playground.cpp index ac78651bf..2390865aa 100644 --- a/src/playground.cpp +++ b/src/playground.cpp @@ -4,7 +4,9 @@ // ADIAR Imports #include -int main(int argc, char* argv[]) { +int +main(int argc, char* argv[]) +{ std::cout << "-------------------------------------------------------------------------------\n" << " Adiar " << adiar::version_string << " : Playground \n" << "-------------------------------------------------------------------------------\n" @@ -13,13 +15,11 @@ int main(int argc, char* argv[]) { size_t M = 1024; try { - if (argc > 1) { - M = std::stoi(argv[1]); - } - } catch (std::invalid_argument const &ex) { + if (argc > 1) { M = std::stoi(argv[1]); } + } catch (const std::invalid_argument& ex) { std::cerr << "Invalid number: " << argv[1] << "\n"; return -1; - } catch (std::out_of_range const &ex) { + } catch (const std::out_of_range& ex) { std::cerr << "Number out of range: " << argv[1] << "\n"; return -1; } @@ -29,11 +29,6 @@ int main(int argc, char* argv[]) { { // ===== Your code starts here ===== - - - - - // ===== Your code ends here ===== } @@ -42,4 +37,3 @@ int main(int argc, char* argv[]) { adiar::adiar_deinit(); return 0; } - diff --git a/test/adiar/bdd/test_apply.cpp b/test/adiar/bdd/test_apply.cpp index 8368a2a5d..18bf76641 100644 --- a/test/adiar/bdd/test_apply.cpp +++ b/test/adiar/bdd/test_apply.cpp @@ -52,7 +52,7 @@ go_bandit([]() { node n1_5 = node(3, node::max_id, terminal_F, terminal_T); node n1_4 = node(2, node::max_id, terminal_T, n1_5.uid()); - node n1_3 = node(2, node::max_id-1, terminal_F, terminal_T); + node n1_3 = node(2, node::max_id - 1, terminal_F, terminal_T); node n1_2 = node(1, node::max_id, n1_3.uid(), n1_4.uid()); node n1_1 = node(0, node::max_id, n1_3.uid(), n1_2.uid()); @@ -133,7 +133,8 @@ go_bandit([]() { nw_x << nx_3 << nx_2 << nx_1; } - // Some are shared, and some are not - easier to find with all in one location - cluttering maybe though? + // Some are shared, and some are not - easier to find with all in one location - cluttering + // maybe though? shared_levelized_file bdd_thin; /* // 1 ---- x0 @@ -284,7 +285,8 @@ go_bandit([]() { */ describe("simple cases without access mode requirements", [&]() { - // Cases with the same file (same DAG) or at least one terminal does not need to run complicated algorithm + // Cases with the same file (same DAG) or at least one terminal does not need to run + // complicated algorithm describe("bdd_and(f,g)", [&]() { it("should resolve F /\\ T terminal-only BDDs", [&]() { @@ -298,13 +300,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("should resolve T /\\ T terminal-only BDDs", [&]() { @@ -324,13 +335,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("should shortcut on irrelevance on x0 /\\ T", [&]() { @@ -352,13 +372,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("should shortcut F /\\ [2]", [&]() { @@ -373,13 +402,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("should return input on being given the same BDD twice", [&]() { @@ -417,13 +455,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); }); @@ -439,13 +486,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("should resolve F \\/ F terminal-only BDDs", [&]() { @@ -466,13 +522,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("should shortcut on irrelevance on x0 \\/ F", [&]() { @@ -501,13 +566,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("should compute (and shortcut) [2] \\/ T", [&]() { @@ -522,13 +596,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); }); @@ -545,13 +628,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); }); @@ -567,33 +659,51 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("should resolve T ^ T terminal-only BDDs", [&]() { __bdd out = bdd_xor(bdd_T, bdd_T); node_test_stream out_nodes(out); - AssertThat(out_nodes.can_pull(), Is().True()) ; + AssertThat(out_nodes.can_pull(), Is().True()); AssertThat(out_nodes.pull(), Is().EqualTo(node(false))); AssertThat(out_nodes.can_pull(), Is().False()); AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("should shortcut on negating on x0 ^ T", [&]() { @@ -622,13 +732,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("should collapse on the same BDD twice to a terminal, when both are negated", [&]() { @@ -643,13 +762,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); }); @@ -665,13 +793,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("should resolve T -> F terminal-only BDDs", [&]() { @@ -685,13 +822,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("should resolve T -> T terminal-only BDDs", [&]() { @@ -705,13 +851,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("should shortcut on irrelevance on T -> x0", [&]() { @@ -733,21 +888,32 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); - it("should return the input when given the same BDD twice, where one is negated [1]", [&]() { - __bdd out = bdd_imp(bdd_not(bdd_2), bdd_2); + it("should return the input when given the same BDD twice, where one is negated [1]", + [&]() { + __bdd out = bdd_imp(bdd_not(bdd_2), bdd_2); - AssertThat(out.get>(), Is().EqualTo(bdd_2)); - AssertThat(out.negate, Is().False()); // negated the already negated input doubly-negating - }); + AssertThat(out.get>(), Is().EqualTo(bdd_2)); + AssertThat(out.negate, + Is().False()); // negated the already negated input doubly-negating + }); it("should return input when given the same BDD twice, where one is negated [2]", [&]() { __bdd out = bdd_imp(bdd_2, bdd_not(bdd_2)); @@ -766,7 +932,8 @@ go_bandit([]() { // // (1,1) ---- x0 // \_ _/ - // _X_ // Match in first, but not coordinatewise + // _X_ // Match in first, but + not coordinatewise // / \ // (3,1) (2,1) ---- x1 // / \_ _/ \ @@ -801,24 +968,27 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("should compute (and shortcut) BBD 1 /\\ [2]", [&]() { @@ -843,70 +1013,85 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 1) })); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 0) })); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 2) })); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,2), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), true, ptr_uint64(3, 0) })); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 3u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(4u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(4u)); }); it("should group all recursion requests together", [&]() { @@ -937,17 +1122,17 @@ go_bandit([]() { shared_levelized_file bdd_group_1, bdd_group_2; { // Garbage collect writers to free write-lock node_writer w1(bdd_group_1); - w1 << node(2,1, ptr_uint64(false), ptr_uint64(true)) - << node(2,0, ptr_uint64(true), ptr_uint64(false)) - << node(1,0, ptr_uint64(2,0), ptr_uint64(2,1)) - << node(0,1, ptr_uint64(1,0), ptr_uint64(2,1)); + w1 << node(2, 1, ptr_uint64(false), ptr_uint64(true)) + << node(2, 0, ptr_uint64(true), ptr_uint64(false)) + << node(1, 0, ptr_uint64(2, 0), ptr_uint64(2, 1)) + << node(0, 1, ptr_uint64(1, 0), ptr_uint64(2, 1)); node_writer w2(bdd_group_2); - w2 << node(3,0, ptr_uint64(false), ptr_uint64(true)) - << node(2,1, ptr_uint64(3,0), ptr_uint64(false)) - << node(2,0, ptr_uint64(false), ptr_uint64(3,0)) - << node(1,0, ptr_uint64(2,1), ptr_uint64(2,0)) - << node(0,1, ptr_uint64(1,0), ptr_uint64(2,0)); + w2 << node(3, 0, ptr_uint64(false), ptr_uint64(true)) + << node(2, 1, ptr_uint64(3, 0), ptr_uint64(false)) + << node(2, 0, ptr_uint64(false), ptr_uint64(3, 0)) + << node(1, 0, ptr_uint64(2, 1), ptr_uint64(2, 0)) + << node(0, 1, ptr_uint64(1, 0), ptr_uint64(2, 0)); } __bdd out = bdd_and(ep, bdd_group_1, bdd_group_2); @@ -955,57 +1140,67 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // (2,2) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (3,4) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (4,3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (T,5) i.e. the added node - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(3u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); }); @@ -1031,35 +1226,39 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should compute (and shortcut) [1] \\/ [2]", [&]() { @@ -1082,59 +1281,67 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(4u)); }); }); @@ -1159,41 +1366,47 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should compute [2] ^ x2", [&]() { @@ -1215,55 +1428,64 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(3u)); }); it("should compute [1] ^ [2]", [&]() { @@ -1275,83 +1497,99 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,2), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 2) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 2), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 3u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 3u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(5u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(5u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(4u)); }); it("should compute [3] ^ [1]", [&]() { @@ -1386,83 +1624,99 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // (2,3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (3,2) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (4,3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (5,3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (6,4) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (7,3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,3) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 3) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (8,T) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,2), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (T,5) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,2), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,3), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 3), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,3), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 3), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,4u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 4u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(5u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(4u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(5u)); }); it("should compute in different order than random access", [&]() { @@ -1491,89 +1745,106 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,3) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 3) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,2), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), false, ptr_uint64(3,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, ptr_uint64(3, 2) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,3), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 3), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,3), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 3), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 2), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,4u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 4u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 3u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(5u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(6u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(5u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(6u)); }); }); @@ -1598,35 +1869,40 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(2u)); }); }); @@ -1678,70 +1954,85 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 1) })); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 0) })); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 2) })); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,2), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), true, ptr_uint64(3, 0) })); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 3u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(4u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(4u)); }); }); @@ -1760,24 +2051,27 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should compute x0 ^ x1 (different levels, random access for first level)", [&]() { @@ -1796,41 +2090,47 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should compute x1 ^ x0 (different levels, random access for second level)", [&]() { @@ -1849,41 +2149,47 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("handles requests where scanning index is on a later level", [&]() { @@ -1928,60 +2234,68 @@ go_bandit([]() { __bdd out = bdd_xor(bdd_ra, bdd_0xnor2); - arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 3u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(3u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(4u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should sort requests first by scanning index then by random acces index", [&]() { @@ -2039,83 +2353,99 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,3) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 3) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,3), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 3), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,3), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 3), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,4u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 4u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(7u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(7u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(3u)); }); it("should random access on the thinnest ([thin] ^ [wide])", [&]() { @@ -2138,71 +2468,84 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 3u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(6u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(6u)); }); it("should random access on the thinnest ([wide] ^ [thin])", [&]() { @@ -2225,71 +2568,84 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 3u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(6u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(6u)); }); it("should random access on canonical ([canon] ^ [non_canon])", [&]() { @@ -2298,89 +2654,106 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,3) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 3) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,2), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,3), true, ptr_uint64(3,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 3), true, ptr_uint64(3, 2) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,3), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 3), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 2), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 2), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,4u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 4u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 3u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(5u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(6u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(5u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(6u)); }); it("should random access on canonical ([non_canon] ^ [canon])", [&]() { @@ -2389,89 +2762,106 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,3) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 3) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,2), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,3), true, ptr_uint64(3,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 3), true, ptr_uint64(3, 2) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,3), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 3), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 2), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 2), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,4u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 4u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 3u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(5u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(6u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(5u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(6u)); }); }); @@ -2495,150 +2885,178 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 3u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(4u)); }); - it("uses random access on thinnest ([thin] -> [wide] : flips non-commutative operator)", [&]() { - /* Result of [thin] -> [wide] - // - // (1,1) ---- x0 - // / \ - // (2,2) (3,3) ---- x1 - // X X - // _____/ \ / \_____ - // (4,4) (5,5) (4,6) ---- x2 - // / \ / \ / \ - // F T* T F F T - // - // * Shortcut due to '->' operator - */ - __bdd out = bdd_imp(ep, bdd_thin, bdd_wide); + it("uses random access on thinnest ([thin] -> [wide] : flips non-commutative operator)", + [&]() { + /* Result of [thin] -> [wide] + // + // (1,1) ---- x0 + // / \ + // (2,2) (3,3) ---- x1 + // X X + // _____/ \ / \_____ + // (4,4) (5,5) (4,6) ---- x2 + // / \ / \ / \ + // F T* T F F T + // + // * Shortcut due to '->' operator + */ + __bdd out = bdd_imp(ep, bdd_thin, bdd_wide); - arc_test_stream arcs(out); + arc_test_stream arcs(out); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 1) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,2) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 2) })); - AssertThat(arcs.can_pull_internal(), Is().False()); + AssertThat(arcs.can_pull_internal(), Is().False()); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), true, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), true, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().False()); + AssertThat(arcs.can_pull_terminal(), Is().False()); - level_info_test_stream levels(out); + level_info_test_stream levels(out); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,3u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 3u))); - AssertThat(levels.can_pull(), Is().False()); + AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); + AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(3u)); - }); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(3u)); + }); }); }); }); - }); +}); diff --git a/test/adiar/bdd/test_bdd.cpp b/test/adiar/bdd/test_bdd.cpp index ca347f48b..d2206ef66 100644 --- a/test/adiar/bdd/test_bdd.cpp +++ b/test/adiar/bdd/test_bdd.cpp @@ -6,9 +6,7 @@ go_bandit([]() { { node_writer nw_0(x0_nf); - nw_0 << node(0, node::max_id, - ptr_uint64(false), - ptr_uint64(true)); + nw_0 << node(0, node::max_id, ptr_uint64(false), ptr_uint64(true)); } bdd x0(x0_nf); @@ -17,9 +15,7 @@ go_bandit([]() { { node_writer nw_1(x1_nf); - nw_1 << node(1, node::max_id, - ptr_uint64(false), - ptr_uint64(true)); + nw_1 << node(1, node::max_id, ptr_uint64(false), ptr_uint64(true)); } bdd x1(x1_nf); @@ -29,13 +25,9 @@ go_bandit([]() { { node_writer nw_01(x0_and_x1_nf); - nw_01 << node(1, node::max_id, - ptr_uint64(false), - ptr_uint64(true)); + nw_01 << node(1, node::max_id, ptr_uint64(false), ptr_uint64(true)); - nw_01 << node(0, node::max_id, - ptr_uint64(false), - ptr_uint64(1, ptr_uint64::max_id)); + nw_01 << node(0, node::max_id, ptr_uint64(false), ptr_uint64(1, ptr_uint64::max_id)); } bdd x0_and_x1(x0_and_x1_nf); @@ -93,14 +85,14 @@ go_bandit([]() { { arc_writer aw(af); - aw.push_internal(arc {ptr_uint64(0,0), true, ptr_uint64(1,0)}); + aw.push_internal(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) }); - aw.push_terminal(arc {ptr_uint64(0,0), false, ptr_uint64(false)}); - aw.push_terminal(arc {ptr_uint64(1,0), false, ptr_uint64(true)}); - aw.push_terminal(arc {ptr_uint64(1,0), true, ptr_uint64(true)}); + aw.push_terminal(arc{ ptr_uint64(0, 0), false, ptr_uint64(false) }); + aw.push_terminal(arc{ ptr_uint64(1, 0), false, ptr_uint64(true) }); + aw.push_terminal(arc{ ptr_uint64(1, 0), true, ptr_uint64(true) }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); } af->max_1level_cut = 1; @@ -129,41 +121,34 @@ go_bandit([]() { AssertThat(t2, Is().EqualTo(terminal_F)); }); - it("should copy-construct shared_levelized_file and negation back to bdd", [&]() { - bdd t2 = bdd(__bdd(x0_and_x1)); - AssertThat(t2.file_ptr(), Is().EqualTo(x0_and_x1_nf)); - AssertThat(t2.is_negated(), Is().False()); - }); + it("should copy-construct shared_levelized_file and negation back to bdd", + [&]() { + bdd t2 = bdd(__bdd(x0_and_x1)); + AssertThat(t2.file_ptr(), Is().EqualTo(x0_and_x1_nf)); + AssertThat(t2.is_negated(), Is().False()); + }); describe("operators", [&]() { - it("should check terminal_F != terminal_T", [&]() { - AssertThat(terminal_F, Is().Not().EqualTo(terminal_T)); - }); + it("should check terminal_F != terminal_T", + [&]() { AssertThat(terminal_F, Is().Not().EqualTo(terminal_T)); }); - it("should check terminal_F != ~terminal_F", [&]() { - AssertThat(terminal_F, Is().Not().EqualTo(~terminal_F)); - }); + it("should check terminal_F != ~terminal_F", + [&]() { AssertThat(terminal_F, Is().Not().EqualTo(~terminal_F)); }); - it("should check terminal_F == ~terminal_T", [&]() { - AssertThat(terminal_F, Is().EqualTo(~terminal_T)); - }); + it("should check terminal_F == ~terminal_T", + [&]() { AssertThat(terminal_F, Is().EqualTo(~terminal_T)); }); - it("should check ~(x0 & x1) != (x0 & x1)", [&]() { - AssertThat(x0_and_x1, Is().Not().EqualTo(x0_nand_x1)); - }); + it("should check ~(x0 & x1) != (x0 & x1)", + [&]() { AssertThat(x0_and_x1, Is().Not().EqualTo(x0_nand_x1)); }); shared_levelized_file x0_and_x1_nf2; { node_writer nw_01(x0_and_x1_nf2); - nw_01 << node(1, node::max_id, - ptr_uint64(false), - ptr_uint64(true)); + nw_01 << node(1, node::max_id, ptr_uint64(false), ptr_uint64(true)); - nw_01 << node(0, node::max_id, - ptr_uint64(false), - ptr_uint64(1, ptr_uint64::max_id)); + nw_01 << node(0, node::max_id, ptr_uint64(false), ptr_uint64(1, ptr_uint64::max_id)); } it("should check (x0 & x1) == (x0 & x1)", [&]() { @@ -171,21 +156,22 @@ go_bandit([]() { AssertThat(x0_and_x1, Is().EqualTo(other)); }); - it("should compute x0 & x1", [&]() { - AssertThat(x0_and_x1 == (x0 & x1), Is().True()); - }); + it("should compute x0 & x1", [&]() { AssertThat(x0_and_x1 == (x0 & x1), Is().True()); }); it("should compute bdd& in x0 ?= x1", [&]() { - bdd out1 = x0; out1 &= x1; + bdd out1 = x0; + out1 &= x1; AssertThat(out1 == (x0 & x1), Is().True()); AssertThat(out1 != (x0 & x1), Is().False()); - bdd out2 = x0; out2 |= x1; + bdd out2 = x0; + out2 |= x1; AssertThat(out2 == (x0 | x1), Is().True()); AssertThat(out2 != (x0 | x1), Is().False()); AssertThat(out2 != (x0 & x1), Is().True()); - bdd out3 = x0; out3 ^= x1; + bdd out3 = x0; + out3 ^= x1; AssertThat(out3 == (x0 ^ x1), Is().True()); AssertThat(out3 != (x0 ^ x1), Is().False()); AssertThat(out3 != (x0 | x1), Is().True()); @@ -236,4 +222,4 @@ go_bandit([]() { }); }); }); - }); +}); diff --git a/test/adiar/bdd/test_build.cpp b/test/adiar/bdd/test_build.cpp index 783d6e36e..a4e6380a0 100644 --- a/test/adiar/bdd/test_build.cpp +++ b/test/adiar/bdd/test_build.cpp @@ -32,7 +32,7 @@ go_bandit([]() { AssertThat(res->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create true terminal [bdd_terminal]", [&]() { @@ -61,7 +61,7 @@ go_bandit([]() { AssertThat(res->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create true terminal [bdd_true]", [&]() { @@ -90,7 +90,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create true terminal [bdd_top]", [&]() { @@ -119,7 +119,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create false terminal [bdd_const]", [&]() { @@ -148,7 +148,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); }); it("can create false terminal [bdd_terminal]", [&]() { @@ -177,7 +177,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); }); it("can create false terminal [bdd_false]", [&]() { @@ -206,7 +206,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); }); it("can create false terminal [bdd_bot]", [&]() { @@ -235,7 +235,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); }); }); @@ -251,7 +251,7 @@ go_bandit([]() { level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -269,7 +269,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create x42", [&]() { @@ -283,7 +283,7 @@ go_bandit([]() { level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(42,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(42, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -301,12 +301,11 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); - it("throws exception for a too large label", []() { - AssertThrows(invalid_argument, bdd_nithvar(bdd::max_label+1)); - }); + it("throws exception for a too large label", + []() { AssertThrows(invalid_argument, bdd_nithvar(bdd::max_label + 1)); }); }); describe("bdd_nithvar(i)", [&]() { @@ -321,7 +320,7 @@ go_bandit([]() { level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -339,7 +338,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create !x3", [&]() { @@ -353,7 +352,7 @@ go_bandit([]() { level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -371,19 +370,16 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); - it("throws exception for a too large label", []() { - AssertThrows(invalid_argument, bdd_nithvar(bdd::max_label+1)); - }); + it("throws exception for a too large label", + []() { AssertThrows(invalid_argument, bdd_nithvar(bdd::max_label + 1)); }); }); describe("bdd_and(generator>)", [&]() { it("creates T from empty generator", [&]() { - const auto gen = []() { - return make_optional>(); - }; + const auto gen = []() { return make_optional>(); }; bdd res = bdd_and(gen); node_test_stream ns(res); @@ -410,16 +406,14 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create x1", [&]() { int calls = 0; const auto gen = [&calls]() -> optional> { - if (calls++ > 0) { - return make_optional>(); - } + if (calls++ > 0) { return make_optional>(); } return make_pair(1u, false); }; @@ -427,16 +421,14 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -455,16 +447,14 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create -x1", [&]() { int calls = 0; const auto gen = [&calls]() -> optional> { - if (calls++ > 0) { - return make_optional>(); - } + if (calls++ > 0) { return make_optional>(); } return make_pair(1u, true); }; @@ -472,16 +462,14 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - terminal_T, - terminal_F))); + AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, terminal_T, terminal_F))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -500,7 +488,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); // TODO: more tests independent of iterators @@ -508,9 +496,7 @@ go_bandit([]() { describe("bdd_and(generator)", [&]() { it("creates T from empty generator", [&]() { - const auto gen = []() { - return make_optional(); - }; + const auto gen = []() { return make_optional(); }; bdd res = bdd_and(gen); node_test_stream ns(res); @@ -537,7 +523,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create x1", [&]() { @@ -551,16 +537,14 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -579,7 +563,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create -x1", [&]() { @@ -593,16 +577,14 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - terminal_T, - terminal_F))); + AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, terminal_T, terminal_F))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -621,7 +603,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); // TODO: more tests independent of iterators @@ -656,7 +638,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create {x1}", [&]() { @@ -666,16 +648,14 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -694,7 +674,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create {-x1}", [&]() { @@ -704,16 +684,14 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - terminal_T, - terminal_F))); + AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, terminal_T, terminal_F))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -732,7 +710,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create {x1, x2, x5}", [&]() { @@ -742,32 +720,30 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - ptr_uint64(5, ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(2, node::max_id, terminal_F, ptr_uint64(5, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -786,7 +762,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create {-x1, -x2, x5}", [&]() { @@ -796,32 +772,30 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(5, ptr_uint64::max_id), - terminal_F))); + AssertThat( + ns.pull(), + Is().EqualTo(node(2, node::max_id, ptr_uint64(5, ptr_uint64::max_id), terminal_F))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_F))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_F))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -840,7 +814,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create {x1, -x2}", [&]() { @@ -850,24 +824,22 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T, - terminal_F))); + AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, terminal_T, terminal_F))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -886,7 +858,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("skips duplicates", [&]() { @@ -896,32 +868,30 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - ptr_uint64(5, ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(2, node::max_id, terminal_F, ptr_uint64(5, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -940,7 +910,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("works with ForwardIt::value_type == 'uint64_t'", [&]() { @@ -950,24 +920,22 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - ptr_uint64(3, ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, terminal_F, ptr_uint64(3, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -986,7 +954,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("works with ForwardIt::value_type == 'char'", [&]() { @@ -996,40 +964,38 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node('d', node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node('d', node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node('c', node::max_id, - terminal_F, - ptr_uint64('d', ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node('c', node::max_id, terminal_F, ptr_uint64('d', ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node('b', node::max_id, - terminal_F, - ptr_uint64('c', ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node('b', node::max_id, terminal_F, ptr_uint64('c', ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node('a', node::max_id, - terminal_F, - ptr_uint64('b', ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node('a', node::max_id, terminal_F, ptr_uint64('b', ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info('d',1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info('d', 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info('c',1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info('c', 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info('b',1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info('b', 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info('a',1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info('a', 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1048,7 +1014,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(4u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("throws exception for non-ascending list", []() { @@ -1060,9 +1026,7 @@ go_bandit([]() { describe("bdd_or(generator>)", [&]() { it("creates F from empty generator", [&]() { - const auto gen = []() { - return make_optional>(); - }; + const auto gen = []() { return make_optional>(); }; bdd res = bdd_or(gen); node_test_stream ns(res); @@ -1089,16 +1053,14 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res.number_of_terminals(false), Is().EqualTo(1u)); - AssertThat(res.number_of_terminals(true), Is().EqualTo(0u)); + AssertThat(res.number_of_terminals(true), Is().EqualTo(0u)); }); it("can create x1", [&]() { int calls = 0; const auto gen = [&calls]() -> optional> { - if (calls++ > 0) { - return make_optional>(); - } + if (calls++ > 0) { return make_optional>(); } return make_pair(1u, false); }; @@ -1106,16 +1068,14 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1134,16 +1094,14 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res.number_of_terminals(false), Is().EqualTo(1u)); - AssertThat(res.number_of_terminals(true), Is().EqualTo(1u)); + AssertThat(res.number_of_terminals(true), Is().EqualTo(1u)); }); it("can create -x1", [&]() { int calls = 0; const auto gen = [&calls]() -> optional> { - if (calls++ > 0) { - return make_optional>(); - } + if (calls++ > 0) { return make_optional>(); } return make_pair(1u, true); }; @@ -1151,16 +1109,14 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - terminal_T, - terminal_F))); + AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, terminal_T, terminal_F))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1179,7 +1135,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res.number_of_terminals(false), Is().EqualTo(1u)); - AssertThat(res.number_of_terminals(true), Is().EqualTo(1u)); + AssertThat(res.number_of_terminals(true), Is().EqualTo(1u)); }); // TODO: more tests independent of iterators (and differentiating it from bdd_and) @@ -1187,9 +1143,7 @@ go_bandit([]() { describe("bdd_or(generator)", [&]() { it("creates F from empty generator", [&]() { - const auto gen = []() { - return make_optional(); - }; + const auto gen = []() { return make_optional(); }; bdd res = bdd_or(gen); node_test_stream ns(res); @@ -1216,7 +1170,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res.number_of_terminals(false), Is().EqualTo(1u)); - AssertThat(res.number_of_terminals(true), Is().EqualTo(0u)); + AssertThat(res.number_of_terminals(true), Is().EqualTo(0u)); }); it("can create x1", [&]() { @@ -1230,16 +1184,14 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1258,7 +1210,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res.number_of_terminals(false), Is().EqualTo(1u)); - AssertThat(res.number_of_terminals(true), Is().EqualTo(1u)); + AssertThat(res.number_of_terminals(true), Is().EqualTo(1u)); }); it("can create -x1", [&]() { @@ -1272,16 +1224,14 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - terminal_T, - terminal_F))); + AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, terminal_T, terminal_F))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1300,7 +1250,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res.number_of_terminals(false), Is().EqualTo(1u)); - AssertThat(res.number_of_terminals(true), Is().EqualTo(1u)); + AssertThat(res.number_of_terminals(true), Is().EqualTo(1u)); }); // TODO: more tests independent of iterators (and differentiating it from bdd_and) @@ -1314,32 +1264,30 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(5, ptr_uint64::max_id), - terminal_T))); + AssertThat( + ns.pull(), + Is().EqualTo(node(2, node::max_id, ptr_uint64(5, ptr_uint64::max_id), terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_T))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_T))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1358,7 +1306,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res.number_of_terminals(false), Is().EqualTo(1u)); - AssertThat(res.number_of_terminals(true), Is().EqualTo(3u)); + AssertThat(res.number_of_terminals(true), Is().EqualTo(3u)); }); it("can create {} as trivially false", [&]() { @@ -1384,7 +1332,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res.number_of_terminals(false), Is().EqualTo(1u)); - AssertThat(res.number_of_terminals(true), Is().EqualTo(0u)); + AssertThat(res.number_of_terminals(true), Is().EqualTo(0u)); }); it("can create {x1, -x3}", [&]() { @@ -1394,24 +1342,22 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - terminal_F))); + AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, terminal_T, terminal_F))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - terminal_T))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(3, ptr_uint64::max_id), terminal_T))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1430,7 +1376,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res.number_of_terminals(false), Is().EqualTo(1u)); - AssertThat(res.number_of_terminals(true), Is().EqualTo(2u)); + AssertThat(res.number_of_terminals(true), Is().EqualTo(2u)); }); it("can create {-x2, x4}", [&]() { @@ -1440,24 +1386,22 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(4, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(4, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T, - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(2, node::max_id, terminal_T, ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1476,7 +1420,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res.number_of_terminals(false), Is().EqualTo(1u)); - AssertThat(res.number_of_terminals(true), Is().EqualTo(2u)); + AssertThat(res.number_of_terminals(true), Is().EqualTo(2u)); }); it("skips duplicates", [&]() { @@ -1486,32 +1430,30 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(5, ptr_uint64::max_id), - terminal_T))); + AssertThat( + ns.pull(), + Is().EqualTo(node(2, node::max_id, ptr_uint64(5, ptr_uint64::max_id), terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_T))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_T))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1530,7 +1472,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res.number_of_terminals(false), Is().EqualTo(1u)); - AssertThat(res.number_of_terminals(true), Is().EqualTo(3u)); + AssertThat(res.number_of_terminals(true), Is().EqualTo(3u)); }); it("works with ForwardIt::value_type == 'int64_t'", [&]() { @@ -1540,40 +1482,38 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, - ptr_uint64(5, ptr_uint64::max_id), - terminal_T))); + AssertThat( + ns.pull(), + Is().EqualTo(node(3, node::max_id, ptr_uint64(5, ptr_uint64::max_id), terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T, - ptr_uint64(3, ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(2, node::max_id, terminal_T, ptr_uint64(3, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_T))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_T))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1592,7 +1532,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res.number_of_terminals(false), Is().EqualTo(1u)); - AssertThat(res.number_of_terminals(true), Is().EqualTo(4u)); + AssertThat(res.number_of_terminals(true), Is().EqualTo(4u)); }); it("throws exception for non-ascending list", []() { @@ -1604,9 +1544,7 @@ go_bandit([]() { describe("bdd_cube(generator)", [&]() { it("creates T from empty generator", [&]() { - const auto gen = []() { - return make_optional(); - }; + const auto gen = []() { return make_optional(); }; bdd res = bdd_cube(gen); node_test_stream ns(res); @@ -1633,16 +1571,14 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create x0", [&]() { int calls = 0; const auto gen = [&calls]() -> optional { - if (calls++ > 0) { - return make_optional(); - } + if (calls++ > 0) { return make_optional(); } return 0; }; @@ -1650,16 +1586,14 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1678,19 +1612,17 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create -x3 & x2 & -x1 & x0", [&]() { int calls = 0; const auto gen = [&calls]() -> optional { - if (calls > 3) { - return make_optional(); - } + if (calls > 3) { return make_optional(); } - const bdd::label_type x = 3-calls; - const bool negate = calls % 2 == 0; + const bdd::label_type x = 3 - calls; + const bool negate = calls % 2 == 0; calls++; @@ -1701,40 +1633,38 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - terminal_F))); + AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, terminal_T, terminal_F))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - bdd::pointer_type(3, node::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(2, node::max_id, terminal_F, bdd::pointer_type(3, node::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - bdd::pointer_type(2, node::max_id), - terminal_F))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, bdd::pointer_type(2, node::max_id), terminal_F))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - terminal_F, - bdd::pointer_type(1, node::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(0, node::max_id, terminal_F, bdd::pointer_type(1, node::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1753,15 +1683,13 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(4u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); }); describe("bdd_cube(generator>)", [&]() { it("creates T from empty generator", [&]() { - const auto gen = []() { - return make_optional>(); - }; + const auto gen = []() { return make_optional>(); }; bdd res = bdd_cube(gen); node_test_stream ns(res); @@ -1788,16 +1716,14 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create x0", [&]() { int calls = 0; const auto gen = [&calls]() -> optional> { - if (calls++ > 0) { - return make_optional>(); - } + if (calls++ > 0) { return make_optional>(); } return make_pair(0u, false); }; @@ -1805,16 +1731,14 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1833,19 +1757,17 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create x3 & ~x2 & x1 & ~x0", [&]() { int calls = 0; const auto gen = [&calls]() -> optional> { - if (calls > 3) { - return make_optional>(); - } + if (calls > 3) { return make_optional>(); } - const bdd::label_type x = 3-calls; - const bool negate = calls % 2 == 1; + const bdd::label_type x = 3 - calls; + const bool negate = calls % 2 == 1; calls++; @@ -1856,40 +1778,38 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - bdd::pointer_type(3, node::max_id), - terminal_F))); + AssertThat( + ns.pull(), + Is().EqualTo(node(2, node::max_id, bdd::pointer_type(3, node::max_id), terminal_F))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - bdd::pointer_type(2, node::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, terminal_F, bdd::pointer_type(2, node::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - bdd::pointer_type(1, node::max_id), - terminal_F))); + AssertThat( + ns.pull(), + Is().EqualTo(node(0, node::max_id, bdd::pointer_type(1, node::max_id), terminal_F))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1908,7 +1828,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(4u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); }); @@ -1941,7 +1861,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create {x42}", [&]() { @@ -1951,16 +1871,14 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(42, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(42, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(42,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(42, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1979,7 +1897,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create {~x4}", [&]() { @@ -1989,16 +1907,14 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_F))); + AssertThat(ns.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_F))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2017,7 +1933,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create {x1, ~x3, x5}", [&]() { @@ -2027,32 +1943,30 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, - ptr_uint64(5, ptr_uint64::max_id), - terminal_F))); + AssertThat( + ns.pull(), + Is().EqualTo(node(3, node::max_id, ptr_uint64(5, ptr_uint64::max_id), terminal_F))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - ptr_uint64(3, ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, terminal_F, ptr_uint64(3, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2071,7 +1985,7 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create {x0, -x2, -x4}", [&]() { @@ -2081,32 +1995,30 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_F))); + AssertThat(ns.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_F))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(4, ptr_uint64::max_id), - terminal_F))); + AssertThat( + ns.pull(), + Is().EqualTo(node(2, node::max_id, ptr_uint64(4, ptr_uint64::max_id), terminal_F))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - terminal_F, - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(0, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2125,42 +2037,40 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create {~x0, ~x2, ~x4}", [&]() { - std::vector> vars = { {0, true}, {2, true}, {4, true} }; + std::vector> vars = { { 0, true }, { 2, true }, { 4, true } }; bdd res = bdd_cube(vars.rbegin(), vars.rend()); node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_F))); + AssertThat(ns.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_F))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(4, ptr_uint64::max_id), - terminal_F))); + AssertThat( + ns.pull(), + Is().EqualTo(node(2, node::max_id, ptr_uint64(4, ptr_uint64::max_id), terminal_F))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_F))); + AssertThat( + ns.pull(), + Is().EqualTo(node(0, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_F))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2179,8 +2089,8 @@ go_bandit([]() { AssertThat(bdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); }); }); - }); +}); diff --git a/test/adiar/bdd/test_count.cpp b/test/adiar/bdd/test_count.cpp index 1d04d96e9..00221d112 100644 --- a/test/adiar/bdd/test_count.cpp +++ b/test/adiar/bdd/test_count.cpp @@ -19,10 +19,10 @@ go_bandit([]() { */ { // Garbage collect writer to free write-lock - node n4 = node(3,0, terminal_F, terminal_T); - node n3 = node(2,0, terminal_F, n4.uid()); - node n2 = node(1,0, n3.uid(), n4.uid()); - node n1 = node(0,0, n3.uid(), n2.uid()); + node n4 = node(3, 0, terminal_F, terminal_T); + node n3 = node(2, 0, terminal_F, n4.uid()); + node n2 = node(1, 0, n3.uid(), n4.uid()); + node n1 = node(0, 0, n3.uid(), n2.uid()); node_writer nw_1(bdd_1); nw_1 << n4 << n3 << n2 << n1; @@ -40,8 +40,8 @@ go_bandit([]() { */ { // Garbage collect writer to free write-lock - node n2 = node(2,0, terminal_F, terminal_T); - node n1 = node(1,0, n2.uid(), terminal_T); + node n2 = node(2, 0, terminal_F, terminal_T); + node n1 = node(1, 0, n2.uid(), terminal_T); node_writer nw_2(bdd_2); nw_2 << n2 << n1; @@ -59,9 +59,9 @@ go_bandit([]() { */ { // Garbage collect writer to free write-lock - node n3 = node(2,1, terminal_T, terminal_F); - node n2 = node(2,0, terminal_F, terminal_T); - node n1 = node(1,0, n2.uid(), n3.uid()); + node n3 = node(2, 1, terminal_T, terminal_F); + node n2 = node(2, 0, terminal_F, terminal_T); + node n1 = node(1, 0, n2.uid(), n3.uid()); node_writer nw_3(bdd_3); nw_3 << n3 << n2 << n1; @@ -82,12 +82,12 @@ go_bandit([]() { */ { // Garbage collect writer to free write-lock - node n6 = node(6,1, terminal_F, terminal_T); - node n5 = node(6,0, terminal_T, terminal_F); - node n4 = node(4,0, n5.uid(), n6.uid()); - node n3 = node(2,1, n5.uid(), n4.uid()); - node n2 = node(2,0, n4.uid(), n6.uid()); - node n1 = node(0,0, n2.uid(), n3.uid()); + node n6 = node(6, 1, terminal_F, terminal_T); + node n5 = node(6, 0, terminal_T, terminal_F); + node n4 = node(4, 0, n5.uid(), n6.uid()); + node n3 = node(2, 1, n5.uid(), n4.uid()); + node n2 = node(2, 0, n4.uid(), n6.uid()); + node n1 = node(0, 0, n2.uid(), n3.uid()); node_writer nw_4(bdd_4); nw_4 << n6 << n5 << n4 << n3 << n2 << n1; @@ -122,7 +122,7 @@ go_bandit([]() { { // Garbage collect writer to free write-lock node_writer nw_root_1(bdd_root_1); - nw_root_1 << node(1,0, terminal_F, terminal_T); + nw_root_1 << node(1, 0, terminal_F, terminal_T); } // Set domain to be empty @@ -154,41 +154,32 @@ go_bandit([]() { }); describe("bdd_pathcount", [&]() { - it("can count paths leading to T terminals [1]", [&]() { - AssertThat(bdd_pathcount(bdd_1), Is().EqualTo(3u)); - }); + it("can count paths leading to T terminals [1]", + [&]() { AssertThat(bdd_pathcount(bdd_1), Is().EqualTo(3u)); }); - it("can count paths leading to T terminals [2]", [&]() { - AssertThat(bdd_pathcount(bdd_2), Is().EqualTo(2u)); - }); + it("can count paths leading to T terminals [2]", + [&]() { AssertThat(bdd_pathcount(bdd_2), Is().EqualTo(2u)); }); - it("can count paths leading to T terminals [3]", [&]() { - AssertThat(bdd_pathcount(bdd_3), Is().EqualTo(2u)); - }); + it("can count paths leading to T terminals [3]", + [&]() { AssertThat(bdd_pathcount(bdd_3), Is().EqualTo(2u)); }); - it("can count paths leading to T terminals [4]", [&]() { - AssertThat(bdd_pathcount(bdd_4), Is().EqualTo(6u)); - }); + it("can count paths leading to T terminals [4]", + [&]() { AssertThat(bdd_pathcount(bdd_4), Is().EqualTo(6u)); }); - it("can count paths leading to F terminals [1]", [&]() { - AssertThat(bdd_pathcount(bdd_not(bdd_1)), Is().EqualTo(5u)); - }); + it("can count paths leading to F terminals [1]", + [&]() { AssertThat(bdd_pathcount(bdd_not(bdd_1)), Is().EqualTo(5u)); }); - it("can count paths leading to F terminals [2]", [&]() { - AssertThat(bdd_pathcount(bdd_not(bdd_2)), Is().EqualTo(1u)); - }); + it("can count paths leading to F terminals [2]", + [&]() { AssertThat(bdd_pathcount(bdd_not(bdd_2)), Is().EqualTo(1u)); }); - it("should count no paths in a true terminal-only BDD", [&]() { - AssertThat(bdd_pathcount(bdd_T), Is().EqualTo(0u)); - }); + it("should count no paths in a true terminal-only BDD", + [&]() { AssertThat(bdd_pathcount(bdd_T), Is().EqualTo(0u)); }); - it("should count no paths in a false terminal-only BDD", [&]() { - AssertThat(bdd_pathcount(bdd_F), Is().EqualTo(0u)); - }); + it("should count no paths in a false terminal-only BDD", + [&]() { AssertThat(bdd_pathcount(bdd_F), Is().EqualTo(0u)); }); - it("should count paths of a root-only BDD [1]", [&]() { - AssertThat(bdd_pathcount(bdd_root_1), Is().EqualTo(1u)); - }); + it("should count paths of a root-only BDD [1]", + [&]() { AssertThat(bdd_pathcount(bdd_root_1), Is().EqualTo(1u)); }); }); describe("bdd_satcount(f, varcount)", [&]() { @@ -242,43 +233,34 @@ go_bandit([]() { AssertThat(bdd_satcount(bdd_not(bdd_F), 2), Is().EqualTo(4u)); }); - it("throws exception on varcount being smaller than the number of levels [1]", [&]() { - AssertThrows(invalid_argument, bdd_satcount(bdd_1, 3)); - }); + it("throws exception on varcount being smaller than the number of levels [1]", + [&]() { AssertThrows(invalid_argument, bdd_satcount(bdd_1, 3)); }); - it("throws exception on varcount being smaller than the number of levels [2]", [&]() { - AssertThrows(invalid_argument, bdd_satcount(bdd_2, 1)); - }); + it("throws exception on varcount being smaller than the number of levels [2]", + [&]() { AssertThrows(invalid_argument, bdd_satcount(bdd_2, 1)); }); - it("throws exception on varcount being smaller than the number of levels [3]", [&]() { - AssertThrows(invalid_argument, bdd_satcount(bdd_3, 1)); - }); + it("throws exception on varcount being smaller than the number of levels [3]", + [&]() { AssertThrows(invalid_argument, bdd_satcount(bdd_3, 1)); }); - it("throws exception on varcount being smaller than the number of levels [4]", [&]() { - AssertThrows(invalid_argument, bdd_satcount(bdd_4, 3)); - }); + it("throws exception on varcount being smaller than the number of levels [4]", + [&]() { AssertThrows(invalid_argument, bdd_satcount(bdd_4, 3)); }); }); describe("bdd_satcount(f) [empty dom]", [&]() { - it("can count assignments leading to T terminals [1]", [&]() { - AssertThat(bdd_satcount(bdd_1), Is().EqualTo(5u)); - }); + it("can count assignments leading to T terminals [1]", + [&]() { AssertThat(bdd_satcount(bdd_1), Is().EqualTo(5u)); }); - it("can count assignments leading to T terminals [2]", [&]() { - AssertThat(bdd_satcount(bdd_2), Is().EqualTo(3u)); - }); + it("can count assignments leading to T terminals [2]", + [&]() { AssertThat(bdd_satcount(bdd_2), Is().EqualTo(3u)); }); - it("can count assignments leading to F terminals [1]", [&]() { - AssertThat(bdd_satcount(bdd_not(bdd_1)), Is().EqualTo(11u)); - }); + it("can count assignments leading to F terminals [1]", + [&]() { AssertThat(bdd_satcount(bdd_not(bdd_1)), Is().EqualTo(11u)); }); - it("can count assignments leading to F terminals [2]", [&]() { - AssertThat(bdd_satcount(bdd_not(bdd_2)), Is().EqualTo(1u)); - }); + it("can count assignments leading to F terminals [2]", + [&]() { AssertThat(bdd_satcount(bdd_not(bdd_2)), Is().EqualTo(1u)); }); - it("should count no assignments to the true terminal-only BDD", [&]() { - AssertThat(bdd_satcount(bdd_T), Is().EqualTo(0u)); - }); + it("should count no assignments to the true terminal-only BDD", + [&]() { AssertThat(bdd_satcount(bdd_T), Is().EqualTo(0u)); }); it("should count no assignments in a false terminal-only BDD", [&]() { AssertThat(bdd_satcount(bdd_not(bdd_F)), Is().EqualTo(0u)); @@ -299,30 +281,25 @@ go_bandit([]() { } domain_set(dom); - it("can count assignments leading to T terminals [1]", [&]() { - AssertThat(bdd_satcount(bdd_1), Is().EqualTo(8u * 5u)); - }); + it("can count assignments leading to T terminals [1]", + [&]() { AssertThat(bdd_satcount(bdd_1), Is().EqualTo(8u * 5u)); }); - it("can count assignments leading to T terminals [2]", [&]() { - AssertThat(bdd_satcount(bdd_2), Is().EqualTo(32u * 3u)); - }); + it("can count assignments leading to T terminals [2]", + [&]() { AssertThat(bdd_satcount(bdd_2), Is().EqualTo(32u * 3u)); }); - it("can count assignments leading to F terminals [1]", [&]() { - AssertThat(bdd_satcount(bdd_not(bdd_1)), Is().EqualTo(8u * 11u)); - }); + it("can count assignments leading to F terminals [1]", + [&]() { AssertThat(bdd_satcount(bdd_not(bdd_1)), Is().EqualTo(8u * 11u)); }); - it("can count assignments leading to F terminals [2]", [&]() { - AssertThat(bdd_satcount(bdd_not(bdd_2)), Is().EqualTo(32u * 1u)); - }); + it("can count assignments leading to F terminals [2]", + [&]() { AssertThat(bdd_satcount(bdd_not(bdd_2)), Is().EqualTo(32u * 1u)); }); it("should count assignments to the true terminal-only BDD", [&]() { AssertThat(bdd_satcount(bdd_T), Is().EqualTo(128u * 1u)); AssertThat(bdd_satcount(bdd_not(bdd_F)), Is().EqualTo(128u * 1u)); }); - it("should count no assignments in a false terminal-only BDD", [&]() { - AssertThat(bdd_satcount(bdd_F), Is().EqualTo(0u)); - }); + it("should count no assignments in a false terminal-only BDD", + [&]() { AssertThat(bdd_satcount(bdd_F), Is().EqualTo(0u)); }); it("should count assignments of a root-only BDD [1]", [&]() { AssertThat(bdd_satcount(bdd_not(bdd_root_1)), Is().EqualTo(64u * 1u)); @@ -330,4 +307,4 @@ go_bandit([]() { }); }); }); - }); +}); diff --git a/test/adiar/bdd/test_evaluate.cpp b/test/adiar/bdd/test_evaluate.cpp index 7a24f2d06..ac85e6d9e 100644 --- a/test/adiar/bdd/test_evaluate.cpp +++ b/test/adiar/bdd/test_evaluate.cpp @@ -19,11 +19,11 @@ go_bandit([]() { // F T */ - node n5 = node(3,0, terminal_F, terminal_T); - node n4 = node(2,1, terminal_T, n5.uid()); - node n3 = node(2,0, terminal_F, terminal_T); - node n2 = node(1,0, n3.uid(), n4.uid()); - node n1 = node(0,0, n3.uid(), n2.uid()); + node n5 = node(3, 0, terminal_F, terminal_T); + node n4 = node(2, 1, terminal_T, n5.uid()); + node n3 = node(2, 0, terminal_F, terminal_T); + node n2 = node(1, 0, n3.uid(), n4.uid()); + node n1 = node(0, 0, n3.uid(), n2.uid()); { // Garbage collect writer to free write-lock node_writer nw(bdd); @@ -45,10 +45,10 @@ go_bandit([]() { // F T */ - node skip_n4 = node(4,0, terminal_F, terminal_T); - node skip_n3 = node(2,1, terminal_T, skip_n4.uid()); - node skip_n2 = node(2,0, terminal_F, terminal_T); - node skip_n1 = node(0,0, skip_n2.uid(), skip_n3.uid()); + node skip_n4 = node(4, 0, terminal_F, terminal_T); + node skip_n3 = node(2, 1, terminal_T, skip_n4.uid()); + node skip_n2 = node(2, 0, terminal_F, terminal_T); + node skip_n1 = node(0, 0, skip_n2.uid(), skip_n3.uid()); { // Garbage collect writer to free write-lock node_writer skip_nw(skip_bdd); @@ -66,7 +66,7 @@ go_bandit([]() { { // Garbage collect writer to free write-lock node_writer nw(non_zero_bdd); - nw << node(1,0, terminal_F, terminal_T); + nw << node(1, 0, terminal_F, terminal_T); } shared_levelized_file bdd_F; @@ -84,31 +84,23 @@ go_bandit([]() { describe("bdd_eval(bdd, adiar::generator<...>)", [&]() { it("returns F on test BDD with assignment (F,F,F,T)", [&]() { std::vector> ass = { - {0, false}, - {1, false}, - {2, false}, - {3, true} + { 0, false }, { 1, false }, { 2, false }, { 3, true } }; AssertThat(bdd_eval(bdd, ass.begin(), ass.end()), Is().False()); }); it("returns F on test BDD with assignment (F,_,F,T)", [&]() { - std::vector> ass = { - {0, false}, - {2, false}, - {3, true} - }; + std::vector> ass = { { 0, false }, + { 2, false }, + { 3, true } }; AssertThat(bdd_eval(bdd, ass.begin(), ass.end()), Is().False()); }); it("returns T on test BDD with assignment (F,T,T,T)", [&]() { std::vector> ass = { - {0, false}, - {1, true}, - {2, true}, - {3, true} + { 0, false }, { 1, true }, { 2, true }, { 3, true } }; AssertThat(bdd_eval(bdd, ass.begin(), ass.end()), Is().True()); @@ -116,10 +108,7 @@ go_bandit([]() { it("returns F on test BDD with assignment (T,F,F,T)", [&]() { std::vector> ass = { - {0, true}, - {1, false}, - {2, false}, - {3, true} + { 0, true }, { 1, false }, { 2, false }, { 3, true } }; AssertThat(bdd_eval(bdd, ass.begin(), ass.end()), Is().False()); @@ -127,10 +116,7 @@ go_bandit([]() { it("returns T on test BDD with assignment (T,F,T,F)", [&]() { std::vector> ass = { - {0, true}, - {1, false}, - {2, true}, - {3, false} + { 0, true }, { 1, false }, { 2, true }, { 3, false } }; AssertThat(bdd_eval(bdd, ass.begin(), ass.end()), Is().True()); @@ -138,10 +124,7 @@ go_bandit([]() { it("returns T on test BDD with assignment (T,T,F,T)", [&]() { std::vector> ass = { - {0, true}, - {1, true}, - {2, false}, - {3, true} + { 0, true }, { 1, true }, { 2, false }, { 3, true } }; AssertThat(bdd_eval(bdd, ass.begin(), ass.end()), Is().True()); @@ -149,10 +132,7 @@ go_bandit([]() { it("returns T on test BDD with assignment (T,T,T,F)", [&]() { std::vector> ass = { - {0, true}, - {1, true}, - {2, true}, - {3, false} + { 0, true }, { 1, true }, { 2, true }, { 3, false } }; AssertThat(bdd_eval(bdd, ass.begin(), ass.end()), Is().False()); @@ -160,10 +140,7 @@ go_bandit([]() { it("returns T on test BDD with assignment (T,T,T,T)", [&]() { std::vector> ass = { - {0, true}, - {1, true}, - {2, true}, - {3, true} + { 0, true }, { 1, true }, { 2, true }, { 3, true } }; AssertThat(bdd_eval(bdd, ass.begin(), ass.end()), Is().True()); @@ -171,11 +148,7 @@ go_bandit([]() { it("should be able to evaluate BDD that skips level [1]", [&skip_bdd]() { std::vector> ass = { - {0, false}, - {1, true}, - {2, false}, - {3, true}, - {4, true} + { 0, false }, { 1, true }, { 2, false }, { 3, true }, { 4, true } }; AssertThat(bdd_eval(skip_bdd, ass.begin(), ass.end()), Is().False()); @@ -183,48 +156,35 @@ go_bandit([]() { it("should be able to evaluate BDD that skips level [2]", [&skip_bdd]() { std::vector> ass = { - {0, true}, - {1, false}, - {2, true}, - {3, true}, - {4, false} + { 0, true }, { 1, false }, { 2, true }, { 3, true }, { 4, false } }; AssertThat(bdd_eval(skip_bdd, ass.begin(), ass.end()), Is().False()); }); it("returns T on BDD with non-zero root with assignment (F,T)", [&]() { - std::vector> ass = { - {0, false}, - {1, true} - }; + std::vector> ass = { { 0, false }, { 1, true } }; AssertThat(bdd_eval(non_zero_bdd, ass.begin(), ass.end()), Is().True()); }); it("returns F on F terminal-only BDD", [&]() { std::vector> ass = { - {0, true}, - {1, false}, - {2, false}, - {3, true} + { 0, true }, { 1, false }, { 2, false }, { 3, true } }; AssertThat(bdd_eval(bdd_F, ass.begin(), ass.end()), Is().False()); }); it("returns F on F terminal-only BDD with empty assignment", [&]() { - std::vector> ass = { }; + std::vector> ass = {}; AssertThat(bdd_eval(bdd_F, ass.begin(), ass.end()), Is().False()); }); it("returns T on T terminal-only BDD", [&]() { std::vector> ass = { - {0, true}, - {1, true}, - {2, false}, - {3, true} + { 0, true }, { 1, true }, { 2, false }, { 3, true } }; AssertThat(bdd_eval(bdd_T, ass.begin(), ass.end()), Is().True()); @@ -238,31 +198,21 @@ go_bandit([]() { it("throws exception when given non-ascending list of assignments", [&]() { std::vector> ass = { - {0, true}, - {2, true}, - {1, true}, - {3, true}, - {4, true} + { 0, true }, { 2, true }, { 1, true }, { 3, true }, { 4, true } }; AssertThrows(invalid_argument, bdd_eval(skip_bdd, ass.begin(), ass.end())); }); it("throws exception when running out of assignments", [&]() { - std::vector> ass = { - {0, true}, - {1, true} - }; + std::vector> ass = { { 0, true }, { 1, true } }; AssertThrows(out_of_range, bdd_eval(skip_bdd, ass.begin(), ass.end())); }); it("throws exception when list is missing a needed assignment", [&]() { std::vector> ass = { - {0, true}, - {1, true}, - {3, true}, - {4, true} + { 0, true }, { 1, true }, { 3, true }, { 4, true } }; AssertThrows(invalid_argument, bdd_eval(skip_bdd, ass.begin(), ass.end())); @@ -271,93 +221,67 @@ go_bandit([]() { describe("bdd_eval(bdd, predicate<...>)", [&]() { it("returns F on test BDD with assignment 'l -> l = 3'", [&]() { - auto af = [](const bdd::label_type l) { - return l == 3; - }; + auto af = [](const bdd::label_type l) { return l == 3; }; AssertThat(bdd_eval(bdd, af), Is().False()); }); it("returns T on test BDD with assignment 'l -> l % 2 == 0'", [&]() { - auto af = [](const bdd::label_type l) { - return (l & 1u) == 0; - }; + auto af = [](const bdd::label_type l) { return (l & 1u) == 0; }; AssertThat(bdd_eval(bdd, af), Is().True()); }); it("returns T on test BDD with assignment 'l -> l > 0'", [&]() { - auto af = [](const bdd::label_type l) { - return l > 0; - }; + auto af = [](const bdd::label_type l) { return l > 0; }; AssertThat(bdd_eval(bdd, af), Is().True()); }); it("returns F on test BDD with assignment 'l -> l == 0 || l == 3'", [&]() { - auto af = [](const bdd::label_type l) { - return l == 0 || l == 3; - }; + auto af = [](const bdd::label_type l) { return l == 0 || l == 3; }; AssertThat(bdd_eval(bdd, af), Is().False()); }); it("returns F on test BDD with assignment 'l -> l % 2 == 1'", [&]() { - auto af = [](const bdd::label_type l) { - return (l & 1) == 1; - }; + auto af = [](const bdd::label_type l) { return (l & 1) == 1; }; AssertThat(bdd_eval(bdd, af), Is().False()); }); it("returns T on test BDD with assignment 'l -> l != 2'", [&]() { - auto af = [](const bdd::label_type l) { - return l != 2; - }; + auto af = [](const bdd::label_type l) { return l != 2; }; AssertThat(bdd_eval(bdd, af), Is().True()); }); it("returns F on test BDD with assignment 'l -> l < 3'", [&]() { - auto af = [](const bdd::label_type l) { - return l < 3; - }; + auto af = [](const bdd::label_type l) { return l < 3; }; AssertThat(bdd_eval(bdd, af), Is().False()); }); it("returns T on test BDD with assignment '_ -> true'", [&]() { - auto af = [](const bdd::label_type) { - return true; - }; + auto af = [](const bdd::label_type) { return true; }; AssertThat(bdd_eval(bdd, af), Is().True()); }); it("returns F on BDD that skips with assignment 'l -> l == 1 || l > 2'", [&]() { - auto af = [](const bdd::label_type l) { - return l == 1 || l > 2; - }; + auto af = [](const bdd::label_type l) { return l == 1 || l > 2; }; AssertThat(bdd_eval(skip_bdd, af), Is().False()); }); it("returns F on BDD that skips with assignment 'l -> l != 1 && l < 4'", [&]() { - auto af = [](const bdd::label_type l) { - return l != 1 && l < 4; - }; + auto af = [](const bdd::label_type l) { return l != 1 && l < 4; }; AssertThat(bdd_eval(skip_bdd, af), Is().False()); }); it("returns T on BDD with non-zero root with assignment 'l -> l == 1'", [&]() { - auto af = [](const bdd::label_type l) { - return l == 1; - }; + auto af = [](const bdd::label_type l) { return l == 1; }; AssertThat(bdd_eval(non_zero_bdd, af), Is().True()); }); it("returns F on F terminal-only BDD with assignment '_ -> true'", [&]() { - auto af = [](const bdd::label_type) { - return true; - }; + auto af = [](const bdd::label_type) { return true; }; AssertThat(bdd_eval(bdd_F, af), Is().False()); }); it("returns T on T terminal-only BDD with assignment '_ -> false'", [&]() { - auto af = [](const bdd::label_type) { - return false; - }; + auto af = [](const bdd::label_type) { return false; }; AssertThat(bdd_eval(bdd_T, af), Is().True()); }); }); @@ -404,11 +328,11 @@ go_bandit([]() { */ { - node n5 = node(3, bdd::max_id, terminal_F, terminal_T); - node n4 = node(2, bdd::max_id, terminal_T, terminal_F); - node n3 = node(2, bdd::max_id-1, terminal_F, n5.uid()); - node n2 = node(1, bdd::max_id, n3.uid(), n4.uid()); - node n1 = node(0, bdd::max_id, n2.uid(), n4.uid()); + node n5 = node(3, bdd::max_id, terminal_F, terminal_T); + node n4 = node(2, bdd::max_id, terminal_T, terminal_F); + node n3 = node(2, bdd::max_id - 1, terminal_F, n5.uid()); + node n2 = node(1, bdd::max_id, n3.uid(), n4.uid()); + node n1 = node(0, bdd::max_id, n2.uid(), n4.uid()); node_writer nw(bdd_1); nw << n5 << n4 << n3 << n2 << n1; @@ -430,12 +354,12 @@ go_bandit([]() { */ { // Garbage collect writer to free write-lock - node n6 = node(3,bdd::max_id, terminal_T, terminal_F); - node n5 = node(2,bdd::max_id, n6.uid(), terminal_T); - node n4 = node(2,bdd::max_id-1, terminal_T, terminal_F); - node n3 = node(2,bdd::max_id-2, terminal_F, n6.uid()); - node n2 = node(1,bdd::max_id, n3.uid(), n4.uid()); - node n1 = node(0,bdd::max_id, n2.uid(), n5.uid()); + node n6 = node(3, bdd::max_id, terminal_T, terminal_F); + node n5 = node(2, bdd::max_id, n6.uid(), terminal_T); + node n4 = node(2, bdd::max_id - 1, terminal_T, terminal_F); + node n3 = node(2, bdd::max_id - 2, terminal_F, n6.uid()); + node n2 = node(1, bdd::max_id, n3.uid(), n4.uid()); + node n1 = node(0, bdd::max_id, n2.uid(), n5.uid()); node_writer nw(bdd_2); nw << n6 << n5 << n4 << n3 << n2 << n1; @@ -453,10 +377,10 @@ go_bandit([]() { */ { // Garbage collect writer to free write-lock - node n4 = node(5,bdd::max_id, terminal_F, terminal_T); - node n3 = node(5,bdd::max_id-1, terminal_T, terminal_F); - node n2 = node(3,bdd::max_id, n3.uid(), n4.uid()); - node n1 = node(1,bdd::max_id, n2.uid(), n4.uid()); + node n4 = node(5, bdd::max_id, terminal_F, terminal_T); + node n3 = node(5, bdd::max_id - 1, terminal_T, terminal_F); + node n2 = node(3, bdd::max_id, n3.uid(), n4.uid()); + node n1 = node(1, bdd::max_id, n2.uid(), n4.uid()); node_writer nw(bdd_3); nw << n4 << n3 << n2 << n1; @@ -478,12 +402,12 @@ go_bandit([]() { */ { // Garbage collect writer to free write-lock - node n6 = node(3,bdd::max_id, terminal_T, terminal_F); - node n5 = node(2,bdd::max_id, n6.uid(), terminal_T); - node n4 = node(2,bdd::max_id-1, terminal_T, terminal_F); - node n3 = node(2,bdd::max_id-2, terminal_T, n6.uid()); - node n2 = node(1,bdd::max_id, n4.uid(), n5.uid()); - node n1 = node(0,bdd::max_id, n3.uid(), n2.uid()); + node n6 = node(3, bdd::max_id, terminal_T, terminal_F); + node n5 = node(2, bdd::max_id, n6.uid(), terminal_T); + node n4 = node(2, bdd::max_id - 1, terminal_T, terminal_F); + node n3 = node(2, bdd::max_id - 2, terminal_T, n6.uid()); + node n2 = node(1, bdd::max_id, n4.uid(), n5.uid()); + node n1 = node(0, bdd::max_id, n3.uid(), n2.uid()); node_writer nw(bdd_4); nw << n6 << n5 << n4 << n3 << n2 << n1; @@ -507,16 +431,14 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -531,7 +453,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns minimal BDD cube [~0]", [&]() { @@ -541,16 +463,14 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -565,7 +485,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns minimal BDD cube [1]", [&]() { @@ -575,40 +495,38 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, bdd::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, bdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, - terminal_F, - bdd::pointer_type(3, bdd::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, bdd::max_id, terminal_F, bdd::pointer_type(3, bdd::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, bdd::max_id, - bdd::pointer_type(2, bdd::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, bdd::max_id, bdd::pointer_type(2, bdd::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, - bdd::pointer_type(1, bdd::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, bdd::max_id, bdd::pointer_type(1, bdd::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -623,42 +541,40 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(5u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(4u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns minimal BDD cube [~1]", [&]() { - bdd out = bdd_satmin(bdd_not(bdd_1)); + bdd out = bdd_satmin(bdd_not(bdd_1)); // Check it looks all right node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, bdd::max_id, - bdd::pointer_type(2, bdd::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, bdd::max_id, bdd::pointer_type(2, bdd::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, - bdd::pointer_type(1, bdd::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, bdd::max_id, bdd::pointer_type(1, bdd::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -673,7 +589,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns minimal BDD cube [2]", [&]() { @@ -683,40 +599,38 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, bdd::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, bdd::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, - terminal_F, - bdd::pointer_type(3, bdd::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, bdd::max_id, terminal_F, bdd::pointer_type(3, bdd::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, bdd::max_id, - bdd::pointer_type(2, bdd::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, bdd::max_id, bdd::pointer_type(2, bdd::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, - bdd::pointer_type(1, bdd::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, bdd::max_id, bdd::pointer_type(1, bdd::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -731,7 +645,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(5u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(4u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns minimal BDD cube [~2]", [&]() { @@ -741,32 +655,30 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, bdd::max_id, - bdd::pointer_type(2, bdd::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, bdd::max_id, bdd::pointer_type(2, bdd::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, - bdd::pointer_type(1, bdd::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, bdd::max_id, bdd::pointer_type(1, bdd::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -781,43 +693,40 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns minimal BDD cube [3]", [&]() { bdd out = bdd_satmin(bdd_3); - // Check it looks all right node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, bdd::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(5, bdd::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, bdd::max_id, - bdd::pointer_type(5, bdd::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(3, bdd::max_id, bdd::pointer_type(5, bdd::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, bdd::max_id, - bdd::pointer_type(3, bdd::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, bdd::max_id, bdd::pointer_type(3, bdd::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -832,43 +741,40 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns minimal BDD cube [~3]", [&]() { bdd out = bdd_satmin(bdd_not(bdd_3)); - // Check it looks all right node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, bdd::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(5, bdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, bdd::max_id, - bdd::pointer_type(5, bdd::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(3, bdd::max_id, bdd::pointer_type(5, bdd::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, bdd::max_id, - bdd::pointer_type(3, bdd::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, bdd::max_id, bdd::pointer_type(3, bdd::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -883,35 +789,32 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns minimal BDD cube [4]", [&]() { bdd out = bdd_satmin(bdd_4); - // Check it looks all right node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, - bdd::pointer_type(2, bdd::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, bdd::max_id, bdd::pointer_type(2, bdd::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -926,43 +829,40 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns minimal BDD cube [~4]", [&]() { bdd out = bdd_satmin(bdd_not(bdd_4)); - // Check it looks all right node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, bdd::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, bdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, - terminal_F, - bdd::pointer_type(3, bdd::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, bdd::max_id, terminal_F, bdd::pointer_type(3, bdd::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, - bdd::pointer_type(2, bdd::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, bdd::max_id, bdd::pointer_type(2, bdd::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -977,13 +877,13 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); }); describe("bdd_satmin(f, c)", [&]() { it("never calls consumer for false terminal", [&]() { - size_t calls = 0u; + size_t calls = 0u; const auto cb = [&calls](pair) { calls++; }; bdd_satmin(bdd_F, cb); @@ -991,7 +891,7 @@ go_bandit([]() { }); it("never calls consumer for true terminal", [&]() { - size_t calls = 0u; + size_t calls = 0u; const auto cb = [&calls](pair) { calls++; }; bdd_satmin(bdd_T, cb); @@ -999,10 +899,10 @@ go_bandit([]() { }); it("calls consumer once with 'x0 == true' for [0]", [&]() { - size_t calls = 0u; + size_t calls = 0u; const auto cb = [&calls](pair xv) { AssertThat(calls, Is().EqualTo(0u)); - AssertThat(xv.first, Is().EqualTo(0u)); + AssertThat(xv.first, Is().EqualTo(0u)); AssertThat(xv.second, Is().EqualTo(true)); calls++; @@ -1013,10 +913,10 @@ go_bandit([]() { }); it("calls consumer once with 'x0 == false' for [~0]", [&]() { - size_t calls = 0u; + size_t calls = 0u; const auto cb = [&calls](pair xv) { AssertThat(calls, Is().EqualTo(0u)); - AssertThat(xv.first, Is().EqualTo(0u)); + AssertThat(xv.first, Is().EqualTo(0u)); AssertThat(xv.second, Is().EqualTo(true)); calls++; @@ -1027,13 +927,14 @@ go_bandit([]() { }); it("calls consumer with minimal truth assignment [1]", [&]() { - size_t calls = 0; - std::vector> expected = - { {0, false}, {1, false}, {2, true}, {3, true} }; + size_t calls = 0; + std::vector> expected = { + { 0, false }, { 1, false }, { 2, true }, { 3, true } + }; const auto cb = [&calls, &expected](pair xv) { AssertThat(calls, Is().LessThan(expected.size())); - AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); + AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); AssertThat(xv.second, Is().EqualTo(expected.at(calls).second)); calls++; }; @@ -1043,13 +944,14 @@ go_bandit([]() { }); it("calls consumer with minimal truth assignment [~1]", [&]() { - size_t calls = 0; - std::vector> expected = - { {0, false}, {1, false}, {2, false} }; + size_t calls = 0; + std::vector> expected = { { 0, false }, + { 1, false }, + { 2, false } }; const auto cb = [&calls, &expected](pair xv) { AssertThat(calls, Is().LessThan(expected.size())); - AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); + AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); AssertThat(xv.second, Is().EqualTo(expected.at(calls).second)); calls++; }; @@ -1059,13 +961,14 @@ go_bandit([]() { }); it("calls consumer with minimal truth assignment [2]", [&]() { - size_t calls = 0; - std::vector> expected = - { {0, false}, {1, false}, {2, true}, {3, false} }; + size_t calls = 0; + std::vector> expected = { + { 0, false }, { 1, false }, { 2, true }, { 3, false } + }; const auto cb = [&calls, &expected](pair xv) { AssertThat(calls, Is().LessThan(expected.size())); - AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); + AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); AssertThat(xv.second, Is().EqualTo(expected.at(calls).second)); calls++; @@ -1076,13 +979,14 @@ go_bandit([]() { }); it("calls consumer with minimal truth assignment [~2]", [&]() { - size_t calls = 0; - std::vector> expected = - { {0, false}, {1, false}, {2, false} }; + size_t calls = 0; + std::vector> expected = { { 0, false }, + { 1, false }, + { 2, false } }; const auto cb = [&calls, &expected](pair xv) { AssertThat(calls, Is().LessThan(expected.size())); - AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); + AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); AssertThat(xv.second, Is().EqualTo(expected.at(calls).second)); calls++; @@ -1093,13 +997,14 @@ go_bandit([]() { }); it("calls consumer with minimal truth assignment [3]", [&]() { - size_t calls = 0; - std::vector> expected = - { {1, false}, {3, false}, {5, false} }; + size_t calls = 0; + std::vector> expected = { { 1, false }, + { 3, false }, + { 5, false } }; const auto cb = [&calls, &expected](pair xv) { AssertThat(calls, Is().LessThan(expected.size())); - AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); + AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); AssertThat(xv.second, Is().EqualTo(expected.at(calls).second)); calls++; }; @@ -1109,13 +1014,14 @@ go_bandit([]() { }); it("calls consumer with minimal truth assignment [~3]", [&]() { - size_t calls = 0; - std::vector> expected = - { {1, false}, {3, false}, {5, true} }; + size_t calls = 0; + std::vector> expected = { { 1, false }, + { 3, false }, + { 5, true } }; const auto cb = [&calls, &expected](pair xv) { AssertThat(calls, Is().LessThan(expected.size())); - AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); + AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); AssertThat(xv.second, Is().EqualTo(expected.at(calls).second)); calls++; }; @@ -1125,13 +1031,12 @@ go_bandit([]() { }); it("calls consumer with minimal truth assignment [4]", [&]() { - size_t calls = 0; - std::vector> expected = - { {0, false}, {2, false} }; + size_t calls = 0; + std::vector> expected = { { 0, false }, { 2, false } }; const auto cb = [&calls, &expected](pair xv) { AssertThat(calls, Is().LessThan(expected.size())); - AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); + AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); AssertThat(xv.second, Is().EqualTo(expected.at(calls).second)); calls++; }; @@ -1141,13 +1046,14 @@ go_bandit([]() { }); it("calls consumer with minimal truth assignment [~4]", [&]() { - size_t calls = 0; - std::vector> expected = - { {0, false}, {2, true}, {3, true} }; + size_t calls = 0; + std::vector> expected = { { 0, false }, + { 2, true }, + { 3, true } }; const auto cb = [&calls, &expected](pair xv) { AssertThat(calls, Is().LessThan(expected.size())); - AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); + AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); AssertThat(xv.second, Is().EqualTo(expected.at(calls).second)); calls++; }; @@ -1160,7 +1066,7 @@ go_bandit([]() { describe("bdd_satmin(f, begin, end)", [&]() { using buffer_type = std::vector>; - const buffer_type::value_type buffer_default(bdd::max_label+1, false); + const buffer_type::value_type buffer_default(bdd::max_label + 1, false); const size_t buffer_size = 4; it("outputs nothing in buffer for false terminal", [&]() { @@ -1168,7 +1074,7 @@ go_bandit([]() { auto ret = bdd_satmin(bdd_F, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+0)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 0)); buffer_type expected(buffer_size, buffer_default); @@ -1182,7 +1088,7 @@ go_bandit([]() { auto ret = bdd_satmin(bdd_T, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+0)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 0)); buffer_type expected(buffer_size, buffer_default); @@ -1196,10 +1102,10 @@ go_bandit([]() { auto ret = bdd_satmin(bdd_0, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+1)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 1)); buffer_type expected(buffer_size, buffer_default); - expected.at(0) = {0, true}; + expected.at(0) = { 0, true }; for (size_t i = 0; i < buffer_size; ++i) { AssertThat(buffer.at(i), Is().EqualTo(expected.at(i))); @@ -1211,10 +1117,10 @@ go_bandit([]() { auto ret = bdd_satmin(bdd_not(bdd_0), buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+1)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 1)); buffer_type expected(buffer_size, buffer_default); - expected.at(0) = {0, false}; + expected.at(0) = { 0, false }; for (size_t i = 0; i < buffer_size; ++i) { AssertThat(buffer.at(i), Is().EqualTo(expected.at(i))); @@ -1231,13 +1137,13 @@ go_bandit([]() { auto ret = bdd_satmin(bdd_1, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+4)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 4)); buffer_type expected(buffer_size, buffer_default); - expected.at(0) = {0, false}; - expected.at(1) = {1, false}; - expected.at(2) = {2, true}; - expected.at(3) = {3, true}; + expected.at(0) = { 0, false }; + expected.at(1) = { 1, false }; + expected.at(2) = { 2, true }; + expected.at(3) = { 3, true }; for (size_t i = 0; i < buffer_size; ++i) { AssertThat(buffer.at(i), Is().EqualTo(expected.at(i))); @@ -1249,12 +1155,12 @@ go_bandit([]() { auto ret = bdd_satmin(bdd_not(bdd_1), buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+3)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 3)); buffer_type expected(buffer_size, buffer_default); - expected.at(0) = {0, false}; - expected.at(1) = {1, false}; - expected.at(2) = {2, false}; + expected.at(0) = { 0, false }; + expected.at(1) = { 1, false }; + expected.at(2) = { 2, false }; for (size_t i = 0; i < buffer_size; ++i) { AssertThat(buffer.at(i), Is().EqualTo(expected.at(i))); @@ -1271,11 +1177,11 @@ go_bandit([]() { auto ret = bdd_satmin(bdd_4, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+2)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 2)); buffer_type expected(buffer_size, buffer_default); - expected.at(0) = {0, false}; - expected.at(1) = {2, false}; + expected.at(0) = { 0, false }; + expected.at(1) = { 2, false }; for (size_t i = 0; i < buffer_size; ++i) { AssertThat(buffer.at(i), Is().EqualTo(expected.at(i))); @@ -1287,12 +1193,12 @@ go_bandit([]() { auto ret = bdd_satmin(bdd_not(bdd_4), buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+3)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 3)); buffer_type expected(buffer_size, buffer_default); - expected.at(0) = {0, false}; - expected.at(1) = {2, true}; - expected.at(2) = {3, true}; + expected.at(0) = { 0, false }; + expected.at(1) = { 2, true }; + expected.at(2) = { 3, true }; for (size_t i = 0; i < buffer_size; ++i) { AssertThat(buffer.at(i), Is().EqualTo(expected.at(i))); @@ -1323,16 +1229,14 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1347,7 +1251,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns maximal BDD cube [~0]", [&]() { @@ -1357,16 +1261,14 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1381,7 +1283,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns maximal BDD cube [1]", [&]() { @@ -1391,24 +1293,22 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, - terminal_F, - bdd::pointer_type(2, bdd::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, bdd::max_id, terminal_F, bdd::pointer_type(2, bdd::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1423,7 +1323,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns maximal BDD cube [~1]", [&]() { @@ -1433,24 +1333,22 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, - terminal_F, - bdd::pointer_type(2, bdd::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, bdd::max_id, terminal_F, bdd::pointer_type(2, bdd::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1465,7 +1363,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns maximal BDD cube [2]", [&]() { @@ -1475,24 +1373,22 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, - terminal_F, - bdd::pointer_type(2, bdd::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, bdd::max_id, terminal_F, bdd::pointer_type(2, bdd::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1507,7 +1403,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns maximal BDD cube [~2]", [&]() { @@ -1517,32 +1413,30 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, bdd::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, bdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, - bdd::pointer_type(3, bdd::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, bdd::max_id, bdd::pointer_type(3, bdd::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, - terminal_F, - bdd::pointer_type(2, bdd::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, bdd::max_id, terminal_F, bdd::pointer_type(2, bdd::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1557,7 +1451,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns maximal BDD cube [3]", [&]() { @@ -1567,24 +1461,22 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, bdd::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(5, bdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, bdd::max_id, - terminal_F, - bdd::pointer_type(5, bdd::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, bdd::max_id, terminal_F, bdd::pointer_type(5, bdd::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1599,7 +1491,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns maximal BDD cube [~3]", [&]() { @@ -1609,24 +1501,22 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, bdd::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(5, bdd::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, bdd::max_id, - terminal_F, - bdd::pointer_type(5, bdd::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, bdd::max_id, terminal_F, bdd::pointer_type(5, bdd::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1641,7 +1531,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns maximal BDD cube [4]", [&]() { @@ -1651,32 +1541,30 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, bdd::max_id, - terminal_F, - bdd::pointer_type(2, bdd::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, bdd::max_id, terminal_F, bdd::pointer_type(2, bdd::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, - terminal_F, - bdd::pointer_type(1, bdd::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, bdd::max_id, terminal_F, bdd::pointer_type(1, bdd::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1691,51 +1579,48 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("returns maximal BDD cube [~4]", [&]() { bdd out = bdd_satmax(bdd_not(bdd_4)); - // Check it looks all right node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, bdd::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, bdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, bdd::max_id, - bdd::pointer_type(3, bdd::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, bdd::max_id, bdd::pointer_type(3, bdd::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, bdd::max_id, - terminal_F, - bdd::pointer_type(2, bdd::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, bdd::max_id, terminal_F, bdd::pointer_type(2, bdd::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, bdd::max_id, - terminal_F, - bdd::pointer_type(1, bdd::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, bdd::max_id, terminal_F, bdd::pointer_type(1, bdd::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1750,13 +1635,13 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(5u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(4u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); }); describe("bdd_satmax(f, c)", [&]() { it("never calls consumer for false terminal", [&]() { - size_t calls = 0u; + size_t calls = 0u; const auto cb = [&calls](pair) { calls++; }; bdd_satmax(bdd_F, cb); @@ -1764,7 +1649,7 @@ go_bandit([]() { }); it("never calls consumer for true terminal", [&]() { - size_t calls = 0u; + size_t calls = 0u; const auto cb = [&calls](pair) { calls++; }; bdd_satmax(bdd_T, cb); @@ -1772,10 +1657,10 @@ go_bandit([]() { }); it("calls consumer once with 'x0 == true' for [0]", [&]() { - size_t calls = 0u; + size_t calls = 0u; const auto cb = [&calls](pair xv) { AssertThat(calls, Is().EqualTo(0u)); - AssertThat(xv.first, Is().EqualTo(0u)); + AssertThat(xv.first, Is().EqualTo(0u)); AssertThat(xv.second, Is().EqualTo(true)); calls++; @@ -1786,10 +1671,10 @@ go_bandit([]() { }); it("calls consumer once with 'x0 == false' for [~0]", [&]() { - size_t calls = 0u; + size_t calls = 0u; const auto cb = [&calls](pair xv) { AssertThat(calls, Is().EqualTo(0u)); - AssertThat(xv.first, Is().EqualTo(0u)); + AssertThat(xv.first, Is().EqualTo(0u)); AssertThat(xv.second, Is().EqualTo(true)); calls++; @@ -1800,13 +1685,12 @@ go_bandit([]() { }); it("calls consumer with maximal truth assignment [1]", [&]() { - size_t calls = 0; - std::vector> expected = - { {0, true}, {2, false} }; + size_t calls = 0; + std::vector> expected = { { 0, true }, { 2, false } }; const auto cb = [&calls, &expected](pair xv) { AssertThat(calls, Is().LessThan(expected.size())); - AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); + AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); AssertThat(xv.second, Is().EqualTo(expected.at(calls).second)); calls++; }; @@ -1816,13 +1700,12 @@ go_bandit([]() { }); it("calls consumer with maximal truth assignment [~1]", [&]() { - size_t calls = 0; - std::vector> expected = - { {0, true}, {2, true} }; + size_t calls = 0; + std::vector> expected = { { 0, true }, { 2, true } }; const auto cb = [&calls, &expected](pair xv) { AssertThat(calls, Is().LessThan(expected.size())); - AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); + AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); AssertThat(xv.second, Is().EqualTo(expected.at(calls).second)); calls++; }; @@ -1832,13 +1715,12 @@ go_bandit([]() { }); it("calls consumer with maximal truth assignment [2]", [&]() { - size_t calls = 0; - std::vector> expected = - { {0, true}, {2, true} }; + size_t calls = 0; + std::vector> expected = { { 0, true }, { 2, true } }; const auto cb = [&calls, &expected](pair xv) { AssertThat(calls, Is().LessThan(expected.size())); - AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); + AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); AssertThat(xv.second, Is().EqualTo(expected.at(calls).second)); calls++; }; @@ -1848,13 +1730,14 @@ go_bandit([]() { }); it("calls consumer with maximal truth assignment [~2]", [&]() { - size_t calls = 0; - std::vector> expected = - { {0, true}, {2, false}, {3, true} }; + size_t calls = 0; + std::vector> expected = { { 0, true }, + { 2, false }, + { 3, true } }; const auto cb = [&calls, &expected](pair xv) { AssertThat(calls, Is().LessThan(expected.size())); - AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); + AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); AssertThat(xv.second, Is().EqualTo(expected.at(calls).second)); calls++; }; @@ -1864,13 +1747,12 @@ go_bandit([]() { }); it("calls consumer with maximal truth assignment [3]", [&]() { - size_t calls = 0; - std::vector> expected = - { {1, true}, {5, true} }; + size_t calls = 0; + std::vector> expected = { { 1, true }, { 5, true } }; const auto cb = [&calls, &expected](pair xv) { AssertThat(calls, Is().LessThan(expected.size())); - AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); + AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); AssertThat(xv.second, Is().EqualTo(expected.at(calls).second)); calls++; }; @@ -1880,13 +1762,12 @@ go_bandit([]() { }); it("calls consumer with maximal truth assignment [~3]", [&]() { - size_t calls = 0; - std::vector> expected = - { {1, true}, {5, false} }; + size_t calls = 0; + std::vector> expected = { { 1, true }, { 5, false } }; const auto cb = [&calls, &expected](pair xv) { AssertThat(calls, Is().LessThan(expected.size())); - AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); + AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); AssertThat(xv.second, Is().EqualTo(expected.at(calls).second)); calls++; }; @@ -1896,13 +1777,14 @@ go_bandit([]() { }); it("calls consumer with maximal truth assignment [4]", [&]() { - size_t calls = 0; - std::vector> expected = - { {0, true}, {1, true}, {2, true} }; + size_t calls = 0; + std::vector> expected = { { 0, true }, + { 1, true }, + { 2, true } }; const auto cb = [&calls, &expected](pair xv) { AssertThat(calls, Is().LessThan(expected.size())); - AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); + AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); AssertThat(xv.second, Is().EqualTo(expected.at(calls).second)); calls++; }; @@ -1912,13 +1794,14 @@ go_bandit([]() { }); it("calls consumer with maximal truth assignment [~4]", [&]() { - size_t calls = 0; - std::vector> expected = - { {0, true}, {1, true}, {2, false}, {3, true} }; + size_t calls = 0; + std::vector> expected = { + { 0, true }, { 1, true }, { 2, false }, { 3, true } + }; const auto cb = [&calls, &expected](pair xv) { AssertThat(calls, Is().LessThan(expected.size())); - AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); + AssertThat(xv.first, Is().EqualTo(expected.at(calls).first)); AssertThat(xv.second, Is().EqualTo(expected.at(calls).second)); calls++; }; @@ -1931,7 +1814,7 @@ go_bandit([]() { describe("bdd_satmax(f, begin, end)", [&]() { using buffer_type = std::vector>; - const buffer_type::value_type buffer_default(bdd::max_label+1, false); + const buffer_type::value_type buffer_default(bdd::max_label + 1, false); const size_t buffer_size = 4; it("outputs nothing in buffer for false terminal", [&]() { @@ -1939,7 +1822,7 @@ go_bandit([]() { auto ret = bdd_satmax(bdd_F, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+0)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 0)); buffer_type expected(buffer_size, buffer_default); @@ -1953,7 +1836,7 @@ go_bandit([]() { auto ret = bdd_satmax(bdd_T, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+0)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 0)); buffer_type expected(buffer_size, buffer_default); @@ -1967,10 +1850,10 @@ go_bandit([]() { auto ret = bdd_satmax(bdd_0, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+1)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 1)); buffer_type expected(buffer_size, buffer_default); - expected.at(0) = {0, true}; + expected.at(0) = { 0, true }; for (size_t i = 0; i < buffer_size; ++i) { AssertThat(buffer.at(i), Is().EqualTo(expected.at(i))); @@ -1982,10 +1865,10 @@ go_bandit([]() { auto ret = bdd_satmax(bdd_not(bdd_0), buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+1)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 1)); buffer_type expected(buffer_size, buffer_default); - expected.at(0) = {0, false}; + expected.at(0) = { 0, false }; for (size_t i = 0; i < buffer_size; ++i) { AssertThat(buffer.at(i), Is().EqualTo(expected.at(i))); @@ -2002,11 +1885,11 @@ go_bandit([]() { auto ret = bdd_satmax(bdd_2, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+2)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 2)); buffer_type expected(buffer_size, buffer_default); - expected.at(0) = {0, true}; - expected.at(1) = {2, true}; + expected.at(0) = { 0, true }; + expected.at(1) = { 2, true }; for (size_t i = 0; i < buffer_size; ++i) { AssertThat(buffer.at(i), Is().EqualTo(expected.at(i))); @@ -2018,12 +1901,12 @@ go_bandit([]() { auto ret = bdd_satmax(bdd_not(bdd_2), buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+3)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 3)); buffer_type expected(buffer_size, buffer_default); - expected.at(0) = {0, true}; - expected.at(1) = {2, false}; - expected.at(2) = {3, true}; + expected.at(0) = { 0, true }; + expected.at(1) = { 2, false }; + expected.at(2) = { 3, true }; for (size_t i = 0; i < buffer_size; ++i) { AssertThat(buffer.at(i), Is().EqualTo(expected.at(i))); @@ -2045,12 +1928,12 @@ go_bandit([]() { auto ret = bdd_satmax(bdd_4, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+3)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 3)); buffer_type expected(buffer_size, buffer_default); - expected.at(0) = {0, true}; - expected.at(1) = {1, true}; - expected.at(2) = {2, true}; + expected.at(0) = { 0, true }; + expected.at(1) = { 1, true }; + expected.at(2) = { 2, true }; for (size_t i = 0; i < buffer_size; ++i) { AssertThat(buffer.at(i), Is().EqualTo(expected.at(i))); @@ -2062,13 +1945,13 @@ go_bandit([]() { auto ret = bdd_satmax(bdd_not(bdd_4), buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+4)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 4)); buffer_type expected(buffer_size, buffer_default); - expected.at(0) = {0, true}; - expected.at(1) = {1, true}; - expected.at(2) = {2, false}; - expected.at(3) = {3, true}; + expected.at(0) = { 0, true }; + expected.at(1) = { 1, true }; + expected.at(2) = { 2, false }; + expected.at(3) = { 3, true }; for (size_t i = 0; i < buffer_size; ++i) { AssertThat(buffer.at(i), Is().EqualTo(expected.at(i))); @@ -2082,4 +1965,4 @@ go_bandit([]() { }); } // bdd_satmin, bdd_satmax }); - }); +}); diff --git a/test/adiar/bdd/test_if_then_else.cpp b/test/adiar/bdd/test_if_then_else.cpp index 0abf84e39..fefb16eba 100644 --- a/test/adiar/bdd/test_if_then_else.cpp +++ b/test/adiar/bdd/test_if_then_else.cpp @@ -23,29 +23,27 @@ go_bandit([]() { nw_T << node(true); node_writer nw_x0(bdd_x0); - nw_x0 << node(0,0,terminal_F,terminal_T); + nw_x0 << node(0, 0, terminal_F, terminal_T); node_writer nw_not_x0(bdd_not_x0); - nw_not_x0 << node(0,0,terminal_T,terminal_F); + nw_not_x0 << node(0, 0, terminal_T, terminal_F); node_writer nw_x1(bdd_x1); - nw_x1 << node(1,0,terminal_F,terminal_T); + nw_x1 << node(1, 0, terminal_F, terminal_T); node_writer nw_not_x1(bdd_not_x1); - nw_not_x1 << node(1,0,terminal_T,terminal_F); + nw_not_x1 << node(1, 0, terminal_T, terminal_F); node_writer nw_x2(bdd_x2); - nw_x2 << node(2,0,terminal_F,terminal_T); + nw_x2 << node(2, 0, terminal_F, terminal_T); node_writer nw_x0_xor_x1(bdd_x0_xor_x1); - nw_x0_xor_x1 << node(1,1,terminal_T,terminal_F) - << node(1,0,terminal_F,terminal_T) - << node(0,0,ptr_uint64(1,0),ptr_uint64(1,1)); + nw_x0_xor_x1 << node(1, 1, terminal_T, terminal_F) << node(1, 0, terminal_F, terminal_T) + << node(0, 0, ptr_uint64(1, 0), ptr_uint64(1, 1)); node_writer nw_x0_xor_x2(bdd_x0_xor_x2); - nw_x0_xor_x2 << node(2,1,terminal_T,terminal_F) - << node(2,0,terminal_F,terminal_T) - << node(0,0,ptr_uint64(2,0),ptr_uint64(2,1)); + nw_x0_xor_x2 << node(2, 1, terminal_T, terminal_F) << node(2, 0, terminal_F, terminal_T) + << node(0, 0, ptr_uint64(2, 0), ptr_uint64(2, 1)); } shared_levelized_file bdd_1; @@ -63,13 +61,13 @@ go_bandit([]() { { // Garbage collect writers to free write-lock node_writer nw_1(bdd_1); - nw_1 << node(3,0,terminal_F,terminal_T) // 7 - << node(2,2,terminal_F,terminal_T) // 6 - << node(2,1,terminal_T,ptr_uint64(3,0)) // 5 - << node(2,0,ptr_uint64(3,0),terminal_T) // 4 - << node(1,1,ptr_uint64(2,1),ptr_uint64(2,0)) // 3 - << node(1,0,ptr_uint64(2,2),ptr_uint64(2,1)) // 2 - << node(0,0,ptr_uint64(1,0),ptr_uint64(1,1)) // 1 + nw_1 << node(3, 0, terminal_F, terminal_T) // 7 + << node(2, 2, terminal_F, terminal_T) // 6 + << node(2, 1, terminal_T, ptr_uint64(3, 0)) // 5 + << node(2, 0, ptr_uint64(3, 0), terminal_T) // 4 + << node(1, 1, ptr_uint64(2, 1), ptr_uint64(2, 0)) // 3 + << node(1, 0, ptr_uint64(2, 2), ptr_uint64(2, 1)) // 2 + << node(0, 0, ptr_uint64(1, 0), ptr_uint64(1, 1)) // 1 ; } @@ -88,15 +86,15 @@ go_bandit([]() { { // Garbage collect writers to free write-lock node_writer nw_2(bdd_2); - nw_2 << node(3,1,terminal_F,terminal_T) // 9 - << node(3,0,terminal_T,terminal_F) // 8 - << node(2,3,terminal_F,terminal_T) // 7 - << node(2,2,terminal_T,terminal_F) // 6 - << node(2,1,terminal_F,ptr_uint64(3,1)) // 5 - << node(2,0,terminal_F,ptr_uint64(3,0)) // 4 - << node(1,1,ptr_uint64(2,2),ptr_uint64(2,3)) // 3 - << node(1,0,ptr_uint64(2,0),ptr_uint64(2,1)) // 2 - << node(0,0,ptr_uint64(1,0),ptr_uint64(1,1)) // 1 + nw_2 << node(3, 1, terminal_F, terminal_T) // 9 + << node(3, 0, terminal_T, terminal_F) // 8 + << node(2, 3, terminal_F, terminal_T) // 7 + << node(2, 2, terminal_T, terminal_F) // 6 + << node(2, 1, terminal_F, ptr_uint64(3, 1)) // 5 + << node(2, 0, terminal_F, ptr_uint64(3, 0)) // 4 + << node(1, 1, ptr_uint64(2, 2), ptr_uint64(2, 3)) // 3 + << node(1, 0, ptr_uint64(2, 0), ptr_uint64(2, 1)) // 2 + << node(0, 0, ptr_uint64(1, 0), ptr_uint64(1, 1)) // 1 ; } @@ -115,12 +113,12 @@ go_bandit([]() { { // Garbage collect writers to free write-lock node_writer nw_3(bdd_3); - nw_3 << node(3,0,terminal_F,terminal_T) // 6 - << node(2,2,terminal_F,terminal_T) // 5 - << node(2,1,terminal_F,ptr_uint64(3,0)) // 4 - << node(2,0,terminal_T,terminal_F) // 3 - << node(1,0,ptr_uint64(2,0),ptr_uint64(2,1)) // 2 - << node(0,0,ptr_uint64(1,0),ptr_uint64(2,2)) // 1 + nw_3 << node(3, 0, terminal_F, terminal_T) // 6 + << node(2, 2, terminal_F, terminal_T) // 5 + << node(2, 1, terminal_F, ptr_uint64(3, 0)) // 4 + << node(2, 0, terminal_T, terminal_F) // 3 + << node(1, 0, ptr_uint64(2, 0), ptr_uint64(2, 1)) // 2 + << node(0, 0, ptr_uint64(1, 0), ptr_uint64(2, 2)) // 1 ; } @@ -138,13 +136,13 @@ go_bandit([]() { */ { // Garbage collect writers to free write-lock node_writer nw_4(bdd_4); - nw_4 << node(3,1,terminal_F,terminal_T) // 7 - << node(3,0,terminal_T,terminal_F) // 6 - << node(2,2,terminal_F,ptr_uint64(3,1)) // 5 - << node(2,1,ptr_uint64(3,0),terminal_T) // 4 - << node(2,0,terminal_T,terminal_F) // 3 - << node(1,0,ptr_uint64(2,1),ptr_uint64(2,2)) // 2 - << node(0,0,ptr_uint64(1,0),ptr_uint64(2,0)) // 1 + nw_4 << node(3, 1, terminal_F, terminal_T) // 7 + << node(3, 0, terminal_T, terminal_F) // 6 + << node(2, 2, terminal_F, ptr_uint64(3, 1)) // 5 + << node(2, 1, ptr_uint64(3, 0), terminal_T) // 4 + << node(2, 0, terminal_T, terminal_F) // 3 + << node(1, 0, ptr_uint64(2, 1), ptr_uint64(2, 2)) // 2 + << node(0, 0, ptr_uint64(1, 0), ptr_uint64(2, 0)) // 1 ; } @@ -162,12 +160,12 @@ go_bandit([]() { */ { // Garbage collect writers to free write-lock node_writer nw_5(bdd_5); - nw_5 << node(3,0,terminal_T,terminal_F) // 6 - << node(2,2,terminal_F,ptr_uint64(3,0)) // 5 - << node(2,1,terminal_F,terminal_T) // 4 - << node(2,0,terminal_T,terminal_F) // 3 - << node(1,0,ptr_uint64(2,2),ptr_uint64(2,0)) // 2 - << node(0,0,ptr_uint64(1,0),ptr_uint64(2,1)) // 1 + nw_5 << node(3, 0, terminal_T, terminal_F) // 6 + << node(2, 2, terminal_F, ptr_uint64(3, 0)) // 5 + << node(2, 1, terminal_F, terminal_T) // 4 + << node(2, 0, terminal_T, terminal_F) // 3 + << node(1, 0, ptr_uint64(2, 2), ptr_uint64(2, 0)) // 2 + << node(0, 0, ptr_uint64(1, 0), ptr_uint64(2, 1)) // 1 ; } @@ -183,11 +181,9 @@ go_bandit([]() { */ { // Garbage collect writers to free write-lock node_writer nw_6(bdd_6); - nw_6 << node(2,1,terminal_T,terminal_F) - << node(2,0,terminal_F,terminal_T) - << node(1,0,ptr_uint64(2,0),ptr_uint64(2,1)) - << node(0,0,terminal_F,ptr_uint64(1,0)) - ; + nw_6 << node(2, 1, terminal_T, terminal_F) << node(2, 0, terminal_F, terminal_T) + << node(1, 0, ptr_uint64(2, 0), ptr_uint64(2, 1)) + << node(0, 0, terminal_F, ptr_uint64(1, 0)); } shared_levelized_file bdd_not_6; @@ -202,11 +198,9 @@ go_bandit([]() { */ { // Garbage collect writers to free write-lock node_writer nw_not_6(bdd_not_6); - nw_not_6 << node(2,1,terminal_F,terminal_T) - << node(2,0,terminal_T,terminal_F) - << node(1,0,ptr_uint64(2,0),ptr_uint64(2,1)) - << node(0,0,terminal_T,ptr_uint64(1,0)) - ; + nw_not_6 << node(2, 1, terminal_F, terminal_T) << node(2, 0, terminal_T, terminal_F) + << node(1, 0, ptr_uint64(2, 0), ptr_uint64(2, 1)) + << node(0, 0, terminal_T, ptr_uint64(1, 0)); } shared_levelized_file bdd_7; @@ -224,11 +218,11 @@ go_bandit([]() { { node_writer nw_7(bdd_7); - nw_7 << node(3,0,terminal_F,terminal_T) // 5 - << node(2,1,ptr_uint64(3,0),terminal_T) // 4 - << node(2,0,terminal_F,ptr_uint64(3,0)) // 3 - << node(1,0,ptr_uint64(2,0),ptr_uint64(2,1)) // 2 - << node(0,0,ptr_uint64(1,0),ptr_uint64(2,1)) // 1 + nw_7 << node(3, 0, terminal_F, terminal_T) // 5 + << node(2, 1, ptr_uint64(3, 0), terminal_T) // 4 + << node(2, 0, terminal_F, ptr_uint64(3, 0)) // 3 + << node(1, 0, ptr_uint64(2, 0), ptr_uint64(2, 1)) // 2 + << node(0, 0, ptr_uint64(1, 0), ptr_uint64(2, 1)) // 1 ; } @@ -246,10 +240,10 @@ go_bandit([]() { */ { node_writer nw_8(bdd_8); - nw_8 << node(3,0,terminal_T,terminal_F) // 4 - << node(2,0,terminal_T,ptr_uint64(3,0)) // 3 - << node(1,0,ptr_uint64(2,0),ptr_uint64(3,0)) // 2 - << node(0,0,ptr_uint64(1,0),ptr_uint64(3,0)) // 1 + nw_8 << node(3, 0, terminal_T, terminal_F) // 4 + << node(2, 0, terminal_T, ptr_uint64(3, 0)) // 3 + << node(1, 0, ptr_uint64(2, 0), ptr_uint64(3, 0)) // 2 + << node(0, 0, ptr_uint64(1, 0), ptr_uint64(3, 0)) // 1 ; } @@ -310,41 +304,45 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should create XNOR of x0 and ~x1 (x0 ? ~x1 : x1) due to same file", [&]() { @@ -353,41 +351,45 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should create OR of x0 and x1 (x0 ? x0 : x1) due to same file", [&]() { @@ -396,35 +398,38 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should create AND of x0 (negated) and x1 (x0 ? ~x0 : x1) due to same file", [&]() { @@ -433,35 +438,38 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("should create AND of x0 and x1 (x0 ? x1 : x0) due to same file", [&]() { @@ -470,35 +478,38 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("should create IMPLIES of x0 and x1 (x0 ? x1 : ~x0) due to same file", [&]() { @@ -507,35 +518,38 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should create OR of x0 and x1 (x0 ? T : x1)", [&]() { @@ -544,35 +558,38 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should create AND of x0 (negated) and x1 (x0 ? F : x1)", [&]() { @@ -581,35 +598,38 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("should create IMPLIES of x0 and x1 (x0 ? x1 : T)", [&]() { @@ -618,35 +638,38 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should create AND of x0 and x1 (x0 ? x1 : F)", [&]() { @@ -655,35 +678,38 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); }); @@ -703,41 +729,46 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat((std::get<__bdd::shared_arc_file_type>(out._union))->max_1level_cut, Is().EqualTo(2u)); + AssertThat((std::get<__bdd::shared_arc_file_type>(out._union))->max_1level_cut, + Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should compute x1 ? ~x0 : x0", [&]() { @@ -755,41 +786,45 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should compute x1 ? x0 : ~x0", [&]() { @@ -807,41 +842,45 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should compute ~x2 ? (x0^x1) : ~(x0^x1)", [&]() { @@ -850,9 +889,8 @@ go_bandit([]() { shared_levelized_file bdd_x0_xnor_x1; { node_writer nw_x0_xnor_x1(bdd_x0_xnor_x1); - nw_x0_xnor_x1 << node(1,1,terminal_T,terminal_F) - << node(1,0,terminal_F,terminal_T) - << node(0,0,ptr_uint64(1,1),ptr_uint64(1,0)); + nw_x0_xnor_x1 << node(1, 1, terminal_T, terminal_F) << node(1, 0, terminal_F, terminal_T) + << node(0, 0, ptr_uint64(1, 1), ptr_uint64(1, 0)); } /* @@ -873,52 +911,60 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // ((2,0),(1,0),(1,1)) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // ((2,0),(1,1),(1,0)) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // ((2,0),F,T) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // ((2,0),T,F) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // ((2,0),F,T) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // ((2,0),T,F) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should compute x3 ? (x1 & x2) : bdd_1", [&]() { @@ -930,7 +976,7 @@ go_bandit([]() { */ { node_writer nw_x3(bdd_x3); - nw_x3 << node(3,0,terminal_F,terminal_T); + nw_x3 << node(3, 0, terminal_F, terminal_T); } shared_levelized_file bdd_x1_and_x2; @@ -943,8 +989,8 @@ go_bandit([]() { */ { node_writer nw_x1_and_x2(bdd_x1_and_x2); - nw_x1_and_x2 << node(2,1,terminal_F,terminal_T) - << node(1,0,terminal_F,ptr_uint64(2,1)); + nw_x1_and_x2 << node(2, 1, terminal_F, terminal_T) + << node(1, 0, terminal_F, ptr_uint64(2, 1)); } /* @@ -983,83 +1029,97 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // (1,1,2) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (1,1,3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (1,2,4) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (1,2,5) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (1,F,5) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (1,F,6) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,3) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 3) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (1,F,7) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,2), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (1,F,T) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), false, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,2), false, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,3), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 3), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (1,T,7) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), true, ptr_uint64(3,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, ptr_uint64(3, 2) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // (1,2,4) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (1,F,6) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,3), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 3), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (1,F,7) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (1,F,T) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (1,T,7) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 2), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,4u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 4u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 3u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(6u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(5u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(5u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); }); it("should compute bdd_3 ? bdd_4 : bdd_5", [&]() { @@ -1091,73 +1151,82 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // (2,2,2) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (3,4,5) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (4,5,3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (5,3,4) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (F,_,6) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (T,6,_) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (6,7,F) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), true, ptr_uint64(3,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, ptr_uint64(3, 2) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // (4,5,3) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (5,3,4) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (F,_,6) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (T,6,_) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (6,7,F) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 2), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 3u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 3u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(3u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(5u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(5u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(4u)); }); it("should compute bdd_6 ? x0^x2 : bdd_not_6", [&]() { @@ -1188,51 +1257,55 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // (2,2,3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (3,3,3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (4,4,3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // (1,1,1) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (3,3,3) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (4,4,3) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(4u)); }); - it("should compute bdd_not_6 ? bdd_6 : x0^x2", [&]() { /* bdd_x0_xor_x2 // _1_ ---- x1 @@ -1261,48 +1334,53 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // (2,3,2) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (3,3,3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (4,3,4) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // (1,1,1) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (3,3,3) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (4,4,3) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(4u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(4u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("should compute ~(x0^x2) ? ~x2 : bdd_1", [&]() { @@ -1316,9 +1394,9 @@ go_bandit([]() { */ { node_writer nw_x0_xnor_x2(bdd_x0_xnor_x2); - nw_x0_xnor_x2 << node(2,1,terminal_T,terminal_F) // 3 - << node(2,0,terminal_F,terminal_T) // 2 - << node(0,0,ptr_uint64(2,1),ptr_uint64(2,0)); // 1 + nw_x0_xnor_x2 << node(2, 1, terminal_T, terminal_F) // 3 + << node(2, 0, terminal_F, terminal_T) // 2 + << node(0, 0, ptr_uint64(2, 1), ptr_uint64(2, 0)); // 1 } /* @@ -1350,73 +1428,83 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // (3,1,2) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (2,1,3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (2,1,4) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (2,1,5) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (3,1,5) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (3,1,6) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,3) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 3) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (F,_,7) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,2), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // (2,1,4) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (2,1,5) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (3,1,5) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (3,1,6) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,3), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 3), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,3), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 3), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (F,_,7) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,4u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 4u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(5u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(5u)); }); it("should compute (x1^x2) ? bdd_1 : bdd_2", [&]() { @@ -1431,9 +1519,9 @@ go_bandit([]() { { node_writer nw_x1_xor_x2(bdd_x1_xor_x2_2); - nw_x1_xor_x2 << node(2,1,terminal_F,terminal_T) // 3 - << node(2,0,terminal_T,terminal_F) // 2 - << node(1,0,ptr_uint64(2,1),ptr_uint64(2,0)); // 1 + nw_x1_xor_x2 << node(2, 1, terminal_F, terminal_T) // 3 + << node(2, 0, terminal_T, terminal_F) // 2 + << node(1, 0, ptr_uint64(2, 1), ptr_uint64(2, 0)); // 1 } /* @@ -1443,12 +1531,17 @@ go_bandit([]() { // (1,2,2) (1,3,3) ---- x1 // / \ / \ // (3,6,4) (2,5,5) (3,5,6) (2,4,7) ---- x2 Order of resolvement: - // / \ / \ / \ / \ (2,5,5)**, (3,5,6)***, (3,6,4)*, (2,4,7)* - // F T T | T \ / T * Forwarding two item once - // | | ** Forwarding one item once - // | | *** Forwarding one item twice + // / \ / \ / \ / \ (2,5,5)**, (3,5,6)***, + (3,6,4)*, (2,4,7)* + // F T T | T \ / T * Forwarding two + item once + // | | ** Forwarding one + item once + // | | *** Forwarding one + item twice // (F,_,9) (T,7,_) ---- x3 - // / \ / \ (To reproduce: look at actual ids and sorting) + // / \ / \ (To reproduce: look at + actual ids and sorting) // F T F T */ __bdd out = bdd_ite(bdd_x1_xor_x2_2, bdd_1, bdd_2); @@ -1456,79 +1549,90 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // (1,2,2) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (1,3,3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (2,5,5) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (3,5,6) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (3,6,4) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (2,4,7) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,3) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 3) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (T,7,_) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,3), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 3), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (F,_,9) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // (2,5,5) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (3,5,6) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (3,6,4) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (2,4,7) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,3), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 3), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (T,7,_) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (F,_,9) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,4u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 4u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(6u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(6u)); }); it("should compute (~x0 & ~x1 & x2) ? bdd_2 : bdd_4", [&]() { @@ -1545,9 +1649,9 @@ go_bandit([]() { { node_writer nw_if(bdd_if); - nw_if << node(2,0,terminal_F,terminal_T) // 3 - << node(1,0,ptr_uint64(2,0),terminal_F) // 2 - << node(0,0,ptr_uint64(1,0),terminal_F); // 1 + nw_if << node(2, 0, terminal_F, terminal_T) // 3 + << node(1, 0, ptr_uint64(2, 0), terminal_F) // 2 + << node(0, 0, ptr_uint64(1, 0), terminal_F); // 1 } /* @@ -1571,73 +1675,82 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // (2,2,2) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (F,_,3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (3,4,4) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (F,_,5) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (F,_,6) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (T,8,_) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (F,_,7) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,2), true, ptr_uint64(3,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), true, ptr_uint64(3, 2) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // (F,_,3) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (F,_,5) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (F,_,6) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (T,8,_) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (F,_,7) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 2), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 3u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 3u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(3u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(5u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(5u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(4u)); }); it("should compute (x0 | (x1 & x2)) ? bdd_8 : bdd_7", [&]() { @@ -1653,9 +1766,9 @@ go_bandit([]() { */ { node_writer nw_if(bdd_if); - nw_if << node(2,0,terminal_F,terminal_T) // 3 - << node(1,0,terminal_F,ptr_uint64(2,0)) // 2 - << node(0,0,ptr_uint64(1,0),terminal_T) // 1 + nw_if << node(2, 0, terminal_F, terminal_T) // 3 + << node(1, 0, terminal_F, ptr_uint64(2, 0)) // 2 + << node(0, 0, ptr_uint64(1, 0), terminal_T) // 1 ; } @@ -1677,61 +1790,70 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // (2,2,2) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (F,_,3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (3,4,4) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (F,_,5) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (T,4,_) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // (F,_,3) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (F,_,5) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (T,4,_) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should compute bdd_6 ? bdd_4 : bdd_2", [&]() { @@ -1753,77 +1875,87 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // (F,_,2) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (2,3,3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (F,_,4) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (F,_,5) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (3,3,6) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (4,3,7) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,3) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 3) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (F,_,8) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (F,_,9) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // (F,_,4) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (F,_,5) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (3,3,6) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (4,3,7) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,3), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 3), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,3), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 3), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (F,_,8) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // (F,_,9) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_T })); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,4u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 4u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(5u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(5u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(5u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(5u)); }); }); @@ -1840,8 +1972,8 @@ go_bandit([]() { { node_writer nw_x1_and_x3(bdd_x1_and_x3); - nw_x1_and_x3 << node(3,42,terminal_F,terminal_T) // 2 - << node(1,0,terminal_F,ptr_uint64(3,42)); // 1 + nw_x1_and_x3 << node(3, 42, terminal_F, terminal_T) // 2 + << node(1, 0, terminal_F, ptr_uint64(3, 42)); // 1 } __bdd out = bdd_ite(bdd_x0, bdd_x2, bdd_x1_and_x3); @@ -1850,55 +1982,61 @@ go_bandit([]() { node_test_stream ns(out); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3,42, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(3, 42, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2,0, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(2, 0, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1,0, - terminal_F, - ptr_uint64(3,42)))); + AssertThat(ns.pull(), Is().EqualTo(node(1, 0, terminal_F, ptr_uint64(3, 42)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0,0, - ptr_uint64(1,0), - ptr_uint64(2,0)))); + AssertThat(ns.pull(), Is().EqualTo(node(0, 0, ptr_uint64(1, 0), ptr_uint64(2, 0)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(3u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(5u)); - - AssertThat(out.get>()->max_2level_cut[cut::Internal], Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get>()->max_2level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(3u)); - AssertThat(out.get>()->max_2level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get>()->max_2level_cut[cut::All], Is().GreaterThanOrEqualTo(5u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().GreaterThanOrEqualTo(2u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().GreaterThanOrEqualTo(3u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().GreaterThanOrEqualTo(5u)); + + AssertThat(out.get>()->max_2level_cut[cut::Internal], + Is().GreaterThanOrEqualTo(2u)); + AssertThat( + out.get>()->max_2level_cut[cut::Internal_False], + Is().GreaterThanOrEqualTo(3u)); + AssertThat( + out.get>()->max_2level_cut[cut::Internal_True], + Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get>()->max_2level_cut[cut::All], + Is().GreaterThanOrEqualTo(5u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should merely zip disjunct levels if possible [2]", [&]() { @@ -1917,12 +2055,12 @@ go_bandit([]() { { node_writer nw_then(bdd_then); - nw_then << node(6,1,terminal_T,terminal_F) // 6 - << node(4,1,terminal_T,ptr_uint64(6,1)) // 5 - << node(4,0,terminal_F,terminal_T) // 4 - << node(3,2,terminal_T,ptr_uint64(4,1)) // 3 - << node(3,0,terminal_T,ptr_uint64(4,0)) // 2 - << node(2,0,ptr_uint64(3,0),ptr_uint64(3,2)); // 1 + nw_then << node(6, 1, terminal_T, terminal_F) // 6 + << node(4, 1, terminal_T, ptr_uint64(6, 1)) // 5 + << node(4, 0, terminal_F, terminal_T) // 4 + << node(3, 2, terminal_T, ptr_uint64(4, 1)) // 3 + << node(3, 0, terminal_T, ptr_uint64(4, 0)) // 2 + << node(2, 0, ptr_uint64(3, 0), ptr_uint64(3, 2)); // 1 } shared_levelized_file bdd_else; @@ -1936,9 +2074,9 @@ go_bandit([]() { { node_writer nw_else(bdd_else); - nw_else << node(8,1,terminal_T,terminal_F) // 3 - << node(8,0,terminal_F,terminal_T) // 2 - << node(5,0,ptr_uint64(8,0),ptr_uint64(8,1)) // 1 + nw_else << node(8, 1, terminal_T, terminal_F) // 3 + << node(8, 0, terminal_F, terminal_T) // 2 + << node(5, 0, ptr_uint64(8, 0), ptr_uint64(8, 1)) // 1 ; } @@ -1948,126 +2086,116 @@ go_bandit([]() { node_test_stream ns(out); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(8,1, - terminal_T, - terminal_F))); + AssertThat(ns.pull(), Is().EqualTo(node(8, 1, terminal_T, terminal_F))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(8,0, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(8, 0, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(6,1, - terminal_T, - terminal_F))); + AssertThat(ns.pull(), Is().EqualTo(node(6, 1, terminal_T, terminal_F))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(5,0, - ptr_uint64(8,0), - ptr_uint64(8,1)))); + AssertThat(ns.pull(), Is().EqualTo(node(5, 0, ptr_uint64(8, 0), ptr_uint64(8, 1)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(4,1, - terminal_T, - ptr_uint64(6,1)))); + AssertThat(ns.pull(), Is().EqualTo(node(4, 1, terminal_T, ptr_uint64(6, 1)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(4,0, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(4, 0, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3,2, - terminal_T, - ptr_uint64(4,1)))); + AssertThat(ns.pull(), Is().EqualTo(node(3, 2, terminal_T, ptr_uint64(4, 1)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3,0, - terminal_T, - ptr_uint64(4,0)))); + AssertThat(ns.pull(), Is().EqualTo(node(3, 0, terminal_T, ptr_uint64(4, 0)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2,0, - ptr_uint64(3,0), - ptr_uint64(3,2)))); + AssertThat(ns.pull(), Is().EqualTo(node(2, 0, ptr_uint64(3, 0), ptr_uint64(3, 2)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1,1, - ptr_uint64(5,0), - ptr_uint64(2,0)))); + AssertThat(ns.pull(), Is().EqualTo(node(1, 1, ptr_uint64(5, 0), ptr_uint64(2, 0)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1,0, - ptr_uint64(2,0), - ptr_uint64(5,0)))); + AssertThat(ns.pull(), Is().EqualTo(node(1, 0, ptr_uint64(2, 0), ptr_uint64(5, 0)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0,0, - ptr_uint64(1,0), - ptr_uint64(1,1)))); + AssertThat(ns.pull(), Is().EqualTo(node(0, 0, ptr_uint64(1, 0), ptr_uint64(1, 1)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(8,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(8, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(6,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(6, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(4,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(4, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().GreaterThanOrEqualTo(4u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(4u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(7u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(11u)); - - AssertThat(out.get>()->max_2level_cut[cut::Internal], Is().GreaterThanOrEqualTo(4u)); - AssertThat(out.get>()->max_2level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(4u)); - AssertThat(out.get>()->max_2level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(7u)); - AssertThat(out.get>()->max_2level_cut[cut::All], Is().GreaterThanOrEqualTo(11u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(7u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().GreaterThanOrEqualTo(4u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().GreaterThanOrEqualTo(4u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().GreaterThanOrEqualTo(7u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().GreaterThanOrEqualTo(11u)); + + AssertThat(out.get>()->max_2level_cut[cut::Internal], + Is().GreaterThanOrEqualTo(4u)); + AssertThat( + out.get>()->max_2level_cut[cut::Internal_False], + Is().GreaterThanOrEqualTo(4u)); + AssertThat( + out.get>()->max_2level_cut[cut::Internal_True], + Is().GreaterThanOrEqualTo(7u)); + AssertThat(out.get>()->max_2level_cut[cut::All], + Is().GreaterThanOrEqualTo(11u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(4u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(7u)); }); it("can derive canonicity when zipping with one-node 'if'", [&]() { shared_levelized_file bdd_if; { node_writer nw_if(bdd_if); - nw_if << node(0, node::max_id,terminal_T,terminal_F); + nw_if << node(0, node::max_id, terminal_T, terminal_F); } shared_levelized_file bdd_a; { node_writer nw_a(bdd_a); - nw_a << node(2, node::max_id,terminal_F,terminal_T); + nw_a << node(2, node::max_id, terminal_F, terminal_T); } shared_levelized_file bdd_b; { node_writer nw_b(bdd_b); - nw_b << node(1, node::max_id,terminal_T,terminal_F); + nw_b << node(1, node::max_id, terminal_T, terminal_F); } bdd out_1 = bdd_ite(bdd_if, bdd_a, bdd_b); @@ -2083,28 +2211,30 @@ go_bandit([]() { AssertThat(bdd_iscanonical(out_2n), Is().True()); }); - it("can derive canonicity when zipping negated 'then' or 'else'", [&]() { shared_levelized_file bdd_if; { node_writer nw_if(bdd_if); - nw_if << node(0, node::max_id,terminal_T,terminal_F); + nw_if << node(0, node::max_id, terminal_T, terminal_F); } AssertThat(bdd_iscanonical(bdd(bdd_if)), Is().True()); shared_levelized_file bdd_a; { node_writer nw_a(bdd_a); - nw_a << node(2, node::max_id,terminal_F,terminal_T); + nw_a << node(2, node::max_id, terminal_F, terminal_T); } AssertThat(bdd_iscanonical(bdd(bdd_a)), Is().True()); shared_levelized_file bdd_b; { node_writer nw_b(bdd_b); - nw_b << node(3, node::max_id, terminal_F, terminal_T) - << node(3, node::max_id-1, terminal_T, terminal_F) - << node(1, node::max_id, ptr_uint64(3, ptr_uint64::max_id), ptr_uint64(3, ptr_uint64::max_id)); + nw_b << node(3, node::max_id, terminal_F, terminal_T) + << node(3, node::max_id - 1, terminal_T, terminal_F) + << node(1, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(3, ptr_uint64::max_id)); } AssertThat(bdd_iscanonical(bdd(bdd_b)), Is().True()); @@ -2132,21 +2262,24 @@ go_bandit([]() { shared_levelized_file bdd_if; { node_writer nw_if(bdd_if); - nw_if << node(1, node::max_id, terminal_T, terminal_T) - << node(1, node::max_id-1, terminal_F, terminal_F) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id-1), ptr_uint64(1, ptr_uint64::max_id)); + nw_if << node(1, node::max_id, terminal_T, terminal_T) + << node(1, node::max_id - 1, terminal_F, terminal_F) + << node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id - 1), + ptr_uint64(1, ptr_uint64::max_id)); } shared_levelized_file bdd_a; { node_writer nw_a(bdd_a); - nw_a << node(3, node::max_id,terminal_F,terminal_T); + nw_a << node(3, node::max_id, terminal_F, terminal_T); } shared_levelized_file bdd_b; { node_writer nw_b(bdd_b); - nw_b << node(2, node::max_id,terminal_T,terminal_F); + nw_b << node(2, node::max_id, terminal_T, terminal_F); } bdd out_1 = bdd_ite(bdd_if, bdd_a, bdd_b); @@ -2165,50 +2298,57 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("should not zip if bdd_else is not beyond max_var of bdd_if", [&]() { @@ -2217,51 +2357,58 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); }); }); - }); +}); diff --git a/test/adiar/bdd/test_negate.cpp b/test/adiar/bdd/test_negate.cpp index c6d35998a..fba7d6118 100644 --- a/test/adiar/bdd/test_negate.cpp +++ b/test/adiar/bdd/test_negate.cpp @@ -39,7 +39,10 @@ go_bandit([]() { nw << node(2, node::max_id, terminal_F_ptr, terminal_T_ptr) << node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_T_ptr) - << node(0, node::max_id, ptr_uint64(2, ptr_uint64::max_id), ptr_uint64(1, ptr_uint64::max_id)); + << node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(1, ptr_uint64::max_id)); } bdd bdd_1(bdd_1_nf); @@ -61,8 +64,11 @@ go_bandit([]() { nw << node(2, node::max_id, terminal_F_ptr, terminal_T_ptr) << node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_T_ptr) - << node(1, node::max_id-1, terminal_T_ptr, ptr_uint64(2, ptr_uint64::max_id)) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id-1), ptr_uint64(1, ptr_uint64::max_id)); + << node(1, node::max_id - 1, terminal_T_ptr, ptr_uint64(2, ptr_uint64::max_id)) + << node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id - 1), + ptr_uint64(1, ptr_uint64::max_id)); } bdd bdd_2(bdd_2_nf); @@ -98,19 +104,18 @@ go_bandit([]() { node_test_stream ns(out); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F_ptr, - terminal_T_ptr))); + AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, terminal_F_ptr, terminal_T_ptr))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_T_ptr))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_T_ptr))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(1, ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node( + 0, node::max_id, ptr_uint64(2, ptr_uint64::max_id), ptr_uint64(1, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); }); @@ -145,44 +150,44 @@ go_bandit([]() { node_test_stream ns(out); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T_ptr, - terminal_F_ptr))); + AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, terminal_T_ptr, terminal_F_ptr))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_F_ptr))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_F_ptr))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(1, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(1, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); }); it("should double-negate terminal-children in BDD 1 back to the original", [&]() { bdd temp = bdd_not(bdd_1); - bdd out = bdd_not(temp); + bdd out = bdd_not(temp); // Check if it is correct node_test_stream ns(out); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F_ptr, - terminal_T_ptr))); + AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, terminal_F_ptr, terminal_T_ptr))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_T_ptr))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_T_ptr))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(1, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(1, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); }); @@ -193,25 +198,24 @@ go_bandit([]() { node_test_stream ns(out); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T_ptr, - terminal_F_ptr))); + AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, terminal_T_ptr, terminal_F_ptr))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_F_ptr))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_F_ptr))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id-1, - terminal_F_ptr, - ptr_uint64(2, ptr_uint64::max_id)))); - + AssertThat(ns.pull(), + Is().EqualTo( + node(1, node::max_id - 1, terminal_F_ptr, ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(1, ptr_uint64::max_id-1), - ptr_uint64(1, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id - 1), + ptr_uint64(1, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); }); @@ -247,19 +251,19 @@ go_bandit([]() { node_test_stream ns(out); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T_ptr, - terminal_F_ptr))); + AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, terminal_T_ptr, terminal_F_ptr))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_F_ptr))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_F_ptr))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(1, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(1, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); }); @@ -270,28 +274,27 @@ go_bandit([]() { node_test_stream ns(out); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T_ptr, - terminal_F_ptr))); + AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, terminal_T_ptr, terminal_F_ptr))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_F_ptr))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_F_ptr))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id-1, - terminal_F_ptr, - ptr_uint64(2, ptr_uint64::max_id)))); - + AssertThat(ns.pull(), + Is().EqualTo( + node(1, node::max_id - 1, terminal_F_ptr, ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(1, ptr_uint64::max_id-1), - ptr_uint64(1, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id - 1), + ptr_uint64(1, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); }); }); }); - }); +}); diff --git a/test/adiar/bdd/test_pred.cpp b/test/adiar/bdd/test_pred.cpp index e886e9e46..15a04ae7e 100644 --- a/test/adiar/bdd/test_pred.cpp +++ b/test/adiar/bdd/test_pred.cpp @@ -129,167 +129,104 @@ go_bandit([]() { // ------------------------------------------------------------------------- describe("bdd_isvar", [&]() { - it("rejects F terminal", [&]() { - AssertThat(bdd_isvar(bdd_F), Is().False()); - }); + it("rejects F terminal", [&]() { AssertThat(bdd_isvar(bdd_F), Is().False()); }); - it("rejects T terminal", [&]() { - AssertThat(bdd_isvar(bdd_T), Is().False()); - }); + it("rejects T terminal", [&]() { AssertThat(bdd_isvar(bdd_T), Is().False()); }); - it("accepts x0 [file content]", [&]() { - AssertThat(bdd_isvar(bdd_x0), Is().True()); - }); + it("accepts x0 [file content]", [&]() { AssertThat(bdd_isvar(bdd_x0), Is().True()); }); - it("accepts x0 [complement flag]", [&]() { - AssertThat(bdd_isvar(bdd(bdd_not_x0, true)), Is().True()); - }); + it("accepts x0 [complement flag]", + [&]() { AssertThat(bdd_isvar(bdd(bdd_not_x0, true)), Is().True()); }); - it("accepts ~x0 [file content]", [&]() { - AssertThat(bdd_isvar(bdd_not_x0), Is().True()); - }); + it("accepts ~x0 [file content]", [&]() { AssertThat(bdd_isvar(bdd_not_x0), Is().True()); }); - it("accepts ~x0 [complement flag]", [&]() { - AssertThat(bdd_isvar(bdd(bdd_x0, true)), Is().True()); - }); + it("accepts ~x0 [complement flag]", + [&]() { AssertThat(bdd_isvar(bdd(bdd_x0, true)), Is().True()); }); - it("accepts x1 [file content]", [&]() { - AssertThat(bdd_isvar(bdd_x1), Is().True()); - }); + it("accepts x1 [file content]", [&]() { AssertThat(bdd_isvar(bdd_x1), Is().True()); }); - it("accepts ~x1 [complement flag]", [&]() { - AssertThat(bdd_isvar(bdd(bdd_x1, true)), Is().True()); - }); + it("accepts ~x1 [complement flag]", + [&]() { AssertThat(bdd_isvar(bdd(bdd_x1, true)), Is().True()); }); - it("rejects x0 & x2", [&]() { - AssertThat(bdd_isvar(bdd_0and2), Is().False()); - }); + it("rejects x0 & x2", [&]() { AssertThat(bdd_isvar(bdd_0and2), Is().False()); }); }); describe("bdd_isithvar", [&]() { - it("rejects F terminal", [&]() { - AssertThat(bdd_isithvar(bdd_F), Is().False()); - }); + it("rejects F terminal", [&]() { AssertThat(bdd_isithvar(bdd_F), Is().False()); }); - it("rejects T terminal", [&]() { - AssertThat(bdd_isithvar(bdd_T), Is().False()); - }); + it("rejects T terminal", [&]() { AssertThat(bdd_isithvar(bdd_T), Is().False()); }); - it("accepts x0 [file content]", [&]() { - AssertThat(bdd_isithvar(bdd_x0), Is().True()); - }); + it("accepts x0 [file content]", [&]() { AssertThat(bdd_isithvar(bdd_x0), Is().True()); }); - it("accepts x0 [complement flag]", [&]() { - AssertThat(bdd_isithvar(bdd(bdd_not_x0, true)), Is().True()); - }); + it("accepts x0 [complement flag]", + [&]() { AssertThat(bdd_isithvar(bdd(bdd_not_x0, true)), Is().True()); }); - it("rejects ~x0 [file content]", [&]() { - AssertThat(bdd_isithvar(bdd_not_x0), Is().False()); - }); + it("rejects ~x0 [file content]", + [&]() { AssertThat(bdd_isithvar(bdd_not_x0), Is().False()); }); - it("rejects ~x0 [complement flag]", [&]() { - AssertThat(bdd_isithvar(bdd(bdd_x0, true)), Is().False()); - }); + it("rejects ~x0 [complement flag]", + [&]() { AssertThat(bdd_isithvar(bdd(bdd_x0, true)), Is().False()); }); - it("accepts x1 [file content]", [&]() { - AssertThat(bdd_isithvar(bdd_x1), Is().True()); - }); + it("accepts x1 [file content]", [&]() { AssertThat(bdd_isithvar(bdd_x1), Is().True()); }); - it("rejects ~x1 [complement flag]", [&]() { - AssertThat(bdd_isithvar(bdd(bdd_x1, true)), Is().False()); - }); + it("rejects ~x1 [complement flag]", + [&]() { AssertThat(bdd_isithvar(bdd(bdd_x1, true)), Is().False()); }); - it("rejects x0 & x2", [&]() { - AssertThat(bdd_isithvar(bdd_0and2), Is().False()); - }); + it("rejects x0 & x2", [&]() { AssertThat(bdd_isithvar(bdd_0and2), Is().False()); }); }); describe("bdd_isnithvar", [&]() { - it("rejects F terminal", [&]() { - AssertThat(bdd_isnithvar(bdd_F), Is().False()); - }); + it("rejects F terminal", [&]() { AssertThat(bdd_isnithvar(bdd_F), Is().False()); }); - it("rejects T terminal", [&]() { - AssertThat(bdd_isnithvar(bdd_T), Is().False()); - }); + it("rejects T terminal", [&]() { AssertThat(bdd_isnithvar(bdd_T), Is().False()); }); - it("rejects x0 [file content]", [&]() { - AssertThat(bdd_isnithvar(bdd_x0), Is().False()); - }); + it("rejects x0 [file content]", [&]() { AssertThat(bdd_isnithvar(bdd_x0), Is().False()); }); - it("rejects x0 [complement flag]", [&]() { - AssertThat(bdd_isnithvar(bdd(bdd_not_x0, true)), Is().False()); - }); + it("rejects x0 [complement flag]", + [&]() { AssertThat(bdd_isnithvar(bdd(bdd_not_x0, true)), Is().False()); }); - it("accepts ~x0 [file content]", [&]() { - AssertThat(bdd_isnithvar(bdd_not_x0), Is().True()); - }); + it("accepts ~x0 [file content]", + [&]() { AssertThat(bdd_isnithvar(bdd_not_x0), Is().True()); }); - it("accepts ~x0 [complement flag]", [&]() { - AssertThat(bdd_isnithvar(bdd(bdd_x0, true)), Is().True()); - }); + it("accepts ~x0 [complement flag]", + [&]() { AssertThat(bdd_isnithvar(bdd(bdd_x0, true)), Is().True()); }); - it("rejects x1 [file content]", [&]() { - AssertThat(bdd_isnithvar(bdd_x1), Is().False()); - }); + it("rejects x1 [file content]", [&]() { AssertThat(bdd_isnithvar(bdd_x1), Is().False()); }); - it("accepts ~x1 [complement flag]", [&]() { - AssertThat(bdd_isnithvar(bdd(bdd_x1, true)), Is().True()); - }); + it("accepts ~x1 [complement flag]", + [&]() { AssertThat(bdd_isnithvar(bdd(bdd_x1, true)), Is().True()); }); - it("rejects x0 & x2", [&]() { - AssertThat(bdd_isnithvar(bdd_0and2), Is().False()); - }); + it("rejects x0 & x2", [&]() { AssertThat(bdd_isnithvar(bdd_0and2), Is().False()); }); }); describe("bdd_iscube", [&]() { - it("rejects F terminal", [&]() { - AssertThat(bdd_iscube(bdd_F), Is().False()); - }); + it("rejects F terminal", [&]() { AssertThat(bdd_iscube(bdd_F), Is().False()); }); - it("accepts T terminal", [&]() { - AssertThat(bdd_iscube(bdd_T), Is().True()); - }); + it("accepts T terminal", [&]() { AssertThat(bdd_iscube(bdd_T), Is().True()); }); - it("accepts x0 [file content]", [&]() { - AssertThat(bdd_iscube(bdd_x0), Is().True()); - }); + it("accepts x0 [file content]", [&]() { AssertThat(bdd_iscube(bdd_x0), Is().True()); }); - it("accepts x0 [complement flag]", [&]() { - AssertThat(bdd_iscube(bdd(bdd_not_x0, true)), Is().True()); - }); + it("accepts x0 [complement flag]", + [&]() { AssertThat(bdd_iscube(bdd(bdd_not_x0, true)), Is().True()); }); - it("accepts ~x0 [file content]", [&]() { - AssertThat(bdd_iscube(bdd_not_x0), Is().True()); - }); + it("accepts ~x0 [file content]", [&]() { AssertThat(bdd_iscube(bdd_not_x0), Is().True()); }); - it("accepts ~x0 [complement flag]", [&]() { - AssertThat(bdd_iscube(bdd(bdd_x0, true)), Is().True()); - }); + it("accepts ~x0 [complement flag]", + [&]() { AssertThat(bdd_iscube(bdd(bdd_x0, true)), Is().True()); }); - it("accepts x1 [file content]", [&]() { - AssertThat(bdd_iscube(bdd_x1), Is().True()); - }); + it("accepts x1 [file content]", [&]() { AssertThat(bdd_iscube(bdd_x1), Is().True()); }); - it("accepts ~x1 [complement flag]", [&]() { - AssertThat(bdd_iscube(bdd(bdd_x1, true)), Is().True()); - }); + it("accepts ~x1 [complement flag]", + [&]() { AssertThat(bdd_iscube(bdd(bdd_x1, true)), Is().True()); }); - it("accepts x0 & x2", [&]() { - AssertThat(bdd_iscube(bdd_0and2), Is().True()); - }); + it("accepts x0 & x2", [&]() { AssertThat(bdd_iscube(bdd_0and2), Is().True()); }); - it("rejects x0 | x2", [&]() { - AssertThat(bdd_iscube(bdd_0or2), Is().False()); - }); + it("rejects x0 | x2", [&]() { AssertThat(bdd_iscube(bdd_0or2), Is().False()); }); - it("accepts ~(x0 | x2) [complement flag]", [&]() { - AssertThat(bdd_iscube(bdd(bdd_0or2, true)), Is().True()); - }); + it("accepts ~(x0 | x2) [complement flag]", + [&]() { AssertThat(bdd_iscube(bdd(bdd_0or2, true)), Is().True()); }); - it("rejects (x0 | x1) & x2", [&]() { - AssertThat(bdd_iscube(bdd_23_13), Is().False()); - }); + it("rejects (x0 | x1) & x2", [&]() { AssertThat(bdd_iscube(bdd_23_13), Is().False()); }); }); }); - }); +}); diff --git a/test/adiar/bdd/test_quantify.cpp b/test/adiar/bdd/test_quantify.cpp index d6ad90fea..c9e52eb8a 100644 --- a/test/adiar/bdd/test_quantify.cpp +++ b/test/adiar/bdd/test_quantify.cpp @@ -2345,31 +2345,31 @@ go_bandit([]() { return 0 < x && x < 3; }); - node_test_stream out_nodes(out); + node_test_stream out_nodes(out); - AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(true))); - AssertThat(out_nodes.can_pull(), Is().False()); + AssertThat(out_nodes.can_pull(), Is().True()); + AssertThat(out_nodes.pull(), Is().EqualTo(node(true))); + AssertThat(out_nodes.can_pull(), Is().False()); - level_info_test_stream out_meta(out); - AssertThat(out_meta.can_pull(), Is().False()); + level_info_test_stream out_meta(out); + AssertThat(out_meta.can_pull(), Is().False()); - // TODO: meta variables... + // TODO: meta variables... - // Check call history - // - // NOTE: Test failure does NOT indicate a bug, but only indicates a - // change. Please verify that this change makes sense and is as - // intended. - AssertThat(call_history.size(), Is().EqualTo(13u)); + // Check call history + // + // NOTE: Test failure does NOT indicate a bug, but only indicates a + // change. Please verify that this change makes sense and is as + // intended. + AssertThat(call_history.size(), Is().EqualTo(13u)); - // - First check for at least one variable satisfying the predicate. - AssertThat(call_history.at(0), Is().EqualTo(4u)); - AssertThat(call_history.at(1), Is().EqualTo(3u)); - AssertThat(call_history.at(2), Is().EqualTo(2u)); + // - First check for at least one variable satisfying the predicate. + AssertThat(call_history.at(0), Is().EqualTo(4u)); + AssertThat(call_history.at(1), Is().EqualTo(3u)); + AssertThat(call_history.at(2), Is().EqualTo(2u)); - // - First top-down sweep (root call) - AssertThat(call_history.at(3), Is().EqualTo(0u)); + // - First top-down sweep (root call) + AssertThat(call_history.at(3), Is().EqualTo(0u)); // - First top-down sweep AssertThat(call_history.at(4), Is().EqualTo(0u)); @@ -2381,11 +2381,11 @@ go_bandit([]() { // - Second top-down sweep (root call) AssertThat(call_history.at(9), Is().EqualTo(0u)); - // - Second top-down sweep - AssertThat(call_history.at(10), Is().EqualTo(0u)); - AssertThat(call_history.at(11), Is().EqualTo(2u)); - AssertThat(call_history.at(12), Is().EqualTo(3u)); - }); + // - Second top-down sweep + AssertThat(call_history.at(10), Is().EqualTo(0u)); + AssertThat(call_history.at(11), Is().EqualTo(2u)); + AssertThat(call_history.at(12), Is().EqualTo(3u)); + }); it("finishes during repeated transposition with variables 1 and 2 in BDD 12b [&&]", [&]() { std::vector call_history; diff --git a/test/adiar/bdd/test_restrict.cpp b/test/adiar/bdd/test_restrict.cpp index 77fad79d1..91a759903 100644 --- a/test/adiar/bdd/test_restrict.cpp +++ b/test/adiar/bdd/test_restrict.cpp @@ -38,11 +38,11 @@ go_bandit([]() { // F T */ - const node n1_5(3,0, terminal_F, terminal_T); - const node n1_4(2,1, terminal_T, n1_5.uid()); - const node n1_3(2,0, terminal_F, terminal_T); - const node n1_2(1,0, n1_3.uid(), n1_4.uid()); - const node n1_1(0,0, n1_3.uid(), n1_2.uid()); + const node n1_5(3, 0, terminal_F, terminal_T); + const node n1_4(2, 1, terminal_T, n1_5.uid()); + const node n1_3(2, 0, terminal_F, terminal_T); + const node n1_2(1, 0, n1_3.uid(), n1_4.uid()); + const node n1_1(0, 0, n1_3.uid(), n1_2.uid()); { // Garbage collect writer to free write-lock node_writer nw(bdd_1); @@ -95,11 +95,11 @@ go_bandit([]() { // / \ / \ // T F F T */ - const node n3_5 = node(2,1, terminal_F, terminal_T); - const node n3_4 = node(2,0, terminal_T, terminal_F); - const node n3_3 = node(1,1, n3_5.uid(), terminal_F); - const node n3_2 = node(1,0, n3_4.uid(), terminal_F); - const node n3_1 = node(0,0, n3_2.uid(), n3_3.uid()); + const node n3_5 = node(2, 1, terminal_F, terminal_T); + const node n3_4 = node(2, 0, terminal_T, terminal_F); + const node n3_3 = node(1, 1, n3_5.uid(), terminal_F); + const node n3_2 = node(1, 0, n3_4.uid(), terminal_F); + const node n3_1 = node(0, 0, n3_2.uid(), n3_3.uid()); { // Garbage collect writer to free write-lock node_writer nw(bdd_3); @@ -116,10 +116,10 @@ go_bandit([]() { // / \ // T F */ - const node n4_4(2,0, terminal_T, terminal_F); - const node n4_3(1,1, terminal_T, terminal_F); - const node n4_2(1,0, n4_4.uid(), terminal_F); - const node n4_1(0,0, n4_2.uid(), n4_3.uid()); + const node n4_4(2, 0, terminal_T, terminal_F); + const node n4_3(1, 1, terminal_T, terminal_F); + const node n4_2(1, 0, n4_4.uid(), terminal_F); + const node n4_1(0, 0, n4_2.uid(), n4_3.uid()); { // Garbage collect writer to free write-lock node_writer nw(bdd_4); @@ -142,15 +142,15 @@ go_bandit([]() { shared_levelized_file bdd_5; - const node n5_9(3,1, terminal_T, terminal_F); - const node n5_8(3,0, terminal_F, terminal_T); - const node n5_7(2,3, n5_9.uid(), terminal_T); - const node n5_6(2,2, terminal_T, n5_9.uid()); - const node n5_5(2,1, terminal_F, n5_8.uid()); - const node n5_4(2,0, terminal_T, terminal_F); - const node n5_3(1,1, n5_6.uid(), n5_7.uid()); - const node n5_2(1,0, n5_4.uid(), n5_5.uid()); - const node n5_1(0,0, n5_2.uid(), n5_3.uid()); + const node n5_9(3, 1, terminal_T, terminal_F); + const node n5_8(3, 0, terminal_F, terminal_T); + const node n5_7(2, 3, n5_9.uid(), terminal_T); + const node n5_6(2, 2, terminal_T, n5_9.uid()); + const node n5_5(2, 1, terminal_F, n5_8.uid()); + const node n5_4(2, 0, terminal_T, terminal_F); + const node n5_3(1, 1, n5_6.uid(), n5_7.uid()); + const node n5_2(1, 0, n5_4.uid(), n5_5.uid()); + const node n5_1(0, 0, n5_2.uid(), n5_3.uid()); { // Garbage collect writer to free write-lock node_writer nw(bdd_5); @@ -175,40 +175,43 @@ go_bandit([]() { // F T */ - std::vector> ass = { {1,true}, {2, true} }; + std::vector> ass = { { 1, true }, { 2, true } }; __bdd out = bdd_restrict(exec_policy(), bdd_1, ass.begin(), ass.end()); arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_1.uid(), true, n1_5.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_1.uid(), true, n1_5.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_1.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_1.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_5.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_5.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_5.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_5.uid(), true, terminal_T })); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("removes root of BDD 1 for (T,_,_,F)", [&]() { @@ -221,46 +224,49 @@ go_bandit([]() { // F T T F */ - std::vector> ass = { {0,true}, {3,false} }; + std::vector> ass = { { 0, true }, { 3, false } }; __bdd out = bdd_restrict(bdd_1, ass.begin(), ass.end()); arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_2.uid(), false, n1_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_2.uid(), false, n1_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_2.uid(), true, n1_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_2.uid(), true, n1_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_3.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_3.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_3.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_3.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_4.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_4.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_4.uid(), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_4.uid(), true, terminal_F })); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("ignores skipped variables in BDD 1 for (F,T,_,F)", [&]() { @@ -270,7 +276,9 @@ go_bandit([]() { // F T */ - std::vector> ass = { {0,false}, {1,true}, {3,false} }; + std::vector> ass = { { 0, false }, + { 1, true }, + { 3, false } }; __bdd out = bdd_restrict(bdd_1, ass.begin(), ass.end()); @@ -279,26 +287,29 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_3.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_3.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_3.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_3.uid(), true, terminal_T })); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("returns F terminal in BDD 1 for (F,_,F,_)", [&]() { - std::vector> ass = { {0,false}, {2,false} }; + std::vector> ass = { { 0, false }, { 2, false } }; __bdd out = bdd_restrict(bdd_1, ass.begin(), ass.end()); @@ -311,17 +322,27 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("returns T terminal in BDD 1 for (T,T,F,_)", [&]() { - std::vector> ass = { {0,true}, {1,true}, {2,false} }; + std::vector> ass = { { 0, true }, + { 1, true }, + { 2, false } }; __bdd out = bdd_restrict(bdd_1, ass.begin(), ass.end()); @@ -334,17 +355,25 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("returns terminal for restricted root in BDD 2 [F]", [&]() { - std::vector> ass = { {1,true}, {2,true} }; + std::vector> ass = { { 1, true }, { 2, true } }; __bdd out = bdd_restrict(bdd_2_high_F, ass.begin(), ass.end()); @@ -357,17 +386,25 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("returns terminal for restricted root in BDD 2 [T]", [&]() { - std::vector> ass = { {0,false}, {2,false} }; + std::vector> ass = { { 0, false }, { 2, false } }; __bdd out = bdd_restrict(bdd_2_low_T, ass.begin(), ass.end()); @@ -380,17 +417,27 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("returns input unchanged when given a T terminal", [&]() { - std::vector> ass = { {0,true}, {2,true}, {42,false} }; + std::vector> ass = { { 0, true }, + { 2, true }, + { 42, false } }; __bdd out = bdd_restrict(bdd_T, ass.begin(), ass.end()); @@ -399,7 +446,9 @@ go_bandit([]() { }); it("returns input unchanged when given a F terminal", [&]() { - std::vector> ass { {2,true}, {21,true}, {28,false} }; + std::vector> ass{ { 2, true }, + { 21, true }, + { 28, false } }; __bdd out = bdd_restrict(bdd_F, ass.begin(), ass.end()); @@ -417,7 +466,9 @@ go_bandit([]() { }); it("returns input unchanged if assignment is disjoint of its variables", [&]() { - std::vector> ass = { {5,false}, {6,true}, {7,true} }; + std::vector> ass = { { 5, false }, + { 6, true }, + { 7, true } }; __bdd out = bdd_restrict(bdd_1, ass.begin(), ass.end()); @@ -433,7 +484,7 @@ go_bandit([]() { // * This arc will be resolved as the last one */ - std::vector> ass = { {1, false}, {2, true} }; + std::vector> ass = { { 1, false }, { 2, true } }; __bdd out = bdd_restrict(bdd_4, ass.begin(), ass.end()); @@ -442,102 +493,111 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n4_1.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n4_1.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n4_1.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n4_1.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("skips 'dead' nodes in BDD 5 for (F,T,_,_)", [&]() { - std::vector> ass = { {0, false}, {1,true} }; + std::vector> ass = { { 0, false }, { 1, true } }; __bdd out = bdd_restrict(bdd_5, ass.begin(), ass.end()); arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n5_5.uid(), true, n5_8.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n5_5.uid(), true, n5_8.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_5.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_5.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_8.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_8.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_8.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_8.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("skips 'dead' nodes in BDD 5 for (T,T,_,_)", [&]() { - std::vector> ass = { {0, true}, {1,true} }; + std::vector> ass = { { 0, true }, { 1, true } }; __bdd out = bdd_restrict(bdd_5, ass.begin(), ass.end()); arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n5_7.uid(), false, n5_9.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n5_7.uid(), false, n5_9.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_7.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_7.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_9.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_9.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_9.uid(), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_9.uid(), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); }); @@ -560,42 +620,45 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_1.uid(), true, n1_2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_1.uid(), true, n1_2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_2.uid(), true, n1_5.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_2.uid(), true, n1_5.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_1.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_1.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_2.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_2.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_5.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_5.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_5.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_5.uid(), true, terminal_T })); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); }); it("bridges over levels in BDD 1 for x1 = F", [&]() { @@ -614,33 +677,36 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_1.uid(), false, n1_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_1.uid(), false, n1_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_1.uid(), true, n1_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_1.uid(), true, n1_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_3.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_3.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_3.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_3.uid(), true, terminal_T })); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("bridges over levels in BDD 1 for x1 = T", [&]() { @@ -661,48 +727,51 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_1.uid(), false, n1_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_1.uid(), false, n1_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_1.uid(), true, n1_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_1.uid(), true, n1_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_4.uid(), true, n1_5.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_4.uid(), true, n1_5.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_3.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_3.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_3.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_3.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_4.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_4.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_5.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_5.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_5.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_5.uid(), true, terminal_T })); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); }); it("removes root of BDD 1 for x0 = T", [&]() { @@ -721,50 +790,53 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_2.uid(), false, n1_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_2.uid(), false, n1_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_2.uid(), true, n1_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_2.uid(), true, n1_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_4.uid(), true, n1_5.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_4.uid(), true, n1_5.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_3.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_3.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_3.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_3.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_4.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_4.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_5.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_5.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_5.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_5.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); }); it("returns terminal of restricted root [F]", [&]() { @@ -779,13 +851,21 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("returns terminal of restricted root [T]", [&]() { @@ -800,13 +880,21 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("returns input unchanged when given a T terminal", [&]() { @@ -824,7 +912,9 @@ go_bandit([]() { }); it("returns input unchanged if variable does not exist", [&]() { - std::vector> ass = { {5,false}, {6,true}, {7,true} }; + std::vector> ass = { { 5, false }, + { 6, true }, + { 7, true } }; __bdd out = bdd_restrict(bdd_1, 4, true); @@ -847,41 +937,44 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n3_1.uid(), false, n3_2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n3_1.uid(), false, n3_2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n3_1.uid(), true, n3_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n3_1.uid(), true, n3_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n3_2.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n3_2.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n3_2.uid(), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n3_2.uid(), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n3_3.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n3_3.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n3_3.uid(), true, terminal_F} )); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n3_3.uid(), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("should sort restricted terminal arc in BDD 4", [&]() { @@ -891,7 +984,8 @@ go_bandit([]() { // _2_ 3 ---- x1 // / \ / \ // F* F T F ---- x2 - // * This arc will be resolved as the last one + // * This arc will be resolved as + the last one */ __bdd out = bdd_restrict(bdd_4, 2, true); @@ -899,41 +993,44 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n4_1.uid(), false, n4_2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n4_1.uid(), false, n4_2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n4_1.uid(), true, n4_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n4_1.uid(), true, n4_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n4_2.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n4_2.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n4_2.uid(), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n4_2.uid(), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n4_3.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n4_3.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n4_3.uid(), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n4_3.uid(), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("skips 'dead' nodes in BDD 5 for x1 = T", [&]() { @@ -942,56 +1039,59 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n5_1.uid(), false, n5_5.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n5_1.uid(), false, n5_5.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n5_1.uid(), true, n5_7.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n5_1.uid(), true, n5_7.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n5_5.uid(), true, n5_8.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n5_5.uid(), true, n5_8.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n5_7.uid(), false, n5_9.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n5_7.uid(), false, n5_9.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_5.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_5.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_7.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_7.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_8.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_8.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_8.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_8.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_9.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_9.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_9.uid(), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_9.uid(), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); }); }); @@ -1010,24 +1110,27 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_3.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_3.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_3.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_3.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("returns terminal in BDD 2", [&]() { @@ -1042,22 +1145,28 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); - it("throws an exception when given the F terminal", [&]() { - AssertThrows(invalid_argument, bdd_low(bdd_F)); - }); + it("throws an exception when given the F terminal", + [&]() { AssertThrows(invalid_argument, bdd_low(bdd_F)); }); - it("throws an exception when given the T terminal", [&]() { - AssertThrows(invalid_argument, bdd_low(bdd_T)); - }); + it("throws an exception when given the T terminal", + [&]() { AssertThrows(invalid_argument, bdd_low(bdd_T)); }); }); describe("bdd_high(const bdd&)", [&]() { @@ -1077,50 +1186,53 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_2.uid(), false, n1_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_2.uid(), false, n1_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_2.uid(), true, n1_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_2.uid(), true, n1_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_4.uid(), true, n1_5.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_4.uid(), true, n1_5.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_3.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_3.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_3.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_3.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_4.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_4.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_5.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_5.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_5.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_5.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__bdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); }); it("returns terminal in BDD 2", [&]() { @@ -1135,22 +1247,28 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); - it("throws an exception when given the F terminal", [&]() { - AssertThrows(invalid_argument, bdd_high(bdd_F)); - }); + it("throws an exception when given the F terminal", + [&]() { AssertThrows(invalid_argument, bdd_high(bdd_F)); }); - it("throws an exception when given the T terminal", [&]() { - AssertThrows(invalid_argument, bdd_high(bdd_T)); - }); + it("throws an exception when given the T terminal", + [&]() { AssertThrows(invalid_argument, bdd_high(bdd_T)); }); }); }); - }); +}); diff --git a/test/adiar/internal/algorithms/test_convert.cpp b/test/adiar/internal/algorithms/test_convert.cpp index a3afbf681..c5d27dfac 100644 --- a/test/adiar/internal/algorithms/test_convert.cpp +++ b/test/adiar/internal/algorithms/test_convert.cpp @@ -4,10 +4,10 @@ go_bandit([]() { // TODO: tests are missing cut sizes describe("adiar/internal/algorithms/convert.h", []() { - const std::vector dom_empty = { }; + const std::vector dom_empty = {}; const std::vector dom_0 = { 0 }; const std::vector dom_012 = { 0, 1, 2 }; - const std::vector dom_0123 = { 0, 1, 2, 3}; + const std::vector dom_0123 = { 0, 1, 2, 3 }; const std::vector dom_024 = { 0, 2, 4 }; shared_levelized_file nf_F; @@ -142,32 +142,30 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(1, ptr_uint64::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); }); @@ -178,37 +176,37 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ ptr_uint64(0, 0), ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ ptr_uint64(1, 0), ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -219,37 +217,39 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -274,28 +274,29 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -306,28 +307,29 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -338,28 +340,29 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(4,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(4, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -427,10 +430,10 @@ go_bandit([]() { shared_levelized_file nf; { - const node n4 = node(2, node::max_id, terminal_F, terminal_T); - const node n3 = node(1, node::max_id, n4.uid(), n4.uid()); - const node n2 = node(1, node::max_id-1, terminal_F, n4.uid()); - const node n1 = node(0, node::max_id, n2.uid(), n3.uid()); + const node n4 = node(2, node::max_id, terminal_F, terminal_T); + const node n3 = node(1, node::max_id, n4.uid(), n4.uid()); + const node n2 = node(1, node::max_id - 1, terminal_F, n4.uid()); + const node n1 = node(0, node::max_id, n2.uid(), n3.uid()); node_writer nw(nf); nw << n4 << n3 << n2 << n1; @@ -451,37 +454,40 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -493,43 +499,47 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -540,52 +550,57 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -606,46 +621,49 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // produced out-of-order - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -666,129 +684,144 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // (1) -> (2) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (1) -- * -> (3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (2) -> (3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // * -> (3) - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // (2) -- * -> T - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().False()); }); // Other large cases - it("converts { Ø, { 0,1 }, { 0,2 }, { 1,2 } } with dom = { 0,1,2 } only adding true-chain", [&]() { - shared_levelized_file nf_in; - // In dom = { 0,1,2 } - /* - // _1_ ---- x0 - // / \ - // 2 3 ---- x1 - // / \ / \ - // T 4 T ---- x2 - // / \ - // F T - */ - { - const node n4 = node(2, node::max_id, terminal_F, terminal_T); - const node n3 = node(1, node::max_id, n4.uid(), terminal_T); - const node n2 = node(1, node::max_id-1, terminal_T, n4.uid()); - const node n1 = node(0, node::max_id, n2.uid(), n3.uid()); + it( + "converts { Ø, { 0,1 }, { 0,2 }, { 1,2 } } with dom = { 0,1,2 } only adding true-chain", + [&]() { + shared_levelized_file nf_in; + // In dom = { 0,1,2 } + /* + // _1_ ---- x0 + // / \ + // 2 3 ---- x1 + // / \ / \ + // T 4 T ---- x2 + // / \ + // F T + */ + { + const node n4 = node(2, node::max_id, terminal_F, terminal_T); + const node n3 = node(1, node::max_id, n4.uid(), terminal_T); + const node n2 = node(1, node::max_id - 1, terminal_T, n4.uid()); + const node n1 = node(0, node::max_id, n2.uid(), n3.uid()); - node_writer nw(nf_in); - nw << n4 << n3 << n2 << n1; - } + node_writer nw(nf_in); + nw << n4 << n3 << n2 << n1; + } - zdd in(nf_in); + zdd in(nf_in); - __bdd out = bdd_from(in, dom_012.begin(), dom_012.end()); + __bdd out = bdd_from(in, dom_012.begin(), dom_012.end()); - arc_test_stream arcs(out); + arc_test_stream arcs(out); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 1) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); - AssertThat(arcs.can_pull_internal(), Is().False()); + AssertThat(arcs.can_pull_internal(), Is().False()); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().False()); + AssertThat(arcs.can_pull_terminal(), Is().False()); - level_info_test_stream levels(out); + level_info_test_stream levels(out); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); - AssertThat(levels.can_pull(), Is().False()); - }); + AssertThat(levels.can_pull(), Is().False()); + }); it("bridges over root and others, and creates pre and post chains", [&]() { std::vector dom = { 0, 1, 2, 3, 4, 5, 6 }; @@ -812,13 +845,13 @@ go_bandit([]() { // T T */ { - const node n7 = node(6, node::max_id, terminal_T, terminal_T); - const node n6 = node(5, node::max_id, n7.uid(), n7.uid()); - const node n5 = node(5, node::max_id-1, terminal_F, n7.uid()); - const node n4 = node(4, node::max_id, n6.uid(), terminal_T); - const node n3 = node(4, node::max_id-1, n5.uid(), n6.uid()); - const node n2 = node(3, node::max_id, n3.uid(), n4.uid()); - const node n1 = node(1, node::max_id, n2.uid(), n2.uid()); + const node n7 = node(6, node::max_id, terminal_T, terminal_T); + const node n6 = node(5, node::max_id, n7.uid(), n7.uid()); + const node n5 = node(5, node::max_id - 1, terminal_F, n7.uid()); + const node n4 = node(4, node::max_id, n6.uid(), terminal_T); + const node n3 = node(4, node::max_id - 1, n5.uid(), n6.uid()); + const node n2 = node(3, node::max_id, n3.uid(), n4.uid()); + const node n1 = node(1, node::max_id, n2.uid(), n2.uid()); node_writer w(in); w << n7 << n6 << n5 << n4 << n3 << n2 << n1; @@ -846,76 +879,83 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // 2 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 3 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 4 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,0), false, ptr_uint64(4,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, ptr_uint64(4, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 5 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,0), true, ptr_uint64(4,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), true, ptr_uint64(4, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 6 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(4,0), false, ptr_uint64(5,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(4, 0), false, ptr_uint64(5, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 7 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(4,1), true, ptr_uint64(5,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(4, 1), true, ptr_uint64(5, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 8 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(5,1), false, ptr_uint64(6,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(5, 1), false, ptr_uint64(6, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // 1 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // 2 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // 4 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // 5 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // 6 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(5,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(5, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(5,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(5, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // 7 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(5,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(5, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // 8 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(6,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(6, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(6,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(6, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(4,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(4, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(5,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(5, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(6,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(6, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -930,32 +970,30 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(1, ptr_uint64::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); }); @@ -968,28 +1006,29 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(4,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(4, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -1048,32 +1087,34 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(1, ptr_uint64::max_id), - ptr_uint64(1, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id), + ptr_uint64(1, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); }); @@ -1084,37 +1125,41 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -1125,37 +1170,40 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -1173,28 +1221,30 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -1249,10 +1299,10 @@ go_bandit([]() { it("converts [Minato] Fig. 3 into Fig. 5 with dom = { 0,1,2 } ", [&]() { shared_levelized_file nf; { - const node n4 = node(2, node::max_id, terminal_T, terminal_F); - const node n3 = node(1, node::max_id, n4.uid(), terminal_F); - const node n2 = node(1, node::max_id-1, terminal_F, n4.uid()); - const node n1 = node(0, node::max_id, n2.uid(), n3.uid()); + const node n4 = node(2, node::max_id, terminal_T, terminal_F); + const node n3 = node(1, node::max_id, n4.uid(), terminal_F); + const node n2 = node(1, node::max_id - 1, terminal_F, n4.uid()); + const node n1 = node(0, node::max_id, n2.uid(), n3.uid()); node_writer nw(nf); nw << n4 << n3 << n2 << n1; @@ -1264,28 +1314,29 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -1293,11 +1344,11 @@ go_bandit([]() { it("converts [Minato] Fig. 3 into Fig. 5 with dom = { 0,1,2,3 } ", [&]() { shared_levelized_file nf; { - const node n5 = node(3, node::max_id, terminal_T, terminal_F); - const node n4 = node(2, node::max_id, n5.uid(), terminal_F); - const node n3 = node(1, node::max_id, n4.uid(), terminal_F); - const node n2 = node(1, node::max_id-1, terminal_F, n4.uid()); - const node n1 = node(0, node::max_id, n2.uid(), n3.uid()); + const node n5 = node(3, node::max_id, terminal_T, terminal_F); + const node n4 = node(2, node::max_id, n5.uid(), terminal_F); + const node n3 = node(1, node::max_id, n4.uid(), terminal_F); + const node n2 = node(1, node::max_id - 1, terminal_F, n4.uid()); + const node n1 = node(0, node::max_id, n2.uid(), n3.uid()); node_writer nw(nf); nw << n5 << n4 << n3 << n2 << n1; @@ -1309,28 +1360,28 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ ptr_uint64(0, 0), ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -1338,10 +1389,10 @@ go_bandit([]() { it("converts [Minato] Fig. 11 with dom = { 0,1,2,3 } ", [&]() { shared_levelized_file nf; { - const node n4 = node(3, node::max_id, terminal_T, terminal_F); - const node n3 = node(2, node::max_id, n4.uid(), terminal_F); - const node n2 = node(1, node::max_id-1, terminal_T, n3.uid()); - const node n1 = node(0, node::max_id, n2.uid(), terminal_F); + const node n4 = node(3, node::max_id, terminal_T, terminal_F); + const node n3 = node(2, node::max_id, n4.uid(), terminal_F); + const node n2 = node(1, node::max_id - 1, terminal_T, n3.uid()); + const node n1 = node(0, node::max_id, n2.uid(), terminal_F); node_writer nw(nf); nw << n4 << n3 << n2 << n1; @@ -1353,37 +1404,40 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -1391,11 +1445,11 @@ go_bandit([]() { it("converts [Minato] Fig. 15 with dom = { 0,1,2 } ", [&]() { shared_levelized_file nf; { - const node n5 = node(2, node::max_id, terminal_F, terminal_T); - const node n4 = node(2, node::max_id-1, terminal_T, terminal_F); - const node n3 = node(1, node::max_id, n5.uid(), terminal_F); - const node n2 = node(1, node::max_id-1, n5.uid(), n4.uid()); - const node n1 = node(0, node::max_id, n3.uid(), n2.uid()); + const node n5 = node(2, node::max_id, terminal_F, terminal_T); + const node n4 = node(2, node::max_id - 1, terminal_T, terminal_F); + const node n3 = node(1, node::max_id, n5.uid(), terminal_F); + const node n2 = node(1, node::max_id - 1, n5.uid(), n4.uid()); + const node n1 = node(0, node::max_id, n3.uid(), n2.uid()); node_writer nw(nf); nw << n5 << n4 << n3 << n2 << n1; @@ -1407,37 +1461,40 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); }); @@ -1452,32 +1509,34 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(1, ptr_uint64::max_id), - ptr_uint64(1, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id), + ptr_uint64(1, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); }); @@ -1510,4 +1569,4 @@ go_bandit([]() { }); }); }); - }); +}); diff --git a/test/adiar/internal/algorithms/test_dot.cpp b/test/adiar/internal/algorithms/test_dot.cpp index 805d461da..fea73211c 100644 --- a/test/adiar/internal/algorithms/test_dot.cpp +++ b/test/adiar/internal/algorithms/test_dot.cpp @@ -1,6 +1,6 @@ #include "../../../test.h" - #include + #include go_bandit([]() { @@ -19,14 +19,13 @@ go_bandit([]() { { // Garbage collect writer early node_writer rw(reduced_bdd); - rw << node(42,1, ptr_uint64(false), ptr_uint64(true)) - << node(42,0, ptr_uint64(true), ptr_uint64(false)) - << node(1,2, ptr_uint64(42,0), ptr_uint64(42,1)) - << node(0,1, ptr_uint64(1,2), ptr_uint64(false)) - ; + rw << node(42, 1, ptr_uint64(false), ptr_uint64(true)) + << node(42, 0, ptr_uint64(true), ptr_uint64(false)) + << node(1, 2, ptr_uint64(42, 0), ptr_uint64(42, 1)) + << node(0, 1, ptr_uint64(1, 2), ptr_uint64(false)); } - bdd_printdot(reduced_bdd, "dot_test_bdd__without_ids.dot"/*, false*/); + bdd_printdot(reduced_bdd, "dot_test_bdd__without_ids.dot" /*, false*/); int exit_value = system("dot -O -Tpng dot_test_bdd__without_ids.dot"); AssertThat(exit_value, Is().EqualTo(0)); }); @@ -37,10 +36,9 @@ go_bandit([]() { { // Garbage collect writer early node_writer rw(reduced_bdd); - rw << node(1,1, ptr_uint64(false), ptr_uint64(true)) - << node(1,0, ptr_uint64(true), ptr_uint64(false)) - << node(0,0, ptr_uint64(1,0), ptr_uint64(1,1)) - ; + rw << node(1, 1, ptr_uint64(false), ptr_uint64(true)) + << node(1, 0, ptr_uint64(true), ptr_uint64(false)) + << node(0, 0, ptr_uint64(1, 0), ptr_uint64(1, 1)); } bdd_printdot(reduced_bdd, "dot_test_bdd__with_ids.dot", true); @@ -77,10 +75,9 @@ go_bandit([]() { { // Garbage collect writer early node_writer rw(reduced_zdd); - rw << node(42,0, ptr_uint64(false), ptr_uint64(true)) - << node(1,2, ptr_uint64(42,0), ptr_uint64(42,0)) - << node(0,1, ptr_uint64(1,2), ptr_uint64(true)) - ; + rw << node(42, 0, ptr_uint64(false), ptr_uint64(true)) + << node(1, 2, ptr_uint64(42, 0), ptr_uint64(42, 0)) + << node(0, 1, ptr_uint64(1, 2), ptr_uint64(true)); } zdd_printdot(reduced_zdd, "dot_test_zdd.dot"); @@ -109,15 +106,15 @@ go_bandit([]() { { // Garbage collect writer early arc_writer uw(unreduced_bdd); - uw.push_terminal({ flag(ptr_uint64(2,0)), ptr_uint64(true) }); - uw.push_terminal({ ptr_uint64(2,0), ptr_uint64(true) }); - uw.push_terminal({ ptr_uint64(1,1), ptr_uint64(true) }); + uw.push_terminal({ flag(ptr_uint64(2, 0)), ptr_uint64(true) }); + uw.push_terminal({ ptr_uint64(2, 0), ptr_uint64(true) }); + uw.push_terminal({ ptr_uint64(1, 1), ptr_uint64(true) }); - uw.push_internal({ ptr_uint64(0,0), ptr_uint64(1,0) }); - uw.push_internal({ ptr_uint64(0,0), ptr_uint64(1,1) }); - uw.push_internal({ ptr_uint64(1,0), ptr_uint64(2,0) }); - uw.push_internal({ flag(ptr_uint64(1,0)), ptr_uint64(2,0) }); - uw.push_internal({ flag(ptr_uint64(1,1)), ptr_uint64(2,0) }); + uw.push_internal({ ptr_uint64(0, 0), ptr_uint64(1, 0) }); + uw.push_internal({ ptr_uint64(0, 0), ptr_uint64(1, 1) }); + uw.push_internal({ ptr_uint64(1, 0), ptr_uint64(2, 0) }); + uw.push_internal({ flag(ptr_uint64(1, 0)), ptr_uint64(2, 0) }); + uw.push_internal({ flag(ptr_uint64(1, 1)), ptr_uint64(2, 0) }); } print_dot(unreduced_bdd, "dot_test_unreduced.dot"); @@ -125,4 +122,4 @@ go_bandit([]() { AssertThat(exit_value, Is().EqualTo(0)); }); }); - }); +}); diff --git a/test/adiar/internal/algorithms/test_isomorphism.cpp b/test/adiar/internal/algorithms/test_isomorphism.cpp index b13a235fd..1a35eda60 100644 --- a/test/adiar/internal/algorithms/test_isomorphism.cpp +++ b/test/adiar/internal/algorithms/test_isomorphism.cpp @@ -1,4 +1,5 @@ #include "../../../test.h" + #include go_bandit([]() { @@ -36,32 +37,32 @@ go_bandit([]() { describe("Case: File Pointer Address", [&]() { it("accepts F when negation flags match", [&]() { AssertThat(is_isomorphic(exec_policy(), dd(F, false), dd(F, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(F, true), dd(F, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(F, true), dd(F, true)), Is().True()); }); it("accepts T when negation flags match", [&]() { AssertThat(is_isomorphic(exec_policy(), dd(F, false), dd(F, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(F, true), dd(F, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(F, true), dd(F, true)), Is().True()); }); it("accepts x42 when negation flags match", [&]() { AssertThat(is_isomorphic(exec_policy(), dd(x42, false), dd(x42, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(x42, true), dd(x42, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(x42, true), dd(x42, true)), Is().True()); }); it("rejects F when negation flags mismatch", [&]() { AssertThat(is_isomorphic(exec_policy(), dd(F, false), dd(F, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(F, true), dd(F, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(F, true), dd(F, false)), Is().False()); }); it("rejects T when negation flags mismatch", [&]() { AssertThat(is_isomorphic(exec_policy(), dd(F, false), dd(F, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(F, true), dd(F, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(F, true), dd(F, false)), Is().False()); }); it("rejects x42 when negation flags mismatch", [&]() { AssertThat(is_isomorphic(exec_policy(), dd(x42, false), dd(x42, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x42, true), dd(x42, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x42, true), dd(x42, false)), Is().False()); }); }); @@ -101,9 +102,9 @@ go_bandit([]() { // T F F T */ { - const node n3(42, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n2(42, node::max_id-1, node::pointer_type(true), node::pointer_type(false)); - const node n1(21, node::max_id, n2.uid(), n3.uid()); + const node n3(42, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n2(42, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)); + const node n1(21, node::max_id, n2.uid(), n3.uid()); node_writer w(x21_xor_x42); w << n3 << n2 << n1; @@ -118,31 +119,47 @@ go_bandit([]() { }); it("rejects x21 (#nodes = 1) vs. x21 & x42 (#nodes = 2)", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(x21, false), dd(x21_and_x42, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21, false), dd(x21_and_x42, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(x21, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(x21, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21, false), dd(x21_and_x42, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21, false), dd(x21_and_x42, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(x21, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(x21, true)), + Is().False()); }); it("rejects x42 (#nodes = 1) vs. x21 & x42 (#nodes = 2)", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(x42, false), dd(x21_and_x42, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x42, false), dd(x21_and_x42, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(x42, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(x42, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x42, false), dd(x21_and_x42, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x42, false), dd(x21_and_x42, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(x42, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(x42, true)), + Is().False()); }); it("rejects x21 (#nodes = 1) vs. x21 ^ x42 (#nodes = 3)", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(x21, false), dd(x21_xor_x42, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21, false), dd(x21_xor_x42, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_xor_x42, true), dd(x21, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_xor_x42, true), dd(x21, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21, false), dd(x21_xor_x42, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21, false), dd(x21_xor_x42, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_xor_x42, true), dd(x21, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_xor_x42, true), dd(x21, true)), + Is().False()); }); it("rejects x21 & x42 (#nodes = 2) vs. x21 ^ x42 (#nodes = 3)", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(x21_xor_x42, false), dd(x21_and_x42, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_xor_x42, false), dd(x21_and_x42, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(x21_xor_x42, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(x21_xor_x42, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_xor_x42, false), dd(x21_and_x42, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_xor_x42, false), dd(x21_and_x42, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(x21_xor_x42, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(x21_xor_x42, true)), + Is().False()); }); }); @@ -161,10 +178,10 @@ go_bandit([]() { // T F */ { - const node n4(3, node::max_id, node::pointer_type(true), node::pointer_type(false)); - const node n3(2, node::max_id, n4.uid(), node::pointer_type(true)); + const node n4(3, node::max_id, node::pointer_type(true), node::pointer_type(false)); + const node n3(2, node::max_id, n4.uid(), node::pointer_type(true)); const node n2(1, node::max_id, node::pointer_type(false), n3.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_4); w << n4 << n3 << n2 << n1; @@ -185,10 +202,10 @@ go_bandit([]() { // T F */ { - const node n4(3, node::max_id, node::pointer_type(true), node::pointer_type(false)); - const node n3(2, node::max_id, n4.uid(), node::pointer_type(true)); + const node n4(3, node::max_id, node::pointer_type(true), node::pointer_type(false)); + const node n3(2, node::max_id, n4.uid(), node::pointer_type(true)); const node n2(1, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_5); w << n4 << n3 << n2 << n1; @@ -209,10 +226,10 @@ go_bandit([]() { // T F */ { - const node n4(3, node::max_id, node::pointer_type(true), node::pointer_type(false)); - const node n3(2, node::max_id, n4.uid(), node::pointer_type(false)); + const node n4(3, node::max_id, node::pointer_type(true), node::pointer_type(false)); + const node n3(2, node::max_id, n4.uid(), node::pointer_type(false)); const node n2(1, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_6); w << n4 << n3 << n2 << n1; @@ -235,7 +252,7 @@ go_bandit([]() { */ { const node n3(42, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n2(22, node::max_id, node::pointer_type(true), n3.uid()); + const node n2(22, node::max_id, node::pointer_type(true), n3.uid()); const node n1(21, node::max_id, node::pointer_type(false), n2.uid()); node_writer w(x21_x22_x42_chain); @@ -244,10 +261,18 @@ go_bandit([]() { describe("Case: Width", [&]() { it("rejects x21 ^ x42 (#levels = 2) vs. (x21 & ~x22) | (x21 & x42) (#levels = 3)", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(x21_x22_x42_chain, false), dd(x21_xor_x42, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_x22_x42_chain, false), dd(x21_xor_x42, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_xor_x42, true), dd(x21_x22_x42_chain, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_xor_x42, true), dd(x21_x22_x42_chain, true)), Is().False()); + AssertThat( + is_isomorphic(exec_policy(), dd(x21_x22_x42_chain, false), dd(x21_xor_x42, false)), + Is().False()); + AssertThat( + is_isomorphic(exec_policy(), dd(x21_x22_x42_chain, false), dd(x21_xor_x42, true)), + Is().False()); + AssertThat( + is_isomorphic(exec_policy(), dd(x21_xor_x42, true), dd(x21_x22_x42_chain, false)), + Is().False()); + AssertThat( + is_isomorphic(exec_policy(), dd(x21_xor_x42, true), dd(x21_x22_x42_chain, true)), + Is().False()); }); it("rejects due to different width", []() { @@ -269,13 +294,13 @@ go_bandit([]() { // F T */ { // Garbage collect writers to free write-lock - const node n7(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n6(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n5(2, node::max_id-1, node::pointer_type(true), n7.uid()); - const node n4(2, node::max_id-2, node::pointer_type(false), n7.uid()); - const node n3(1, node::max_id, n5.uid(), n6.uid()); - const node n2(1, node::max_id-1, n4.uid(), n5.uid()); - const node n1(0, node::max_id, n2.uid(), n2.uid()); + const node n7(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n6(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n5(2, node::max_id - 1, node::pointer_type(true), n7.uid()); + const node n4(2, node::max_id - 2, node::pointer_type(false), n7.uid()); + const node n3(1, node::max_id, n5.uid(), n6.uid()); + const node n2(1, node::max_id - 1, n4.uid(), n5.uid()); + const node n1(0, node::max_id, n2.uid(), n2.uid()); node_writer w(in_a); w << n7 << n6 << n5 << n4 << n3 << n2 << n1; @@ -294,50 +319,54 @@ go_bandit([]() { // TF FT */ { // Garbage collect writers to free write-lock - const node n7(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n6(3, node::max_id-1, node::pointer_type(true), node::pointer_type(false)); - const node n5(2, node::max_id, n7.uid(), node::pointer_type(true)); - const node n4(2, node::max_id-1, node::pointer_type(false), n6.uid()); - const node n3(1, node::max_id, n4.uid(), n5.uid()); - const node n2(1, node::max_id-1, n5.uid(), n4.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n7(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n6(3, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)); + const node n5(2, node::max_id, n7.uid(), node::pointer_type(true)); + const node n4(2, node::max_id - 1, node::pointer_type(false), n6.uid()); + const node n3(1, node::max_id, n4.uid(), n5.uid()); + const node n2(1, node::max_id - 1, n5.uid(), n4.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(in_b); w << n7 << n6 << n5 << n4 << n3 << n2 << n1; } AssertThat(is_isomorphic(exec_policy(), dd(in_a, false), dd(in_b, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(in_a, false), dd(in_b, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(in_b, true), dd(in_a, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(in_b, true), dd(in_a, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(in_a, false), dd(in_b, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(in_b, true), dd(in_a, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(in_b, true), dd(in_a, true)), Is().False()); }); }); describe("Case: #Terminal Arcs", [&]() { it("rejects F (̈́[1,0]) vs. T ([0,1])", [&]() { AssertThat(is_isomorphic(exec_policy(), dd(F, false), dd(T, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(T, true), dd(F, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(T, true), dd(F, true)), Is().False()); }); it("rejects F (̈́[1,0]) vs. ~F ([0,1])", [&]() { const auto F_copy = shared_levelized_file::copy(F); - AssertThat(is_isomorphic(exec_policy(), dd(F, false), dd(F_copy, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(F_copy, true), dd(F, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(F, false), dd(F_copy, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(F_copy, true), dd(F, false)), Is().False()); }); it("rejects F ([1,0]) vs. x42 ([1,1])", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(F, false), dd(x42, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(F, false), dd(x42, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x42, true), dd(F, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x42, true), dd(F, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(F, false), dd(x42, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(F, false), dd(x42, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x42, true), dd(F, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x42, true), dd(F, true)), Is().False()); }); it("rejects T ([0,1]) vs. x21 & x42 ([2,1])", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(T, false), dd(x21_and_x42, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(T, false), dd(x21_and_x42, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(T, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(T, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(T, false), dd(x21_and_x42, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(T, false), dd(x21_and_x42, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(T, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(T, true)), + Is().False()); }); it("rejects x21 & x42 (̈́[1,2]) vs. ~x21 | (x21 & x42) ([2,1])", [&]() { @@ -361,8 +390,8 @@ go_bandit([]() { AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, false)), Is().False()); AssertThat(is_isomorphic(exec_policy(), dd(b, false), dd(a, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(b, true), dd(a, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(b, true), dd(a, true)), Is().False()); }); it("rejects x21 & x42 (̈́[1,2]) vs. ~(x21 & ~x42) ([2,1])", [&]() { @@ -384,32 +413,36 @@ go_bandit([]() { w << n2 << n1; } - AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(b, true), dd(a, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(b, false), dd(a, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(b, true), dd(a, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(b, false), dd(a, true)), Is().False()); }); it("rejects x21 ([1,1]) vs. x21 & x42 ([2,1])", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(x21, false), dd(x21_and_x42, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21, false), dd(x21_and_x42, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(x21, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(x21, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21, false), dd(x21_and_x42, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21, false), dd(x21_and_x42, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(x21, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, true), dd(x21, true)), + Is().False()); }); it("rejects [4] ([2,2]) vs. ~[5] ([3,2]) due to one extra F terminal", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_4, false), dd(dd_5, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_4, false), dd(dd_5, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_4, false), dd(dd_5, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_4, false), dd(dd_5, true)), Is().False()); }); it("rejects [4] ([2,2]) vs. [5] ([2,3]) due to one extra T terminal", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_4, false), dd(dd_5, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_5, false), dd(dd_4, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_4, false), dd(dd_5, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_5, false), dd(dd_4, false)), Is().False()); }); it("rejects [5] ([2,3]) vs. [6] ([3,2])", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_5, false), dd(dd_6, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_5, true), dd(dd_6, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_5, false), dd(dd_6, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_5, true), dd(dd_6, true)), Is().False()); }); }); @@ -426,11 +459,11 @@ go_bandit([]() { // F T */ { - const node n5(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n4(2, node::max_id, node::pointer_type(true), node::pointer_type(false)); - const node n3(1, node::max_id, n4.uid(), node::pointer_type(true)); - const node n2(1, node::max_id-1, node::pointer_type(false), n5.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n5(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n4(2, node::max_id, node::pointer_type(true), node::pointer_type(false)); + const node n3(1, node::max_id, n4.uid(), node::pointer_type(true)); + const node n2(1, node::max_id - 1, node::pointer_type(false), n5.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_8); w << n5 << n4 << n3 << n2 << n1; @@ -451,11 +484,11 @@ go_bandit([]() { // T F F T */ { - const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n4(2, node::max_id-1, node::pointer_type(true), node::pointer_type(false)); - const node n3(1, node::max_id, n4.uid(), node::pointer_type(true)); - const node n2(1, node::max_id-1, node::pointer_type(false), n5.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n4(2, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)); + const node n3(1, node::max_id, n4.uid(), node::pointer_type(true)); + const node n2(1, node::max_id - 1, node::pointer_type(false), n5.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_9); w << n5 << n4 << n3 << n2 << n1; @@ -464,9 +497,9 @@ go_bandit([]() { describe("Case: #Levels", [&]() { it("rejects [8] vs. [9] on the number of levels", [&]() { AssertThat(is_isomorphic(exec_policy(), dd(dd_8, false), dd(dd_9, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_8, false), dd(dd_9, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_9, true), dd(dd_8, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_9, true), dd(dd_8, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_8, false), dd(dd_9, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_9, true), dd(dd_8, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_9, true), dd(dd_8, true)), Is().False()); }); }); @@ -489,16 +522,20 @@ go_bandit([]() { describe("Case: Individual Level's Label and Width)", [&]() { it("rejects x21 vs x42 on the label", [&]() { AssertThat(is_isomorphic(exec_policy(), dd(x21, false), dd(x42, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21, false), dd(x42, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x42, true), dd(x21, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x42, true), dd(x21, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21, false), dd(x42, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x42, true), dd(x21, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x42, true), dd(x21, true)), Is().False()); }); it("rejects x21 & x42 vs x21 & x22 on the label", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, false), dd(x21_and_x22, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, false), dd(x21_and_x22, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x22, true), dd(x21_and_x42, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x22, true), dd(x21_and_x42, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, false), dd(x21_and_x22, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x42, false), dd(x21_and_x22, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x22, true), dd(x21_and_x42, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x21_and_x22, true), dd(x21_and_x42, true)), + Is().False()); }); it("rejects due to levels have mismatching width", []() { @@ -515,12 +552,12 @@ go_bandit([]() { // T F F T */ { // Garbage collect writers to free write-lock - const node n6(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n5(3, node::max_id-1, node::pointer_type(true), node::pointer_type(false)); - const node n4(2, node::max_id, n5.uid(), n6.uid()); - const node n3(1, node::max_id, n4.uid(), n6.uid()); - const node n2(1, node::max_id-1, n5.uid(), n4.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n6(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n5(3, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)); + const node n4(2, node::max_id, n5.uid(), n6.uid()); + const node n3(1, node::max_id, n4.uid(), n6.uid()); + const node n2(1, node::max_id - 1, n5.uid(), n4.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(in_a); w << n6 << n5 << n4 << n3 << n2 << n1; @@ -542,21 +579,21 @@ go_bandit([]() { // F T */ { // Garbage collect writers to free write-lock - const node n6(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n5(2, node::max_id, n6.uid(), node::pointer_type(true)); - const node n4(2, node::max_id, n6.uid(), node::pointer_type(false)); - const node n3(1, node::max_id, n4.uid(), n5.uid()); - const node n2(1, node::max_id-1, n6.uid(), n4.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n6(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n5(2, node::max_id, n6.uid(), node::pointer_type(true)); + const node n4(2, node::max_id, n6.uid(), node::pointer_type(false)); + const node n3(1, node::max_id, n4.uid(), n5.uid()); + const node n2(1, node::max_id - 1, n6.uid(), n4.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(in_b); w << n6 << n5 << n4 << n3 << n2 << n1; } AssertThat(is_isomorphic(exec_policy(), dd(in_a, false), dd(in_b, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(in_a, false), dd(in_b, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(in_b, true), dd(in_a, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(in_b, true), dd(in_a, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(in_a, false), dd(in_b, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(in_b, true), dd(in_a, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(in_b, true), dd(in_a, true)), Is().False()); }); }); @@ -607,10 +644,10 @@ go_bandit([]() { // F T */ { - const node n4(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n3(1, node::max_id, n4.uid(), node::pointer_type(false)); - const node n2(1, node::max_id-1, node::pointer_type(true), n4.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n4(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n3(1, node::max_id, n4.uid(), node::pointer_type(false)); + const node n2(1, node::max_id - 1, node::pointer_type(true), n4.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_1); w << n4 << n3 << n2 << n1; @@ -629,10 +666,10 @@ go_bandit([]() { // T F */ { - const node n4(2, node::max_id, node::pointer_type(true), node::pointer_type(false)); - const node n3(1, node::max_id, n4.uid(), node::pointer_type(true)); - const node n2(1, node::max_id-1, node::pointer_type(false), n4.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n4(2, node::max_id, node::pointer_type(true), node::pointer_type(false)); + const node n3(1, node::max_id, n4.uid(), node::pointer_type(true)); + const node n2(1, node::max_id - 1, node::pointer_type(false), n4.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_1n); w << n4 << n3 << n2 << n1; @@ -651,10 +688,10 @@ go_bandit([]() { // T T */ { - const node n4(2, node::max_id, node::pointer_type(true), node::pointer_type(true)); - const node n3(1, node::max_id, n4.uid(), node::pointer_type(false)); - const node n2(1, node::max_id-1, node::pointer_type(false), n4.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n4(2, node::max_id, node::pointer_type(true), node::pointer_type(true)); + const node n3(1, node::max_id, n4.uid(), node::pointer_type(false)); + const node n2(1, node::max_id - 1, node::pointer_type(false), n4.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_1_low_leaf); w << n4 << n3 << n2 << n1; @@ -674,10 +711,10 @@ go_bandit([]() { // F F */ { - const node n4(2, node::max_id, node::pointer_type(false), node::pointer_type(false)); - const node n3(1, node::max_id, n4.uid(), node::pointer_type(true)); - const node n2(1, node::max_id-1, node::pointer_type(true), n4.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n4(2, node::max_id, node::pointer_type(false), node::pointer_type(false)); + const node n3(1, node::max_id, n4.uid(), node::pointer_type(true)); + const node n2(1, node::max_id - 1, node::pointer_type(true), n4.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_1_high_leaf); w << n4 << n3 << n2 << n1; @@ -695,11 +732,11 @@ go_bandit([]() { // T F F T */ { - const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n4(2, node::max_id-1, node::pointer_type(true), node::pointer_type(false)); - const node n3(1, node::max_id, n4.uid(), node::pointer_type(false)); - const node n2(1, node::max_id-1, node::pointer_type(false), n5.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n4(2, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)); + const node n3(1, node::max_id, n4.uid(), node::pointer_type(false)); + const node n2(1, node::max_id - 1, node::pointer_type(false), n5.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_2); w << n5 << n4 << n3 << n2 << n1; @@ -719,11 +756,11 @@ go_bandit([]() { // T F F T */ { - const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n4(2, node::max_id-1, node::pointer_type(true), node::pointer_type(false)); - const node n3(1, node::max_id, n5.uid(), node::pointer_type(true)); - const node n2(1, node::max_id-1, node::pointer_type(true), n4.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n4(2, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)); + const node n3(1, node::max_id, n5.uid(), node::pointer_type(true)); + const node n2(1, node::max_id - 1, node::pointer_type(true), n4.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_2n); w << n5 << n4 << n3 << n2 << n1; @@ -742,11 +779,11 @@ go_bandit([]() { // T F F T */ { - const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n4(2, node::max_id-1, node::pointer_type(true), node::pointer_type(false)); - const node n3(1, node::max_id, node::pointer_type(true), node::pointer_type(false)); - const node n2(1, node::max_id-1, n4.uid(), n5.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n4(2, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)); + const node n3(1, node::max_id, node::pointer_type(true), node::pointer_type(false)); + const node n2(1, node::max_id - 1, n4.uid(), n5.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_2_low_child); w << n5 << n4 << n3 << n2 << n1; @@ -765,11 +802,11 @@ go_bandit([]() { // T F F T */ { - const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n4(2, node::max_id-1, node::pointer_type(true), node::pointer_type(false)); - const node n3(1, node::max_id, node::pointer_type(true), node::pointer_type(false)); - const node n2(1, node::max_id-1, n5.uid(), n4.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n4(2, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)); + const node n3(1, node::max_id, node::pointer_type(true), node::pointer_type(false)); + const node n2(1, node::max_id - 1, n5.uid(), n4.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_2_low_child2); w << n5 << n4 << n3 << n2 << n1; @@ -788,11 +825,11 @@ go_bandit([]() { // T F F T */ { - const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n4(2, node::max_id-1, node::pointer_type(true), node::pointer_type(false)); - const node n3(1, node::max_id, n5.uid(), node::pointer_type(false)); - const node n2(1, node::max_id-1, node::pointer_type(false), n4.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n4(2, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)); + const node n3(1, node::max_id, n5.uid(), node::pointer_type(false)); + const node n2(1, node::max_id - 1, node::pointer_type(false), n4.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_2_high_child); w << n5 << n4 << n3 << n2 << n1; @@ -812,9 +849,9 @@ go_bandit([]() { */ { const node n4(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n3(2, node::max_id, node::pointer_type(true), n4.uid()); - const node n2(1, node::max_id, n3.uid(), node::pointer_type(false)); - const node n1(0, node::max_id, n3.uid(), n2.uid()); + const node n3(2, node::max_id, node::pointer_type(true), n4.uid()); + const node n2(1, node::max_id, n3.uid(), node::pointer_type(false)); + const node n1(0, node::max_id, n3.uid(), n2.uid()); node_writer w(dd_3); w << n4 << n3 << n2 << n1; @@ -835,10 +872,10 @@ go_bandit([]() { // T F */ { - const node n4(3, node::max_id, node::pointer_type(true), node::pointer_type(false)); + const node n4(3, node::max_id, node::pointer_type(true), node::pointer_type(false)); const node n3(2, node::max_id, node::pointer_type(false), n4.uid()); - const node n2(1, node::max_id, n3.uid(), node::pointer_type(true)); - const node n1(0, node::max_id, n3.uid(), n2.uid()); + const node n2(1, node::max_id, n3.uid(), node::pointer_type(true)); + const node n1(0, node::max_id, n3.uid(), n2.uid()); node_writer w(dd_3n); w << n4 << n3 << n2 << n1; @@ -860,9 +897,9 @@ go_bandit([]() { */ { const node n4(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n3(2, node::max_id, node::pointer_type(true), n4.uid()); - const node n2(1, node::max_id, n4.uid(), node::pointer_type(false)); - const node n1(0, node::max_id, n3.uid(), n2.uid()); + const node n3(2, node::max_id, node::pointer_type(true), n4.uid()); + const node n2(1, node::max_id, n4.uid(), node::pointer_type(false)); + const node n1(0, node::max_id, n3.uid(), n2.uid()); node_writer w(dd_3_low_child); w << n4 << n3 << n2 << n1; @@ -884,9 +921,9 @@ go_bandit([]() { */ { const node n4(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n3(2, node::max_id, n4.uid(), node::pointer_type(false)); + const node n3(2, node::max_id, n4.uid(), node::pointer_type(false)); const node n2(1, node::max_id, node::pointer_type(true), n3.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_4n); w << n4 << n3 << n2 << n1; @@ -907,10 +944,10 @@ go_bandit([]() { // T F */ { - const node n4(3, node::max_id, node::pointer_type(true), node::pointer_type(false)); - const node n3(2, node::max_id, n4.uid(), node::pointer_type(true)); + const node n4(3, node::max_id, node::pointer_type(true), node::pointer_type(false)); + const node n3(2, node::max_id, n4.uid(), node::pointer_type(true)); const node n2(1, node::max_id, node::pointer_type(false), n4.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_4_high_child); w << n4 << n3 << n2 << n1; @@ -927,11 +964,11 @@ go_bandit([]() { // T F F T */ { - const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n4(2, node::max_id-1, node::pointer_type(true), node::pointer_type(false)); - const node n3(1, node::max_id, n5.uid(), node::pointer_type(true)); - const node n2(1, node::max_id-1, n4.uid(), node::pointer_type(true)); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n4(2, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)); + const node n3(1, node::max_id, n5.uid(), node::pointer_type(true)); + const node n2(1, node::max_id - 1, n4.uid(), node::pointer_type(true)); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_7); w << n5 << n4 << n3 << n2 << n1; @@ -951,11 +988,11 @@ go_bandit([]() { // T F F T */ { - const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n4(2, node::max_id-1, node::pointer_type(true), node::pointer_type(false)); - const node n3(1, node::max_id, n5.uid(), node::pointer_type(false)); - const node n2(1, node::max_id-1, n4.uid(), node::pointer_type(false)); - const node n1(0, node::max_id, n3.uid(), n2.uid()); + const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n4(2, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)); + const node n3(1, node::max_id, n5.uid(), node::pointer_type(false)); + const node n2(1, node::max_id - 1, n4.uid(), node::pointer_type(false)); + const node n1(0, node::max_id, n3.uid(), n2.uid()); node_writer w(dd_7n); w << n5 << n4 << n3 << n2 << n1; @@ -974,11 +1011,11 @@ go_bandit([]() { // T F F T */ { - const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n4(2, node::max_id-1, node::pointer_type(true), node::pointer_type(false)); - const node n3(1, node::max_id, node::pointer_type(true), node::pointer_type(true)); - const node n2(1, node::max_id-1, n4.uid(), n5.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n4(2, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)); + const node n3(1, node::max_id, node::pointer_type(true), node::pointer_type(true)); + const node n2(1, node::max_id - 1, n4.uid(), n5.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_7_high_child); w << n5 << n4 << n3 << n2 << n1; @@ -993,7 +1030,7 @@ go_bandit([]() { const auto b = shared_levelized_file::copy(F); AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); }); it("accepts T", [&]() { @@ -1001,7 +1038,7 @@ go_bandit([]() { const auto b = shared_levelized_file::copy(T); AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); }); it("accepts x42", [&]() { @@ -1009,7 +1046,7 @@ go_bandit([]() { const auto b = shared_levelized_file::copy(x42); AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); }); it("accepts ~x42", [&]() { @@ -1017,14 +1054,16 @@ go_bandit([]() { const auto b = shared_levelized_file::copy(not_x42); AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); }); it("rejects on child mismatch [terminal value]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(not_x42, false), dd(x42, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x42, false), dd(not_x42, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(not_x42, true), dd(x42, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(x42, true), dd(not_x42, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(not_x42, false), dd(x42, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x42, false), dd(not_x42, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(not_x42, true), dd(x42, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(x42, true), dd(not_x42, true)), Is().False()); }); it("accepts [trivial_x69]", [&]() { @@ -1032,14 +1071,20 @@ go_bandit([]() { const auto b = shared_levelized_file::copy(trivial_x69); AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); }); it("rejects on child mismatch [terminal value]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(trivial_x69, false), dd(not_trivial_x69, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(not_trivial_x69, false), dd(trivial_x69, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(trivial_x69, true), dd(not_trivial_x69, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(not_trivial_x69, true), dd(trivial_x69, true)), Is().False()); + AssertThat( + is_isomorphic(exec_policy(), dd(trivial_x69, false), dd(not_trivial_x69, false)), + Is().False()); + AssertThat( + is_isomorphic(exec_policy(), dd(not_trivial_x69, false), dd(trivial_x69, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(trivial_x69, true), dd(not_trivial_x69, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(not_trivial_x69, true), dd(trivial_x69, true)), + Is().False()); }); it("accepts [1]", [&]() { @@ -1047,28 +1092,36 @@ go_bandit([]() { const auto b = shared_levelized_file::copy(dd_1); AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); }); it("rejects on low child mismatch [terminal value]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_1, false), dd(dd_1n, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1n, false), dd(dd_1, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1, true), dd(dd_1n, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1n, true), dd(dd_1, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1, false), dd(dd_1n, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1n, false), dd(dd_1, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1, true), dd(dd_1n, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1n, true), dd(dd_1, true)), Is().False()); }); it("rejects on low child mismatch [terminal value]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_1, false), dd(dd_1_low_leaf, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1_low_leaf, false), dd(dd_1, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1, true), dd(dd_1_low_leaf, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1_low_leaf, true), dd(dd_1, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1, false), dd(dd_1_low_leaf, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1_low_leaf, false), dd(dd_1, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1, true), dd(dd_1_low_leaf, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1_low_leaf, true), dd(dd_1, true)), + Is().False()); }); it("rejects on high child mismatch [terminal value]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_1, false), dd(dd_1_high_leaf, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1_high_leaf, false), dd(dd_1, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1, true), dd(dd_1_high_leaf, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1_high_leaf, true), dd(dd_1, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1, false), dd(dd_1_high_leaf, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1_high_leaf, false), dd(dd_1, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1, true), dd(dd_1_high_leaf, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1_high_leaf, true), dd(dd_1, true)), + Is().False()); }); it("accepts [2]", [&]() { @@ -1076,35 +1129,51 @@ go_bandit([]() { const auto b = shared_levelized_file::copy(dd_2); AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); }); it("rejects on low child mismatch [terminal value]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_2, false), dd(dd_2n, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, false), dd(dd_2, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2, true), dd(dd_2n, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, true), dd(dd_2, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2, false), dd(dd_2n, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, false), dd(dd_2, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2, true), dd(dd_2n, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, true), dd(dd_2, true)), Is().False()); }); it("rejects on low child mismatch [internal vs. terminal]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_2, false), dd(dd_2_low_child, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2_low_child, false), dd(dd_2, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2, true), dd(dd_2_low_child, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2_low_child, true), dd(dd_2, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2, false), dd(dd_2_low_child, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2_low_child, false), dd(dd_2, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2, true), dd(dd_2_low_child, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2_low_child, true), dd(dd_2, true)), + Is().False()); }); it("rejects on low child mismatch [node id]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_2_low_child, false), dd(dd_2_low_child2, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2_low_child2, false), dd(dd_2_low_child, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2_low_child, true), dd(dd_2_low_child2, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2_low_child2, true), dd(dd_2_low_child, true)), Is().False()); + AssertThat( + is_isomorphic(exec_policy(), dd(dd_2_low_child, false), dd(dd_2_low_child2, false)), + Is().False()); + AssertThat( + is_isomorphic(exec_policy(), dd(dd_2_low_child2, false), dd(dd_2_low_child, false)), + Is().False()); + AssertThat( + is_isomorphic(exec_policy(), dd(dd_2_low_child, true), dd(dd_2_low_child2, true)), + Is().False()); + AssertThat( + is_isomorphic(exec_policy(), dd(dd_2_low_child2, true), dd(dd_2_low_child, true)), + Is().False()); }); it("rejects on high child mismatch [node id]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_2, false), dd(dd_2_high_child, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2_high_child, false), dd(dd_2, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2, true), dd(dd_2_high_child, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2_high_child, true) , dd(dd_2, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2, false), dd(dd_2_high_child, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2_high_child, false), dd(dd_2, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2, true), dd(dd_2_high_child, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2_high_child, true), dd(dd_2, true)), + Is().False()); }); it("accepts [3]", [&]() { @@ -1112,14 +1181,18 @@ go_bandit([]() { const auto b = shared_levelized_file::copy(dd_3); AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); }); it("rejects on low child mismatch [node label]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_3, false), dd(dd_3_low_child, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_3_low_child, false), dd(dd_3, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_3, true), dd(dd_3_low_child, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_3_low_child, true), dd(dd_3, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_3, false), dd(dd_3_low_child, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_3_low_child, false), dd(dd_3, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_3, true), dd(dd_3_low_child, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_3_low_child, true), dd(dd_3, true)), + Is().False()); }); it("accepts [4]", [&]() { @@ -1127,14 +1200,18 @@ go_bandit([]() { const auto b = shared_levelized_file::copy(dd_4); AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); }); it("rejects on high child mismatch [node label]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_4, false), dd(dd_4_high_child, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_4_high_child, false), dd(dd_4, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_4, true), dd(dd_4_high_child, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_4_high_child, true) , dd(dd_4, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_4, false), dd(dd_4_high_child, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_4_high_child, false), dd(dd_4, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_4, true), dd(dd_4_high_child, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_4_high_child, true), dd(dd_4, true)), + Is().False()); }); it("accepts [7]", [&]() { @@ -1142,79 +1219,95 @@ go_bandit([]() { const auto b = shared_levelized_file::copy(dd_7); AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, true)), Is().True()); }); it("rejects on root's children flipped [node id]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_7, false), dd(dd_7n, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_7n, false), dd(dd_7, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_7, true), dd(dd_7n, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_7n, true) , dd(dd_7, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_7, false), dd(dd_7n, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_7n, false), dd(dd_7, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_7, true), dd(dd_7n, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_7n, true), dd(dd_7, true)), Is().False()); }); it("rejects on high child mismatch [internal vs. terminal]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_7, false), dd(dd_7_high_child, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_7_high_child, false), dd(dd_7, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_7, true), dd(dd_7_high_child, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_7_high_child, true) , dd(dd_7, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_7, false), dd(dd_7_high_child, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_7_high_child, false), dd(dd_7, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_7, true), dd(dd_7_high_child, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_7_high_child, true), dd(dd_7, true)), + Is().False()); }); }); describe("Case: O(sort(N)) Comparison Check", [&]() { it("accepts ~F and T", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(T, false), dd(F, true)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(F, true), dd(T, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(T, false), dd(F, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(F, true), dd(T, false)), Is().True()); }); it("accepts F and ~T", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(T, false), dd(F, true)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(F, true), dd(T, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(T, false), dd(F, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(F, true), dd(T, false)), Is().True()); }); it("rejects x42 and ~x42", [&]() { const auto a = x42; const auto b = shared_levelized_file::copy(x42); - AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, false)), Is().False()); }); it("accepts x42 and negated ~x42", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(x42, false), dd(not_x42, true)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(x42, true), dd(not_x42, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(x42, false), dd(not_x42, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(x42, true), dd(not_x42, false)), Is().True()); }); it("accepts [1] and negated [~1]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_1, false), dd(dd_1n, true)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1, true), dd(dd_1n, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1, false), dd(dd_1n, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1, true), dd(dd_1n, false)), Is().True()); }); it("rejects on low child mismatch [terminal value]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_1n, true), dd(dd_1_low_leaf, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1_low_leaf, false), dd(dd_1n, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1n, false), dd(dd_1_low_leaf, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1_low_leaf, true), dd(dd_1n, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1n, true), dd(dd_1_low_leaf, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1_low_leaf, false), dd(dd_1n, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1n, false), dd(dd_1_low_leaf, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1_low_leaf, true), dd(dd_1n, false)), + Is().False()); }); it("rejects on high child mismatch [terminal value]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_1n, true), dd(dd_1_high_leaf, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1_high_leaf, false), dd(dd_1n, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1n, false), dd(dd_1_high_leaf, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1_high_leaf, true), dd(dd_1n, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1n, true), dd(dd_1_high_leaf, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1_high_leaf, false), dd(dd_1n, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1n, false), dd(dd_1_high_leaf, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1_high_leaf, true), dd(dd_1n, false)), + Is().False()); }); it("accepts [2] and negated [~2]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_2, false), dd(dd_2n, true)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, true), dd(dd_2, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2, true), dd(dd_2n, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, false), dd(dd_2, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2, false), dd(dd_2n, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, true), dd(dd_2, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2, true), dd(dd_2n, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, false), dd(dd_2, true)), Is().True()); }); it("rejects on low child mismatch [internal vs. terminal]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, true), dd(dd_2_low_child, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2_low_child, false), dd(dd_2n, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, false), dd(dd_2_low_child, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2_low_child, true), dd(dd_2n, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, true), dd(dd_2_low_child, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2_low_child, false), dd(dd_2n, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, false), dd(dd_2_low_child, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2_low_child, true), dd(dd_2n, false)), + Is().False()); }); it("rejects on low child mismatch [node id]", [&]() { @@ -1232,69 +1325,93 @@ go_bandit([]() { // T F F T */ { - const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n4(2, node::max_id-1, node::pointer_type(true), node::pointer_type(false)); - const node n3(1, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n2(1, node::max_id-1, n5.uid(), n4.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n5(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n4(2, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)); + const node n3(1, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n2(1, node::max_id - 1, n5.uid(), n4.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_2_low_childn); w << n5 << n4 << n3 << n2 << n1; } - AssertThat(is_isomorphic(exec_policy(), dd(dd_2_low_childn, true), dd(dd_2_low_child2, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2_low_child2, false), dd(dd_2_low_childn, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2_low_childn, false), dd(dd_2_low_child2, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2_low_child2, true), dd(dd_2_low_childn, false)), Is().False()); + AssertThat( + is_isomorphic(exec_policy(), dd(dd_2_low_childn, true), dd(dd_2_low_child2, false)), + Is().False()); + AssertThat( + is_isomorphic(exec_policy(), dd(dd_2_low_child2, false), dd(dd_2_low_childn, true)), + Is().False()); + AssertThat( + is_isomorphic(exec_policy(), dd(dd_2_low_childn, false), dd(dd_2_low_child2, true)), + Is().False()); + AssertThat( + is_isomorphic(exec_policy(), dd(dd_2_low_child2, true), dd(dd_2_low_childn, false)), + Is().False()); }); it("rejects on high child mismatch [node id]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, true), dd(dd_2_high_child, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2_high_child, false), dd(dd_2n, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, false), dd(dd_2_high_child, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2_high_child, true) , dd(dd_2n, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, true), dd(dd_2_high_child, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2_high_child, false), dd(dd_2n, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, false), dd(dd_2_high_child, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2_high_child, true), dd(dd_2n, false)), + Is().False()); }); it("accepts [3] and negated [~3]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_3, false), dd(dd_3n, true)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_3n, true), dd(dd_3, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_3, true), dd(dd_3n, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_3n, false), dd(dd_3, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_3, false), dd(dd_3n, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_3n, true), dd(dd_3, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_3, true), dd(dd_3n, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_3n, false), dd(dd_3, true)), Is().True()); }); it("rejects on low child mismatch [node label]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_3n, true), dd(dd_3_low_child, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_3_low_child, false), dd(dd_3n, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_3n, false), dd(dd_3_low_child, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_3_low_child, true), dd(dd_3n, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_3n, true), dd(dd_3_low_child, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_3_low_child, false), dd(dd_3n, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_3n, false), dd(dd_3_low_child, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_3_low_child, true), dd(dd_3n, false)), + Is().False()); }); it("accepts [4] and negated [~4]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_4, false), dd(dd_4n, true)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_4n, false), dd(dd_4, true)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_4, true), dd(dd_4n, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_4n, true), dd(dd_4, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_4, false), dd(dd_4n, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_4n, false), dd(dd_4, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_4, true), dd(dd_4n, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_4n, true), dd(dd_4, false)), Is().True()); }); it("rejects on high child mismatch [node label]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_4n, true), dd(dd_4_high_child, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_4_high_child, false), dd(dd_4n, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_4n, false), dd(dd_4_high_child, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_4_high_child, true) , dd(dd_4n, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_4n, true), dd(dd_4_high_child, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_4_high_child, false), dd(dd_4n, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_4n, false), dd(dd_4_high_child, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_4_high_child, true), dd(dd_4n, false)), + Is().False()); }); it("accepts [7] and negated [~7]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_7, false), dd(dd_7n, true)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_7n, false), dd(dd_7, true)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_7, true), dd(dd_7n, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_7n, true), dd(dd_7, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_7, false), dd(dd_7n, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_7n, false), dd(dd_7, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_7, true), dd(dd_7n, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_7n, true), dd(dd_7, false)), Is().True()); }); it("rejects on high child mismatch [internal vs. terminal]", [&]() { - AssertThat(is_isomorphic(exec_policy(), dd(dd_7n, true), dd(dd_7_high_child, false)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_7_high_child, false), dd(dd_7n, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_7n, false), dd(dd_7_high_child, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_7_high_child, true) , dd(dd_7n, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_7n, true), dd(dd_7_high_child, false)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_7_high_child, false), dd(dd_7n, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_7n, false), dd(dd_7_high_child, true)), + Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_7_high_child, true), dd(dd_7n, false)), + Is().False()); }); it("rejects on root's children mismatching", [&]() { @@ -1308,7 +1425,7 @@ go_bandit([]() { */ { const node n2(1, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n1(0, node::max_id, n2.uid(), node::pointer_type(false)); + const node n1(0, node::max_id, n2.uid(), node::pointer_type(false)); node_writer w(a); w << n2 << n1; @@ -1331,7 +1448,7 @@ go_bandit([]() { } AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, false)), Is().False()); }); it("rejects on root's low child mismatches [terminal value]", [&]() { @@ -1347,8 +1464,8 @@ go_bandit([]() { */ { const node n3(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n2(1, node::max_id, n3.uid(), node::pointer_type(false)); - const node n1(0, node::max_id, node::pointer_type(true), n2.uid()); + const node n2(1, node::max_id, n3.uid(), node::pointer_type(false)); + const node n1(0, node::max_id, node::pointer_type(true), n2.uid()); node_writer w(a); w << n3 << n2 << n1; @@ -1356,8 +1473,8 @@ go_bandit([]() { const auto b = shared_levelized_file::copy(a); - AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, false)), Is().False()); }); it("rejects on root's high child mismatches [terminal value]", [&]() { @@ -1373,8 +1490,8 @@ go_bandit([]() { */ { const node n3(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n2(1, node::max_id, n3.uid(), node::pointer_type(false)); - const node n1(0, node::max_id, n2.uid(), node::pointer_type(true)); + const node n2(1, node::max_id, n3.uid(), node::pointer_type(false)); + const node n1(0, node::max_id, n2.uid(), node::pointer_type(true)); node_writer w(a); w << n3 << n2 << n1; @@ -1382,8 +1499,8 @@ go_bandit([]() { const auto b = shared_levelized_file::copy(a); - AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(a, false), dd(b, true)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, false)), Is().False()); }); it("accepts with nodes swapped [1]", [&]() { @@ -1403,10 +1520,10 @@ go_bandit([]() { */ shared_levelized_file dd_1b; { // Garbage collect writers to free write-lock - const node n4(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n3(1, node::max_id, node::pointer_type(true), n4.uid()); - const node n2(1, node::max_id-1, n4.uid(), node::pointer_type(false)); - const node n1(0, node::max_id, n3.uid(), n2.uid()); + const node n4(2, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n3(1, node::max_id, node::pointer_type(true), n4.uid()); + const node n2(1, node::max_id - 1, n4.uid(), node::pointer_type(false)); + const node n1(0, node::max_id, n3.uid(), n2.uid()); node_writer w(dd_1b); w << n4 << n3 << n2 << n1; @@ -1414,17 +1531,17 @@ go_bandit([]() { adiar_assert(dd_1b->canonical == false); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1, false), dd(dd_1b, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1b, false), dd(dd_1, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1, false), dd(dd_1b, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1b, false), dd(dd_1, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1n, true), dd(dd_1b, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1n, true), dd(dd_1b, false)), Is().True()); AssertThat(is_isomorphic(exec_policy(), dd(dd_1b, false), dd(dd_1n, true)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1n, false), dd(dd_1b, true)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1b, true), dd(dd_1n, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1n, false), dd(dd_1b, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1b, true), dd(dd_1n, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1, true), dd(dd_1b, true)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_1b, true), dd(dd_1, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1, true), dd(dd_1b, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_1b, true), dd(dd_1, true)), Is().True()); }); it("accepts with nodes swapped [2]", [&]() { @@ -1441,11 +1558,11 @@ go_bandit([]() { */ shared_levelized_file dd_2b; { // Garbage collect writers to free write-lock - const node n5(2, node::max_id, node::pointer_type(true), node::pointer_type(false)); - const node n4(2, node::max_id-1, node::pointer_type(false), node::pointer_type(true)); - const node n3(1, node::max_id, n5.uid(), node::pointer_type(false)); - const node n2(1, node::max_id-1, node::pointer_type(false), n4.uid()); - const node n1(0, node::max_id, n2.uid(), n3.uid()); + const node n5(2, node::max_id, node::pointer_type(true), node::pointer_type(false)); + const node n4(2, node::max_id - 1, node::pointer_type(false), node::pointer_type(true)); + const node n3(1, node::max_id, n5.uid(), node::pointer_type(false)); + const node n2(1, node::max_id - 1, node::pointer_type(false), n4.uid()); + const node n1(0, node::max_id, n2.uid(), n3.uid()); node_writer w(dd_2b); w << n5 << n4 << n3 << n2 << n1; @@ -1453,17 +1570,17 @@ go_bandit([]() { adiar_assert(dd_2b->canonical == false); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2, false), dd(dd_2b, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2b, false), dd(dd_2, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2, false), dd(dd_2b, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2b, false), dd(dd_2, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, true), dd(dd_2b, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, true), dd(dd_2b, false)), Is().True()); AssertThat(is_isomorphic(exec_policy(), dd(dd_2b, false), dd(dd_2n, true)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, false), dd(dd_2b, true)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2b, true), dd(dd_2n, false)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2n, false), dd(dd_2b, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2b, true), dd(dd_2n, false)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2, true), dd(dd_2b, true)), Is().True()); - AssertThat(is_isomorphic(exec_policy(), dd(dd_2b, true), dd(dd_2, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2, true), dd(dd_2b, true)), Is().True()); + AssertThat(is_isomorphic(exec_policy(), dd(dd_2b, true), dd(dd_2, true)), Is().True()); }); it("rejects when number of requests exceed the input's width", [&]() { @@ -1491,12 +1608,12 @@ go_bandit([]() { */ shared_levelized_file a; { // Garbage collect writers to free write-lock - const node n6(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n5(3, node::max_id-1, node::pointer_type(true), node::pointer_type(false)); - const node n4(2, node::max_id, n5.uid(), n6.uid()); - const node n3(2, node::max_id-1, n6.uid(), n5.uid()); - const node n2(1, node::max_id, n3.uid(), n4.uid()); - const node n1(0, node::max_id, n3.uid(), n2.uid()); + const node n6(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n5(3, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)); + const node n4(2, node::max_id, n5.uid(), n6.uid()); + const node n3(2, node::max_id - 1, n6.uid(), n5.uid()); + const node n2(1, node::max_id, n3.uid(), n4.uid()); + const node n1(0, node::max_id, n3.uid(), n2.uid()); node_writer w(a); w << n6 << n5 << n4 << n3 << n2 << n1; @@ -1512,21 +1629,21 @@ go_bandit([]() { // . . */ { // Garbage collect writers to free write-lock - const node n6(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node n5(3, node::max_id-1, node::pointer_type(true), node::pointer_type(false)); - const node n4(2, node::max_id, n5.uid(), n6.uid()); - const node n3(2, node::max_id-1, n6.uid(), n5.uid()); - const node n2(1, node::max_id, n4.uid(), n3.uid()); - const node n1(0, node::max_id, n3.uid(), n2.uid()); + const node n6(3, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node n5(3, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)); + const node n4(2, node::max_id, n5.uid(), n6.uid()); + const node n3(2, node::max_id - 1, n6.uid(), n5.uid()); + const node n2(1, node::max_id, n4.uid(), n3.uid()); + const node n1(0, node::max_id, n3.uid(), n2.uid()); node_writer w(b); w << n6 << n5 << n4 << n3 << n2 << n1; } AssertThat(is_isomorphic(exec_policy(), dd(b, false), dd(a, true)), Is().False()); - AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, false)), Is().False()); + AssertThat(is_isomorphic(exec_policy(), dd(a, true), dd(b, false)), Is().False()); }); }); }); }); - }); +}); diff --git a/test/adiar/internal/algorithms/test_nested_sweeping.cpp b/test/adiar/internal/algorithms/test_nested_sweeping.cpp index 1775cd864..e5c0fcc6a 100644 --- a/test/adiar/internal/algorithms/test_nested_sweeping.cpp +++ b/test/adiar/internal/algorithms/test_nested_sweeping.cpp @@ -1,13 +1,13 @@ #include "../../../test.h" #include +#include -#include #include #include +#include #include #include -#include //////////////////////////////////////////////////////////////////////////////// /// Policy that provides the most simplistic top-down sweep to test the Inner @@ -19,9 +19,10 @@ /// single non-nil member, i.e. it is a request preserving a /// subtree but (presumably) not changing it. //////////////////////////////////////////////////////////////////////////////// -template +template class test_not_sweep - : public bdd_policy, public statistics::__alg_base::__lpq_t + : public bdd_policy + , public statistics::__alg_base::__lpq_t { private: const size_t _nesting_modulo; @@ -34,38 +35,45 @@ class test_not_sweep using request_pred_t = request_data_first_lt; - template - using pq_t = levelized_node_priority_queue; + template + using pq_t = levelized_node_priority_queue; public: test_not_sweep(const size_t nm) : _nesting_modulo(nm) - { } + {} public: ////////////////////////////////////////////////////////////////////////////// - static size_t stream_memory() - { return node_stream<>::memory_usage() + arc_writer::memory_usage(); } + static size_t + stream_memory() + { + return node_stream<>::memory_usage() + arc_writer::memory_usage(); + } ////////////////////////////////////////////////////////////////////////////// - static size_t pq_memory(const size_t inner_memory) - { return inner_memory; } + static size_t + pq_memory(const size_t inner_memory) + { + return inner_memory; + } ////////////////////////////////////////////////////////////////////////////// - static size_t pq_bound(const shared_levelized_file &/*outer_file*/, - const size_t /*outer_roots*/) - { return 8; } + static size_t + pq_bound(const shared_levelized_file& /*outer_file*/, const size_t /*outer_roots*/) + { + return 8; + } public: ////////////////////////////////////////////////////////////////////////////// /// \brief The Sweep Logic for the PQ access mode case. ////////////////////////////////////////////////////////////////////////////// - template + template __bdd - sweep_pq(const exec_policy &ep, - const shared_levelized_file &outer_file, - inner_pq_t &inner_pq, + sweep_pq(const exec_policy& ep, + const shared_levelized_file& outer_file, + inner_pq_t& inner_pq, const size_t /*inner_remaining_memory == 0*/) { node_stream<> ns(outer_file); @@ -79,7 +87,7 @@ class test_not_sweep inner_pq.setup_next_level(); const node::label_type level_label = inner_pq.current_level(); - node::id_type level_size = 0u; + node::id_type level_size = 0u; while (!inner_pq.empty_level()) { // Give node a new name @@ -94,14 +102,12 @@ class test_not_sweep // Seek node in stream and forward its out-going edges const node n = ns.seek(next); forward_arc(inner_pq, aw, u, n.low()); - forward_arc(inner_pq, aw, u, n.high()); + forward_arc(inner_pq, aw, u, n.high()); // Output all in-going edges that match the target while (inner_pq.can_pull() && inner_pq.top().target.first() == next) { request_t req = inner_pq.pull(); - if (req.data.source.is_nil()) { - continue; - } + if (req.data.source.is_nil()) { continue; } aw.push_internal({ req.data.source, u }); } @@ -116,14 +122,17 @@ class test_not_sweep private: ////////////////////////////////////////////////////////////////////////////// - template - void forward_arc(inner_pq_t &inner_pq, arc_writer &aw, - const node::uid_type &uid, const node::pointer_type &c) + template + void + forward_arc(inner_pq_t& inner_pq, + arc_writer& aw, + const node::uid_type& uid, + const node::pointer_type& c) { if (c.is_terminal()) { aw.push_terminal({ uid, is_high, !c }); } else { - inner_pq.push({{c, node::pointer_type::nil()}, {}, {uid.as_ptr(is_high)}}); + inner_pq.push({ { c, node::pointer_type::nil() }, {}, { uid.as_ptr(is_high) } }); } } @@ -131,44 +140,44 @@ class test_not_sweep ////////////////////////////////////////////////////////////////////////////// /// \brief Whether it wants to sweep on some level. ////////////////////////////////////////////////////////////////////////////// - bool has_sweep(node::pointer_type::label_type l) const - { return (l % _nesting_modulo) == 0u; } + bool + has_sweep(node::pointer_type::label_type l) const + { + return (l % _nesting_modulo) == 0u; + } ////////////////////////////////////////////////////////////////////////////// /// \brief Pick PQ type and Run Sweep. ////////////////////////////////////////////////////////////////////////////// - template + template __bdd - sweep(const exec_policy &ep, - const shared_levelized_file &outer_file, - outer_roots_t &outer_roots, + sweep(const exec_policy& ep, + const shared_levelized_file& outer_file, + outer_roots_t& outer_roots, const size_t inner_memory) { - return nested_sweeping::inner::down__sweep_switch(ep, *this, - outer_file, outer_roots, - inner_memory, - *this); + return nested_sweeping::inner::down__sweep_switch( + ep, *this, outer_file, outer_roots, inner_memory, *this); } ////////////////////////////////////////////////////////////////////////////// /// \brief Create request ////////////////////////////////////////////////////////////////////////////// static inline request_t - request_from_node(const node &n, const ptr_uint64 &parent) + request_from_node(const node& n, const ptr_uint64& parent) { // Always pick high child - return request_t({n.high(), only_gc ? node::pointer_type::nil() : n.high()}, - {}, - {parent}); + return request_t({ n.high(), only_gc ? node::pointer_type::nil() : n.high() }, {}, { parent }); } //////////////////////////////////////////////////////////////////////////// static constexpr bool final_canonical = FinalCanonical; }; -template +template class test_terminal_sweep - : public bdd_policy, public statistics::__alg_base::__lpq_t + : public bdd_policy + , public statistics::__alg_base::__lpq_t { private: const size_t _nesting_modulo; @@ -176,41 +185,48 @@ class test_terminal_sweep public: // HACK: The request is for a 'tuple' to allow us to tell the Nested Sweeping // framework we are indeed changing subgraph. - using request_t = request_data<2, with_parent, 0, 1>; + using request_t = request_data<2, with_parent, 0, 1>; using request_pred_t = request_first_lt; - template - using pq_t = levelized_node_priority_queue; + template + using pq_t = levelized_node_priority_queue; public: test_terminal_sweep(const size_t nm) : _nesting_modulo(nm) - { } + {} public: ////////////////////////////////////////////////////////////////////////////// - static size_t stream_memory() - { return 0u; } + static size_t + stream_memory() + { + return 0u; + } ////////////////////////////////////////////////////////////////////////////// - static size_t pq_memory(const size_t inner_memory) - { return inner_memory; } + static size_t + pq_memory(const size_t inner_memory) + { + return inner_memory; + } ////////////////////////////////////////////////////////////////////////////// - static size_t pq_bound(const shared_levelized_file &/*outer_file*/, - const size_t /*outer_roots*/) - { return 1u; } + static size_t + pq_bound(const shared_levelized_file& /*outer_file*/, const size_t /*outer_roots*/) + { + return 1u; + } public: ////////////////////////////////////////////////////////////////////////////// /// \brief The Sweep Logic for the PQ access mode case. ////////////////////////////////////////////////////////////////////////////// - template + template __bdd - sweep_pq(const exec_policy &ep, - const shared_levelized_file &outer_file, - inner_pq_t &inner_pq, + sweep_pq(const exec_policy& ep, + const shared_levelized_file& outer_file, + inner_pq_t& inner_pq, const size_t /*inner_remaining_memory == 0*/) { node_stream<> ns(outer_file); @@ -224,7 +240,7 @@ class test_terminal_sweep inner_pq.setup_next_level(); const node::label_type level_label = inner_pq.current_level(); - node::id_type level_size = 0u; + node::id_type level_size = 0u; while (!inner_pq.empty_level()) { // Get target of next request @@ -233,16 +249,16 @@ class test_terminal_sweep if (next.label() % _nesting_modulo == 1) { // Collapse immediately to a terminal - t = node::pointer_type(level_label % (_nesting_modulo+1) > 0); + t = node::pointer_type(level_label % (_nesting_modulo + 1) > 0); } else { // Create a simple (i, _, _) node with two terminals. t = node::pointer_type(level_label, level_size++); - const node::pointer_type t0((level_label) % (_nesting_modulo) > 1); + const node::pointer_type t0((level_label) % (_nesting_modulo) > 1); aw.push_terminal({ t, false, t0 }); - const node::pointer_type t1((level_label+1) % (_nesting_modulo) > 1); - aw.push_terminal({ t, true, t1 }); + const node::pointer_type t1((level_label + 1) % (_nesting_modulo) > 1); + aw.push_terminal({ t, true, t1 }); } // Output all in-going edges that match the target @@ -255,9 +271,7 @@ class test_terminal_sweep } } } - if (level_size > 0) { - aw.push(level_info(level_label, level_size)); - } + if (level_size > 0) { aw.push(level_info(level_label, level_size)); } } return __bdd(af, ep); @@ -267,33 +281,34 @@ class test_terminal_sweep ////////////////////////////////////////////////////////////////////////////// /// \brief Whether it wants to sweep on some level. ////////////////////////////////////////////////////////////////////////////// - bool has_sweep(node::pointer_type::label_type l) const - { return (l % _nesting_modulo) == 0u; } + bool + has_sweep(node::pointer_type::label_type l) const + { + return (l % _nesting_modulo) == 0u; + } ////////////////////////////////////////////////////////////////////////////// /// \brief Pick PQ type and Run Sweep. ////////////////////////////////////////////////////////////////////////////// - template + template __bdd - sweep(const exec_policy &ep, - const shared_levelized_file &outer_file, - outer_roots_t &outer_roots, + sweep(const exec_policy& ep, + const shared_levelized_file& outer_file, + outer_roots_t& outer_roots, const size_t inner_memory) { - return nested_sweeping::inner::down__sweep_switch(ep, *this, - outer_file, outer_roots, - inner_memory, - *this); + return nested_sweeping::inner::down__sweep_switch( + ep, *this, outer_file, outer_roots, inner_memory, *this); } ////////////////////////////////////////////////////////////////////////////// /// \brief Create request ////////////////////////////////////////////////////////////////////////////// static inline request_t - request_from_node(const node &n, const ptr_uint64 &parent) + request_from_node(const node& n, const ptr_uint64& parent) { // Always pick low child - return request_t({n.low()}, {}, {parent}); + return request_t({ n.low() }, {}, { parent }); } //////////////////////////////////////////////////////////////////////////// @@ -321,11 +336,11 @@ go_bandit([]() { const uid_uint64 terminal_F(false); const uid_uint64 terminal_T(true); - const uid_uint64 outer_n1(0,0); - const uid_uint64 outer_n2(1,0); - const uid_uint64 outer_n3(2,0); - const uid_uint64 outer_n4(3,0); - const uid_uint64 outer_n5(4,0); + const uid_uint64 outer_n1(0, 0); + const uid_uint64 outer_n2(1, 0); + const uid_uint64 outer_n3(2, 0); + const uid_uint64 outer_n4(3, 0); + const uid_uint64 outer_n5(4, 0); shared_levelized_file outer_dag; @@ -342,13 +357,13 @@ go_bandit([]() { aw.push_terminal({ outer_n3, false, terminal_F }); aw.push_terminal({ outer_n4, false, terminal_F }); aw.push_terminal({ outer_n5, false, terminal_F }); - aw.push_terminal({ outer_n5, true, terminal_T }); + aw.push_terminal({ outer_n5, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); - aw.push(level_info(2,1u)); - aw.push(level_info(3,1u)); - aw.push(level_info(4,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 1u)); + aw.push(level_info(3, 1u)); + aw.push(level_info(4, 1u)); } describe("nested_sweeping:: _ ::decorators", [&]() { @@ -356,17 +371,19 @@ go_bandit([]() { it("can sort pushed 'requests_t' [cardinality = 2]", []() { using test_request_t = request_data<2, with_parent, 0, 1>; - using test_roots_sorter_t = - nested_sweeping::outer::roots_sorter>; + using test_roots_sorter_t = nested_sweeping::outer:: + roots_sorter>; test_roots_sorter_t s(1024, 16); - const test_request_t i1({arc::pointer_type(1,1), arc::pointer_type::nil()}, {}, {arc::pointer_type(0,0, false)}); + const test_request_t i1({ arc::pointer_type(1, 1), arc::pointer_type::nil() }, + {}, + { arc::pointer_type(0, 0, false) }); s.push(i1); - const test_request_t i2({arc::pointer_type(1,0), arc::pointer_type::nil()}, {}, {arc::pointer_type(0,0, true)}); + const test_request_t i2({ arc::pointer_type(1, 0), arc::pointer_type::nil() }, + {}, + { arc::pointer_type(0, 0, true) }); s.push(i2); s.sort(); @@ -374,14 +391,14 @@ go_bandit([]() { AssertThat(s.can_pull(), Is().True()); const test_request_t o1 = s.pull(); - AssertThat(o1.target, Is().EqualTo(i2.target)); - AssertThat(o1.data.source, Is().EqualTo(flag(i2.data.source))); + AssertThat(o1.target, Is().EqualTo(i2.target)); + AssertThat(o1.data.source, Is().EqualTo(flag(i2.data.source))); AssertThat(s.can_pull(), Is().True()); const test_request_t o2 = s.pull(); - AssertThat(o2.target, Is().EqualTo(i1.target)); - AssertThat(o2.data.source, Is().EqualTo(flag(i1.data.source))); + AssertThat(o2.target, Is().EqualTo(i1.target)); + AssertThat(o2.data.source, Is().EqualTo(flag(i1.data.source))); AssertThat(s.can_pull(), Is().False()); }); @@ -389,35 +406,35 @@ go_bandit([]() { it("can convert and sort 'reduced_arc' [cardinality == 1]", []() { using test_request_t = request_data<1, with_parent, 0, 1>; - using test_roots_sorter_t = - nested_sweeping::outer::roots_sorter>; + using test_roots_sorter_t = nested_sweeping::outer:: + roots_sorter>; test_roots_sorter_t s(1024, 16); { - const reduce_arc i1 = arc(arc::pointer_type(0,0), false, arc::pointer_type(1,1)); + const reduce_arc i1 = arc(arc::pointer_type(0, 0), false, arc::pointer_type(1, 1)); s.push(i1); - const reduce_arc i2 = arc(arc::pointer_type(0,0), true, arc::pointer_type(1,0)); + const reduce_arc i2 = arc(arc::pointer_type(0, 0), true, arc::pointer_type(1, 0)); s.push(i2); } s.sort(); AssertThat(s.can_pull(), Is().True()); - const test_request_t e1({arc::pointer_type(1,0)}, {}, {arc::pointer_type(0,0, true)}); + const test_request_t e1( + { arc::pointer_type(1, 0) }, {}, { arc::pointer_type(0, 0, true) }); const test_request_t o1 = s.pull(); - AssertThat(o1.target, Is().EqualTo(e1.target)); + AssertThat(o1.target, Is().EqualTo(e1.target)); AssertThat(o1.data.source, Is().EqualTo(flag(e1.data.source))); AssertThat(s.can_pull(), Is().True()); - const test_request_t e2({arc::pointer_type(1,1)}, {}, {arc::pointer_type(0,0, false)}); + const test_request_t e2( + { arc::pointer_type(1, 1) }, {}, { arc::pointer_type(0, 0, false) }); const test_request_t o2 = s.pull(); - AssertThat(o2.target, Is().EqualTo(e2.target)); + AssertThat(o2.target, Is().EqualTo(e2.target)); AssertThat(o2.data.source, Is().EqualTo(flag(e2.data.source))); AssertThat(s.can_pull(), Is().False()); @@ -426,35 +443,37 @@ go_bandit([]() { it("can convert and sort 'reduced_arc' [cardinality == 2]", []() { using test_request_t = request_data<2, with_parent, 0, 1>; - using test_roots_sorter_t = - nested_sweeping::outer::roots_sorter>; + using test_roots_sorter_t = nested_sweeping::outer:: + roots_sorter>; test_roots_sorter_t s(1024, 16); { - const reduce_arc a1 = arc(arc::pointer_type(0,0), false, arc::pointer_type(1,1)); + const reduce_arc a1 = arc(arc::pointer_type(0, 0), false, arc::pointer_type(1, 1)); s.push(a1); - const reduce_arc a2 = arc(arc::pointer_type(0,0), true, arc::pointer_type(1,0)); + const reduce_arc a2 = arc(arc::pointer_type(0, 0), true, arc::pointer_type(1, 0)); s.push(a2); } s.sort(); AssertThat(s.can_pull(), Is().True()); - const test_request_t e1({arc::pointer_type(1,0), arc::pointer_type::nil()}, {}, {arc::pointer_type(0,0, true)}); + const test_request_t e1({ arc::pointer_type(1, 0), arc::pointer_type::nil() }, + {}, + { arc::pointer_type(0, 0, true) }); const test_request_t o1 = s.pull(); - AssertThat(o1.target, Is().EqualTo(e1.target)); + AssertThat(o1.target, Is().EqualTo(e1.target)); AssertThat(o1.data.source, Is().EqualTo(flag(e1.data.source))); AssertThat(s.can_pull(), Is().True()); - const test_request_t e2({arc::pointer_type(1,1), arc::pointer_type::nil()}, {}, {arc::pointer_type(0,0, false)}); + const test_request_t e2({ arc::pointer_type(1, 1), arc::pointer_type::nil() }, + {}, + { arc::pointer_type(0, 0, false) }); const test_request_t o2 = s.pull(); - AssertThat(o2.target, Is().EqualTo(e2.target)); + AssertThat(o2.target, Is().EqualTo(e2.target)); AssertThat(o2.data.source, Is().EqualTo(flag(e2.data.source))); AssertThat(s.can_pull(), Is().False()); @@ -463,17 +482,23 @@ go_bandit([]() { it("can mix insertion of 'request_t' and 'reduced_arc' [cardinality == 2]", []() { using test_request_t = request_data<2, with_parent, 0, 1>; - using test_roots_sorter_t = - nested_sweeping::outer::roots_sorter>; + using test_roots_sorter_t = nested_sweeping::outer:: + roots_sorter>; test_roots_sorter_t s(1024, 16); - const test_request_t i1({arc::pointer_type(3,3), arc::pointer_type::nil()}, {}, {arc::pointer_type(2,0, false)}); - const test_request_t i2({arc::pointer_type(3,1), arc::pointer_type::nil()}, {}, {arc::pointer_type(2,0, true)}); - const test_request_t i3({arc::pointer_type(3,2), arc::pointer_type::nil()}, {}, {arc::pointer_type(2,1, false)}); - const test_request_t i4({arc::pointer_type(3,4), arc::pointer_type::nil()}, {}, {arc::pointer_type(2,1, true)}); + const test_request_t i1({ arc::pointer_type(3, 3), arc::pointer_type::nil() }, + {}, + { arc::pointer_type(2, 0, false) }); + const test_request_t i2({ arc::pointer_type(3, 1), arc::pointer_type::nil() }, + {}, + { arc::pointer_type(2, 0, true) }); + const test_request_t i3({ arc::pointer_type(3, 2), arc::pointer_type::nil() }, + {}, + { arc::pointer_type(2, 1, false) }); + const test_request_t i4({ arc::pointer_type(3, 4), arc::pointer_type::nil() }, + {}, + { arc::pointer_type(2, 1, true) }); { s.push(reduce_arc(arc(i1.data.source, i1.target[0]))); @@ -487,25 +512,25 @@ go_bandit([]() { AssertThat(s.can_pull(), Is().True()); const test_request_t o1 = s.pull(); - AssertThat(o1.target, Is().EqualTo(i2.target)); + AssertThat(o1.target, Is().EqualTo(i2.target)); AssertThat(o1.data.source, Is().EqualTo(flag(i2.data.source))); AssertThat(s.can_pull(), Is().True()); const test_request_t o2 = s.pull(); - AssertThat(o2.target, Is().EqualTo(i3.target)); + AssertThat(o2.target, Is().EqualTo(i3.target)); AssertThat(o2.data.source, Is().EqualTo(flag(i3.data.source))); AssertThat(s.can_pull(), Is().True()); const test_request_t o3 = s.pull(); - AssertThat(o3.target, Is().EqualTo(i1.target)); + AssertThat(o3.target, Is().EqualTo(i1.target)); AssertThat(o3.data.source, Is().EqualTo(flag(i1.data.source))); AssertThat(s.can_pull(), Is().True()); const test_request_t o4 = s.pull(); - AssertThat(o4.target, Is().EqualTo(i4.target)); + AssertThat(o4.target, Is().EqualTo(i4.target)); AssertThat(o4.data.source, Is().EqualTo(flag(i4.data.source))); AssertThat(s.can_pull(), Is().False()); @@ -514,17 +539,23 @@ go_bandit([]() { it("can reset after sorting", []() { using test_request_t = request_data<2, with_parent, 0, 1>; - using test_roots_sorter_t = - nested_sweeping::outer::roots_sorter>; + using test_roots_sorter_t = nested_sweeping::outer:: + roots_sorter>; test_roots_sorter_t s(1024, 16); - const test_request_t i1({arc::pointer_type(3,3), arc::pointer_type::nil()}, {}, {arc::pointer_type(2,0, false)}); - const test_request_t i2({arc::pointer_type(3,2), arc::pointer_type::nil()}, {}, {arc::pointer_type(2,0, true)}); - const test_request_t i3({arc::pointer_type(3,2), arc::pointer_type::nil()}, {}, {arc::pointer_type(2,1, false)}); - const test_request_t i4({arc::pointer_type(3,1), arc::pointer_type::nil()}, {}, {arc::pointer_type(2,1, true)}); + const test_request_t i1({ arc::pointer_type(3, 3), arc::pointer_type::nil() }, + {}, + { arc::pointer_type(2, 0, false) }); + const test_request_t i2({ arc::pointer_type(3, 2), arc::pointer_type::nil() }, + {}, + { arc::pointer_type(2, 0, true) }); + const test_request_t i3({ arc::pointer_type(3, 2), arc::pointer_type::nil() }, + {}, + { arc::pointer_type(2, 1, false) }); + const test_request_t i4({ arc::pointer_type(3, 1), arc::pointer_type::nil() }, + {}, + { arc::pointer_type(2, 1, true) }); { s.push(reduce_arc(arc(i1.data.source, i1.target[0]))); @@ -536,13 +567,13 @@ go_bandit([]() { AssertThat(s.can_pull(), Is().True()); const test_request_t o1 = s.pull(); - AssertThat(o1.target, Is().EqualTo(i2.target)); + AssertThat(o1.target, Is().EqualTo(i2.target)); AssertThat(o1.data.source, Is().EqualTo(flag(i2.data.source))); AssertThat(s.can_pull(), Is().True()); const test_request_t o2 = s.pull(); - AssertThat(o2.target, Is().EqualTo(i1.target)); + AssertThat(o2.target, Is().EqualTo(i1.target)); AssertThat(o2.data.source, Is().EqualTo(flag(i1.data.source))); AssertThat(s.can_pull(), Is().False()); @@ -559,13 +590,13 @@ go_bandit([]() { AssertThat(s.can_pull(), Is().True()); const test_request_t o3 = s.pull(); - AssertThat(o3.target, Is().EqualTo(i4.target)); + AssertThat(o3.target, Is().EqualTo(i4.target)); AssertThat(o3.data.source, Is().EqualTo(flag(i4.data.source))); AssertThat(s.can_pull(), Is().True()); const test_request_t o4 = s.pull(); - AssertThat(o4.target, Is().EqualTo(i3.target)); + AssertThat(o4.target, Is().EqualTo(i3.target)); AssertThat(o4.data.source, Is().EqualTo(flag(i3.data.source))); AssertThat(s.can_pull(), Is().False()); @@ -574,16 +605,16 @@ go_bandit([]() { it("can move from another sorter", []() { using test_request_t = request_data<1, with_parent, 0, 1>; - using test_roots_sorter_t = - nested_sweeping::outer::roots_sorter>; + using test_roots_sorter_t = nested_sweeping::outer:: + roots_sorter>; test_roots_sorter_t s1(1024, 16); test_roots_sorter_t s2(1024, 16); - const test_request_t i1({arc::pointer_type(3,2)}, {}, {arc::pointer_type(2,0, false)}); - const test_request_t i2({arc::pointer_type(3,1)}, {}, {arc::pointer_type(2,1, true)}); + const test_request_t i1( + { arc::pointer_type(3, 2) }, {}, { arc::pointer_type(2, 0, false) }); + const test_request_t i2( + { arc::pointer_type(3, 1) }, {}, { arc::pointer_type(2, 1, true) }); s1.push(i1); s1.push(i2); @@ -594,39 +625,39 @@ go_bandit([]() { AssertThat(s2.can_pull(), Is().True()); const test_request_t o1 = s2.pull(); - AssertThat(o1.target, Is().EqualTo(i2.target)); + AssertThat(o1.target, Is().EqualTo(i2.target)); AssertThat(o1.data.source, Is().EqualTo(flag(i2.data.source))); AssertThat(s2.can_pull(), Is().True()); const test_request_t o2 = s2.pull(); - AssertThat(o2.target, Is().EqualTo(i1.target)); + AssertThat(o2.target, Is().EqualTo(i1.target)); AssertThat(o2.data.source, Is().EqualTo(flag(i1.data.source))); AssertThat(s2.can_pull(), Is().False()); }); - it("can move from another sorter and push more elements", []() { using test_request_t = request_data<1, with_parent, 0, 1>; - using test_roots_sorter_t = - nested_sweeping::outer::roots_sorter>; + using test_roots_sorter_t = nested_sweeping::outer:: + roots_sorter>; test_roots_sorter_t s1(1024, 16); test_roots_sorter_t s2(1024, 16); - const test_request_t i1({arc::pointer_type(3,3)}, {}, {arc::pointer_type(2,0, false)}); - const test_request_t i2({arc::pointer_type(3,1)}, {}, {arc::pointer_type(2,1, true)}); + const test_request_t i1( + { arc::pointer_type(3, 3) }, {}, { arc::pointer_type(2, 0, false) }); + const test_request_t i2( + { arc::pointer_type(3, 1) }, {}, { arc::pointer_type(2, 1, true) }); s1.push(i1); s1.push(i2); s2.move(s1); // From hereon forward s1 is in an illegal state - const test_request_t i3({arc::pointer_type(3,2)}, {}, {arc::pointer_type(2,1, false)}); + const test_request_t i3( + { arc::pointer_type(3, 2) }, {}, { arc::pointer_type(2, 1, false) }); s2.push(i3); s2.sort(); @@ -634,19 +665,19 @@ go_bandit([]() { AssertThat(s2.can_pull(), Is().True()); const test_request_t o1 = s2.pull(); - AssertThat(o1.target, Is().EqualTo(i2.target)); + AssertThat(o1.target, Is().EqualTo(i2.target)); AssertThat(o1.data.source, Is().EqualTo(flag(i2.data.source))); AssertThat(s2.can_pull(), Is().True()); const test_request_t o2 = s2.pull(); - AssertThat(o2.target, Is().EqualTo(i3.target)); + AssertThat(o2.target, Is().EqualTo(i3.target)); AssertThat(o2.data.source, Is().EqualTo(flag(i3.data.source))); AssertThat(s2.can_pull(), Is().True()); const test_request_t o3 = s2.pull(); - AssertThat(o3.target, Is().EqualTo(i1.target)); + AssertThat(o3.target, Is().EqualTo(i1.target)); AssertThat(o3.data.source, Is().EqualTo(flag(i1.data.source))); AssertThat(s2.can_pull(), Is().False()); @@ -655,51 +686,47 @@ go_bandit([]() { it("updates its 'size'", []() { using test_request_t = request_data<2, with_parent, 0, 1>; - using test_roots_sorter_t = - nested_sweeping::outer::roots_sorter>; + using test_roots_sorter_t = nested_sweeping::outer:: + roots_sorter>; test_roots_sorter_t s(1024, 16); AssertThat(s.size(), Is().EqualTo(0u)); - s.push(arc(arc::pointer_type(2,0), false, arc::pointer_type(3,0))); + s.push(arc(arc::pointer_type(2, 0), false, arc::pointer_type(3, 0))); AssertThat(s.size(), Is().EqualTo(1u)); - s.push({ {arc::pointer_type(3,0)}, {}, {arc::pointer_type(2,0, true)} }); + s.push({ { arc::pointer_type(3, 0) }, {}, { arc::pointer_type(2, 0, true) } }); AssertThat(s.size(), Is().EqualTo(2u)); s.reset(); AssertThat(s.size(), Is().EqualTo(0u)); - s.push({ {arc::pointer_type(1,0)}, {}, {arc::pointer_type(0,0, true)} }); + s.push({ { arc::pointer_type(1, 0) }, {}, { arc::pointer_type(0, 0, true) } }); AssertThat(s.size(), Is().EqualTo(1u)); }); it("provides the deepest source from arcs [1]", []() { using test_request_t = request_data<2, with_parent, 0, 1>; - using test_roots_sorter_t = - nested_sweeping::outer::roots_sorter>; + using test_roots_sorter_t = nested_sweeping::outer:: + roots_sorter>; test_roots_sorter_t s(1024, 16); AssertThat(s.deepest_source(), Is().EqualTo(test_roots_sorter_t::no_level)); - const reduce_arc a1 = arc(arc::pointer_type(0,0), false, arc::pointer_type(1,1)); + const reduce_arc a1 = arc(arc::pointer_type(0, 0), false, arc::pointer_type(1, 1)); s.push(a1); AssertThat(s.deepest_source(), Is().EqualTo(0u)); - const reduce_arc a2 = arc(arc::pointer_type(1,0), false, arc::pointer_type(2,0)); + const reduce_arc a2 = arc(arc::pointer_type(1, 0), false, arc::pointer_type(2, 0)); s.push(a2); AssertThat(s.deepest_source(), Is().EqualTo(1u)); - const reduce_arc a3 = arc(arc::pointer_type(0,0), true, arc::pointer_type(1,0)); + const reduce_arc a3 = arc(arc::pointer_type(0, 0), true, arc::pointer_type(1, 0)); s.push(a3); AssertThat(s.deepest_source(), Is().EqualTo(1u)); @@ -708,21 +735,19 @@ go_bandit([]() { it("provides the deepest source from arcs [2]", []() { using test_request_t = request_data<2, with_parent, 0, 1>; - using test_roots_sorter_t = - nested_sweeping::outer::roots_sorter>; + using test_roots_sorter_t = nested_sweeping::outer:: + roots_sorter>; test_roots_sorter_t s(1024, 16); AssertThat(s.deepest_source(), Is().EqualTo(test_roots_sorter_t::no_level)); - const reduce_arc a1 = arc(arc::pointer_type(2,0), false, arc::pointer_type(3,1)); + const reduce_arc a1 = arc(arc::pointer_type(2, 0), false, arc::pointer_type(3, 1)); s.push(a1); AssertThat(s.deepest_source(), Is().EqualTo(2u)); - const reduce_arc a2 = arc(arc::pointer_type(1,0), false, arc::pointer_type(4,0)); + const reduce_arc a2 = arc(arc::pointer_type(1, 0), false, arc::pointer_type(4, 0)); s.push(a2); AssertThat(s.deepest_source(), Is().EqualTo(2u)); @@ -731,26 +756,27 @@ go_bandit([]() { it("provides the deepest source from requests [1]", []() { using test_request_t = request_data<2, with_parent, 0, 1>; - using test_roots_sorter_t = - nested_sweeping::outer::roots_sorter>; + using test_roots_sorter_t = nested_sweeping::outer:: + roots_sorter>; test_roots_sorter_t s(1024, 16); AssertThat(s.deepest_source(), Is().EqualTo(test_roots_sorter_t::no_level)); - const test_request_t r1({arc::pointer_type(1,1)}, {}, {arc::pointer_type(0,0, false)}); + const test_request_t r1( + { arc::pointer_type(1, 1) }, {}, { arc::pointer_type(0, 0, false) }); s.push(r1); AssertThat(s.deepest_source(), Is().EqualTo(0u)); - const test_request_t r2({arc::pointer_type(2,0)}, {}, {arc::pointer_type(1,0, false)}); + const test_request_t r2( + { arc::pointer_type(2, 0) }, {}, { arc::pointer_type(1, 0, false) }); s.push(r2); AssertThat(s.deepest_source(), Is().EqualTo(1u)); - const test_request_t r3({arc::pointer_type(1,0)}, {}, {arc::pointer_type(0,0, true)}); + const test_request_t r3( + { arc::pointer_type(1, 0) }, {}, { arc::pointer_type(0, 0, true) }); s.push(r3); AssertThat(s.deepest_source(), Is().EqualTo(1u)); @@ -759,21 +785,21 @@ go_bandit([]() { it("provides the deepest source from requests [1]", []() { using test_request_t = request_data<2, with_parent, 0, 1>; - using test_roots_sorter_t = - nested_sweeping::outer::roots_sorter>; + using test_roots_sorter_t = nested_sweeping::outer:: + roots_sorter>; test_roots_sorter_t s(1024, 16); AssertThat(s.deepest_source(), Is().EqualTo(test_roots_sorter_t::no_level)); - const test_request_t r1({arc::pointer_type(3,1)}, {}, {arc::pointer_type(2,0, false)}); + const test_request_t r1( + { arc::pointer_type(3, 1) }, {}, { arc::pointer_type(2, 0, false) }); s.push(r1); AssertThat(s.deepest_source(), Is().EqualTo(2u)); - const test_request_t r2({arc::pointer_type(4,0)}, {}, {arc::pointer_type(1,0, false)}); + const test_request_t r2( + { arc::pointer_type(4, 0) }, {}, { arc::pointer_type(1, 0, false) }); s.push(r2); AssertThat(s.deepest_source(), Is().EqualTo(2u)); @@ -782,16 +808,14 @@ go_bandit([]() { it("provides a different deepest source after reset", []() { using test_request_t = request_data<2, with_parent, 0, 1>; - using test_roots_sorter_t = - nested_sweeping::outer::roots_sorter>; + using test_roots_sorter_t = nested_sweeping::outer:: + roots_sorter>; test_roots_sorter_t s(1024, 16); AssertThat(s.deepest_source(), Is().EqualTo(test_roots_sorter_t::no_level)); - const reduce_arc a1 = arc(arc::pointer_type(2,0), false, arc::pointer_type(1,1)); + const reduce_arc a1 = arc(arc::pointer_type(2, 0), false, arc::pointer_type(1, 1)); s.push(a1); AssertThat(s.deepest_source(), Is().EqualTo(2u)); @@ -800,7 +824,7 @@ go_bandit([]() { AssertThat(s.deepest_source(), Is().EqualTo(test_roots_sorter_t::no_level)); - const reduce_arc a2 = arc(arc::pointer_type(1,0), false, arc::pointer_type(2,0)); + const reduce_arc a2 = arc(arc::pointer_type(1, 0), false, arc::pointer_type(2, 0)); s.push(a2); AssertThat(s.deepest_source(), Is().EqualTo(1u)); @@ -810,10 +834,8 @@ go_bandit([]() { describe("outer::up__pq_decorator", [&]() { using test_request_t = request_data<2, with_parent, 0, 1>; - using test_roots_sorter_t = - nested_sweeping::outer::roots_sorter>; + using test_roots_sorter_t = nested_sweeping::outer:: + roots_sorter>; using test_pq_t = nested_sweeping::outer::up__pq_t<1, memory_mode::Internal>; @@ -821,7 +843,7 @@ go_bandit([]() { nested_sweeping::outer::up__pq_decorator; it("forwards internal arcs to PQ when below threshold", [&]() { - test_pq_t pq({outer_dag}, memory_available(), 16); + test_pq_t pq({ outer_dag }, memory_available(), 16); pq.setup_next_level(4u); test_roots_sorter_t sorter(1024, 16); @@ -835,7 +857,7 @@ go_bandit([]() { }); it("forwards internal arcs to PQ when at threshold", [&]() { - test_pq_t pq({outer_dag}, memory_available(), 16); + test_pq_t pq({ outer_dag }, memory_available(), 16); pq.setup_next_level(4u); test_roots_sorter_t sorter(1024, 16); @@ -849,7 +871,7 @@ go_bandit([]() { }); it("forwards internal arcs to Sorter when above threshold", [&]() { - test_pq_t pq({outer_dag}, memory_available(), 16); + test_pq_t pq({ outer_dag }, memory_available(), 16); pq.setup_next_level(4u); test_roots_sorter_t sorter(1024, 16); @@ -863,7 +885,7 @@ go_bandit([]() { }); it("forwards terminal arcs to PQ even if at threshold", [&]() { - test_pq_t pq({outer_dag}, memory_available(), 16); + test_pq_t pq({ outer_dag }, memory_available(), 16); pq.setup_next_level(4u); test_roots_sorter_t sorter(1024, 16); @@ -877,7 +899,7 @@ go_bandit([]() { }); it("forwards terminal arcs to PQ even if above threshold", [&]() { - test_pq_t pq({outer_dag}, memory_available(), 16); + test_pq_t pq({ outer_dag }, memory_available(), 16); pq.setup_next_level(4u); test_roots_sorter_t sorter(1024, 16); @@ -891,7 +913,7 @@ go_bandit([]() { }); it("forwards correctly with multiple arcs", [&]() { - test_pq_t pq({outer_dag}, memory_available(), 16); + test_pq_t pq({ outer_dag }, memory_available(), 16); pq.setup_next_level(4u); test_roots_sorter_t sorter(1024, 16); @@ -911,7 +933,7 @@ go_bandit([]() { AssertThat(sorter.size(), Is().EqualTo(0u)); // internal at threshold - d.push(arc(outer_n3, true, outer_n5)); + d.push(arc(outer_n3, true, outer_n5)); AssertThat(pq.size(), Is().EqualTo(3u)); AssertThat(sorter.size(), Is().EqualTo(0u)); @@ -930,7 +952,7 @@ go_bandit([]() { }); it("provides combined size (w and w/o terminals)", [&]() { - test_pq_t pq({outer_dag}, memory_available(), 16); + test_pq_t pq({ outer_dag }, memory_available(), 16); pq.setup_next_level(4u); test_roots_sorter_t sorter(1024, 16); @@ -944,7 +966,7 @@ go_bandit([]() { // terminal at threshold d.push(arc(outer_n3, false, terminal_F)); // internal at threshold - d.push(arc(outer_n3, true, outer_n5)); + d.push(arc(outer_n3, true, outer_n5)); // internal above threshold d.push(arc(outer_n2, false, outer_n5)); // terminal above threshold @@ -958,7 +980,7 @@ go_bandit([]() { }); it("forwards internal request to PQ", [&]() { - test_pq_t pq({outer_dag}, memory_available(), 16); + test_pq_t pq({ outer_dag }, memory_available(), 16); pq.setup_next_level(4u); test_roots_sorter_t sorter(1024, 16); @@ -966,14 +988,14 @@ go_bandit([]() { test_decorator d(pq, sorter, 2); // internal at threshold - d.push(test_request_t({outer_n5}, {}, {outer_n1.as_ptr(true)})); + d.push(test_request_t({ outer_n5 }, {}, { outer_n1.as_ptr(true) })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(sorter.size(), Is().EqualTo(1u)); }); it("forwards terminal request to PQ", [&]() { - test_pq_t pq({outer_dag}, memory_available(), 16); + test_pq_t pq({ outer_dag }, memory_available(), 16); pq.setup_next_level(4u); test_roots_sorter_t sorter(1024, 16); @@ -981,14 +1003,14 @@ go_bandit([]() { test_decorator d(pq, sorter, 2); // internal at threshold - d.push(test_request_t({terminal_T}, {}, {outer_n1})); + d.push(test_request_t({ terminal_T }, {}, { outer_n1 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(sorter.size(), Is().EqualTo(0u)); }); it("forwards arc with nil source to sorter", [&]() { - test_pq_t pq({outer_dag}, memory_available(), 16); + test_pq_t pq({ outer_dag }, memory_available(), 16); pq.setup_next_level(0u); // <-- set up pq to have no extra levels. AssertThat(pq.has_next_level(), Is().False()); // sanity check @@ -998,7 +1020,7 @@ go_bandit([]() { test_decorator d(pq, sorter, 2); // internal at threshold - d.push(arc(arc::pointer_type::nil(), arc::pointer_type(42,0))); + d.push(arc(arc::pointer_type::nil(), arc::pointer_type(42, 0))); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(sorter.size(), Is().EqualTo(1u)); @@ -1019,9 +1041,9 @@ go_bandit([]() { // / \ // F T */ - const node::pointer_type n1(1,0); - const node::pointer_type n2(2,0); - const node::pointer_type n3(3,0); + const node::pointer_type n1(1, 0); + const node::pointer_type n2(2, 0); + const node::pointer_type n3(3, 0); shared_levelized_file dag; @@ -1034,11 +1056,11 @@ go_bandit([]() { aw.push_terminal({ n1, false, terminal_F }); aw.push_terminal({ n2, false, terminal_F }); aw.push_terminal({ n3, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); - aw.push(level_info(1,1u)); - aw.push(level_info(2,1u)); - aw.push(level_info(3,1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 1u)); + aw.push(level_info(3, 1u)); } test_not_sweep<> inner_impl(4); @@ -1058,9 +1080,9 @@ go_bandit([]() { // / \ // F T */ - const node::pointer_type n1(1,0); - const node::pointer_type n2(2,0); - const node::pointer_type n3(3,0); + const node::pointer_type n1(1, 0); + const node::pointer_type n2(2, 0); + const node::pointer_type n3(3, 0); shared_levelized_file dag; @@ -1073,11 +1095,11 @@ go_bandit([]() { aw.push_terminal({ n1, false, terminal_F }); aw.push_terminal({ n2, false, terminal_F }); aw.push_terminal({ n3, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); - aw.push(level_info(1,1u)); - aw.push(level_info(2,1u)); - aw.push(level_info(3,1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 1u)); + aw.push(level_info(3, 1u)); } test_not_sweep<> inner_impl(2); @@ -1100,10 +1122,10 @@ go_bandit([]() { // / \ // F T */ - const node::pointer_type n1(0,0); - const node::pointer_type n2(2,0); - const node::pointer_type n3(3,0); - const node::pointer_type n4(4,0); + const node::pointer_type n1(0, 0); + const node::pointer_type n2(2, 0); + const node::pointer_type n3(3, 0); + const node::pointer_type n4(4, 0); shared_levelized_file dag; @@ -1118,12 +1140,12 @@ go_bandit([]() { aw.push_terminal({ n2, false, terminal_F }); aw.push_terminal({ n3, false, terminal_F }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(2,1u)); - aw.push(level_info(3,1u)); - aw.push(level_info(4,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(2, 1u)); + aw.push(level_info(3, 1u)); + aw.push(level_info(4, 1u)); } test_not_sweep<> inner_impl(2); @@ -1137,12 +1159,12 @@ go_bandit([]() { }); describe("inner::down__pq_decorator", [&terminal_F, &terminal_T]() { - const uid_uint64 inner_n1 = ptr_uint64(3,0); - const uid_uint64 inner_n2 = ptr_uint64(3,1); - const uid_uint64 inner_n3 = ptr_uint64(4,0); - const uid_uint64 inner_n4 = ptr_uint64(4,1); - const uid_uint64 inner_n5 = ptr_uint64(5,0); - const uid_uint64 inner_n6 = ptr_uint64(5,1); + const uid_uint64 inner_n1 = ptr_uint64(3, 0); + const uid_uint64 inner_n2 = ptr_uint64(3, 1); + const uid_uint64 inner_n3 = ptr_uint64(4, 0); + const uid_uint64 inner_n4 = ptr_uint64(4, 1); + const uid_uint64 inner_n5 = ptr_uint64(5, 0); + const uid_uint64 inner_n6 = ptr_uint64(5, 1); shared_levelized_file dag; @@ -1159,25 +1181,19 @@ go_bandit([]() { { // Garbage collect writer to free write-lock node_writer nw(dag); - nw << node(inner_n6, terminal_F, terminal_T) - << node(inner_n5, terminal_T, terminal_F) - << node(inner_n4, terminal_T, inner_n5) - << node(inner_n3, terminal_F, terminal_T) - << node(inner_n2, inner_n4, inner_n6) - << node(inner_n1, inner_n3, inner_n4) - ; + nw << node(inner_n6, terminal_F, terminal_T) << node(inner_n5, terminal_T, terminal_F) + << node(inner_n4, terminal_T, inner_n5) << node(inner_n3, terminal_F, terminal_T) + << node(inner_n2, inner_n4, inner_n6) << node(inner_n1, inner_n3, inner_n4); } using test_request_t = request_data<1, with_parent, 0, 1>; - using test_roots_sorter_t = - nested_sweeping::outer::roots_sorter>; + using test_roots_sorter_t = nested_sweeping::outer:: + roots_sorter>; - const test_request_t root1({inner_n1}, {}, {ptr_uint64(1,0, false)}); - const test_request_t root2({inner_n2}, {}, {ptr_uint64(1,0, true)}); - const test_request_t root3({inner_n6}, {}, {ptr_uint64(1,1, false)}); + const test_request_t root1({ inner_n1 }, {}, { ptr_uint64(1, 0, false) }); + const test_request_t root2({ inner_n2 }, {}, { ptr_uint64(1, 0, true) }); + const test_request_t root3({ inner_n6 }, {}, { ptr_uint64(1, 1, false) }); /* // @@ -1206,17 +1222,19 @@ go_bandit([]() { statistics::levelized_priority_queue_t lpq_stats; - using test_pq_t = levelized_node_priority_queue, - 1, memory_mode::Internal, - 1, - 0 /* <-- this is important for nested sweeping */>; + using test_pq_t = + levelized_node_priority_queue, + 1, + memory_mode::Internal, + 1, + 0 /* <-- this is important for nested sweeping */>; using test_decorator = nested_sweeping::inner::down__pq_decorator; it("initializes with levels of PQ but with size of Sorter", [&]() { - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); test_decorator dec(pq, sorter); AssertThat(dec.has_current_level(), Is().False()); @@ -1229,9 +1247,9 @@ go_bandit([]() { }); it("merges size of PQ and Sorter", [&]() { - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); - const test_request_t root4({inner_n2}, {}, {ptr_uint64(1,2, false)}); + const test_request_t root4({ inner_n2 }, {}, { ptr_uint64(1, 2, false) }); pq.push(root4); test_decorator dec(pq, sorter); @@ -1240,7 +1258,7 @@ go_bandit([]() { }); it("setup_next_level() forward to first Sorter level", [&]() { - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); test_decorator dec(pq, sorter); AssertThat(dec.has_current_level(), Is().False()); @@ -1251,7 +1269,7 @@ go_bandit([]() { }); it("setup_next_level(k) forward to Sorter's level if k is larger", [&]() { - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); test_decorator dec(pq, sorter); AssertThat(dec.has_current_level(), Is().False()); @@ -1262,9 +1280,10 @@ go_bandit([]() { }); it("setup_next_level(k) forward to level k if k is smaller", [&]() { - sorter.pull(); sorter.pull(); // Next is at level 6 + sorter.pull(); + sorter.pull(); // Next is at level 6 - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); test_decorator dec(pq, sorter); AssertThat(dec.has_current_level(), Is().False()); @@ -1275,7 +1294,7 @@ go_bandit([]() { }); it("can pull requests from Sorter", [&]() { - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); test_decorator dec(pq, sorter); dec.setup_next_level(); @@ -1285,7 +1304,7 @@ go_bandit([]() { AssertThat(dec.can_pull(), Is().True()); const auto r1 = dec.pull(); - AssertThat(r1.target, Is().EqualTo(root1.target)); + AssertThat(r1.target, Is().EqualTo(root1.target)); AssertThat(r1.data.source, Is().EqualTo(flag(root1.data.source))); AssertThat(dec.empty_level(), Is().False()); @@ -1293,7 +1312,7 @@ go_bandit([]() { AssertThat(dec.can_pull(), Is().True()); const auto r2 = dec.pull(); - AssertThat(r2.target, Is().EqualTo(root2.target)); + AssertThat(r2.target, Is().EqualTo(root2.target)); AssertThat(r2.data.source, Is().EqualTo(flag(root2.data.source))); AssertThat(dec.empty_level(), Is().True()); @@ -1303,10 +1322,10 @@ go_bandit([]() { }); it("can pull merge of PQ and Sorter [tie on 'n2']", [&]() { - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); // Add new request to tie with sorter - const test_request_t root4({inner_n2}, {}, {ptr_uint64(1,2, false)}); + const test_request_t root4({ inner_n2 }, {}, { ptr_uint64(1, 2, false) }); pq.push(root4); test_decorator dec(pq, sorter); @@ -1318,7 +1337,7 @@ go_bandit([]() { AssertThat(dec.can_pull(), Is().True()); const auto r1 = dec.pull(); - AssertThat(r1.target, Is().EqualTo(root1.target)); + AssertThat(r1.target, Is().EqualTo(root1.target)); AssertThat(r1.data.source, Is().EqualTo(flag(root1.data.source))); AssertThat(dec.empty_level(), Is().False()); @@ -1326,7 +1345,7 @@ go_bandit([]() { AssertThat(dec.can_pull(), Is().True()); const auto r2 = dec.pull(); - AssertThat(r2.target, Is().EqualTo(root2.target)); + AssertThat(r2.target, Is().EqualTo(root2.target)); AssertThat(r2.data.source, Is().EqualTo(flag(root2.data.source))); AssertThat(dec.empty_level(), Is().False()); @@ -1334,7 +1353,7 @@ go_bandit([]() { AssertThat(dec.can_pull(), Is().True()); const auto r3 = dec.pull(); - AssertThat(r3.target, Is().EqualTo(root4.target)); + AssertThat(r3.target, Is().EqualTo(root4.target)); AssertThat(r3.data.source, Is().EqualTo(root4.data.source)); AssertThat(dec.empty_level(), Is().True()); @@ -1344,10 +1363,10 @@ go_bandit([]() { }); it("can pull merge of PQ and Sorter [tie on 'n1']", [&]() { - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); // Add new request to tie with sorter - const test_request_t root4({inner_n1}, {}, {ptr_uint64(1,2, false)}); + const test_request_t root4({ inner_n1 }, {}, { ptr_uint64(1, 2, false) }); pq.push(root4); test_decorator dec(pq, sorter); @@ -1359,7 +1378,7 @@ go_bandit([]() { AssertThat(dec.can_pull(), Is().True()); const auto r1 = dec.pull(); - AssertThat(r1.target, Is().EqualTo(root1.target)); + AssertThat(r1.target, Is().EqualTo(root1.target)); AssertThat(r1.data.source, Is().EqualTo(flag(root1.data.source))); AssertThat(dec.empty_level(), Is().False()); @@ -1367,7 +1386,7 @@ go_bandit([]() { AssertThat(dec.can_pull(), Is().True()); const auto r2 = dec.pull(); - AssertThat(r2.target, Is().EqualTo(root4.target)); + AssertThat(r2.target, Is().EqualTo(root4.target)); AssertThat(r2.data.source, Is().EqualTo(root4.data.source)); AssertThat(dec.empty_level(), Is().False()); @@ -1375,7 +1394,7 @@ go_bandit([]() { AssertThat(dec.can_pull(), Is().True()); const auto r3 = dec.pull(); - AssertThat(r3.target, Is().EqualTo(root2.target)); + AssertThat(r3.target, Is().EqualTo(root2.target)); AssertThat(r3.data.source, Is().EqualTo(flag(root2.data.source))); AssertThat(dec.empty_level(), Is().True()); @@ -1387,15 +1406,17 @@ go_bandit([]() { it("can pull when Sorter is empty", [&]() { // empty out sorter AssertThat(sorter.size(), Is().EqualTo(3u)); - sorter.pull(); sorter.pull(); sorter.pull(); + sorter.pull(); + sorter.pull(); + sorter.pull(); AssertThat(sorter.size(), Is().EqualTo(0u)); AssertThat(sorter.empty(), Is().True()); // Start test - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); // Add new request to tie with sorter - const test_request_t root4({inner_n1}, {}, {ptr_uint64(1,2, false)}); + const test_request_t root4({ inner_n1 }, {}, { ptr_uint64(1, 2, false) }); pq.push(root4); test_decorator dec(pq, sorter); @@ -1407,7 +1428,7 @@ go_bandit([]() { AssertThat(dec.can_pull(), Is().True()); const auto r = dec.pull(); - AssertThat(r.target, Is().EqualTo(root4.target)); + AssertThat(r.target, Is().EqualTo(root4.target)); AssertThat(r.data.source, Is().EqualTo(root4.data.source)); AssertThat(dec.empty_level(), Is().True()); @@ -1417,7 +1438,7 @@ go_bandit([]() { }); it("can top the same request from Sorter multiple times", [&]() { - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); test_decorator dec(pq, sorter); dec.setup_next_level(); @@ -1428,7 +1449,7 @@ go_bandit([]() { // Top the sorter AssertThat(dec.can_pull(), Is().True()); const auto r1 = dec.top(); - AssertThat(r1.target, Is().EqualTo(root1.target)); + AssertThat(r1.target, Is().EqualTo(root1.target)); AssertThat(r1.data.source, Is().EqualTo(flag(root1.data.source))); AssertThat(dec.empty_level(), Is().False()); @@ -1437,7 +1458,7 @@ go_bandit([]() { // Top it again AssertThat(dec.can_pull(), Is().True()); const auto r2 = dec.top(); - AssertThat(r2.target, Is().EqualTo(root1.target)); + AssertThat(r2.target, Is().EqualTo(root1.target)); AssertThat(r2.data.source, Is().EqualTo(flag(root1.data.source))); AssertThat(dec.empty_level(), Is().False()); @@ -1445,9 +1466,9 @@ go_bandit([]() { }); it("can top the same request from PQ multiple times", [&]() { - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); - const test_request_t root4({inner_n1}, {}, {ptr_uint64(1,2, false)}); + const test_request_t root4({ inner_n1 }, {}, { ptr_uint64(1, 2, false) }); pq.push(root4); test_decorator dec(pq, sorter); @@ -1460,7 +1481,7 @@ go_bandit([]() { // Skip over the one request from the sorter (but check it truly is that one) AssertThat(dec.can_pull(), Is().True()); const auto r1 = dec.pull(); - AssertThat(r1.target, Is().EqualTo(root1.target)); + AssertThat(r1.target, Is().EqualTo(root1.target)); AssertThat(r1.data.source, Is().EqualTo(flag(root1.data.source))); AssertThat(dec.empty_level(), Is().False()); @@ -1469,7 +1490,7 @@ go_bandit([]() { // Top the priority queue once AssertThat(dec.can_pull(), Is().True()); const auto r2 = dec.top(); - AssertThat(r2.target, Is().EqualTo(root4.target)); + AssertThat(r2.target, Is().EqualTo(root4.target)); AssertThat(r2.data.source, Is().EqualTo(root4.data.source)); AssertThat(dec.empty_level(), Is().False()); @@ -1478,7 +1499,7 @@ go_bandit([]() { // Top it again AssertThat(dec.can_pull(), Is().True()); const auto r3 = dec.top(); - AssertThat(r3.target, Is().EqualTo(root4.target)); + AssertThat(r3.target, Is().EqualTo(root4.target)); AssertThat(r3.data.source, Is().EqualTo(root4.data.source)); AssertThat(dec.empty_level(), Is().False()); @@ -1486,7 +1507,7 @@ go_bandit([]() { }); it("can top and pop requests from Sorter", [&]() { - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); test_decorator dec(pq, sorter); dec.setup_next_level(); @@ -1498,7 +1519,7 @@ go_bandit([]() { const auto r1 = dec.top(); dec.pop(); - AssertThat(r1.target, Is().EqualTo(root1.target)); + AssertThat(r1.target, Is().EqualTo(root1.target)); AssertThat(r1.data.source, Is().EqualTo(flag(root1.data.source))); AssertThat(dec.empty_level(), Is().False()); @@ -1508,7 +1529,7 @@ go_bandit([]() { const auto r2 = dec.top(); dec.pop(); - AssertThat(r2.target, Is().EqualTo(root2.target)); + AssertThat(r2.target, Is().EqualTo(root2.target)); AssertThat(r2.data.source, Is().EqualTo(flag(root2.data.source))); AssertThat(dec.empty_level(), Is().True()); @@ -1518,10 +1539,10 @@ go_bandit([]() { }); it("can top and pop merge of PQ and Sorter [tie on 'n2']", [&]() { - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); // Add new request to tie with sorter - const test_request_t root4({inner_n2}, {}, {ptr_uint64(1,2, false)}); + const test_request_t root4({ inner_n2 }, {}, { ptr_uint64(1, 2, false) }); pq.push(root4); test_decorator dec(pq, sorter); @@ -1535,7 +1556,7 @@ go_bandit([]() { const auto r1 = dec.top(); dec.pop(); - AssertThat(r1.target, Is().EqualTo(root1.target)); + AssertThat(r1.target, Is().EqualTo(root1.target)); AssertThat(r1.data.source, Is().EqualTo(flag(root1.data.source))); AssertThat(dec.empty_level(), Is().False()); @@ -1545,7 +1566,7 @@ go_bandit([]() { const auto r2 = dec.top(); dec.pop(); - AssertThat(r2.target, Is().EqualTo(root2.target)); + AssertThat(r2.target, Is().EqualTo(root2.target)); AssertThat(r2.data.source, Is().EqualTo(flag(root2.data.source))); AssertThat(dec.empty_level(), Is().False()); @@ -1555,7 +1576,7 @@ go_bandit([]() { const auto r3 = dec.top(); dec.pop(); - AssertThat(r3.target, Is().EqualTo(root4.target)); + AssertThat(r3.target, Is().EqualTo(root4.target)); AssertThat(r3.data.source, Is().EqualTo(root4.data.source)); AssertThat(dec.empty_level(), Is().True()); @@ -1565,10 +1586,10 @@ go_bandit([]() { }); it("can top and pop merge of PQ and Sorter [tie on 'n1']", [&]() { - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); // Add new request to tie with sorter - const test_request_t root4({inner_n1}, {}, {ptr_uint64(1,2, false)}); + const test_request_t root4({ inner_n1 }, {}, { ptr_uint64(1, 2, false) }); pq.push(root4); test_decorator dec(pq, sorter); @@ -1582,7 +1603,7 @@ go_bandit([]() { const auto r1 = dec.top(); dec.pop(); - AssertThat(r1.target, Is().EqualTo(root1.target)); + AssertThat(r1.target, Is().EqualTo(root1.target)); AssertThat(r1.data.source, Is().EqualTo(flag(root1.data.source))); AssertThat(dec.empty_level(), Is().False()); @@ -1592,7 +1613,7 @@ go_bandit([]() { const auto r2 = dec.top(); dec.pop(); - AssertThat(r2.target, Is().EqualTo(root4.target)); + AssertThat(r2.target, Is().EqualTo(root4.target)); AssertThat(r2.data.source, Is().EqualTo(root4.data.source)); AssertThat(dec.empty_level(), Is().False()); @@ -1602,7 +1623,7 @@ go_bandit([]() { const auto r3 = dec.top(); dec.pop(); - AssertThat(r3.target, Is().EqualTo(root2.target)); + AssertThat(r3.target, Is().EqualTo(root2.target)); AssertThat(r3.data.source, Is().EqualTo(flag(root2.data.source))); AssertThat(dec.empty_level(), Is().True()); @@ -1614,15 +1635,17 @@ go_bandit([]() { it("can top and pop when Sorter is empty", [&]() { // empty out sorter AssertThat(sorter.size(), Is().EqualTo(3u)); - sorter.pull(); sorter.pull(); sorter.pull(); + sorter.pull(); + sorter.pull(); + sorter.pull(); AssertThat(sorter.size(), Is().EqualTo(0u)); AssertThat(sorter.empty(), Is().True()); // Start test - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); // Add new request to tie with sorter - const test_request_t root4({inner_n1}, {}, {ptr_uint64(1,2, false)}); + const test_request_t root4({ inner_n1 }, {}, { ptr_uint64(1, 2, false) }); pq.push(root4); test_decorator dec(pq, sorter); @@ -1636,7 +1659,7 @@ go_bandit([]() { const auto r = dec.top(); dec.pop(); - AssertThat(r.target, Is().EqualTo(root4.target)); + AssertThat(r.target, Is().EqualTo(root4.target)); AssertThat(r.data.source, Is().EqualTo(root4.data.source)); AssertThat(dec.empty_level(), Is().True()); @@ -1648,14 +1671,14 @@ go_bandit([]() { it("cleans taint flags on targets from outer roots", [&]() { sorter.reset(); // ignore 'before_each' and do our own setup - const test_request_t root1_taint({flag(inner_n1)}, {}, {ptr_uint64(1,0, false)}); + const test_request_t root1_taint({ flag(inner_n1) }, {}, { ptr_uint64(1, 0, false) }); sorter.push(root1_taint); sorter.push(root2); sorter.push(root3); sorter.sort(); - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); test_decorator dec(pq, sorter); dec.setup_next_level(); @@ -1665,7 +1688,7 @@ go_bandit([]() { AssertThat(dec.can_pull(), Is().True()); const auto r1 = dec.pull(); - AssertThat(r1.target, Is().EqualTo(root1.target)); + AssertThat(r1.target, Is().EqualTo(root1.target)); AssertThat(r1.data.source, Is().EqualTo(flag(root1.data.source))); AssertThat(dec.empty_level(), Is().False()); @@ -1675,55 +1698,58 @@ go_bandit([]() { it("cleans taint flags on targets from outer roots [cardinality == 1]", [&]() { sorter.reset(); // ignore 'before_each' and do our own setup - const test_request_t root1_taint({flag(inner_n1)}, {}, {ptr_uint64(1,0, false)}); + const test_request_t root1_taint({ flag(inner_n1) }, {}, { ptr_uint64(1, 0, false) }); sorter.push(root1_taint); sorter.sort(); - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); test_decorator dec(pq, sorter); dec.setup_next_level(); AssertThat(dec.can_pull(), Is().True()); const auto r1 = dec.pull(); - AssertThat(r1.target, Is().EqualTo(root1.target)); + AssertThat(r1.target, Is().EqualTo(root1.target)); AssertThat(r1.data.source, Is().EqualTo(flag(root1.data.source))); }); it("cleans taint flags on targets from outer roots [cardinality == 2]", [&dag, &inner_n1, &inner_n2, &lpq_stats]() { - using test_request_t = request_data<2, with_parent, 0, 1>; + using test_request_t = request_data<2, with_parent, 0, 1>; - using test_roots_sorter_t = - nested_sweeping::outer::roots_sorter>; + using test_roots_sorter_t = + nested_sweeping::outer::roots_sorter>; - using test_pq_t = levelized_node_priority_queue, - 1, memory_mode::Internal, - 1, - 0 /* <-- this is important for nested sweeping */>; + using test_pq_t = + levelized_node_priority_queue, + 1, + memory_mode::Internal, + 1, + 0 /* <-- this is important for nested sweeping */>; - using test_decorator = - nested_sweeping::inner::down__pq_decorator; + using test_decorator = + nested_sweeping::inner::down__pq_decorator; - test_roots_sorter_t sorter(1024, 16); + test_roots_sorter_t sorter(1024, 16); - const test_request_t req({flag(inner_n1), flag(inner_n2)}, {}, {ptr_uint64(1,0, false)}); - sorter.push(req); + const test_request_t req( + { flag(inner_n1), flag(inner_n2) }, {}, { ptr_uint64(1, 0, false) }); + sorter.push(req); - test_pq_t pq({bdd(dag)}, memory_available(), 16, lpq_stats); - test_decorator dec(pq, sorter); + test_pq_t pq({ bdd(dag) }, memory_available(), 16, lpq_stats); + test_decorator dec(pq, sorter); - dec.setup_next_level(); + dec.setup_next_level(); - AssertThat(dec.can_pull(), Is().True()); - const auto r1 = dec.pull(); - AssertThat(r1.target, Is().EqualTo(test_request_t::target_t(inner_n1, inner_n2))); - AssertThat(r1.data.source, Is().EqualTo(flag(req.data.source))); - }); + AssertThat(dec.can_pull(), Is().True()); + const auto r1 = dec.pull(); + AssertThat(r1.target, Is().EqualTo(test_request_t::target_t(inner_n1, inner_n2))); + AssertThat(r1.data.source, Is().EqualTo(flag(req.data.source))); + }); }); describe("inner::up__pq_decorator", [&]() { @@ -1751,21 +1777,21 @@ go_bandit([]() { aw.push_terminal({ outer_n3, false, terminal_F }); aw.push_terminal({ outer_n4, false, terminal_F }); aw.push_terminal({ outer_n5, false, terminal_F }); - aw.push_terminal({ outer_n5, true, terminal_T }); + aw.push_terminal({ outer_n5, true, terminal_T }); - aw.push(level_info(2,1u)); - aw.push(level_info(3,1u)); - aw.push(level_info(4,1u)); + aw.push(level_info(2, 1u)); + aw.push(level_info(3, 1u)); + aw.push(level_info(4, 1u)); } using test_decorator = nested_sweeping::inner::up__pq_decorator; - const size_t pq_mem = memory_available()/2; + const size_t pq_mem = memory_available() / 2; it("forwards unflagged terminal to Inner PQ", [&]() { - outer_test_pq_t outer_pq({outer_dag}, pq_mem, 16); - inner_test_pq_t inner_pq({inner_dag}, pq_mem, 16); + outer_test_pq_t outer_pq({ outer_dag }, pq_mem, 16); + inner_test_pq_t inner_pq({ inner_dag }, pq_mem, 16); test_decorator dec(inner_pq, outer_pq); @@ -1779,8 +1805,8 @@ go_bandit([]() { }); it("forwards unflagged internal node to Inner PQ", [&]() { - outer_test_pq_t outer_pq({outer_dag}, pq_mem, 16); - inner_test_pq_t inner_pq({inner_dag}, pq_mem, 16); + outer_test_pq_t outer_pq({ outer_dag }, pq_mem, 16); + inner_test_pq_t inner_pq({ inner_dag }, pq_mem, 16); test_decorator dec(inner_pq, outer_pq); @@ -1794,8 +1820,8 @@ go_bandit([]() { }); it("forwards flagged terminal to Outer PQ", [&]() { - outer_test_pq_t outer_pq({outer_dag}, pq_mem, 16); - inner_test_pq_t inner_pq({inner_dag}, pq_mem, 16); + outer_test_pq_t outer_pq({ outer_dag }, pq_mem, 16); + inner_test_pq_t inner_pq({ inner_dag }, pq_mem, 16); test_decorator dec(inner_pq, outer_pq); @@ -1809,8 +1835,8 @@ go_bandit([]() { }); it("forwards flagged internal node to Outer PQ", [&]() { - outer_test_pq_t outer_pq({outer_dag}, pq_mem, 16); - inner_test_pq_t inner_pq({inner_dag}, pq_mem, 16); + outer_test_pq_t outer_pq({ outer_dag }, pq_mem, 16); + inner_test_pq_t inner_pq({ inner_dag }, pq_mem, 16); test_decorator dec(inner_pq, outer_pq); @@ -1824,8 +1850,8 @@ go_bandit([]() { }); it("unflags source when handing over to Outer PQ", [&]() { - outer_test_pq_t outer_pq({outer_dag}, pq_mem, 16); - inner_test_pq_t inner_pq({inner_dag}, pq_mem, 16); + outer_test_pq_t outer_pq({ outer_dag }, pq_mem, 16); + inner_test_pq_t inner_pq({ inner_dag }, pq_mem, 16); test_decorator dec(inner_pq, outer_pq); dec.push(arc(flag(outer_n4.as_ptr(true)), outer_n5)); @@ -1838,14 +1864,14 @@ go_bandit([]() { }); it("sets up next level only based on Inner PQ", [&]() { - outer_test_pq_t outer_pq({outer_dag}, pq_mem, 16); - inner_test_pq_t inner_pq({inner_dag}, pq_mem, 16); + outer_test_pq_t outer_pq({ outer_dag }, pq_mem, 16); + inner_test_pq_t inner_pq({ inner_dag }, pq_mem, 16); test_decorator dec(inner_pq, outer_pq); - dec.push(arc(outer_n3.as_ptr(false), terminal_F)); // inner (x2) - dec.push(arc(flag(outer_n4.as_ptr(true)), outer_n5)); // outer (x3) - dec.push(arc(outer_n3.as_ptr(true), outer_n5)); // inner (x2) + dec.push(arc(outer_n3.as_ptr(false), terminal_F)); // inner (x2) + dec.push(arc(flag(outer_n4.as_ptr(true)), outer_n5)); // outer (x3) + dec.push(arc(outer_n3.as_ptr(true), outer_n5)); // inner (x2) dec.setup_next_level(); @@ -1854,14 +1880,14 @@ go_bandit([]() { }); it("counts arcs from both Inner and Outer PQ", [&]() { - outer_test_pq_t outer_pq({outer_dag}, pq_mem, 16); - inner_test_pq_t inner_pq({inner_dag}, pq_mem, 16); + outer_test_pq_t outer_pq({ outer_dag }, pq_mem, 16); + inner_test_pq_t inner_pq({ inner_dag }, pq_mem, 16); test_decorator dec(inner_pq, outer_pq); - dec.push(arc(outer_n4.as_ptr(false), terminal_F)); // inner (x3) - dec.push(arc(flag(outer_n4.as_ptr(true)), outer_n5)); // outer (x3) - dec.push(arc(outer_n4.as_ptr(true), outer_n5)); // inner (x3) + dec.push(arc(outer_n4.as_ptr(false), terminal_F)); // inner (x3) + dec.push(arc(flag(outer_n4.as_ptr(true)), outer_n5)); // outer (x3) + dec.push(arc(outer_n4.as_ptr(true), outer_n5)); // inner (x3) AssertThat(outer_pq.size(), Is().EqualTo(1u)); @@ -1872,7 +1898,7 @@ go_bandit([]() { AssertThat(dec.empty_level(), Is().False()); AssertThat(dec.can_pull(), Is().True()); - AssertThat(dec.top(), Is().EqualTo(arc(outer_n4, true, outer_n5))); + AssertThat(dec.top(), Is().EqualTo(arc(outer_n4, true, outer_n5))); AssertThat(dec.pull(), Is().EqualTo(arc(outer_n4, true, outer_n5))); AssertThat(dec.size(), Is().EqualTo(2u)); @@ -1880,7 +1906,7 @@ go_bandit([]() { AssertThat(dec.empty_level(), Is().False()); AssertThat(dec.can_pull(), Is().True()); - AssertThat(dec.top(), Is().EqualTo(arc(outer_n4, false, terminal_F))); + AssertThat(dec.top(), Is().EqualTo(arc(outer_n4, false, terminal_F))); AssertThat(dec.pull(), Is().EqualTo(arc(outer_n4, false, terminal_F))); AssertThat(dec.empty_level(), Is().True()); @@ -1889,7 +1915,7 @@ go_bandit([]() { AssertThat(dec.empty(), Is().True()); dec.push(arc(flag(outer_n3.as_ptr(false)), terminal_F)); // outer - dec.push(arc(outer_n3.as_ptr(true), outer_n5)); // inner + dec.push(arc(outer_n3.as_ptr(true), outer_n5)); // inner AssertThat(dec.empty_level(), Is().True()); AssertThat(dec.size(), Is().EqualTo(3u)); @@ -1897,12 +1923,12 @@ go_bandit([]() { }); it("empty() is independent of Outer PQ size", [&]() { - outer_test_pq_t outer_pq({outer_dag}, pq_mem, 16); - inner_test_pq_t inner_pq({inner_dag}, pq_mem, 16); + outer_test_pq_t outer_pq({ outer_dag }, pq_mem, 16); + inner_test_pq_t inner_pq({ inner_dag }, pq_mem, 16); test_decorator dec(inner_pq, outer_pq); - dec.push(arc(flag(outer_n4.as_ptr(true)), outer_n5)); // outer (x3) + dec.push(arc(flag(outer_n4.as_ptr(true)), outer_n5)); // outer (x3) AssertThat(dec.size(), Is().EqualTo(1u)); AssertThat(dec.empty(), Is().True()); @@ -1910,19 +1936,19 @@ go_bandit([]() { }); describe("inner::up__arc_stream__decorator", [&terminal_F, &terminal_T]() { - const arc::pointer_type n0(0,0); - const arc::pointer_type n1(1,0); - const arc::pointer_type n2(2,0); + const arc::pointer_type n0(0, 0); + const arc::pointer_type n1(1, 0); + const arc::pointer_type n2(2, 0); shared_levelized_file outer; { // Garbage collect writer to free write-lock arc_writer aw(outer); aw.push_internal({ n0, false, n1 }); - aw.push_terminal({ n0, true, terminal_F }); + aw.push_terminal({ n0, true, terminal_F }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); outer->max_1level_cut = 1; } @@ -1931,14 +1957,14 @@ go_bandit([]() { { // Garbage collect writer to free write-lock arc_writer aw(inner); - aw.push_internal({ n1, true, n2 }); + aw.push_internal({ n1, true, n2 }); aw.push_terminal({ n1, false, terminal_T }); aw.push_terminal({ n2, false, terminal_F }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); - aw.push(level_info(1,1u)); - aw.push(level_info(2,1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 1u)); inner->max_1level_cut = 1; } @@ -1955,8 +1981,8 @@ go_bandit([]() { AssertThat(dec.can_pull_internal(), Is().False()); AssertThat(dec.can_pull_terminal(), Is().True()); - AssertThat(dec.peek_terminal(), Is().EqualTo(arc(n2, true, terminal_T))); - AssertThat(dec.pull_terminal(), Is().EqualTo(arc(n2, true, terminal_T))); + AssertThat(dec.peek_terminal(), Is().EqualTo(arc(n2, true, terminal_T))); + AssertThat(dec.pull_terminal(), Is().EqualTo(arc(n2, true, terminal_T))); AssertThat(dec.can_pull_terminal(), Is().True()); AssertThat(dec.peek_terminal(), Is().EqualTo(arc(n2, false, terminal_F))); AssertThat(dec.pull_terminal(), Is().EqualTo(arc(n2, false, terminal_F))); @@ -2017,10 +2043,10 @@ go_bandit([]() { const arc::pointer_type terminal_F(false); const arc::pointer_type terminal_T(true); - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); shared_levelized_file in; @@ -2028,27 +2054,27 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n1, true, n3 }); aw.push_internal({ n2, false, n4 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n2, true, n4 }); aw.push_internal({ n3, false, n4 }); - aw.push_internal({ n3, true, n4 }); + aw.push_internal({ n3, true, n4 }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 1u)); } // Outer state - shared_levelized_file out = __reduce_init_output(); + shared_levelized_file out = __reduce_init_output(); node_writer out_writer(out); arc_stream arcs(in); - pq_t pq({in}, memory_available(), 16); + pq_t pq({ in }, memory_available(), 16); // Simulate reduction of x2 arcs.pull_terminal(); // 4 ---> T @@ -2083,7 +2109,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); // Check node and meta files are correct out_writer.detach(); @@ -2091,16 +2117,14 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().False()); }); @@ -2116,9 +2140,9 @@ go_bandit([]() { const arc::pointer_type terminal_F(false); const arc::pointer_type terminal_T(true); - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); shared_levelized_file in; @@ -2126,25 +2150,25 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n1, true, n3 }); aw.push_terminal({ n2, false, terminal_T }); - aw.push_terminal({ n2, true, terminal_F }); + aw.push_terminal({ n2, true, terminal_F }); aw.push_terminal({ n3, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); } // Outer state - shared_levelized_file out = __reduce_init_output(); + shared_levelized_file out = __reduce_init_output(); node_writer out_writer(out); arc_stream arcs(in); - pq_t pq({in}, memory_available(), 16); + pq_t pq({ in }, memory_available(), 16); // Reduce level x1 nested_sweeping::__reduce_level__fast(arcs, 1, pq, out_writer); @@ -2160,7 +2184,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); // Check node and meta files are correct out_writer.detach(); @@ -2168,21 +2192,18 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id-1, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, node::max_id - 1, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(out_meta.can_pull(), Is().False()); }); @@ -2198,9 +2219,9 @@ go_bandit([]() { const arc::pointer_type terminal_F(false); const arc::pointer_type terminal_T(true); - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); shared_levelized_file in; @@ -2208,25 +2229,25 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n1, true, n3 }); aw.push_terminal({ n2, false, terminal_F }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); aw.push_terminal({ n3, false, terminal_T }); - aw.push_terminal({ n3, true, terminal_F }); + aw.push_terminal({ n3, true, terminal_F }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); } // Outer state - shared_levelized_file out = __reduce_init_output(); + shared_levelized_file out = __reduce_init_output(); node_writer out_writer(out); arc_stream arcs(in); - pq_t pq({in}, memory_available(), 16); + pq_t pq({ in }, memory_available(), 16); // Reduce level x1 nested_sweeping::__reduce_level__fast(arcs, 1, pq, out_writer); @@ -2242,7 +2263,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); // Check node and meta files are correct out_writer.detach(); @@ -2250,21 +2271,18 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id-1, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, node::max_id - 1, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(out_meta.can_pull(), Is().False()); }); @@ -2284,11 +2302,11 @@ go_bandit([]() { const arc::pointer_type terminal_F(false); const arc::pointer_type terminal_T(true); - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); - const arc::pointer_type n5(2,1); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); + const arc::pointer_type n5(2, 1); shared_levelized_file in; @@ -2296,39 +2314,39 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n1, true, n3 }); aw.push_internal({ n2, false, n4 }); aw.push_internal({ n3, false, n4 }); - aw.push_internal({ n3, true, n5 }); + aw.push_internal({ n3, true, n5 }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); aw.push_terminal({ n4, false, terminal_T }); - aw.push_terminal({ n4, true, terminal_F }); + aw.push_terminal({ n4, true, terminal_F }); aw.push_terminal({ n5, false, terminal_F }); - aw.push_terminal({ n5, true, terminal_T }); + aw.push_terminal({ n5, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,2u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 2u)); } // Outer state - shared_levelized_file out = __reduce_init_output(); + shared_levelized_file out = __reduce_init_output(); node_writer out_writer(out); arc_stream arcs(in); - pq_t pq({in}, memory_available(), 16); + pq_t pq({ in }, memory_available(), 16); // Simulate reduction of x2 arcs.pull_terminal(); // 5 ---> T arcs.pull_terminal(); // 5 - -> F - out_writer.unsafe_push(node(2, node::max_id, terminal_F, terminal_T)); + out_writer.unsafe_push(node(2, node::max_id, terminal_F, terminal_T)); arcs.pull_terminal(); // 4 ---> F arcs.pull_terminal(); // 4 - -> T - out_writer.unsafe_push(node(2, node::max_id-1, terminal_T, terminal_F)); + out_writer.unsafe_push(node(2, node::max_id - 1, terminal_T, terminal_F)); out_writer.unsafe_push(level_info(2, 2)); out_writer.unsafe_max_1level_cut({ 0, 2, 3, 5 }); @@ -2336,9 +2354,9 @@ go_bandit([]() { // 3 ---> 5 pq.push(arc(arcs.pull_internal().source(), node::pointer_type(2, node::max_id))); // 3 - -> 4 - pq.push(arc(arcs.pull_internal().source(), node::pointer_type(2, node::max_id-1))); + pq.push(arc(arcs.pull_internal().source(), node::pointer_type(2, node::max_id - 1))); // 2 - -> 4 - pq.push(arc(arcs.pull_internal().source(), node::pointer_type(2, node::max_id-1))); + pq.push(arc(arcs.pull_internal().source(), node::pointer_type(2, node::max_id - 1))); pq.setup_next_level(1); @@ -2356,7 +2374,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(5u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); // Check node and meta files are correct out_writer.detach(); @@ -2364,34 +2382,33 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-1, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, node::max_id - 1, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id-1), - node::pointer_type(2, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(2, node::max_id - 1), + node::pointer_type(2, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id-1, - node::pointer_type(2, node::max_id-1), - terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node( + 1, node::max_id - 1, node::pointer_type(2, node::max_id - 1), terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(out_meta.can_pull(), Is().False()); }); @@ -2411,10 +2428,10 @@ go_bandit([]() { const arc::pointer_type terminal_F(false); const arc::pointer_type terminal_T(true); - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); shared_levelized_file in; @@ -2422,28 +2439,28 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n1, true, n3 }); aw.push_internal({ n2, false, n4 }); aw.push_internal({ n3, false, n4 }); - aw.push_internal({ n3, true, n4 }); + aw.push_internal({ n3, true, n4 }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); aw.push_terminal({ n4, false, terminal_T }); - aw.push_terminal({ n4, true, terminal_F }); + aw.push_terminal({ n4, true, terminal_F }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,2u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 2u)); } // Outer state - shared_levelized_file out = __reduce_init_output(); + shared_levelized_file out = __reduce_init_output(); node_writer out_writer(out); arc_stream arcs(in); - pq_t pq({in}, memory_available(), 16); + pq_t pq({ in }, memory_available(), 16); // Simulate reduction of x2 arcs.pull_terminal(); // 4 ---> T @@ -2476,7 +2493,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); // Check node and meta files are correct out_writer.detach(); @@ -2484,24 +2501,22 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, node::pointer_type(2, node::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); }); @@ -2519,10 +2534,10 @@ go_bandit([]() { const arc::pointer_type terminal_F(false); const arc::pointer_type terminal_T(true); - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); shared_levelized_file in; @@ -2530,28 +2545,28 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n1, true, n3 }); aw.push_internal({ n2, false, n4 }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); aw.push_terminal({ n3, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_F }); + aw.push_terminal({ n3, true, terminal_F }); aw.push_terminal({ n4, false, terminal_T }); - aw.push_terminal({ n4, true, terminal_F }); + aw.push_terminal({ n4, true, terminal_F }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,2u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 2u)); } // Outer state - shared_levelized_file out = __reduce_init_output(); + shared_levelized_file out = __reduce_init_output(); node_writer out_writer(out); arc_stream arcs(in); - pq_t pq({in}, memory_available(), 16); + pq_t pq({ in }, memory_available(), 16); // Simulate reduction of x2 arcs.pull_terminal(); // 4 ---> T @@ -2581,7 +2596,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); // Check node and meta files are correct out_writer.detach(); @@ -2589,24 +2604,22 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, node::pointer_type(2, node::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); }); @@ -2628,12 +2641,12 @@ go_bandit([]() { const arc::pointer_type terminal_F(false); const arc::pointer_type terminal_T(true); - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(2,0); - const arc::pointer_type n4(2,1); - const arc::pointer_type n5(2,2); - const arc::pointer_type n6(3,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(2, 0); + const arc::pointer_type n4(2, 1); + const arc::pointer_type n5(2, 2); + const arc::pointer_type n6(3, 0); shared_levelized_file in; @@ -2642,32 +2655,32 @@ go_bandit([]() { aw.push_internal({ n1, false, n2 }); aw.push_internal({ n2, false, n3 }); - aw.push_internal({ n2, true, n4 }); - aw.push_internal({ n1, true, n5 }); - aw.push_internal({ n3, true, n6 }); - aw.push_internal({ n5, true, n6 }); + aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n1, true, n5 }); + aw.push_internal({ n3, true, n6 }); + aw.push_internal({ n5, true, n6 }); aw.push_terminal({ n3, false, terminal_F }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); aw.push_terminal({ n5, false, terminal_F }); aw.push_terminal({ n6, false, terminal_F }); - aw.push_terminal({ n6, true, terminal_T }); + aw.push_terminal({ n6, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); - aw.push(level_info(2,3u)); - aw.push(level_info(3,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 3u)); + aw.push(level_info(3, 1u)); } // Outer state - shared_levelized_file out = __reduce_init_output(); + shared_levelized_file out = __reduce_init_output(); node_writer out_writer(out); arc_stream arcs(in); - pq_t pq({in}, memory_available(), 16); + pq_t pq({ in }, memory_available(), 16); // Simulate reduction of x3 arcs.pull_terminal(); // 6 ---> T @@ -2698,7 +2711,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(6u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(4u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); // Check node and meta files are correct out_writer.detach(); @@ -2706,34 +2719,35 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - node::pointer_type(false), - node::pointer_type(3, node::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node( + 2, node::max_id, node::pointer_type(false), node::pointer_type(3, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-1, - node::pointer_type(false), - node::pointer_type(true)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node( + 2, node::max_id - 1, node::pointer_type(false), node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-2, - node::pointer_type(false), - node::pointer_type(3, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id - 2, + node::pointer_type(false), + node::pointer_type(3, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,3u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 3u))); AssertThat(out_meta.can_pull(), Is().False()); }); @@ -2751,11 +2765,11 @@ go_bandit([]() { const arc::pointer_type terminal_F(false); const arc::pointer_type terminal_T(true); - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); - const arc::pointer_type n5(2,1); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); + const arc::pointer_type n5(2, 1); shared_levelized_file in; @@ -2763,39 +2777,39 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n1, true, n3 }); aw.push_internal({ n2, false, n4 }); aw.push_internal({ n3, false, n4 }); - aw.push_internal({ n2, true, n5 }); - aw.push_internal({ n3, true, n5 }); + aw.push_internal({ n2, true, n5 }); + aw.push_internal({ n3, true, n5 }); aw.push_terminal({ n4, false, terminal_T }); - aw.push_terminal({ n4, true, terminal_F }); + aw.push_terminal({ n4, true, terminal_F }); aw.push_terminal({ n5, false, terminal_F }); - aw.push_terminal({ n5, true, terminal_T }); + aw.push_terminal({ n5, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,2u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 2u)); } // Outer state - shared_levelized_file out = __reduce_init_output(); + shared_levelized_file out = __reduce_init_output(); node_writer out_writer(out); arc_stream arcs(in); - pq_t pq({in}, memory_available(), 16); + pq_t pq({ in }, memory_available(), 16); // Simulate reduction of x2 arcs.pull_terminal(); // 5 ---> T arcs.pull_terminal(); // 5 - -> F - out_writer.unsafe_push(node(2, node::max_id, terminal_F, terminal_T)); + out_writer.unsafe_push(node(2, node::max_id, terminal_F, terminal_T)); arcs.pull_terminal(); // 4 ---> F arcs.pull_terminal(); // 4 - -> T - out_writer.unsafe_push(node(2, node::max_id-1, terminal_T, terminal_F)); + out_writer.unsafe_push(node(2, node::max_id - 1, terminal_T, terminal_F)); out_writer.unsafe_push(level_info(2, 2)); out_writer.unsafe_max_1level_cut({ 0, 2, 2, 4 }); @@ -2805,9 +2819,9 @@ go_bandit([]() { // 2 ---> 5 pq.push(arc(arcs.pull_internal().source(), node::pointer_type(2, node::max_id))); // 3 - -> 4 - pq.push(arc(arcs.pull_internal().source(), node::pointer_type(2, node::max_id-1))); + pq.push(arc(arcs.pull_internal().source(), node::pointer_type(2, node::max_id - 1))); // 2 - -> 4 - pq.push(arc(arcs.pull_internal().source(), node::pointer_type(2, node::max_id-1))); + pq.push(arc(arcs.pull_internal().source(), node::pointer_type(2, node::max_id - 1))); pq.setup_next_level(1); @@ -2825,7 +2839,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); // Check node and meta files are correct out_writer.detach(); @@ -2833,29 +2847,28 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-1, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, node::max_id - 1, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id-1), - node::pointer_type(2, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(2, node::max_id - 1), + node::pointer_type(2, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); }); @@ -2873,11 +2886,11 @@ go_bandit([]() { const arc::pointer_type terminal_F(false); const arc::pointer_type terminal_T(true); - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(2,0); - const arc::pointer_type n4(2,1); - const arc::pointer_type n5(2,2); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(2, 0); + const arc::pointer_type n4(2, 1); + const arc::pointer_type n5(2, 2); shared_levelized_file in; @@ -2886,29 +2899,29 @@ go_bandit([]() { aw.push_internal({ n1, false, n2 }); aw.push_internal({ n2, false, n3 }); - aw.push_internal({ n2, true, n5 }); - aw.push_internal({ n1, true, n5 }); + aw.push_internal({ n2, true, n5 }); + aw.push_internal({ n1, true, n5 }); aw.push_terminal({ n3, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_F }); + aw.push_terminal({ n4, true, terminal_F }); aw.push_terminal({ n5, false, terminal_F }); - aw.push_terminal({ n5, true, terminal_T }); + aw.push_terminal({ n5, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); - aw.push(level_info(2,3u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 3u)); } // Outer state - shared_levelized_file out = __reduce_init_output(); + shared_levelized_file out = __reduce_init_output(); node_writer out_writer(out); arc_stream arcs(in); - pq_t pq({in}, memory_available(), 16); + pq_t pq({ in }, memory_available(), 16); out_writer.unsafe_max_1level_cut({ 0, 0, 0, 0 }); @@ -2928,7 +2941,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); // Check node and meta files are correct out_writer.detach(); @@ -2936,16 +2949,14 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().False()); }); @@ -2959,7 +2970,7 @@ go_bandit([]() { const arc::pointer_type terminal_F(false); const arc::pointer_type terminal_T(true); - const arc::pointer_type n1(0,0); + const arc::pointer_type n1(0, 0); shared_levelized_file in; @@ -2967,19 +2978,19 @@ go_bandit([]() { arc_writer aw(in); aw.push_terminal({ n1, false, terminal_T }); - aw.push_terminal({ n1, true, terminal_T }); + aw.push_terminal({ n1, true, terminal_T }); - aw.push(level_info(0,1u)); + aw.push(level_info(0, 1u)); } // Outer state - shared_levelized_file out = __reduce_init_output(); + shared_levelized_file out = __reduce_init_output(); node_writer out_writer(out); arc_stream arcs(in); - pq_t pq({in}, memory_available(), 16); + pq_t pq({ in }, memory_available(), 16); // Reduce level x0 nested_sweeping::__reduce_level__fast(arcs, 0, pq, out_writer); @@ -2995,7 +3006,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(0u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); // Check node and meta files are correct out_writer.detach(); @@ -3023,9 +3034,9 @@ go_bandit([]() { const arc::pointer_type terminal_F(false); const arc::pointer_type terminal_T(true); - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); shared_levelized_file in; @@ -3033,25 +3044,25 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n1, true, n3 }); aw.push_terminal({ n2, false, terminal_T }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); aw.push_terminal({ n3, false, terminal_T }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); } // Outer state - shared_levelized_file out = __reduce_init_output(); + shared_levelized_file out = __reduce_init_output(); node_writer out_writer(out); arc_stream arcs(in); - pq_t pq({in}, memory_available(), 16); + pq_t pq({ in }, memory_available(), 16); // Simulate reduction of x1 arcs.pull_terminal(); // 3 ---> T @@ -3081,7 +3092,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(0u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); // Check node and meta files are correct out_writer.detach(); @@ -3118,10 +3129,10 @@ go_bandit([]() { // F T */ - const node n5 = node(2,0, terminal_F, terminal_T); - const node n4 = node(1,2, n5.uid(), terminal_F); - const node n3 = node(1,1, terminal_F, n5.uid()); - const node n2 = node(1,0, terminal_F, terminal_T); + const node n5 = node(2, 0, terminal_F, terminal_T); + const node n4 = node(1, 2, n5.uid(), terminal_F); + const node n3 = node(1, 1, terminal_F, n5.uid()); + const node n2 = node(1, 0, terminal_F, terminal_T); shared_levelized_file outer_file; { // Garbage collect writer to free write-lock @@ -3138,63 +3149,64 @@ go_bandit([]() { // 2 3 4 ---- x1 */ inner_roots_t inner_roots(1024, 8); - const node::uid_type u1 = node::uid_type(0,0); + const node::uid_type u1 = node::uid_type(0, 0); - inner_roots.push({{n2.uid()}, {}, {u1.as_ptr(false)}}); - inner_roots.push({{n3.uid()}, {}, {u1.as_ptr(true)}}); + inner_roots.push({ { n2.uid() }, {}, { u1.as_ptr(false) } }); + inner_roots.push({ { n3.uid() }, {}, { u1.as_ptr(true) } }); const shared_levelized_file out = - nested_sweeping::inner::down(exec_policy(), test_policy, outer_file, inner_roots, memory_available()) - .template get>(); + nested_sweeping::inner::down( + exec_policy(), test_policy, outer_file, inner_roots, memory_available()) + .template get>(); arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // From sorter - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { flag(u1.as_ptr(false)), n2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ flag(u1.as_ptr(false)), n2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); // From sorter - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { flag(u1.as_ptr(true)), n3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ flag(u1.as_ptr(true)), n3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n3.uid(), true, n5.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n3.uid(), true, n5.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2.uid(), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2.uid(), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n3.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n3.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5.uid(), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5.uid(), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out->max_1level_cut, Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); // Side effects on `inner_roots`. - AssertThat(inner_roots.size(), Is().EqualTo(0u)); - AssertThat(inner_roots.can_push(), Is().True()); + AssertThat(inner_roots.size(), Is().EqualTo(0u)); + AssertThat(inner_roots.can_push(), Is().True()); }); it("can be run from multiple roots", [&]() { @@ -3211,73 +3223,74 @@ go_bandit([]() { */ inner_roots_t inner_roots(1024, 8); - const node::uid_type u0 = node::uid_type(0,0); - const node::uid_type u1 = node::uid_type(0,1); + const node::uid_type u0 = node::uid_type(0, 0); + const node::uid_type u1 = node::uid_type(0, 1); - inner_roots.push({{n2.uid()}, {}, {u0.as_ptr(false)}}); - inner_roots.push({{n3.uid()}, {}, {u0.as_ptr(true)}}); + inner_roots.push({ { n2.uid() }, {}, { u0.as_ptr(false) } }); + inner_roots.push({ { n3.uid() }, {}, { u0.as_ptr(true) } }); - inner_roots.push({{n2.uid()}, {}, {u1.as_ptr(false)}}); - inner_roots.push({{n5.uid()}, {}, {u1.as_ptr(true)}}); + inner_roots.push({ { n2.uid() }, {}, { u1.as_ptr(false) } }); + inner_roots.push({ { n5.uid() }, {}, { u1.as_ptr(true) } }); const shared_levelized_file out = - nested_sweeping::inner::down(exec_policy(), test_policy, outer_file, inner_roots, memory_available()) - .template get>(); + nested_sweeping::inner::down( + exec_policy(), test_policy, outer_file, inner_roots, memory_available()) + .template get>(); arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // From sorter - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { flag(u0.as_ptr(false)), n2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ flag(u0.as_ptr(false)), n2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); // From sorter - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { flag(u1.as_ptr(false)), n2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ flag(u1.as_ptr(false)), n2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); // From sorter - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { flag(u0.as_ptr(true)), n3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ flag(u0.as_ptr(true)), n3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); // From sorter - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { flag(u1.as_ptr(true)), n5.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ flag(u1.as_ptr(true)), n5.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n3.uid(), true, n5.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n3.uid(), true, n5.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2.uid(), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2.uid(), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n3.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n3.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5.uid(), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5.uid(), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out->max_1level_cut, Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); // Side effects on `inner_roots`. - AssertThat(inner_roots.size(), Is().EqualTo(0u)); - AssertThat(inner_roots.can_push(), Is().True()); + AssertThat(inner_roots.size(), Is().EqualTo(0u)); + AssertThat(inner_roots.can_push(), Is().True()); }); it("can collapse to a terminal", []() { @@ -3300,11 +3313,12 @@ go_bandit([]() { inner_roots_t inner_roots(1024, 8); - inner_roots.push({{n1.uid()}, {}, {node::pointer_type::nil()}}); + inner_roots.push({ { n1.uid() }, {}, { node::pointer_type::nil() } }); const shared_levelized_file out = - nested_sweeping::inner::down(exec_policy(), test_policy, outer_file, inner_roots, memory_available()) - .template get>(); + nested_sweeping::inner::down( + exec_policy(), test_policy, outer_file, inner_roots, memory_available()) + .template get>(); // Check it looks all right node_test_stream out_nodes(out); @@ -3331,7 +3345,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); }); @@ -3358,24 +3372,24 @@ go_bandit([]() { const uid_uint64 terminal_F(false); const uid_uint64 terminal_T(true); - const uid_uint64 n0(0,0); - const uid_uint64 n1(1,0); - const uid_uint64 n2(1,1); - const uid_uint64 n3(2,0); - const uid_uint64 n4(2,1); - const uid_uint64 n5(2,2); - const uid_uint64 n6(3,0); + const uid_uint64 n0(0, 0); + const uid_uint64 n1(1, 0); + const uid_uint64 n2(1, 1); + const uid_uint64 n3(2, 0); + const uid_uint64 n4(2, 1); + const uid_uint64 n5(2, 2); + const uid_uint64 n6(3, 0); shared_levelized_file in_outer; { // Garbage collect writer to free write-lock arc_writer aw(in_outer); aw.push_internal({ n0, false, n1 }); - aw.push_internal({ n0, true, n2 }); + aw.push_internal({ n0, true, n2 }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,3u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 3u)); in_outer->max_1level_cut = 3; } @@ -3386,23 +3400,23 @@ go_bandit([]() { { // Garbage collect writer to free write-lock arc_writer aw(in_inner); - aw.push_internal({ flag(n1.as_ptr(true)), n3 }); + aw.push_internal({ flag(n1.as_ptr(true)), n3 }); aw.push_internal({ flag(n2.as_ptr(false)), n4 }); - aw.push_internal({ flag(n2.as_ptr(true)), n5 }); + aw.push_internal({ flag(n2.as_ptr(true)), n5 }); aw.push_internal({ n3.as_ptr(true), n6 }); aw.push_internal({ n5.as_ptr(true), n6 }); aw.push_terminal({ n3.as_ptr(false), terminal_T }); aw.push_terminal({ n4.as_ptr(false), terminal_F }); - aw.push_terminal({ n4.as_ptr(true), terminal_T }); + aw.push_terminal({ n4.as_ptr(true), terminal_T }); aw.push_terminal({ n5.as_ptr(false), terminal_T }); aw.push_terminal({ n6.as_ptr(false), terminal_T }); - aw.push_terminal({ n6.as_ptr(true), terminal_F }); + aw.push_terminal({ n6.as_ptr(true), terminal_F }); // NOTE: 'level_info(0,1u)' is not a processable part of the forest; // NOTE: 'level_info(1,2u)' is not a processable part of the forest; - aw.push(level_info(2,3u)); - aw.push(level_info(3,1u)); + aw.push(level_info(2, 3u)); + aw.push(level_info(3, 1u)); in_inner->max_1level_cut = 2; } @@ -3413,7 +3427,7 @@ go_bandit([]() { const size_t available_memory = memory_available(); - outer_pq_t out_pq({in_outer}, available_memory / 2, in_outer->max_1level_cut); + outer_pq_t out_pq({ in_outer }, available_memory / 2, in_outer->max_1level_cut); out_pq.setup_next_level(2); /* output @@ -3426,8 +3440,12 @@ go_bandit([]() { // T F */ nested_sweeping::inner::up(exec_policy::nested::fast_reduce(-1.0), - stream_outer, out_pq, out_writer, - in_inner, available_memory / 2, false); + stream_outer, + out_pq, + out_writer, + in_inner, + available_memory / 2, + false); // Check meta variables before detach computations AssertThat(out->width, Is().EqualTo(2u)); @@ -3442,7 +3460,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().LessThanOrEqualTo(6u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); // Check node and meta files are correct out_writer.detach(); @@ -3450,45 +3468,46 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); // 6 - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(3, node::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); // 5 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // 3 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-1, - terminal_T, - ptr_uint64(3, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo( + node(2, node::max_id - 1, terminal_T, ptr_uint64(3, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(out_meta.can_pull(), Is().False()); // Check outer priority queue is correct - AssertThat(out_pq.size(), Is().EqualTo(3u)); + AssertThat(out_pq.size(), Is().EqualTo(3u)); out_pq.setup_next_level(); AssertThat(out_pq.can_pull(), Is().True()); - AssertThat(out_pq.pull(), Is().EqualTo(arc(n2, true, ptr_uint64(2, ptr_uint64::max_id-1)))); + AssertThat(out_pq.pull(), + Is().EqualTo(arc(n2, true, ptr_uint64(2, ptr_uint64::max_id - 1)))); AssertThat(out_pq.can_pull(), Is().True()); - AssertThat(out_pq.pull(), Is().EqualTo(arc(n2, false, ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(out_pq.pull(), + Is().EqualTo(arc(n2, false, ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(out_pq.can_pull(), Is().True()); - AssertThat(out_pq.pull(), Is().EqualTo(arc(n1, true, ptr_uint64(2, ptr_uint64::max_id-1)))); + AssertThat(out_pq.pull(), + Is().EqualTo(arc(n1, true, ptr_uint64(2, ptr_uint64::max_id - 1)))); AssertThat(out_pq.can_pull(), Is().False()); }); @@ -3499,7 +3518,7 @@ go_bandit([]() { const size_t available_memory = memory_available(); - outer_pq_t out_pq({in_outer}, available_memory / 2, in_outer->max_1level_cut); + outer_pq_t out_pq({ in_outer }, available_memory / 2, in_outer->max_1level_cut); out_pq.setup_next_level(2); /* output @@ -3514,8 +3533,12 @@ go_bandit([]() { // T F */ nested_sweeping::inner::up(exec_policy::nested::fast_reduce(1.0), - stream_outer, out_pq, out_writer, - in_inner, available_memory / 2, false); + stream_outer, + out_pq, + out_writer, + in_inner, + available_memory / 2, + false); // Check meta variables before detach computations AssertThat(out->width, Is().EqualTo(3u)); @@ -3526,7 +3549,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(6u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); // Check node and meta files are correct out_writer.detach(); @@ -3534,51 +3557,51 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); // 6 - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - terminal_F))); - + AssertThat(out_nodes.pull(), + Is().EqualTo(node(3, node::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); // 5 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T, - ptr_uint64(3, ptr_uint64::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, node::max_id, terminal_T, ptr_uint64(3, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // 4 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-1, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, node::max_id - 1, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // 3 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-2, - terminal_T, - ptr_uint64(3, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo( + node(2, node::max_id - 2, terminal_T, ptr_uint64(3, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,3u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 3u))); AssertThat(out_meta.can_pull(), Is().False()); // Check outer priority queue is correct - AssertThat(out_pq.size(), Is().EqualTo(3u)); + AssertThat(out_pq.size(), Is().EqualTo(3u)); out_pq.setup_next_level(); AssertThat(out_pq.can_pull(), Is().True()); - AssertThat(out_pq.pull(), Is().EqualTo(arc(n2, true, ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(out_pq.pull(), + Is().EqualTo(arc(n2, true, ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(out_pq.can_pull(), Is().True()); - AssertThat(out_pq.pull(), Is().EqualTo(arc(n2, false, ptr_uint64(2, ptr_uint64::max_id-1)))); + AssertThat(out_pq.pull(), + Is().EqualTo(arc(n2, false, ptr_uint64(2, ptr_uint64::max_id - 1)))); AssertThat(out_pq.can_pull(), Is().True()); - AssertThat(out_pq.pull(), Is().EqualTo(arc(n1, true, ptr_uint64(2, ptr_uint64::max_id-2)))); + AssertThat(out_pq.pull(), + Is().EqualTo(arc(n1, true, ptr_uint64(2, ptr_uint64::max_id - 2)))); AssertThat(out_pq.can_pull(), Is().False()); }); @@ -3589,7 +3612,7 @@ go_bandit([]() { const size_t available_memory = memory_available(); - outer_pq_t out_pq({in_outer}, available_memory / 2, in_outer->max_1level_cut); + outer_pq_t out_pq({ in_outer }, available_memory / 2, in_outer->max_1level_cut); out_pq.setup_next_level(2); /* output @@ -3602,8 +3625,12 @@ go_bandit([]() { // T F */ nested_sweeping::inner::up(exec_policy::nested::fast_reduce(1.0), - stream_outer, out_pq, out_writer, - in_inner, available_memory / 2, true); + stream_outer, + out_pq, + out_writer, + in_inner, + available_memory / 2, + true); // Check meta variables before detach computations AssertThat(out->width, Is().EqualTo(2u)); @@ -3618,7 +3645,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().LessThanOrEqualTo(6u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); // Check node and meta files are correct out_writer.detach(); @@ -3626,45 +3653,46 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); // 6 - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(3, node::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); // 5 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // 3 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-1, - terminal_T, - ptr_uint64(3, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo( + node(2, node::max_id - 1, terminal_T, ptr_uint64(3, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(out_meta.can_pull(), Is().False()); // Check outer priority queue is correct - AssertThat(out_pq.size(), Is().EqualTo(3u)); + AssertThat(out_pq.size(), Is().EqualTo(3u)); out_pq.setup_next_level(); AssertThat(out_pq.can_pull(), Is().True()); - AssertThat(out_pq.pull(), Is().EqualTo(arc(n2, true, ptr_uint64(2, ptr_uint64::max_id-1)))); + AssertThat(out_pq.pull(), + Is().EqualTo(arc(n2, true, ptr_uint64(2, ptr_uint64::max_id - 1)))); AssertThat(out_pq.can_pull(), Is().True()); - AssertThat(out_pq.pull(), Is().EqualTo(arc(n2, false, ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(out_pq.pull(), + Is().EqualTo(arc(n2, false, ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(out_pq.can_pull(), Is().True()); - AssertThat(out_pq.pull(), Is().EqualTo(arc(n1, true, ptr_uint64(2, ptr_uint64::max_id-1)))); + AssertThat(out_pq.pull(), + Is().EqualTo(arc(n1, true, ptr_uint64(2, ptr_uint64::max_id - 1)))); AssertThat(out_pq.can_pull(), Is().False()); }); @@ -3689,24 +3717,24 @@ go_bandit([]() { const uid_uint64 terminal_F(false); const uid_uint64 terminal_T(true); - const uid_uint64 n0(0,0); - const uid_uint64 n1(1,0); - const uid_uint64 n2(1,1); - const uid_uint64 n3(2,0); - const uid_uint64 n4(2,1); - const uid_uint64 n5(2,2); - const uid_uint64 n6(3,0); + const uid_uint64 n0(0, 0); + const uid_uint64 n1(1, 0); + const uid_uint64 n2(1, 1); + const uid_uint64 n3(2, 0); + const uid_uint64 n4(2, 1); + const uid_uint64 n5(2, 2); + const uid_uint64 n6(3, 0); shared_levelized_file in_outer; { // Garbage collect writer to free write-lock arc_writer aw(in_outer); aw.push_internal({ n0, false, n1 }); - aw.push_internal({ n0, true, n2 }); + aw.push_internal({ n0, true, n2 }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,3u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 3u)); in_outer->max_1level_cut = 3; } @@ -3717,23 +3745,23 @@ go_bandit([]() { { // Garbage collect writer to free write-lock arc_writer aw(in_inner); - aw.push_internal({ flag(n1.as_ptr(true)), n3 }); + aw.push_internal({ flag(n1.as_ptr(true)), n3 }); aw.push_internal({ flag(n2.as_ptr(false)), n4 }); - aw.push_internal({ flag(n2.as_ptr(true)), n5 }); + aw.push_internal({ flag(n2.as_ptr(true)), n5 }); aw.push_internal({ n3.as_ptr(true), n6 }); aw.push_internal({ n4.as_ptr(true), n6 }); aw.push_terminal({ n3.as_ptr(false), terminal_T }); aw.push_terminal({ n4.as_ptr(false), terminal_T }); aw.push_terminal({ n5.as_ptr(false), terminal_F }); - aw.push_terminal({ n5.as_ptr(true), terminal_T }); + aw.push_terminal({ n5.as_ptr(true), terminal_T }); aw.push_terminal({ n6.as_ptr(false), terminal_T }); - aw.push_terminal({ n6.as_ptr(true), terminal_F }); + aw.push_terminal({ n6.as_ptr(true), terminal_F }); // NOTE: 'level_info(0,1u)' is not a processable part of the forest; // NOTE: 'level_info(1,2u)' is not a processable part of the forest; - aw.push(level_info(2,3u)); - aw.push(level_info(3,1u)); + aw.push(level_info(2, 3u)); + aw.push(level_info(3, 1u)); in_inner->max_1level_cut = 2; } @@ -3743,7 +3771,7 @@ go_bandit([]() { const size_t available_memory = memory_available(); - outer_pq_t out_pq({in_outer}, available_memory / 2, in_outer->max_1level_cut); + outer_pq_t out_pq({ in_outer }, available_memory / 2, in_outer->max_1level_cut); out_pq.setup_next_level(2); /* output @@ -3756,8 +3784,12 @@ go_bandit([]() { // T F */ nested_sweeping::inner::up(exec_policy::nested::fast_reduce(1.0), - stream_outer, out_pq, out_writer, - in_inner, available_memory / 2, false); + stream_outer, + out_pq, + out_writer, + in_inner, + available_memory / 2, + false); // Check meta variables before detach computations AssertThat(out->width, Is().EqualTo(2u)); @@ -3772,7 +3804,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().LessThanOrEqualTo(6u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); // Check node and meta files are correct out_writer.detach(); @@ -3780,35 +3812,30 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); // 6 - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - terminal_F))); - + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); // 5 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // 4 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-1, - terminal_T, - ptr_uint64(3, ptr_uint64::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, node::max_id - 1, terminal_T, ptr_uint64(3, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(out_meta.can_pull(), Is().False()); // Check outer priority queue is correct - AssertThat(out_pq.size(), Is().EqualTo(3u)); + AssertThat(out_pq.size(), Is().EqualTo(3u)); out_pq.setup_next_level(); @@ -3816,10 +3843,12 @@ go_bandit([]() { AssertThat(out_pq.pull(), Is().EqualTo(arc(n2, true, ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(out_pq.can_pull(), Is().True()); - AssertThat(out_pq.pull(), Is().EqualTo(arc(n2, false, ptr_uint64(2, ptr_uint64::max_id-1)))); + AssertThat(out_pq.pull(), + Is().EqualTo(arc(n2, false, ptr_uint64(2, ptr_uint64::max_id - 1)))); AssertThat(out_pq.can_pull(), Is().True()); - AssertThat(out_pq.pull(), Is().EqualTo(arc(n1, true, ptr_uint64(2, ptr_uint64::max_id-1)))); + AssertThat(out_pq.pull(), + Is().EqualTo(arc(n1, true, ptr_uint64(2, ptr_uint64::max_id - 1)))); AssertThat(out_pq.can_pull(), Is().False()); }); @@ -3835,16 +3864,16 @@ go_bandit([]() { const uid_uint64 terminal_F(false); const uid_uint64 terminal_T(true); - const uid_uint64 n1(1,0); - const uid_uint64 n2(3,0); + const uid_uint64 n1(1, 0); + const uid_uint64 n2(3, 0); shared_levelized_file in_outer; { // Garbage collect writer to free write-lock arc_writer aw(in_outer); - aw.push(level_info(1,1u)); - aw.push(level_info(2,1u)); - aw.push(level_info(3,1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 1u)); + aw.push(level_info(3, 1u)); in_outer->max_1level_cut = 2; } @@ -3861,7 +3890,7 @@ go_bandit([]() { aw.push_terminal({ n2.as_ptr(true), terminal_T }); // NOTE: 'level_info(1,1u)' is not a processable part of the forest; - aw.push(level_info(3,1u)); + aw.push(level_info(3, 1u)); in_inner->max_1level_cut = 1; } @@ -3871,7 +3900,7 @@ go_bandit([]() { const size_t available_memory = memory_available(); - outer_pq_t out_pq({in_outer}, available_memory / 2, in_outer->max_1level_cut); + outer_pq_t out_pq({ in_outer }, available_memory / 2, in_outer->max_1level_cut); out_pq.push({ n1, false, terminal_F }); out_pq.setup_next_level(2u); @@ -3884,19 +3913,23 @@ go_bandit([]() { // F F T */ nested_sweeping::inner::up(exec_policy::nested::fast_reduce(-1.0), - stream_outer, out_pq, out_writer, - in_inner, available_memory / 2, false); + stream_outer, + out_pq, + out_writer, + in_inner, + available_memory / 2, + false); // Check meta variables before detach computations AssertThat(out->width, Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(0u)); + AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(0u)); AssertThat(out->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); - AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(3u)); + AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); + AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); // Check node and meta files are correct out_writer.detach(); @@ -3904,21 +3937,19 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().False()); // Check outer priority queue is correct - AssertThat(out_pq.size(), Is().EqualTo(2u)); + AssertThat(out_pq.size(), Is().EqualTo(2u)); out_pq.setup_next_level(); @@ -3942,8 +3973,8 @@ go_bandit([]() { const uid_uint64 terminal_F(false); const uid_uint64 terminal_T(true); - const uid_uint64 n1(1,0); - const uid_uint64 n2(3,0); + const uid_uint64 n1(1, 0); + const uid_uint64 n2(3, 0); shared_levelized_file in_outer; { // Garbage collect writer to free write-lock @@ -3951,14 +3982,14 @@ go_bandit([]() { aw.push_terminal({ n1, false, terminal_F }); - aw.push(level_info(1,1u)); - aw.push(level_info(2,1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 1u)); in_outer->max_1level_cut = 1; } arc_stream<> stream_outer(in_outer); AssertThat(stream_outer.unread_terminals(false), Is().EqualTo(1u)); - AssertThat(stream_outer.unread_terminals(true), Is().EqualTo(0u)); + AssertThat(stream_outer.unread_terminals(true), Is().EqualTo(0u)); shared_levelized_file in_inner; @@ -3968,11 +3999,11 @@ go_bandit([]() { aw.push_internal({ flag(n1.as_ptr(true)), n2 }); aw.push_terminal({ n2.as_ptr(false), terminal_F }); - aw.push_terminal({ n2.as_ptr(true), terminal_T }); + aw.push_terminal({ n2.as_ptr(true), terminal_T }); // NOTE: 'level_info(1,1u)' is not a processable part of the forest; // NOTE: 'level_info(2,?u)' is not a processable part of the forest; - aw.push(level_info(3,1u)); + aw.push(level_info(3, 1u)); in_inner->max_1level_cut = 1; } @@ -3982,7 +4013,7 @@ go_bandit([]() { const size_t available_memory = memory_available(); - outer_pq_t out_pq({in_outer}, available_memory / 2, in_outer->max_1level_cut); + outer_pq_t out_pq({ in_outer }, available_memory / 2, in_outer->max_1level_cut); out_pq.setup_next_level(2u); /* output @@ -3993,19 +4024,23 @@ go_bandit([]() { // F T */ nested_sweeping::inner::up(exec_policy::nested::fast_reduce(-1.0), - stream_outer, out_pq, out_writer, - in_inner, available_memory / 2, false); + stream_outer, + out_pq, + out_writer, + in_inner, + available_memory / 2, + false); // Check meta variables before detach computations AssertThat(out->width, Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(0u)); + AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(0u)); AssertThat(out->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); - AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(3u)); + AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); + AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); // Check node and meta files are correct out_writer.detach(); @@ -4013,21 +4048,19 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().False()); // Check outer priority queue is correct - AssertThat(out_pq.size(), Is().EqualTo(1u)); + AssertThat(out_pq.size(), Is().EqualTo(1u)); out_pq.setup_next_level(); @@ -4050,16 +4083,16 @@ go_bandit([]() { const uid_uint64 terminal_F(false); const uid_uint64 terminal_T(true); - const uid_uint64 n1(1,0); - const uid_uint64 n2(3,0); - const uid_uint64 n3(4,0); + const uid_uint64 n1(1, 0); + const uid_uint64 n2(3, 0); + const uid_uint64 n3(4, 0); shared_levelized_file in_outer; { // Garbage collect writer to free write-lock arc_writer aw(in_outer); - aw.push(level_info(1,1u)); - aw.push(level_info(2,1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 1u)); in_outer->max_1level_cut = 1; } @@ -4075,11 +4108,11 @@ go_bandit([]() { aw.push_terminal({ n2.as_ptr(false), terminal_F }); aw.push_terminal({ n3.as_ptr(false), terminal_T }); - aw.push_terminal({ n3.as_ptr(true), terminal_T }); + aw.push_terminal({ n3.as_ptr(true), terminal_T }); // NOTE: 'level_info(1,1u)' is not a processable part of the forest; - aw.push(level_info(3,1u)); - aw.push(level_info(4,1u)); + aw.push(level_info(3, 1u)); + aw.push(level_info(4, 1u)); in_inner->max_1level_cut = 1; } @@ -4089,7 +4122,7 @@ go_bandit([]() { const size_t available_memory = memory_available(); - outer_pq_t out_pq({in_outer}, available_memory / 2, in_outer->max_1level_cut); + outer_pq_t out_pq({ in_outer }, available_memory / 2, in_outer->max_1level_cut); out_pq.setup_next_level(2); /* output @@ -4100,19 +4133,23 @@ go_bandit([]() { // F T <-- T tainted in global cut */ nested_sweeping::inner::up(exec_policy::nested::fast_reduce(-1.0), - stream_outer, out_pq, out_writer, - in_inner, available_memory / 2, false); + stream_outer, + out_pq, + out_writer, + in_inner, + available_memory / 2, + false); // Check meta variables before detach computations AssertThat(out->width, Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(0u)); + AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(0u)); AssertThat(out->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); + AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); // Check node and meta files are correct out_writer.detach(); @@ -4120,21 +4157,19 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().False()); // Check outer priority queue is correct - AssertThat(out_pq.size(), Is().EqualTo(1u)); + AssertThat(out_pq.size(), Is().EqualTo(1u)); out_pq.setup_next_level(); @@ -4155,15 +4190,15 @@ go_bandit([]() { const uid_uint64 terminal_F(false); const uid_uint64 terminal_T(true); - const uid_uint64 n1(1,0); - const uid_uint64 n2(3,0); + const uid_uint64 n1(1, 0); + const uid_uint64 n2(3, 0); shared_levelized_file in_outer; { // Garbage collect writer to free write-lock arc_writer aw(in_outer); - aw.push(level_info(1,1u)); - aw.push(level_info(2,1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 1u)); in_outer->max_1level_cut = 1; } @@ -4177,10 +4212,10 @@ go_bandit([]() { aw.push_internal({ flag(n1.as_ptr(true)), n2 }); aw.push_terminal({ n2.as_ptr(false), terminal_T }); - aw.push_terminal({ n2.as_ptr(true), terminal_T }); + aw.push_terminal({ n2.as_ptr(true), terminal_T }); // NOTE: 'level_info(1,1u)' is not a processable part of the forest; - aw.push(level_info(3,1u)); + aw.push(level_info(3, 1u)); in_inner->max_1level_cut = 1; } @@ -4190,7 +4225,7 @@ go_bandit([]() { const size_t available_memory = memory_available(); - outer_pq_t out_pq({in_outer}, available_memory / 2, in_outer->max_1level_cut); + outer_pq_t out_pq({ in_outer }, available_memory / 2, in_outer->max_1level_cut); out_pq.setup_next_level(2); /* output @@ -4199,19 +4234,23 @@ go_bandit([]() { // T <-- in 'out_pq', not in 'out' */ nested_sweeping::inner::up(exec_policy::nested::fast_reduce(-1.0), - stream_outer, out_pq, out_writer, - in_inner, available_memory / 2, false); + stream_outer, + out_pq, + out_writer, + in_inner, + available_memory / 2, + false); // Check meta variables before detach computations AssertThat(out->width, Is().EqualTo(0u)); - AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(0u)); + AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(0u)); AssertThat(out->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(0u)); + AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); + AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(0u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(0u)); // Check node and meta files are correct out_writer.detach(); @@ -4225,7 +4264,7 @@ go_bandit([]() { AssertThat(out_meta.can_pull(), Is().False()); // Check outer priority queue is correct - AssertThat(out_pq.size(), Is().EqualTo(1u)); + AssertThat(out_pq.size(), Is().EqualTo(1u)); out_pq.setup_next_level(); @@ -4246,15 +4285,15 @@ go_bandit([]() { const uid_uint64 terminal_F(false); const uid_uint64 terminal_T(true); - const uid_uint64 n1(1,0); - const uid_uint64 n2(3,0); + const uid_uint64 n1(1, 0); + const uid_uint64 n2(3, 0); shared_levelized_file in_outer; { // Garbage collect writer to free write-lock arc_writer aw(in_outer); - aw.push(level_info(1,1u)); - aw.push(level_info(2,1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 1u)); in_outer->max_1level_cut = 3; } @@ -4269,10 +4308,10 @@ go_bandit([]() { aw.push_terminal({ flag(n1.as_ptr(false)), terminal_F }); aw.push_terminal({ n2.as_ptr(false), terminal_F }); - aw.push_terminal({ n2.as_ptr(true), terminal_T }); + aw.push_terminal({ n2.as_ptr(true), terminal_T }); // NOTE: 'level_info(1,1u)' is not a processable part of the forest; - aw.push(level_info(3,1u)); + aw.push(level_info(3, 1u)); in_inner->max_1level_cut = 1; } @@ -4282,7 +4321,7 @@ go_bandit([]() { const size_t available_memory = memory_available(); - outer_pq_t out_pq({in_outer}, available_memory / 2, in_outer->max_1level_cut); + outer_pq_t out_pq({ in_outer }, available_memory / 2, in_outer->max_1level_cut); out_pq.setup_next_level(2); /* output @@ -4293,19 +4332,23 @@ go_bandit([]() { // F F T */ nested_sweeping::inner::up(exec_policy::nested::fast_reduce(-1.0), - stream_outer, out_pq, out_writer, - in_inner, available_memory / 2, false); + stream_outer, + out_pq, + out_writer, + in_inner, + available_memory / 2, + false); // Check meta variables before detach computations AssertThat(out->width, Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(0u)); + AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(0u)); AssertThat(out->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); - AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(3u)); + AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); + AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); // Check node and meta files are correct out_writer.detach(); @@ -4313,26 +4356,25 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().False()); // Check outer priority queue is correct - AssertThat(out_pq.size(), Is().EqualTo(2u)); + AssertThat(out_pq.size(), Is().EqualTo(2u)); out_pq.setup_next_level(); AssertThat(out_pq.can_pull(), Is().True()); // Edge is tainted by reduction rule 1 - AssertThat(out_pq.pull(), Is().EqualTo(arc(n1, true, node::pointer_type(3, node::max_id)))); + AssertThat(out_pq.pull(), + Is().EqualTo(arc(n1, true, node::pointer_type(3, node::max_id)))); AssertThat(out_pq.can_pull(), Is().True()); // Edge is tainted by reduction rule 1 AssertThat(out_pq.pull(), Is().EqualTo(arc(n1, false, terminal_F))); @@ -4354,7 +4396,7 @@ go_bandit([]() { test_not_sweep<> inner_impl(2); - const bdd out = nested_sweep<>(exec_policy(),in, inner_impl); + const bdd out = nested_sweep<>(exec_policy(), in, inner_impl); AssertThat(out.file_ptr(), Is().EqualTo(in)); }); @@ -4372,29 +4414,29 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(1,0); - const ptr_uint64 n2(2,0); - const ptr_uint64 n3(3,0); - const ptr_uint64 n4(3,1); + const ptr_uint64 n1(1, 0); + const ptr_uint64 n2(2, 0); + const ptr_uint64 n3(3, 0); + const ptr_uint64 n4(3, 1); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, true, n2 }); + aw.push_internal({ n1, true, n2 }); aw.push_internal({ n2, false, n3 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n2, true, n4 }); aw.push_terminal({ n1, false, terminal_T }); aw.push_terminal({ n3, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); - aw.push(level_info(1,1u)); - aw.push(level_info(2,1u)); - aw.push(level_info(3,2u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 1u)); + aw.push(level_info(3, 2u)); in->max_1level_cut = 3; } @@ -4421,18 +4463,18 @@ go_bandit([]() { // n1 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - terminal_T, - node::pointer_type(3, node::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, terminal_T, node::pointer_type(3, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -4449,7 +4491,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("accumulates a single nested sweep [non-root level] [2]", []() { @@ -4465,11 +4507,11 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(1,0); - const ptr_uint64 n2(2,0); - const ptr_uint64 n3(2,1); - const ptr_uint64 n4(3,0); - const ptr_uint64 n5(3,1); + const ptr_uint64 n1(1, 0); + const ptr_uint64 n2(2, 0); + const ptr_uint64 n3(2, 1); + const ptr_uint64 n4(3, 0); + const ptr_uint64 n5(3, 1); shared_levelized_file in; @@ -4477,20 +4519,20 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n2, true, n4 }); aw.push_internal({ n3, false, n4 }); - aw.push_internal({ n3, true, n5 }); + aw.push_internal({ n3, true, n5 }); aw.push_terminal({ n2, false, terminal_F }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); aw.push_terminal({ n5, false, terminal_T }); - aw.push_terminal({ n5, true, terminal_T }); + aw.push_terminal({ n5, true, terminal_T }); - aw.push(level_info(1,1u)); - aw.push(level_info(2,2u)); - aw.push(level_info(3,2u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 2u)); + aw.push(level_info(3, 2u)); in->max_1level_cut = 3; } @@ -4517,19 +4559,19 @@ go_bandit([]() { // n1 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(3, ptr_uint64::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -4552,7 +4594,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("accumulates a single nested sweep [root level]", []() { @@ -4566,8 +4608,8 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(0,0); - const ptr_uint64 n2(1,0); + const ptr_uint64 n1(0, 0); + const ptr_uint64 n2(1, 0); shared_levelized_file in; @@ -4578,10 +4620,10 @@ go_bandit([]() { aw.push_terminal({ n1, false, terminal_F }); aw.push_terminal({ n2, false, terminal_F }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); in->max_1level_cut = 1; } @@ -4609,7 +4651,7 @@ go_bandit([]() { level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -4626,7 +4668,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("accumulates multiple nested sweeps [excl. root]", []() { @@ -4646,14 +4688,14 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(1,0); - const ptr_uint64 n2(2,0); - const ptr_uint64 n3(2,1); - const ptr_uint64 n4(3,0); - const ptr_uint64 n5(3,1); - const ptr_uint64 n6(4,0); - const ptr_uint64 n7(5,0); - const ptr_uint64 n8(5,1); + const ptr_uint64 n1(1, 0); + const ptr_uint64 n2(2, 0); + const ptr_uint64 n3(2, 1); + const ptr_uint64 n4(3, 0); + const ptr_uint64 n5(3, 1); + const ptr_uint64 n6(4, 0); + const ptr_uint64 n7(5, 0); + const ptr_uint64 n8(5, 1); shared_levelized_file in; @@ -4661,28 +4703,28 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n2, true, n4 }); aw.push_internal({ n3, false, n4 }); - aw.push_internal({ n3, true, n5 }); + aw.push_internal({ n3, true, n5 }); aw.push_internal({ n5, false, n6 }); - aw.push_internal({ n5, true, n6 }); - aw.push_internal({ n4, true, n7 }); + aw.push_internal({ n5, true, n6 }); + aw.push_internal({ n4, true, n7 }); aw.push_internal({ n6, false, n7 }); - aw.push_internal({ n6, true, n8 }); + aw.push_internal({ n6, true, n8 }); aw.push_terminal({ n2, false, terminal_F }); aw.push_terminal({ n4, false, terminal_F }); aw.push_terminal({ n7, false, terminal_F }); - aw.push_terminal({ n7, true, terminal_T }); + aw.push_terminal({ n7, true, terminal_T }); aw.push_terminal({ n8, false, terminal_T }); - aw.push_terminal({ n8, true, terminal_F }); + aw.push_terminal({ n8, true, terminal_F }); - aw.push(level_info(1,1u)); - aw.push(level_info(2,2u)); - aw.push(level_info(3,2u)); - aw.push(level_info(4,1u)); - aw.push(level_info(5,2u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 2u)); + aw.push(level_info(3, 2u)); + aw.push(level_info(4, 1u)); + aw.push(level_info(5, 2u)); in->max_1level_cut = 3; } @@ -4713,32 +4755,35 @@ go_bandit([]() { // n7 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id-1, terminal_T, terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(5, node::max_id - 1, terminal_T, terminal_F))); // n4 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - ptr_uint64(5, ptr_uint64::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(3, node::max_id, terminal_T, ptr_uint64(5, ptr_uint64::max_id)))); // n1 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - ptr_uint64(5, ptr_uint64::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(5, ptr_uint64::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -4758,7 +4803,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(5u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); it("accumulates multiple nested sweeps [incl. root]", []() { @@ -4776,12 +4821,12 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(0,0); - const ptr_uint64 n2(1,0); - const ptr_uint64 n3(1,1); - const ptr_uint64 n4(2,0); - const ptr_uint64 n5(2,1); - const ptr_uint64 n6(3,0); + const ptr_uint64 n1(0, 0); + const ptr_uint64 n2(1, 0); + const ptr_uint64 n3(1, 1); + const ptr_uint64 n4(2, 0); + const ptr_uint64 n5(2, 1); + const ptr_uint64 n6(3, 0); shared_levelized_file in; @@ -4789,23 +4834,23 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n2, true, n4 }); aw.push_internal({ n3, false, n4 }); - aw.push_internal({ n3, true, n5 }); - aw.push_internal({ n4, true, n6 }); + aw.push_internal({ n3, true, n5 }); + aw.push_internal({ n4, true, n6 }); aw.push_internal({ n5, false, n6 }); aw.push_terminal({ n2, false, terminal_T }); aw.push_terminal({ n4, false, terminal_T }); - aw.push_terminal({ n5, true, terminal_F }); + aw.push_terminal({ n5, true, terminal_F }); aw.push_terminal({ n6, false, terminal_F }); - aw.push_terminal({ n6, true, terminal_T }); + aw.push_terminal({ n6, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,2u)); - aw.push(level_info(3,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 2u)); + aw.push(level_info(3, 1u)); in->max_1level_cut = 3; } @@ -4830,25 +4875,23 @@ go_bandit([]() { // n6 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, terminal_F, terminal_T))); // n3 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(3, node::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, node::pointer_type(3, node::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -4865,7 +4908,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("accumulates multiple nested sweeps on (transposed) node file", []() { @@ -4877,14 +4920,14 @@ go_bandit([]() { const ptr_uint64 terminal_T(true); // In canonical order (realistic output from Reduce) - const node n7(5,node::max_id, terminal_F, terminal_T); - const node n8(5,node::max_id-1, terminal_T, terminal_F); - const node n6(4,node::max_id, n7.uid(), n8.uid()); - //const node n5(3,_, n6.uid(), n6.uid()); - const node n4(3,node::max_id, terminal_F, n7.uid()); - const node n3(2,node::max_id, n4.uid(), n6.uid()); - const node n2(2,node::max_id-1, terminal_F, n4.uid()); - const node n1(1,node::max_id, n2.uid(), n3.uid()); + const node n7(5, node::max_id, terminal_F, terminal_T); + const node n8(5, node::max_id - 1, terminal_T, terminal_F); + const node n6(4, node::max_id, n7.uid(), n8.uid()); + // const node n5(3,_, n6.uid(), n6.uid()); + const node n4(3, node::max_id, terminal_F, n7.uid()); + const node n3(2, node::max_id, n4.uid(), n6.uid()); + const node n2(2, node::max_id - 1, terminal_F, n4.uid()); + const node n1(1, node::max_id, n2.uid(), n3.uid()); shared_levelized_file in; @@ -4912,32 +4955,35 @@ go_bandit([]() { // n7 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id-1, terminal_T, terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(5, node::max_id - 1, terminal_T, terminal_F))); // n4 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - ptr_uint64(5, ptr_uint64::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(3, node::max_id, terminal_T, ptr_uint64(5, ptr_uint64::max_id)))); // n1 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - ptr_uint64(5, ptr_uint64::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(5, ptr_uint64::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -4957,7 +5003,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(5u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); it("accumulates multiple nested sweeps with arcs that span multiple sweeps", []() { @@ -4981,11 +5027,11 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(1,0); - const ptr_uint64 n2(2,0); - const ptr_uint64 n3(3,0); - const ptr_uint64 n4(4,0); - const ptr_uint64 n5(5,0); + const ptr_uint64 n1(1, 0); + const ptr_uint64 n2(2, 0); + const ptr_uint64 n3(3, 0); + const ptr_uint64 n4(4, 0); + const ptr_uint64 n5(5, 0); shared_levelized_file in; @@ -4993,22 +5039,22 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n2, true, n3 }); + aw.push_internal({ n2, true, n3 }); aw.push_internal({ n2, false, n4 }); aw.push_internal({ n3, false, n4 }); - aw.push_internal({ n1, true, n5 }); - aw.push_internal({ n4, true, n5 }); + aw.push_internal({ n1, true, n5 }); + aw.push_internal({ n4, true, n5 }); - aw.push_terminal({ n3, true, terminal_F }); + aw.push_terminal({ n3, true, terminal_F }); aw.push_terminal({ n4, false, terminal_T }); aw.push_terminal({ n5, false, terminal_F }); - aw.push_terminal({ n5, true, terminal_T }); + aw.push_terminal({ n5, true, terminal_T }); - aw.push(level_info(1,1u)); - aw.push(level_info(2,1u)); - aw.push(level_info(3,1u)); - aw.push(level_info(4,1u)); - aw.push(level_info(5,1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 1u)); + aw.push(level_info(3, 1u)); + aw.push(level_info(4, 1u)); + aw.push(level_info(5, 1u)); in->max_1level_cut = 3; } @@ -5035,34 +5081,34 @@ go_bandit([]() { // n5 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, terminal_F, terminal_T))); // n3 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - node::pointer_type(5, node::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(3, node::max_id, node::pointer_type(5, node::max_id), terminal_T))); // n1 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(3, node::max_id), - node::pointer_type(5, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(3, node::max_id), + node::pointer_type(5, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -5079,7 +5125,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("handles all root arcs collapsing into terminals", []() { @@ -5102,12 +5148,12 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(1,0); - const ptr_uint64 n2(2,0); - const ptr_uint64 n3(2,1); - const ptr_uint64 n4(3,0); - const ptr_uint64 n5(5,0); - const ptr_uint64 n6(5,1); + const ptr_uint64 n1(1, 0); + const ptr_uint64 n2(2, 0); + const ptr_uint64 n3(2, 1); + const ptr_uint64 n4(3, 0); + const ptr_uint64 n5(5, 0); + const ptr_uint64 n6(5, 1); shared_levelized_file in; @@ -5115,23 +5161,23 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n2, true, n4 }); aw.push_internal({ n3, false, n4 }); aw.push_internal({ n2, false, n5 }); - aw.push_internal({ n3, true, n6 }); + aw.push_internal({ n3, true, n6 }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); aw.push_terminal({ n5, false, terminal_T }); - aw.push_terminal({ n5, true, terminal_F }); + aw.push_terminal({ n5, true, terminal_F }); aw.push_terminal({ n6, false, terminal_F }); - aw.push_terminal({ n6, true, terminal_T }); + aw.push_terminal({ n6, true, terminal_T }); - aw.push(level_info(1,1u)); - aw.push(level_info(2,2u)); - aw.push(level_info(3,1u)); - aw.push(level_info(5,2u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 2u)); + aw.push(level_info(3, 1u)); + aw.push(level_info(5, 2u)); in->max_1level_cut = 4; } @@ -5150,16 +5196,14 @@ go_bandit([]() { // n1 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -5176,7 +5220,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("handles some root arcs collapsing into terminals", []() { @@ -5197,10 +5241,10 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(2,0); - const ptr_uint64 n2(3,0); - const ptr_uint64 n3(4,0); - const ptr_uint64 n4(5,0); + const ptr_uint64 n1(2, 0); + const ptr_uint64 n2(3, 0); + const ptr_uint64 n3(4, 0); + const ptr_uint64 n4(5, 0); shared_levelized_file in; @@ -5209,18 +5253,18 @@ go_bandit([]() { aw.push_internal({ n1, false, n2 }); aw.push_internal({ n2, false, n3 }); - aw.push_internal({ n1, true, n4 }); + aw.push_internal({ n1, true, n4 }); - aw.push_terminal({ n2, true, terminal_F }); + aw.push_terminal({ n2, true, terminal_F }); aw.push_terminal({ n3, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); - aw.push(level_info(2,1u)); - aw.push(level_info(3,1u)); - aw.push(level_info(4,1u)); - aw.push(level_info(5,1u)); + aw.push(level_info(2, 1u)); + aw.push(level_info(3, 1u)); + aw.push(level_info(4, 1u)); + aw.push(level_info(5, 1u)); in->max_1level_cut = 2; } @@ -5240,30 +5284,27 @@ go_bandit([]() { */ const bdd out = nested_sweep<>(exec_policy(), __bdd(in, exec_policy()), inner_impl); - // Check it looks all right node_test_stream out_nodes(out); // n4' AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, terminal_T, terminal_F))); // n1 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - node::pointer_type(5, node::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, node::max_id, terminal_F, node::pointer_type(5, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -5280,7 +5321,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("can garbage collect temp solution when no parent references it [non-root level]", []() { @@ -5296,26 +5337,26 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(1,0); - const ptr_uint64 n2(2,0); - const ptr_uint64 n3(3,0); + const ptr_uint64 n1(1, 0); + const ptr_uint64 n2(2, 0); + const ptr_uint64 n3(3, 0); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, true, n2 }); + aw.push_internal({ n1, true, n2 }); aw.push_internal({ n2, false, n3 }); aw.push_terminal({ n1, false, terminal_F }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); aw.push_terminal({ n3, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); - aw.push(level_info(1,1u)); - aw.push(level_info(2,1u)); - aw.push(level_info(3,1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 1u)); + aw.push(level_info(3, 1u)); in->max_1level_cut = 1; } @@ -5334,15 +5375,13 @@ go_bandit([]() { // n1 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -5359,7 +5398,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("can suppress nesting-level node into a terminal [non-root level]", []() { @@ -5375,26 +5414,26 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(1,0); - const ptr_uint64 n2(2,0); - const ptr_uint64 n3(3,0); + const ptr_uint64 n1(1, 0); + const ptr_uint64 n2(2, 0); + const ptr_uint64 n3(3, 0); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, true, n2 }); + aw.push_internal({ n1, true, n2 }); aw.push_internal({ n2, false, n3 }); aw.push_terminal({ n1, false, terminal_F }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); aw.push_terminal({ n3, false, terminal_T }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); - aw.push(level_info(1,1u)); - aw.push(level_info(2,1u)); - aw.push(level_info(3,1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 1u)); + aw.push(level_info(3, 1u)); in->max_1level_cut = 1; } @@ -5413,15 +5452,13 @@ go_bandit([]() { // n1 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -5438,7 +5475,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("can suppress nesting-level node into a terminal [root level]", []() { @@ -5452,22 +5489,22 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(0,0); - const ptr_uint64 n2(1,0); + const ptr_uint64 n1(0, 0); + const ptr_uint64 n2(1, 0); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, false, n2 }); + aw.push_internal({ n1, false, n2 }); - aw.push_terminal({ n1, true, terminal_T }); + aw.push_terminal({ n1, true, terminal_T }); aw.push_terminal({ n2, false, terminal_T }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); in->max_1level_cut = 1; } @@ -5504,7 +5541,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("can preserve subtree for suppressed root with inner sweep", []() { @@ -5519,8 +5556,8 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(0,0); - const ptr_uint64 n2(1,0); + const ptr_uint64 n1(0, 0); + const ptr_uint64 n2(1, 0); shared_levelized_file in; @@ -5528,13 +5565,13 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n2 }); + aw.push_internal({ n1, true, n2 }); aw.push_terminal({ n2, false, terminal_F }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); in->max_1level_cut = 2; } @@ -5559,7 +5596,7 @@ go_bandit([]() { level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -5576,7 +5613,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("can solve root-level nesting request directly to a terminal", []() { @@ -5590,22 +5627,22 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(0,0); - const ptr_uint64 n2(1,0); + const ptr_uint64 n1(0, 0); + const ptr_uint64 n2(1, 0); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, false, n2 }); + aw.push_internal({ n1, false, n2 }); - aw.push_terminal({ n1, true, terminal_T }); + aw.push_terminal({ n1, true, terminal_T }); aw.push_terminal({ n2, false, terminal_F }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); in->max_1level_cut = 1; } @@ -5642,7 +5679,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("can collapse to a terminal [outer up]", []() { @@ -5656,22 +5693,22 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(1,0); - const ptr_uint64 n2(2,0); + const ptr_uint64 n1(1, 0); + const ptr_uint64 n2(2, 0); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, false, n2 }); + aw.push_internal({ n1, false, n2 }); - aw.push_terminal({ n1, true, terminal_F }); + aw.push_terminal({ n1, true, terminal_F }); aw.push_terminal({ n2, false, terminal_T }); - aw.push_terminal({ n2, true, terminal_F }); + aw.push_terminal({ n2, true, terminal_F }); - aw.push(level_info(1,1u)); - aw.push(level_info(2,1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 1u)); in->max_1level_cut = 1; } @@ -5708,7 +5745,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(0u)); }); it("can collapse to a terminal [inner down]", []() { @@ -5722,8 +5759,8 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(0,0); - const ptr_uint64 n2(1,0); + const ptr_uint64 n1(0, 0); + const ptr_uint64 n2(1, 0); shared_levelized_file in; @@ -5732,12 +5769,12 @@ go_bandit([]() { aw.push_internal({ n1, false, n2 }); - aw.push_terminal({ n1, true, terminal_T }); + aw.push_terminal({ n1, true, terminal_T }); aw.push_terminal({ n2, false, terminal_T }); - aw.push_terminal({ n2, true, terminal_F }); + aw.push_terminal({ n2, true, terminal_F }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); in->max_1level_cut = 1; } @@ -5774,7 +5811,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("can collapse to a terminal [inner up]", []() { @@ -5790,8 +5827,8 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(0,0); - const ptr_uint64 n2(2,0); + const ptr_uint64 n1(0, 0); + const ptr_uint64 n2(2, 0); shared_levelized_file in; @@ -5800,12 +5837,12 @@ go_bandit([]() { aw.push_internal({ n1, false, n2 }); - aw.push_terminal({ n1, true, terminal_T }); + aw.push_terminal({ n1, true, terminal_T }); aw.push_terminal({ n2, false, terminal_T }); - aw.push_terminal({ n2, true, terminal_F }); + aw.push_terminal({ n2, true, terminal_F }); - aw.push(level_info(0,1u)); - aw.push(level_info(2,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(2, 1u)); in->max_1level_cut = 1; } @@ -5843,7 +5880,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); describe("bail-out optimisation", []() { @@ -5864,13 +5901,13 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(1,0); - const ptr_uint64 n2(2,0); - const ptr_uint64 n3(2,1); - const ptr_uint64 n4(3,0); - const ptr_uint64 n5(3,1); - const ptr_uint64 n6(4,0); - const ptr_uint64 n7(5,0); + const ptr_uint64 n1(1, 0); + const ptr_uint64 n2(2, 0); + const ptr_uint64 n3(2, 1); + const ptr_uint64 n4(3, 0); + const ptr_uint64 n5(3, 1); + const ptr_uint64 n6(4, 0); + const ptr_uint64 n7(5, 0); shared_levelized_file in; @@ -5878,26 +5915,26 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n2, true, n4 }); aw.push_internal({ n3, false, n4 }); - aw.push_internal({ n3, true, n5 }); - aw.push_internal({ n4, true, n6 }); + aw.push_internal({ n3, true, n5 }); + aw.push_internal({ n4, true, n6 }); aw.push_internal({ n5, false, n6 }); - aw.push_internal({ n6, true, n7 }); + aw.push_internal({ n6, true, n7 }); aw.push_terminal({ n2, false, terminal_T }); aw.push_terminal({ n4, false, terminal_T }); - aw.push_terminal({ n5, true, terminal_F }); + aw.push_terminal({ n5, true, terminal_F }); aw.push_terminal({ n6, false, terminal_F }); aw.push_terminal({ n7, false, terminal_F }); - aw.push_terminal({ n7, true, terminal_T }); + aw.push_terminal({ n7, true, terminal_T }); - aw.push(level_info(1,1u)); - aw.push(level_info(2,2u)); - aw.push(level_info(3,2u)); - aw.push(level_info(4,1u)); - aw.push(level_info(5,1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 2u)); + aw.push(level_info(3, 2u)); + aw.push(level_info(4, 1u)); + aw.push(level_info(5, 1u)); in->max_1level_cut = 3; } @@ -5924,40 +5961,40 @@ go_bandit([]() { // n7 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, terminal_T, terminal_F))); // n5 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - node::pointer_type(5, node::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(3, node::max_id, node::pointer_type(5, node::max_id), terminal_T))); // n4 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id-1, - terminal_F, - node::pointer_type(5, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo( + node(3, node::max_id - 1, terminal_F, node::pointer_type(5, node::max_id)))); // n1 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(3, node::max_id-1), - node::pointer_type(3, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(3, node::max_id - 1), + node::pointer_type(3, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -5978,7 +6015,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(5u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("handles node suppression cut-taint when bailing out", []() { @@ -5998,14 +6035,14 @@ go_bandit([]() { const ptr_uint64 terminal_F(false); const ptr_uint64 terminal_T(true); - const ptr_uint64 n1(1,0); - const ptr_uint64 n2(2,0); - const ptr_uint64 n3(2,1); - const ptr_uint64 n4(3,0); - const ptr_uint64 n5(3,1); - const ptr_uint64 n6(4,0); - const ptr_uint64 n7(4,1); - const ptr_uint64 n8(5,0); + const ptr_uint64 n1(1, 0); + const ptr_uint64 n2(2, 0); + const ptr_uint64 n3(2, 1); + const ptr_uint64 n4(3, 0); + const ptr_uint64 n5(3, 1); + const ptr_uint64 n6(4, 0); + const ptr_uint64 n7(4, 1); + const ptr_uint64 n8(5, 0); shared_levelized_file in; @@ -6013,28 +6050,28 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n2, true, n4 }); aw.push_internal({ n3, false, n5 }); - aw.push_internal({ n3, true, n5 }); - aw.push_internal({ n4, true, n6 }); - aw.push_internal({ n5, true, n7 }); - aw.push_internal({ n6, true, n8 }); + aw.push_internal({ n3, true, n5 }); + aw.push_internal({ n4, true, n6 }); + aw.push_internal({ n5, true, n7 }); + aw.push_internal({ n6, true, n8 }); aw.push_terminal({ n2, false, terminal_T }); aw.push_terminal({ n4, false, terminal_T }); aw.push_terminal({ n5, false, terminal_F }); aw.push_terminal({ n6, false, terminal_F }); aw.push_terminal({ n7, false, terminal_T }); - aw.push_terminal({ n7, true, terminal_F }); + aw.push_terminal({ n7, true, terminal_F }); aw.push_terminal({ n8, false, terminal_F }); - aw.push_terminal({ n8, true, terminal_T }); + aw.push_terminal({ n8, true, terminal_T }); - aw.push(level_info(1,1u)); - aw.push(level_info(2,2u)); - aw.push(level_info(3,2u)); - aw.push(level_info(4,2u)); - aw.push(level_info(5,1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 2u)); + aw.push(level_info(3, 2u)); + aw.push(level_info(4, 2u)); + aw.push(level_info(5, 1u)); in->max_1level_cut = 3; } @@ -6061,34 +6098,32 @@ go_bandit([]() { // n7 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, terminal_T, terminal_F))); // n5 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_F, - node::pointer_type(5, node::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(3, node::max_id, terminal_F, node::pointer_type(5, node::max_id)))); // n1 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(3, node::max_id), - terminal_F))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, node::pointer_type(3, node::max_id), terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -6115,7 +6150,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); }); @@ -6133,8 +6168,10 @@ go_bandit([]() { // / \ || (4) is suppressable either way. // / \ || // | | || - // 5 7 6 ---- x5 <-- (5) and (7) should be merged but (6) blocks the view for fast-reduce - // / \ / \ / \ NOTE: the picture is (for sake of clarity) out-of-order + // 5 7 6 ---- x5 <-- (5) and (7) should be merged but (6) blocks the + view for fast-reduce + // / \ / \ / \ NOTE: the picture is (for sake of clarity) + out-of-order // | X | F T // \ / \ / // 8 9 ---- x6 (%2) @@ -6144,17 +6181,17 @@ go_bandit([]() { // / \ / \ // F T T F */ - const node::pointer_type n1(1,0); - const node::pointer_type n2(2,0); - const node::pointer_type n3(3,0); - const node::pointer_type n4(3,1); - const node::pointer_type n5(5,0); - const node::pointer_type n6(5,1); - const node::pointer_type n7(5,2); - const node::pointer_type n8(6,0); - const node::pointer_type n9(6,1); - const node::pointer_type n10(7,0); - const node::pointer_type n11(7,1); + const node::pointer_type n1(1, 0); + const node::pointer_type n2(2, 0); + const node::pointer_type n3(3, 0); + const node::pointer_type n4(3, 1); + const node::pointer_type n5(5, 0); + const node::pointer_type n6(5, 1); + const node::pointer_type n7(5, 2); + const node::pointer_type n8(6, 0); + const node::pointer_type n9(6, 1); + const node::pointer_type n10(7, 0); + const node::pointer_type n11(7, 1); const node::pointer_type terminal_F(false); const node::pointer_type terminal_T(true); @@ -6164,36 +6201,36 @@ go_bandit([]() { { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, true, n2 }); + aw.push_internal({ n1, true, n2 }); aw.push_internal({ n1, false, n3 }); aw.push_internal({ n2, false, n3 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n2, true, n4 }); aw.push_internal({ n3, false, n5 }); aw.push_internal({ n4, false, n6 }); - aw.push_internal({ n4, true, n6 }); - aw.push_internal({ n3, true, n7 }); + aw.push_internal({ n4, true, n6 }); + aw.push_internal({ n3, true, n7 }); aw.push_internal({ n5, false, n8 }); aw.push_internal({ n7, false, n8 }); - aw.push_internal({ n5, true, n9 }); - aw.push_internal({ n7, true, n9 }); - aw.push_internal({ n8, true, n10 }); - aw.push_internal({ n9, true, n11 }); - - aw.push_terminal({ n6, false, terminal_F }); - aw.push_terminal({ n6, true, terminal_T }); - aw.push_terminal({ n8, false, terminal_F }); - aw.push_terminal({ n9, false, terminal_T }); + aw.push_internal({ n5, true, n9 }); + aw.push_internal({ n7, true, n9 }); + aw.push_internal({ n8, true, n10 }); + aw.push_internal({ n9, true, n11 }); + + aw.push_terminal({ n6, false, terminal_F }); + aw.push_terminal({ n6, true, terminal_T }); + aw.push_terminal({ n8, false, terminal_F }); + aw.push_terminal({ n9, false, terminal_T }); aw.push_terminal({ n10, false, terminal_F }); - aw.push_terminal({ n10, true, terminal_T }); + aw.push_terminal({ n10, true, terminal_T }); aw.push_terminal({ n11, false, terminal_T }); - aw.push_terminal({ n11, true, terminal_F }); + aw.push_terminal({ n11, true, terminal_F }); - aw.push(level_info(1,1u)); - aw.push(level_info(2,1u)); - aw.push(level_info(3,2u)); - aw.push(level_info(5,3u)); - aw.push(level_info(6,2u)); - aw.push(level_info(7,2u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 1u)); + aw.push(level_info(3, 2u)); + aw.push(level_info(5, 3u)); + aw.push(level_info(6, 2u)); + aw.push(level_info(7, 2u)); in->max_1level_cut = 5; // TODO: why is this cut 5 and not 4? } @@ -6237,7 +6274,8 @@ go_bandit([]() { // n11 (doubly-negated) AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(7, node::max_id-1, terminal_T, terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(7, node::max_id - 1, terminal_T, terminal_F))); // n7 (singly-negated) AssertThat(out_nodes.can_pull(), Is().True()); @@ -6245,28 +6283,32 @@ go_bandit([]() { // n5/6 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id-1, - node::pointer_type(7, node::max_id), - node::pointer_type(7, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(5, + node::max_id - 1, + node::pointer_type(7, node::max_id), + node::pointer_type(7, node::max_id - 1)))); // n1 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(5, node::max_id-1), - node::pointer_type(5, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(5, node::max_id - 1), + node::pointer_type(5, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(7,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(7, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -6304,7 +6346,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(6u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); it("outputs an unordered, unmerged, and unsuppressed BDD if set to 'false'", [&]() { @@ -6346,51 +6388,61 @@ go_bandit([]() { // n10 (doubly-negated) AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(7, node::max_id-1, terminal_F, terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(7, node::max_id - 1, terminal_F, terminal_T))); // n7 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, - node::pointer_type(7, node::max_id-1), - node::pointer_type(7, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(5, + node::max_id, + node::pointer_type(7, node::max_id - 1), + node::pointer_type(7, node::max_id)))); // n6 (singly-negated) AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id-1, terminal_T, terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(5, node::max_id - 1, terminal_T, terminal_F))); // n5 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id-2, - node::pointer_type(7, node::max_id-1), - node::pointer_type(7, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(5, + node::max_id - 2, + node::pointer_type(7, node::max_id - 1), + node::pointer_type(7, node::max_id)))); // n3 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - node::pointer_type(5, node::max_id-2), - node::pointer_type(5, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(3, + node::max_id, + node::pointer_type(5, node::max_id - 2), + node::pointer_type(5, node::max_id)))); // n1 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(3, node::max_id), - node::pointer_type(5, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(3, node::max_id), + node::pointer_type(5, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(7,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(7, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5,3u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5, 3u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -6413,9 +6465,9 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(8u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); }); }); }); - }); +}); diff --git a/test/adiar/internal/algorithms/test_reduce.cpp b/test/adiar/internal/algorithms/test_reduce.cpp index fea531e76..7abea22b4 100644 --- a/test/adiar/internal/algorithms/test_reduce.cpp +++ b/test/adiar/internal/algorithms/test_reduce.cpp @@ -61,29 +61,29 @@ go_bandit([]() { // F T F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(2,0); - const arc::pointer_type n4(2,1); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(2, 0); + const arc::pointer_type n4(2, 1); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, true, n2 }); + aw.push_internal({ n1, true, n2 }); aw.push_internal({ n1, false, n3 }); aw.push_internal({ n2, false, n4 }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); aw.push_terminal({ n3, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); - aw.push(level_info(2,2u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 2u)); } in->max_1level_cut = 2; @@ -99,33 +99,33 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); // n4 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n2 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, node::pointer_type(2, node::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(2, node::max_id), - node::pointer_type(1, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(2, node::max_id), + node::pointer_type(1, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -146,7 +146,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("applies to terminal arcs [2]", [&]() { @@ -162,11 +162,11 @@ go_bandit([]() { // /| |\ / \ // FT FT F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(2,0); - const arc::pointer_type n3(2,1); - const arc::pointer_type n4(3,0); - const arc::pointer_type n5(3,1); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(2, 0); + const arc::pointer_type n3(2, 1); + const arc::pointer_type n4(3, 0); + const arc::pointer_type n5(3, 1); shared_levelized_file in; @@ -174,20 +174,20 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n1, true, n3 }); aw.push_internal({ n3, false, n4 }); - aw.push_internal({ n2, true, n5 }); + aw.push_internal({ n2, true, n5 }); aw.push_terminal({ n2, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); aw.push_terminal({ n5, false, terminal_F }); - aw.push_terminal({ n5, true, terminal_T }); + aw.push_terminal({ n5, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(2,2u)); - aw.push(level_info(3,2u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(2, 2u)); + aw.push(level_info(3, 2u)); } in->max_1level_cut = 2; @@ -201,36 +201,36 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - node::pointer_type(3, node::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, node::max_id, node::pointer_type(3, node::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-1, - terminal_F, - node::pointer_type(3, node::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, node::max_id - 1, terminal_F, node::pointer_type(3, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(2, node::max_id-1), - node::pointer_type(2, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(2, node::max_id - 1), + node::pointer_type(2, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -251,7 +251,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(5u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("applies to node arcs [1]", [&]() { @@ -267,36 +267,36 @@ go_bandit([]() { // F T T F F T F */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(2,0); - const arc::pointer_type n4(2,1); - const arc::pointer_type n5(3,0); - const arc::pointer_type n6(3,1); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(2, 0); + const arc::pointer_type n4(2, 1); + const arc::pointer_type n5(3, 0); + const arc::pointer_type n6(3, 1); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, true, n2 }); + aw.push_internal({ n1, true, n2 }); aw.push_internal({ n1, false, n3 }); aw.push_internal({ n2, false, n4 }); aw.push_internal({ n3, false, n5 }); aw.push_internal({ n4, false, n5 }); - aw.push_internal({ n3, true, n6 }); - aw.push_internal({ n4, true, n6 }); + aw.push_internal({ n3, true, n6 }); + aw.push_internal({ n4, true, n6 }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); aw.push_terminal({ n5, false, terminal_F }); - aw.push_terminal({ n5, true, terminal_T }); + aw.push_terminal({ n5, true, terminal_T }); aw.push_terminal({ n6, false, terminal_T }); - aw.push_terminal({ n6, true, terminal_F }); + aw.push_terminal({ n6, true, terminal_F }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); - aw.push(level_info(2,2u)); - aw.push(level_info(3,2u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 2u)); + aw.push(level_info(3, 2u)); } in->max_1level_cut = 4; @@ -316,41 +316,45 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); // n6 - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id-1, terminal_T, terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(3, node::max_id - 1, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); // n4 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - node::pointer_type(3, node::max_id), - node::pointer_type(3, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id, + node::pointer_type(3, node::max_id), + node::pointer_type(3, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // n2 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, node::pointer_type(2, node::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(2, node::max_id), - node::pointer_type(1, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(2, node::max_id), + node::pointer_type(1, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); - level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -371,7 +375,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(6u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); it("applies to both node and terminal arcs", [&]() { @@ -387,33 +391,33 @@ go_bandit([]() { // F T F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(2,0); - const arc::pointer_type n4(2,1); - const arc::pointer_type n5(3,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(2, 0); + const arc::pointer_type n4(2, 1); + const arc::pointer_type n5(3, 0); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, true, n2 }); + aw.push_internal({ n1, true, n2 }); aw.push_internal({ n1, false, n3 }); aw.push_internal({ n2, false, n4 }); aw.push_internal({ n3, false, n5 }); aw.push_internal({ n4, false, n5 }); - aw.push_terminal({ n2, true, terminal_T }); - aw.push_terminal({ n3, true, terminal_T }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); aw.push_terminal({ n5, false, terminal_F }); - aw.push_terminal({ n5, true, terminal_T }); + aw.push_terminal({ n5, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); - aw.push(level_info(2,2u)); - aw.push(level_info(3,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 2u)); + aw.push(level_info(3, 1u)); } in->max_1level_cut = 4; @@ -433,36 +437,38 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); // n4 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - node::pointer_type(3, node::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, node::max_id, node::pointer_type(3, node::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n2 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, node::pointer_type(2, node::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(2, node::max_id), - node::pointer_type(1, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(2, node::max_id), + node::pointer_type(1, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -488,7 +494,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(5u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); it("applies to 'disjoint' branches", [&]() { @@ -505,13 +511,13 @@ go_bandit([]() { // F T F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); - const arc::pointer_type n5(2,1); - const arc::pointer_type n6(2,2); - const arc::pointer_type n7(3,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); + const arc::pointer_type n5(2, 1); + const arc::pointer_type n6(2, 2); + const arc::pointer_type n7(3, 0); shared_levelized_file in; @@ -519,25 +525,25 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n1, true, n3 }); aw.push_internal({ n2, false, n4 }); - aw.push_internal({ n2, true, n5 }); + aw.push_internal({ n2, true, n5 }); aw.push_internal({ n3, false, n5 }); - aw.push_internal({ n3, true, n6 }); + aw.push_internal({ n3, true, n6 }); aw.push_internal({ n5, false, n7 }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_T }); - aw.push_terminal({ n5, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n5, true, terminal_T }); aw.push_terminal({ n6, false, terminal_F }); - aw.push_terminal({ n6, true, terminal_T }); + aw.push_terminal({ n6, true, terminal_T }); aw.push_terminal({ n7, false, terminal_F }); aw.push_terminal({ n7, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,3u)); - aw.push(level_info(3,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 3u)); + aw.push(level_info(3, 1u)); } in->max_1level_cut = 4; @@ -553,54 +559,56 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); // n7 - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n6 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n5 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-1, - node::pointer_type(3, node::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, node::max_id - 1, node::pointer_type(3, node::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n3 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id-1), - node::pointer_type(2, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(2, node::max_id - 1), + node::pointer_type(2, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n2 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id-1, - node::pointer_type(2, node::max_id), - node::pointer_type(2, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id - 1, + node::pointer_type(2, node::max_id), + node::pointer_type(2, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(1, node::max_id-1), - node::pointer_type(1, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(1, node::max_id - 1), + node::pointer_type(1, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -625,7 +633,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(7u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); it("does forward the correct children [1]", [&]() { @@ -639,12 +647,12 @@ go_bandit([]() { // F T F T T F F T T F */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); - const arc::pointer_type n5(2,1); - const arc::pointer_type n6(2,2); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); + const arc::pointer_type n5(2, 1); + const arc::pointer_type n6(2, 2); shared_levelized_file in; @@ -652,22 +660,22 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n1, true, n3 }); aw.push_internal({ n2, false, n4 }); - aw.push_internal({ n2, true, n5 }); + aw.push_internal({ n2, true, n5 }); aw.push_internal({ n3, false, n5 }); - aw.push_internal({ n3, true, n6 }); + aw.push_internal({ n3, true, n6 }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); aw.push_terminal({ n5, false, terminal_F }); - aw.push_terminal({ n5, true, terminal_T }); + aw.push_terminal({ n5, true, terminal_T }); aw.push_terminal({ n6, false, terminal_T }); - aw.push_terminal({ n6, true, terminal_F }); + aw.push_terminal({ n6, true, terminal_F }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,3u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 3u)); } in->max_1level_cut = 4; @@ -681,37 +689,38 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); // 5 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // 6 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-1, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, node::max_id - 1, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); // 3 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id), - node::pointer_type(2, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(2, node::max_id), + node::pointer_type(2, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // 1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(2, node::max_id), - node::pointer_type(1, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(2, node::max_id), + node::pointer_type(1, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -735,7 +744,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(5u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("does forward the correct children [2]", [&]() { @@ -749,12 +758,12 @@ go_bandit([]() { // T F T F F T T F F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); - const arc::pointer_type n5(2,1); - const arc::pointer_type n6(2,2); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); + const arc::pointer_type n5(2, 1); + const arc::pointer_type n6(2, 2); shared_levelized_file in; @@ -762,22 +771,22 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n1, true, n3 }); aw.push_internal({ n2, false, n4 }); - aw.push_internal({ n2, true, n5 }); + aw.push_internal({ n2, true, n5 }); aw.push_internal({ n3, false, n5 }); - aw.push_internal({ n3, true, n6 }); + aw.push_internal({ n3, true, n6 }); aw.push_terminal({ n4, false, terminal_T }); - aw.push_terminal({ n4, true, terminal_F }); + aw.push_terminal({ n4, true, terminal_F }); aw.push_terminal({ n5, false, terminal_T }); - aw.push_terminal({ n5, true, terminal_F }); + aw.push_terminal({ n5, true, terminal_F }); aw.push_terminal({ n6, false, terminal_F }); - aw.push_terminal({ n6, true, terminal_T }); + aw.push_terminal({ n6, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,3u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 3u)); } in->max_1level_cut = 4; @@ -791,37 +800,38 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); // 6 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // 5 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-1, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, node::max_id - 1, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); // 3 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id-1), - node::pointer_type(2, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(2, node::max_id - 1), + node::pointer_type(2, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // 1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(2, node::max_id-1), - node::pointer_type(1, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(2, node::max_id - 1), + node::pointer_type(1, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -844,7 +854,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(5u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); }); @@ -860,29 +870,29 @@ go_bandit([]() { // F T F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(2,0); - const arc::pointer_type n4(2,1); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(2, 0); + const arc::pointer_type n4(2, 1); shared_levelized_file in; { // Garbage collect writer early arc_writer aw(in); - aw.push_internal({ n1, true, n2 }); + aw.push_internal({ n1, true, n2 }); aw.push_internal({ n1, false, n3 }); aw.push_internal({ n2, false, n3 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n2, true, n4 }); aw.push_terminal({ n3, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); aw.push_terminal({ n4, false, terminal_T }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); - aw.push(level_info(2,2u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 2u)); } in->max_1level_cut = 3; @@ -898,34 +908,33 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); // n3 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n2 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, node::pointer_type(2, node::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(2, node::max_id), - node::pointer_type(1, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(2, node::max_id), + node::pointer_type(1, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); - level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -946,7 +955,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("applies to node arcs", [&]() { @@ -962,33 +971,33 @@ go_bandit([]() { // F T F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(2,0); - const arc::pointer_type n4(2,1); - const arc::pointer_type n5(3,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(2, 0); + const arc::pointer_type n4(2, 1); + const arc::pointer_type n5(3, 0); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, true, n2 }); + aw.push_internal({ n1, true, n2 }); aw.push_internal({ n1, false, n3 }); aw.push_internal({ n2, false, n3 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n2, true, n4 }); aw.push_internal({ n4, false, n5 }); - aw.push_internal({ n4, true, n5 }); + aw.push_internal({ n4, true, n5 }); aw.push_terminal({ n3, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); aw.push_terminal({ n5, false, terminal_F }); - aw.push_terminal({ n5, true, terminal_T }); + aw.push_terminal({ n5, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); - aw.push(level_info(2,2u)); - aw.push(level_info(3,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 2u)); + aw.push(level_info(3, 1u)); } in->max_1level_cut = 3; @@ -1012,31 +1021,34 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); // n2 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id), - node::pointer_type(3, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(2, node::max_id), + node::pointer_type(3, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(2, node::max_id), - node::pointer_type(1, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(2, node::max_id), + node::pointer_type(1, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); - level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1060,7 +1072,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(5u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("works with two reductions on the same level", [&]() { @@ -1074,11 +1086,11 @@ go_bandit([]() { // F T T F F T T F */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); - const arc::pointer_type n5(2,1); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); + const arc::pointer_type n5(2, 1); shared_levelized_file in; @@ -1086,20 +1098,20 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n1, true, n3 }); aw.push_internal({ n2, false, n4 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n2, true, n4 }); aw.push_internal({ n3, false, n5 }); - aw.push_internal({ n3, true, n5 }); + aw.push_internal({ n3, true, n5 }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); aw.push_terminal({ n5, false, terminal_T }); - aw.push_terminal({ n5, true, terminal_F }); + aw.push_terminal({ n5, true, terminal_F }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,2u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 2u)); } in->max_1level_cut = 4; @@ -1119,23 +1131,25 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); // n4 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-1, terminal_T, terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, node::max_id - 1, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(2, node::max_id), - node::pointer_type(2, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(2, node::max_id), + node::pointer_type(2, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().False()); - level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1160,7 +1174,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("can be applied together with reduction rule 2 [1]", [&]() { @@ -1174,10 +1188,10 @@ go_bandit([]() { // F T F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(2,0); - const arc::pointer_type n4(2,1); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(2, 0); + const arc::pointer_type n4(2, 1); shared_levelized_file in; @@ -1186,17 +1200,17 @@ go_bandit([]() { aw.push_internal({ n1, false, n2 }); aw.push_internal({ n2, false, n3 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n2, true, n4 }); - aw.push_terminal({ n1, true, terminal_T }); + aw.push_terminal({ n1, true, terminal_T }); aw.push_terminal({ n3, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); - aw.push(level_info(2,2u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 2u)); } in->max_1level_cut = 2; @@ -1212,24 +1226,22 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); // n4 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(2, node::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, node::max_id, node::pointer_type(2, node::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1254,7 +1266,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("can be applied together with reduction rule 2 [2]", [&]() { @@ -1270,12 +1282,12 @@ go_bandit([]() { // F T F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); - const arc::pointer_type n5(2,1); - const arc::pointer_type n6(3,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); + const arc::pointer_type n5(2, 1); + const arc::pointer_type n6(3, 0); shared_levelized_file in; @@ -1283,23 +1295,23 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n2, true, n4 }); aw.push_internal({ n3, false, n4 }); - aw.push_internal({ n3, true, n5 }); + aw.push_internal({ n3, true, n5 }); aw.push_internal({ n2, false, n6 }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); aw.push_terminal({ n5, false, terminal_F }); - aw.push_terminal({ n5, true, terminal_T }); + aw.push_terminal({ n5, true, terminal_T }); aw.push_terminal({ n6, false, terminal_F }); - aw.push_terminal({ n6, true, terminal_T }); + aw.push_terminal({ n6, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,2u)); - aw.push(level_info(3,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 2u)); + aw.push(level_info(3, 1u)); } in->max_1level_cut = 4; @@ -1314,42 +1326,42 @@ go_bandit([]() { // n6 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, terminal_F, terminal_T))); // n4 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); // n2 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(3, node::max_id), - node::pointer_type(2, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(3, node::max_id), + node::pointer_type(2, node::max_id)))); // n1 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(1, node::max_id), - node::pointer_type(2, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(1, node::max_id), + node::pointer_type(2, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1381,7 +1393,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(5u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("can reduce the root [1]", [&]() { @@ -1395,29 +1407,29 @@ go_bandit([]() { // F T F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(2,0); - const arc::pointer_type n4(2,1); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(2, 0); + const arc::pointer_type n4(2, 1); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, true, n2 }); + aw.push_internal({ n1, true, n2 }); aw.push_internal({ n1, false, n3 }); aw.push_internal({ n2, false, n3 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n2, true, n4 }); aw.push_terminal({ n3, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); - aw.push(level_info(2,2u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 2u)); } in->max_1level_cut = 3; @@ -1439,7 +1451,7 @@ go_bandit([]() { level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1456,7 +1468,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("can reduce the root [2]", [&]() { @@ -1474,15 +1486,15 @@ go_bandit([]() { // F T F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); - const arc::pointer_type n5(2,1); - const arc::pointer_type n6(3,0); - const arc::pointer_type n7(3,1); - const arc::pointer_type n8(3,2); - const arc::pointer_type n9(4,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); + const arc::pointer_type n5(2, 1); + const arc::pointer_type n6(3, 0); + const arc::pointer_type n7(3, 1); + const arc::pointer_type n8(3, 2); + const arc::pointer_type n9(4, 0); shared_levelized_file in; @@ -1490,30 +1502,30 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n1, true, n3 }); aw.push_internal({ n2, false, n4 }); aw.push_internal({ n3, false, n4 }); - aw.push_internal({ n2, true, n5 }); - aw.push_internal({ n3, true, n5 }); + aw.push_internal({ n2, true, n5 }); + aw.push_internal({ n3, true, n5 }); aw.push_internal({ n4, false, n6 }); - aw.push_internal({ n4, true, n7 }); + aw.push_internal({ n4, true, n7 }); aw.push_internal({ n5, false, n7 }); - aw.push_internal({ n5, true, n8 }); - aw.push_internal({ n6, true, n9 }); + aw.push_internal({ n5, true, n8 }); + aw.push_internal({ n6, true, n9 }); aw.push_internal({ n7, false, n9 }); aw.push_terminal({ n6, false, terminal_F }); - aw.push_terminal({ n7, true, terminal_T }); + aw.push_terminal({ n7, true, terminal_T }); aw.push_terminal({ n8, false, terminal_F }); - aw.push_terminal({ n8, true, terminal_T }); + aw.push_terminal({ n8, true, terminal_T }); aw.push_terminal({ n9, false, terminal_F }); - aw.push_terminal({ n9, true, terminal_T }); + aw.push_terminal({ n9, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,2u)); - aw.push(level_info(3,3u)); - aw.push(level_info(4,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 2u)); + aw.push(level_info(3, 3u)); + aw.push(level_info(4, 1u)); } in->max_1level_cut = 4; @@ -1533,52 +1545,55 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); // n8 - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n7 - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id-1, - node::pointer_type(4, node::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(3, node::max_id - 1, node::pointer_type(4, node::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n6 - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id-2, - terminal_F, - node::pointer_type(4, node::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(3, node::max_id - 2, terminal_F, node::pointer_type(4, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n5 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - node::pointer_type(3, node::max_id-1), - node::pointer_type(3, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id, + node::pointer_type(3, node::max_id - 1), + node::pointer_type(3, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n4 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-1, - node::pointer_type(3, node::max_id-2), - node::pointer_type(3, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id - 1, + node::pointer_type(3, node::max_id - 2), + node::pointer_type(3, node::max_id - 1)))); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id-1), - node::pointer_type(2, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(2, node::max_id - 1), + node::pointer_type(2, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); - level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,3u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 3u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1599,7 +1614,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(8u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); it("accounts for multiple ingoing arcs to reduction rule 1 node", [&]() { @@ -1615,12 +1630,12 @@ go_bandit([]() { // T F F T T T T F F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(2,0); - const arc::pointer_type n4(3,0); - const arc::pointer_type n5(3,1); - const arc::pointer_type n6(3,2); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(2, 0); + const arc::pointer_type n4(3, 0); + const arc::pointer_type n5(3, 1); + const arc::pointer_type n6(3, 2); shared_levelized_file in; @@ -1630,21 +1645,21 @@ go_bandit([]() { aw.push_internal({ n1, false, n2 }); aw.push_internal({ n2, false, n3 }); aw.push_internal({ n3, false, n4 }); - aw.push_internal({ n3, true, n5 }); - aw.push_internal({ n1, true, n6 }); - aw.push_internal({ n2, true, n6 }); + aw.push_internal({ n3, true, n5 }); + aw.push_internal({ n1, true, n6 }); + aw.push_internal({ n2, true, n6 }); aw.push_terminal({ n4, false, terminal_T }); - aw.push_terminal({ n4, true, terminal_F }); + aw.push_terminal({ n4, true, terminal_F }); aw.push_terminal({ n5, false, terminal_F }); - aw.push_terminal({ n5, true, terminal_T }); + aw.push_terminal({ n5, true, terminal_T }); aw.push_terminal({ n6, false, terminal_T }); - aw.push_terminal({ n6, true, terminal_T }); + aw.push_terminal({ n6, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); - aw.push(level_info(2,1u)); - aw.push(level_info(3,3u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 1u)); + aw.push(level_info(3, 3u)); } in->max_1level_cut = 4; @@ -1659,47 +1674,46 @@ go_bandit([]() { // n4 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id-1, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(3, node::max_id - 1, terminal_T, terminal_F))); // n4 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - node::pointer_type(3, node::max_id-1), - node::pointer_type(3, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id, + node::pointer_type(3, node::max_id - 1), + node::pointer_type(3, node::max_id)))); // n2 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, node::pointer_type(2, node::max_id), terminal_T))); // n1 AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(1, node::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, node::max_id, node::pointer_type(1, node::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1726,7 +1740,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(6u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); }); it("can apply reduction rule 1 to a single node", [&]() { @@ -1736,7 +1750,7 @@ go_bandit([]() { // F F */ - const arc::pointer_type n1(0,0); + const arc::pointer_type n1(0, 0); shared_levelized_file in; @@ -1744,9 +1758,9 @@ go_bandit([]() { arc_writer aw(in); aw.push_terminal({ n1, false, terminal_F }); - aw.push_terminal({ n1, true, terminal_F }); + aw.push_terminal({ n1, true, terminal_F }); - aw.push(level_info(0,1u)); + aw.push(level_info(0, 1u)); } in->max_1level_cut = 0; @@ -1781,7 +1795,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(0u)); }); it("can propagate reduction rule 1 up to a terminal", [&]() { @@ -1793,22 +1807,22 @@ go_bandit([]() { // T T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, true, n2 }); + aw.push_internal({ n1, true, n2 }); aw.push_terminal({ n1, false, terminal_T }); aw.push_terminal({ n2, false, terminal_T }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); } in->max_1level_cut = 1; @@ -1841,7 +1855,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("can return non-reducible single-node variable with max_id", [&]() { @@ -1851,7 +1865,7 @@ go_bandit([]() { // F T F T */ - const arc::pointer_type n1(0,0); + const arc::pointer_type n1(0, 0); shared_levelized_file in; @@ -1859,9 +1873,9 @@ go_bandit([]() { arc_writer aw(in); aw.push_terminal({ n1, false, terminal_F }); - aw.push_terminal({ n1, true, terminal_T }); + aw.push_terminal({ n1, true, terminal_T }); - aw.push(level_info(0u,1u)); + aw.push(level_info(0u, 1u)); } in->max_1level_cut = 0; @@ -1881,7 +1895,7 @@ go_bandit([]() { level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0u,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0u, 1u))); AssertThat(out_meta.can_pull(), Is().False()); AssertThat(out->width, Is().EqualTo(1u)); @@ -1897,7 +1911,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("can account for a chain of don't cares contributing to the maximum cut [1]", [&]() { @@ -1917,17 +1931,17 @@ go_bandit([]() { // T F T T F F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); - const arc::pointer_type n5(2,1); - const arc::pointer_type n6(3,0); - const arc::pointer_type n7(3,1); - const arc::pointer_type n8(4,0); - const arc::pointer_type n9(4,1); - const arc::pointer_type n10(5,0); - const arc::pointer_type n11(5,1); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); + const arc::pointer_type n5(2, 1); + const arc::pointer_type n6(3, 0); + const arc::pointer_type n7(3, 1); + const arc::pointer_type n8(4, 0); + const arc::pointer_type n9(4, 1); + const arc::pointer_type n10(5, 0); + const arc::pointer_type n11(5, 1); shared_levelized_file in; @@ -1935,35 +1949,35 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n1, true, n3 }); aw.push_internal({ n2, false, n4 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n2, true, n4 }); aw.push_internal({ n3, false, n4 }); - aw.push_internal({ n3, true, n5 }); + aw.push_internal({ n3, true, n5 }); aw.push_internal({ n4, false, n6 }); - aw.push_internal({ n4, true, n6 }); + aw.push_internal({ n4, true, n6 }); aw.push_internal({ n5, false, n6 }); - aw.push_internal({ n5, true, n7 }); + aw.push_internal({ n5, true, n7 }); aw.push_internal({ n6, false, n8 }); - aw.push_internal({ n6, true, n8 }); + aw.push_internal({ n6, true, n8 }); aw.push_internal({ n7, false, n8 }); - aw.push_internal({ n7, true, n9 }); + aw.push_internal({ n7, true, n9 }); aw.push_internal({ n8, false, n10 }); - aw.push_internal({ n8, true, n10 }); + aw.push_internal({ n8, true, n10 }); aw.push_internal({ n9, false, n10 }); - aw.push_internal({ n9, true, n11 }); + aw.push_internal({ n9, true, n11 }); aw.push_terminal({ n10, false, terminal_T }); - aw.push_terminal({ n10, true, terminal_F }); + aw.push_terminal({ n10, true, terminal_F }); aw.push_terminal({ n11, false, terminal_F }); - aw.push_terminal({ n11, true, terminal_T }); - - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,2u)); - aw.push(level_info(3,2u)); - aw.push(level_info(4,2u)); - aw.push(level_info(5,2u)); + aw.push_terminal({ n11, true, terminal_T }); + + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 2u)); + aw.push(level_info(3, 2u)); + aw.push(level_info(4, 2u)); + aw.push(level_info(5, 2u)); } in->max_1level_cut = 4; @@ -1977,62 +1991,68 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); // n11 - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n10 - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id-1, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(5, node::max_id - 1, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); // n9 - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - node::pointer_type(5, node::max_id-1), - node::pointer_type(5, node::max_id)))); - + AssertThat(out_nodes.pull(), + Is().EqualTo(node(4, + node::max_id, + node::pointer_type(5, node::max_id - 1), + node::pointer_type(5, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n7 - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - node::pointer_type(5, node::max_id-1), - node::pointer_type(4, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(3, + node::max_id, + node::pointer_type(5, node::max_id - 1), + node::pointer_type(4, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n5 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - node::pointer_type(5, node::max_id-1), - node::pointer_type(3, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id, + node::pointer_type(5, node::max_id - 1), + node::pointer_type(3, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n3 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(5, node::max_id-1), - node::pointer_type(2, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(5, node::max_id - 1), + node::pointer_type(2, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(5, node::max_id-1), - node::pointer_type(1, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(5, node::max_id - 1), + node::pointer_type(1, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -2057,7 +2077,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(8u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("can account for a chain of don't cares contributing to the maximum cut [2]", [&]() { @@ -2077,62 +2097,62 @@ go_bandit([]() { // T F T T F F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); - const arc::pointer_type n5(2,1); - const arc::pointer_type n6(2,2); - const arc::pointer_type n7(3,0); - const arc::pointer_type n8(3,1); - const arc::pointer_type n9(3,2); - const arc::pointer_type n10(4,0); - const arc::pointer_type n11(4,1); - const arc::pointer_type n12(4,2); - const arc::pointer_type n13(5,0); - const arc::pointer_type n14(5,1); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); + const arc::pointer_type n5(2, 1); + const arc::pointer_type n6(2, 2); + const arc::pointer_type n7(3, 0); + const arc::pointer_type n8(3, 1); + const arc::pointer_type n9(3, 2); + const arc::pointer_type n10(4, 0); + const arc::pointer_type n11(4, 1); + const arc::pointer_type n12(4, 2); + const arc::pointer_type n13(5, 0); + const arc::pointer_type n14(5, 1); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); - aw.push_internal({ n2, false, n4 }); - aw.push_internal({ n2, true, n5 }); - aw.push_internal({ n3, false, n5 }); - aw.push_internal({ n3, true, n6 }); - aw.push_internal({ n4, false, n7 }); - aw.push_internal({ n4, true, n8 }); - aw.push_internal({ n5, false, n8 }); - aw.push_internal({ n5, true, n8 }); - aw.push_internal({ n6, false, n8 }); - aw.push_internal({ n6, true, n9 }); - aw.push_internal({ n7, false, n10 }); - aw.push_internal({ n7, true, n11 }); - aw.push_internal({ n8, false, n11 }); - aw.push_internal({ n8, true, n11 }); - aw.push_internal({ n9, false, n11 }); - aw.push_internal({ n9, true, n12 }); - aw.push_internal({ n10, true, n13 }); + aw.push_internal({ n1, false, n2 }); + aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n2, false, n4 }); + aw.push_internal({ n2, true, n5 }); + aw.push_internal({ n3, false, n5 }); + aw.push_internal({ n3, true, n6 }); + aw.push_internal({ n4, false, n7 }); + aw.push_internal({ n4, true, n8 }); + aw.push_internal({ n5, false, n8 }); + aw.push_internal({ n5, true, n8 }); + aw.push_internal({ n6, false, n8 }); + aw.push_internal({ n6, true, n9 }); + aw.push_internal({ n7, false, n10 }); + aw.push_internal({ n7, true, n11 }); + aw.push_internal({ n8, false, n11 }); + aw.push_internal({ n8, true, n11 }); + aw.push_internal({ n9, false, n11 }); + aw.push_internal({ n9, true, n12 }); + aw.push_internal({ n10, true, n13 }); aw.push_internal({ n11, false, n13 }); - aw.push_internal({ n11, true, n13 }); + aw.push_internal({ n11, true, n13 }); aw.push_internal({ n12, false, n13 }); aw.push_internal({ n10, false, n14 }); - aw.push_internal({ n12, true, n14 }); + aw.push_internal({ n12, true, n14 }); aw.push_terminal({ n13, false, terminal_T }); - aw.push_terminal({ n13, true, terminal_F }); + aw.push_terminal({ n13, true, terminal_F }); aw.push_terminal({ n14, false, terminal_F }); - aw.push_terminal({ n14, true, terminal_T }); - - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,3u)); - aw.push(level_info(3,3u)); - aw.push(level_info(4,3u)); - aw.push(level_info(5,2u)); + aw.push_terminal({ n14, true, terminal_T }); + + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 3u)); + aw.push(level_info(3, 3u)); + aw.push(level_info(4, 3u)); + aw.push(level_info(5, 2u)); } in->max_1level_cut = 8; @@ -2146,81 +2166,96 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); // n14 - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n13 - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id-1, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(5, node::max_id - 1, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); // n12 - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - node::pointer_type(5, node::max_id-1), - node::pointer_type(5, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(4, + node::max_id, + node::pointer_type(5, node::max_id - 1), + node::pointer_type(5, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n10 - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id-1, - node::pointer_type(5, node::max_id), - node::pointer_type(5, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(4, + node::max_id - 1, + node::pointer_type(5, node::max_id), + node::pointer_type(5, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // n7 - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - node::pointer_type(4, node::max_id-1), - node::pointer_type(5, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(3, + node::max_id, + node::pointer_type(4, node::max_id - 1), + node::pointer_type(5, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // n9 - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id-1, - node::pointer_type(5, node::max_id-1), - node::pointer_type(4, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(3, + node::max_id - 1, + node::pointer_type(5, node::max_id - 1), + node::pointer_type(4, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n4 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - node::pointer_type(3, node::max_id), - node::pointer_type(5, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id, + node::pointer_type(3, node::max_id), + node::pointer_type(5, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // n6 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-1, - node::pointer_type(5, node::max_id-1), - node::pointer_type(3, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id - 1, + node::pointer_type(5, node::max_id - 1), + node::pointer_type(3, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // n2 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id), - node::pointer_type(5, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(2, node::max_id), + node::pointer_type(5, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // n3 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id-1, - node::pointer_type(5, node::max_id-1), - node::pointer_type(2, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id - 1, + node::pointer_type(5, node::max_id - 1), + node::pointer_type(2, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(1, node::max_id), - node::pointer_type(1, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(1, node::max_id), + node::pointer_type(1, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(4,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(4, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -2245,7 +2280,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(15u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("applies tainted arcs eagerly to the maximum cut", [&]() { @@ -2263,14 +2298,14 @@ go_bandit([]() { // F T F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); - const arc::pointer_type n5(2,1); - const arc::pointer_type n6(2,2); - const arc::pointer_type n7(3,0); - const arc::pointer_type n8(4,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); + const arc::pointer_type n5(2, 1); + const arc::pointer_type n6(2, 2); + const arc::pointer_type n7(3, 0); + const arc::pointer_type n8(4, 0); shared_levelized_file in; @@ -2278,28 +2313,28 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n1, true, n3 }); aw.push_internal({ n2, false, n4 }); - aw.push_internal({ n2, true, n5 }); + aw.push_internal({ n2, true, n5 }); aw.push_internal({ n3, false, n5 }); - aw.push_internal({ n3, true, n6 }); - aw.push_internal({ n5, true, n7 }); + aw.push_internal({ n3, true, n6 }); + aw.push_internal({ n5, true, n7 }); aw.push_internal({ n7, false, n8 }); - aw.push_internal({ n7, true, n8 }); + aw.push_internal({ n7, true, n8 }); aw.push_terminal({ n4, false, terminal_F }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); aw.push_terminal({ n5, false, terminal_F }); aw.push_terminal({ n6, false, terminal_T }); - aw.push_terminal({ n6, true, terminal_F }); + aw.push_terminal({ n6, true, terminal_F }); aw.push_terminal({ n8, false, terminal_F }); - aw.push_terminal({ n8, true, terminal_T }); + aw.push_terminal({ n8, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,3u)); - aw.push(level_info(3,1u)); - aw.push(level_info(4,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 3u)); + aw.push(level_info(3, 1u)); + aw.push(level_info(4, 1u)); in->max_1level_cut = 4; } @@ -2319,41 +2354,50 @@ go_bandit([]() { AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n6 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-1, terminal_T, terminal_F))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, node::max_id - 1, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().True()); // n5 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-2, terminal_F, node::pointer_type(4, node::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, node::max_id - 2, terminal_F, node::pointer_type(4, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n3 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id-2), - node::pointer_type(2, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(2, node::max_id - 2), + node::pointer_type(2, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // n2 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id-1, - node::pointer_type(2, node::max_id), - node::pointer_type(2, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id - 1, + node::pointer_type(2, node::max_id), + node::pointer_type(2, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // n2 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(1, node::max_id-1), - node::pointer_type(1, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(1, node::max_id - 1), + node::pointer_type(1, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,3u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 3u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -2381,7 +2425,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(9u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(4u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); it("merges nodes, despite of reduction rule 1 flag on child", [&]() { @@ -2395,10 +2439,10 @@ go_bandit([]() { // T T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); shared_levelized_file in; @@ -2406,18 +2450,18 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n2, true, n4 }); aw.push_terminal({ n2, false, terminal_F }); aw.push_terminal({ n3, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); aw.push_terminal({ n4, false, terminal_T }); - aw.push_terminal({ n4, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 1u)); } in->max_1level_cut = 2; @@ -2438,7 +2482,7 @@ go_bandit([]() { level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -2455,7 +2499,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); }); @@ -2469,22 +2513,22 @@ go_bandit([]() { // T F */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, true, n2 }); + aw.push_internal({ n1, true, n2 }); aw.push_terminal({ n1, false, terminal_T }); aw.push_terminal({ n2, false, terminal_T }); - aw.push_terminal({ n2, true, terminal_F }); + aw.push_terminal({ n2, true, terminal_F }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); } in->max_1level_cut = 1; @@ -2505,7 +2549,7 @@ go_bandit([]() { level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -2522,7 +2566,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("applies to node arcs", [&]() { @@ -2538,33 +2582,33 @@ go_bandit([]() { // F T F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(2,0); - const arc::pointer_type n4(2,1); - const arc::pointer_type n5(3,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(2, 0); + const arc::pointer_type n4(2, 1); + const arc::pointer_type n5(3, 0); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, true, n2 }); + aw.push_internal({ n1, true, n2 }); aw.push_internal({ n1, false, n3 }); aw.push_internal({ n2, false, n3 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n2, true, n4 }); aw.push_internal({ n4, false, n5 }); aw.push_terminal({ n3, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_T }); - aw.push_terminal({ n4, true, terminal_F }); + aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n4, true, terminal_F }); aw.push_terminal({ n5, false, terminal_F }); - aw.push_terminal({ n5, true, terminal_T }); + aw.push_terminal({ n5, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); - aw.push(level_info(2,2u)); - aw.push(level_info(3,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); + aw.push(level_info(2, 2u)); + aw.push(level_info(3, 1u)); } in->max_1level_cut = 3; @@ -2588,31 +2632,34 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); // n2 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id), - node::pointer_type(3, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(2, node::max_id), + node::pointer_type(3, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(2, node::max_id), - node::pointer_type(1, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(2, node::max_id), + node::pointer_type(1, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); - level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -2641,7 +2688,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(5u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("can be applied together with reduction rule 2", [&]() { @@ -2655,10 +2702,10 @@ go_bandit([]() { // T F */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); shared_levelized_file in; @@ -2666,18 +2713,18 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); - aw.push_internal({ n3, true, n4 }); + aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n3, true, n4 }); aw.push_terminal({ n2, false, terminal_F }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); aw.push_terminal({ n3, false, terminal_F }); aw.push_terminal({ n4, false, terminal_T }); - aw.push_terminal({ n4, true,terminal_F }); + aw.push_terminal({ n4, true, terminal_F }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 1u)); } in->max_1level_cut = 2; @@ -2693,24 +2740,24 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); // n3 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(1, node::max_id), - node::pointer_type(1, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(1, node::max_id), + node::pointer_type(1, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -2737,7 +2784,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("applies to a single node", [&]() { @@ -2747,7 +2794,7 @@ go_bandit([]() { // T F */ - const arc::pointer_type n1(0,0); + const arc::pointer_type n1(0, 0); shared_levelized_file in; @@ -2755,9 +2802,9 @@ go_bandit([]() { arc_writer aw(in); aw.push_terminal({ n1, false, terminal_T }); - aw.push_terminal({ n1, true, terminal_F }); + aw.push_terminal({ n1, true, terminal_F }); - aw.push(level_info(0,1u)); + aw.push(level_info(0, 1u)); } in->max_1level_cut = 0; @@ -2792,7 +2839,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("can reduce the root", [&]() { @@ -2804,22 +2851,22 @@ go_bandit([]() { // F T F T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1,n2 }); + aw.push_internal({ n1, n2 }); - aw.push_terminal({ n1, true, terminal_F }); + aw.push_terminal({ n1, true, terminal_F }); aw.push_terminal({ n2, false, terminal_F }); - aw.push_terminal({ n2, true, terminal_T }); + aw.push_terminal({ n2, true, terminal_T }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); } in->max_1level_cut = 1; @@ -2841,7 +2888,7 @@ go_bandit([]() { level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -2858,7 +2905,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("can propagate reduction rule 1 up to a terminal", [&]() { @@ -2870,22 +2917,22 @@ go_bandit([]() { // F F */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, true, n2 }); + aw.push_internal({ n1, true, n2 }); aw.push_terminal({ n1, false, terminal_F }); aw.push_terminal({ n2, false, terminal_F }); - aw.push_terminal({ n2, true, terminal_F }); + aw.push_terminal({ n2, true, terminal_F }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); } in->max_1level_cut = 1; @@ -2918,7 +2965,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(0u)); }); it("can return non-reducible single-node variable with max_id [1]", [&]() { @@ -2928,7 +2975,7 @@ go_bandit([]() { // F T F T */ - const arc::pointer_type n1(42,0); + const arc::pointer_type n1(42, 0); shared_levelized_file in; @@ -2936,9 +2983,9 @@ go_bandit([]() { arc_writer aw(in); aw.push_terminal({ n1, false, terminal_F }); - aw.push_terminal({ n1, true, terminal_T }); + aw.push_terminal({ n1, true, terminal_T }); - aw.push(level_info(42,1u)); + aw.push(level_info(42, 1u)); } in->max_1level_cut = 0; @@ -2958,7 +3005,7 @@ go_bandit([]() { level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(42u,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(42u, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -2975,7 +3022,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("can return non-reducible single-node variable with max_id [2]", [&]() { @@ -2985,7 +3032,7 @@ go_bandit([]() { // T T T T */ - const arc::pointer_type n1(12,0); + const arc::pointer_type n1(12, 0); shared_levelized_file in; @@ -2993,9 +3040,9 @@ go_bandit([]() { arc_writer aw(in); aw.push_terminal({ n1, false, terminal_T }); - aw.push_terminal({ n1, true, terminal_T }); + aw.push_terminal({ n1, true, terminal_T }); - aw.push(level_info(12,1u)); + aw.push(level_info(12, 1u)); } in->max_1level_cut = 0; @@ -3015,7 +3062,7 @@ go_bandit([]() { level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(12u,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(12u, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -3032,10 +3079,9 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); - it("can account for a chain of don't cares contributing to the maximum cut [1]", [&]() { /* // _1_ 1 ---- x0 @@ -3053,53 +3099,53 @@ go_bandit([]() { // F T T T F T T T */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); - const arc::pointer_type n5(2,1); - const arc::pointer_type n6(3,0); - const arc::pointer_type n7(3,1); - const arc::pointer_type n8(4,0); - const arc::pointer_type n9(4,1); - const arc::pointer_type n10(5,0); - const arc::pointer_type n11(5,1); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); + const arc::pointer_type n5(2, 1); + const arc::pointer_type n6(3, 0); + const arc::pointer_type n7(3, 1); + const arc::pointer_type n8(4, 0); + const arc::pointer_type n9(4, 1); + const arc::pointer_type n10(5, 0); + const arc::pointer_type n11(5, 1); shared_levelized_file in; { // Garbage collect writer to free write-lock arc_writer aw(in); - aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); - aw.push_internal({ n2, false, n4 }); - aw.push_internal({ n2, true, n5 }); - aw.push_internal({ n3, false, n5 }); - aw.push_internal({ n4, false, n6 }); - aw.push_internal({ n4, true, n7 }); - aw.push_internal({ n5, false, n7 }); - aw.push_internal({ n6, false, n8 }); - aw.push_internal({ n6, true, n9 }); - aw.push_internal({ n7, false, n9 }); - aw.push_internal({ n8, false, n10 }); - aw.push_internal({ n8, true, n11 }); - aw.push_internal({ n9, false, n11 }); - - aw.push_terminal({ n3, true, terminal_F }); - aw.push_terminal({ n5, true, terminal_F }); - aw.push_terminal({ n7, true, terminal_F }); - aw.push_terminal({ n9, true, terminal_F }); + aw.push_internal({ n1, false, n2 }); + aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n2, false, n4 }); + aw.push_internal({ n2, true, n5 }); + aw.push_internal({ n3, false, n5 }); + aw.push_internal({ n4, false, n6 }); + aw.push_internal({ n4, true, n7 }); + aw.push_internal({ n5, false, n7 }); + aw.push_internal({ n6, false, n8 }); + aw.push_internal({ n6, true, n9 }); + aw.push_internal({ n7, false, n9 }); + aw.push_internal({ n8, false, n10 }); + aw.push_internal({ n8, true, n11 }); + aw.push_internal({ n9, false, n11 }); + + aw.push_terminal({ n3, true, terminal_F }); + aw.push_terminal({ n5, true, terminal_F }); + aw.push_terminal({ n7, true, terminal_F }); + aw.push_terminal({ n9, true, terminal_F }); aw.push_terminal({ n10, false, terminal_F }); - aw.push_terminal({ n10, true, terminal_T }); + aw.push_terminal({ n10, true, terminal_T }); aw.push_terminal({ n11, false, terminal_T }); - aw.push_terminal({ n11, true, terminal_T }); - - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,2u)); - aw.push(level_info(3,2u)); - aw.push(level_info(4,2u)); - aw.push(level_info(5,2u)); + aw.push_terminal({ n11, true, terminal_T }); + + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 2u)); + aw.push(level_info(3, 2u)); + aw.push(level_info(4, 2u)); + aw.push(level_info(5, 2u)); } in->max_1level_cut = 4; @@ -3113,62 +3159,68 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); // n11 - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n10 - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id-1, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(5, node::max_id - 1, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n9 - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - node::pointer_type(5, node::max_id-1), - node::pointer_type(5, node::max_id)))); - + AssertThat(out_nodes.pull(), + Is().EqualTo(node(4, + node::max_id, + node::pointer_type(5, node::max_id - 1), + node::pointer_type(5, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n7 - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - node::pointer_type(4, node::max_id), - node::pointer_type(5, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(3, + node::max_id, + node::pointer_type(4, node::max_id), + node::pointer_type(5, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n5 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - node::pointer_type(3, node::max_id), - node::pointer_type(5, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id, + node::pointer_type(3, node::max_id), + node::pointer_type(5, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n3 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id), - node::pointer_type(5, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(2, node::max_id), + node::pointer_type(5, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(1, node::max_id), - node::pointer_type(5, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(1, node::max_id), + node::pointer_type(5, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -3193,7 +3245,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(8u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); it("Merges nodes, despite of reduction rule 1 flag on child", [&]() { @@ -3207,10 +3259,10 @@ go_bandit([]() { // T F */ - const arc::pointer_type n1(0,0); - const arc::pointer_type n2(1,0); - const arc::pointer_type n3(1,1); - const arc::pointer_type n4(2,0); + const arc::pointer_type n1(0, 0); + const arc::pointer_type n2(1, 0); + const arc::pointer_type n3(1, 1); + const arc::pointer_type n4(2, 0); shared_levelized_file in; @@ -3218,18 +3270,18 @@ go_bandit([]() { arc_writer aw(in); aw.push_internal({ n1, false, n2 }); - aw.push_internal({ n1, true, n3 }); - aw.push_internal({ n2, true, n4 }); + aw.push_internal({ n1, true, n3 }); + aw.push_internal({ n2, true, n4 }); aw.push_terminal({ n2, false, terminal_F }); aw.push_terminal({ n3, false, terminal_F }); - aw.push_terminal({ n3, true, terminal_T }); + aw.push_terminal({ n3, true, terminal_T }); aw.push_terminal({ n4, false, terminal_T }); - aw.push_terminal({ n4, true, terminal_F }); + aw.push_terminal({ n4, true, terminal_F }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,2u)); - aw.push(level_info(2,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 2u)); + aw.push(level_info(2, 1u)); } in->max_1level_cut = 2; @@ -3246,19 +3298,21 @@ go_bandit([]() { AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(1, node::max_id), - node::pointer_type(1, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(1, node::max_id), + node::pointer_type(1, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -3284,8 +3338,8 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); }); }); - }); +}); diff --git a/test/adiar/internal/data_structures/test_level_merger.cpp b/test/adiar/internal/data_structures/test_level_merger.cpp index b2f6ff6d8..1e68f898c 100644 --- a/test/adiar/internal/data_structures/test_level_merger.cpp +++ b/test/adiar/internal/data_structures/test_level_merger.cpp @@ -10,15 +10,15 @@ go_bandit([]() { { // Garbage collect the writer levelized_file_writer fw(f); - fw.push(level_info(4,1u)); - fw.push(level_info(3,2u)); - fw.push(level_info(2,2u)); - fw.push(level_info(1,1u)); + fw.push(level_info(4, 1u)); + fw.push(level_info(3, 2u)); + fw.push(level_info(2, 2u)); + fw.push(level_info(1, 1u)); } level_merger, std::less<>, 1u> merger; - merger.hook({f}); + merger.hook({ f }); AssertThat(merger.can_pull(), Is().True()); AssertThat(merger.pull(), Is().EqualTo(1u)); @@ -41,15 +41,15 @@ go_bandit([]() { { // Garbage collect the writer levelized_file_writer fw(f); - fw.push(level_info(4,1u)); - fw.push(level_info(3,2u)); - fw.push(level_info(2,1u)); - fw.push(level_info(1,1u)); + fw.push(level_info(4, 1u)); + fw.push(level_info(3, 2u)); + fw.push(level_info(2, 1u)); + fw.push(level_info(1, 1u)); } level_merger, std::less<>, 1> merger; - merger.hook({f}); + merger.hook({ f }); AssertThat(merger.pull(), Is().EqualTo(1u)); @@ -69,12 +69,12 @@ go_bandit([]() { { // Garbage collect the writer levelized_file_writer fw1(f1); - fw1.push(level_info(1,1u)); + fw1.push(level_info(1, 1u)); } level_merger, std::less<>, 2> merger; - merger.hook({f1, f2}); + merger.hook({ f1, f2 }); AssertThat(merger.can_pull(), Is().True()); AssertThat(merger.pull(), Is().EqualTo(1u)); @@ -82,7 +82,6 @@ go_bandit([]() { AssertThat(merger.can_pull(), Is().False()); }); - it("can pull from merge of two level_info streams, where one is empty [2]", [&]() { shared_levelized_file f1; shared_levelized_file f2; @@ -90,13 +89,13 @@ go_bandit([]() { { // Garbage collect the writer levelized_file_writer fw1(f1); - fw1.push(level_info(1,1u)); - fw1.push(level_info(2,1u)); + fw1.push(level_info(1, 1u)); + fw1.push(level_info(2, 1u)); } level_merger, std::greater<>, 2> merger; - merger.hook({f1, f2}); + merger.hook({ f1, f2 }); AssertThat(merger.can_pull(), Is().True()); AssertThat(merger.pull(), Is().EqualTo(2u)); @@ -114,19 +113,19 @@ go_bandit([]() { { // Garbage collect the writers levelized_file_writer fw1(f1); - fw1.push(level_info(4,1u)); - fw1.push(level_info(2,2u)); - fw1.push(level_info(1,1u)); + fw1.push(level_info(4, 1u)); + fw1.push(level_info(2, 2u)); + fw1.push(level_info(1, 1u)); levelized_file_writer fw2(f2); - fw2.push(level_info(4,1u)); - fw2.push(level_info(3,1u)); + fw2.push(level_info(4, 1u)); + fw2.push(level_info(3, 1u)); } level_merger, std::less<>, 2> merger; - merger.hook({f1, f2}); + merger.hook({ f1, f2 }); AssertThat(merger.can_pull(), Is().True()); AssertThat(merger.pull(), Is().EqualTo(1u)); @@ -150,16 +149,16 @@ go_bandit([]() { { // Garbage collect the writers levelized_file_writer fw1(f1); - fw1.push(level_info(2,1u)); + fw1.push(level_info(2, 1u)); levelized_file_writer fw2(f2); - fw2.push(level_info(1,1u)); + fw2.push(level_info(1, 1u)); } level_merger, std::less<>, 2> merger; - merger.hook({f1, f2}); + merger.hook({ f1, f2 }); AssertThat(merger.can_pull(), Is().True()); AssertThat(merger.pull(), Is().EqualTo(1u)); @@ -177,16 +176,16 @@ go_bandit([]() { { // Garbage collect the writers levelized_file_writer fw1(f1); - fw1.push(level_info(2,1u)); + fw1.push(level_info(2, 1u)); levelized_file_writer fw2(f2); - fw2.push(level_info(1,1u)); + fw2.push(level_info(1, 1u)); } level_merger, std::greater<>, 2> merger; - merger.hook({f1, f2}); + merger.hook({ f1, f2 }); AssertThat(merger.can_pull(), Is().True()); AssertThat(merger.pull(), Is().EqualTo(2u)); @@ -204,19 +203,19 @@ go_bandit([]() { { // Garbage collect the writers levelized_file_writer fw1(f1); - fw1.push(level_info(4,2u)); - fw1.push(level_info(2,1u)); + fw1.push(level_info(4, 2u)); + fw1.push(level_info(2, 1u)); levelized_file_writer fw2(f2); - fw2.push(level_info(4,3u)); - fw2.push(level_info(3,2u)); - fw2.push(level_info(1,1u)); + fw2.push(level_info(4, 3u)); + fw2.push(level_info(3, 2u)); + fw2.push(level_info(1, 1u)); } level_merger, std::less<>, 2> merger; - merger.hook({f1, f2}); + merger.hook({ f1, f2 }); AssertThat(merger.peek(), Is().EqualTo(1u)); AssertThat(merger.pull(), Is().EqualTo(1u)); @@ -235,19 +234,19 @@ go_bandit([]() { { // Garbage collect the writers levelized_file_writer fw1(f1); - fw1.push(level_info(4,2u)); - fw1.push(level_info(2,1u)); + fw1.push(level_info(4, 2u)); + fw1.push(level_info(2, 1u)); levelized_file_writer fw2(f2); - fw2.push(level_info(4,3u)); - fw2.push(level_info(3,2u)); - fw2.push(level_info(1,1u)); + fw2.push(level_info(4, 3u)); + fw2.push(level_info(3, 2u)); + fw2.push(level_info(1, 1u)); } level_merger, std::greater<>, 2, true> merger; - merger.hook({f1, f2}); + merger.hook({ f1, f2 }); AssertThat(merger.peek(), Is().EqualTo(4u)); AssertThat(merger.pull(), Is().EqualTo(4u)); @@ -266,19 +265,19 @@ go_bandit([]() { { // Garbage collect the writers levelized_file_writer fw1(f1); - fw1.push(level_info(4,2u)); - fw1.push(level_info(2,1u)); + fw1.push(level_info(4, 2u)); + fw1.push(level_info(2, 1u)); levelized_file_writer fw2(f2); - fw2.push(level_info(4,1u)); - fw2.push(level_info(3,2u)); - fw2.push(level_info(1,1u)); + fw2.push(level_info(4, 1u)); + fw2.push(level_info(3, 2u)); + fw2.push(level_info(1, 1u)); } level_merger, std::less<>, 2> merger; - merger.hook({f1,f2}); + merger.hook({ f1, f2 }); f1.reset(); f2.reset(); @@ -301,7 +300,7 @@ go_bandit([]() { level_merger, std::less<>, 1> merger; - merger.hook({f}); + merger.hook({ f }); AssertThat(merger.can_pull(), Is().True()); AssertThat(merger.pull(), Is().EqualTo(0u)); @@ -329,7 +328,7 @@ go_bandit([]() { level_merger, std::less<>, 2> merger; - merger.hook({f1, f2}); + merger.hook({ f1, f2 }); AssertThat(merger.can_pull(), Is().True()); AssertThat(merger.pull(), Is().EqualTo(0u)); @@ -347,4 +346,4 @@ go_bandit([]() { }); }); }); - }); +}); diff --git a/test/adiar/internal/data_structures/test_levelized_priority_queue.cpp b/test/adiar/internal/data_structures/test_levelized_priority_queue.cpp index 335a93ca7..0a40e532b 100644 --- a/test/adiar/internal/data_structures/test_levelized_priority_queue.cpp +++ b/test/adiar/internal/data_structures/test_levelized_priority_queue.cpp @@ -2,21 +2,26 @@ #include -struct lpq_test_data { +struct lpq_test_data +{ ptr_uint64::label_type label; uint64_t nonce; - ptr_uint64::label_type level() const - { return label; } + ptr_uint64::label_type + level() const + { + return label; + } }; namespace snowhouse { - template<> + template <> struct Stringizer { - static std::string ToString(const lpq_test_data& d) + static std::string + ToString(const lpq_test_data& d) { std::stringstream stream; stream << "{ " << d.label << ", " << d.nonce << " }"; @@ -35,24 +40,30 @@ namespace adiar::internal static constexpr size_t files = 1u; struct stats - { /* No extra 'lpq_test_data' specific variables */ }; + { /* No extra 'lpq_test_data' specific variables */ + }; }; } -bool operator== (const lpq_test_data &a, const lpq_test_data &b) +bool +operator==(const lpq_test_data& a, const lpq_test_data& b) { return a.label == b.label && a.nonce == b.nonce; } -struct lpq_test_lt { - bool operator()(const lpq_test_data &a, const lpq_test_data &b) +struct lpq_test_lt +{ + bool + operator()(const lpq_test_data& a, const lpq_test_data& b) { return a.label < b.label || (a.label == b.label && a.nonce < b.nonce); } }; -struct lpq_test_gt { - bool operator()(const lpq_test_data &a, const lpq_test_data &b) +struct lpq_test_gt +{ + bool + operator()(const lpq_test_data& a, const lpq_test_data& b) { return a.label > b.label || (a.label == b.label && a.nonce > b.nonce); } @@ -62,10 +73,14 @@ typedef shared_file_ptr> lpq_test_file; typedef levelized_file_writer lpq_test_writer; template -using test_priority_queue = levelized_priority_queue, false, + file_t, + 1u, + std::less<>, + false, 1u>; go_bandit([]() { @@ -83,7 +98,7 @@ go_bandit([]() { it("initialises #levels = 0", []() { lpq_test_file f; - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_current_level(), Is().False()); @@ -98,7 +113,8 @@ go_bandit([]() { fw << 2; } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_current_level(), Is().False()); @@ -113,7 +129,8 @@ go_bandit([]() { fw << 1 << 2; } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_current_level(), Is().False()); @@ -131,7 +148,8 @@ go_bandit([]() { << 3 << 4; // buckets } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_current_level(), Is().False()); @@ -150,7 +168,8 @@ go_bandit([]() { << 5; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_current_level(), Is().False()); @@ -178,11 +197,12 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -210,11 +230,12 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -242,11 +263,12 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -273,12 +295,13 @@ go_bandit([]() { << 4 << 5 << 6; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {3, 1}); // bucket - pq.push(lpq_test_data {4, 2}); // overflow + pq.push(lpq_test_data{ 3, 1 }); // bucket + pq.push(lpq_test_data{ 4, 2 }); // overflow AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -313,12 +336,13 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {2, 1}); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 2, 1 }); + pq.push(lpq_test_data{ 3, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -360,12 +384,13 @@ go_bandit([]() { << 4 << 5; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {2, 1}); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 2, 1 }); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -402,19 +427,20 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped - << 2 << 3 // buckets - << 4 << 5 // overflow that is skipped - << 6 // overflow with an element - << 7 << 8 // overflow that will have relabelled buckets - << 9; // overflow not yet touched + fw << 1 // skipped + << 2 << 3 // buckets + << 4 << 5 // overflow that is skipped + << 6 // overflow with an element + << 7 << 8 // overflow that will have relabelled buckets + << 9; // overflow not yet touched } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {6, 1}); + pq.push(lpq_test_data{ 6, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -437,19 +463,20 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped - << 2 << 3 << 4 // buckets (after element in 3) - << 5 << 6 // overflow that is skipped - << 7 // overflow with an element - << 8; // overflow that will have relabelled bucket(s) + fw << 1 // skipped + << 2 << 3 << 4 // buckets (after element in 3) + << 5 << 6 // overflow that is skipped + << 7 // overflow with an element + << 8; // overflow that will have relabelled bucket(s) } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {7, 1}); - pq.push(lpq_test_data {3, 2}); + pq.push(lpq_test_data{ 7, 1 }); + pq.push(lpq_test_data{ 3, 2 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -491,11 +518,12 @@ go_bandit([]() { << 5; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -519,9 +547,10 @@ go_bandit([]() { << 6; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); pq.setup_next_level(); // 2 pq.pop(); @@ -534,7 +563,8 @@ go_bandit([]() { pq.setup_next_level(3u); AssertThat(pq.has_current_level(), Is().True()); - AssertThat(pq.current_level(), Is().EqualTo(2u));; + AssertThat(pq.current_level(), Is().EqualTo(2u)); + ; }); it("forwards to first bucket", []() { @@ -548,11 +578,12 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -580,11 +611,12 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -612,11 +644,12 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -642,9 +675,10 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 1 }); AssertThat(pq.has_current_level(), Is().False()); @@ -669,11 +703,12 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -696,11 +731,12 @@ go_bandit([]() { << 5; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -726,11 +762,12 @@ go_bandit([]() { << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -758,12 +795,13 @@ go_bandit([]() { << 4 << 5 << 6; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -786,23 +824,24 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped - << 2 << 3 << 4 // buckets (after element in 2) - << 5 << 6 << 7 // overflow that is skipped - << 9 << 10 // overflow that will become a bucket - << 11 ; // overflow + fw << 1 // skipped + << 2 << 3 << 4 // buckets (after element in 2) + << 5 << 6 << 7 // overflow that is skipped + << 9 << 10 // overflow that will become a bucket + << 11; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); pq.setup_next_level(); pq.pop(); AssertThat(pq.has_current_level(), Is().True()); AssertThat(pq.current_level(), Is().EqualTo(2u)); - pq.push(lpq_test_data {9, 2}); + pq.push(lpq_test_data{ 9, 2 }); pq.setup_next_level(8u); @@ -816,29 +855,29 @@ go_bandit([]() { ////////////////////////////////////////////////////////////////////////// // .push / pull // - describe(".push(elem_t &) + pull()", []{ + describe(".push(elem_t &) + pull()", [] { it("can push when there are fewer levels than buckets", []() { lpq_test_file f; { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); - pq.push(lpq_test_data {2, 2}); + pq.push(lpq_test_data{ 2, 1 }); + pq.push(lpq_test_data{ 2, 2 }); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -849,47 +888,47 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(4,2u)); // overflow - fw.push(level_info(3,3u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(4, 2u)); // overflow + fw.push(level_info(3, 3u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); - pq.push(lpq_test_data {2, 2}); + pq.push(lpq_test_data{ 2, 1 }); + pq.push(lpq_test_data{ 2, 2 }); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); - pq.push(lpq_test_data {3, 2}); + pq.push(lpq_test_data{ 3, 2 }); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 2 })); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 1 }); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 3 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 1 })); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 2 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -900,20 +939,20 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(4,1u)); // overflow - fw.push(level_info(3,3u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(4, 1u)); // overflow + fw.push(level_info(3, 3u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -924,28 +963,28 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(4,2u)); // overflow - fw.push(level_info(3,3u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(4, 2u)); // overflow + fw.push(level_info(3, 3u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {3, 1}); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 3, 1 }); + pq.push(lpq_test_data{ 4, 1 }); pq.setup_next_level(); // 3 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -956,33 +995,33 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(5,1u)); // . - fw.push(level_info(4,2u)); // overflow - fw.push(level_info(3,3u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(5, 1u)); // . + fw.push(level_info(4, 2u)); // overflow + fw.push(level_info(3, 3u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {5, 2}); - pq.push(lpq_test_data {5, 1}); - pq.push(lpq_test_data {3, 3}); + pq.push(lpq_test_data{ 5, 2 }); + pq.push(lpq_test_data{ 5, 1 }); + pq.push(lpq_test_data{ 3, 3 }); pq.setup_next_level(); // 3 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 3 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -993,35 +1032,35 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(5,2u)); // . - fw.push(level_info(4,2u)); // overflow - fw.push(level_info(3,3u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(5, 2u)); // . + fw.push(level_info(4, 2u)); // overflow + fw.push(level_info(3, 3u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {5, 2}); // overflow + pq.push(lpq_test_data{ 5, 2 }); // overflow - pq.push(lpq_test_data {4, 1}); // overflow + pq.push(lpq_test_data{ 4, 1 }); // overflow pq.setup_next_level(); // buckets [5, dead] AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); - pq.push(lpq_test_data {5, 1}); // bucket + pq.push(lpq_test_data{ 5, 1 }); // bucket AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // read: 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -1032,17 +1071,17 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(4,2u)); - fw.push(level_info(3,4u)); - fw.push(level_info(2,2u)); - fw.push(level_info(1,1)); + fw.push(level_info(4, 2u)); + fw.push(level_info(3, 4u)); + fw.push(level_info(2, 2u)); + fw.push(level_info(1, 1)); } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); pq.setup_next_level(3u); // 3 @@ -1051,7 +1090,7 @@ go_bandit([]() { pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -1062,18 +1101,18 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(5,2u)); - fw.push(level_info(4,4u)); - fw.push(level_info(3,4u)); - fw.push(level_info(2,2u)); - fw.push(level_info(1,1u)); + fw.push(level_info(5, 2u)); + fw.push(level_info(4, 4u)); + fw.push(level_info(3, 4u)); + fw.push(level_info(2, 2u)); + fw.push(level_info(1, 1u)); } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 1}); + pq.push(lpq_test_data{ 5, 1 }); pq.setup_next_level(4u); // 3 @@ -1082,7 +1121,7 @@ go_bandit([]() { pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -1097,40 +1136,41 @@ go_bandit([]() { << 3 << 4 << 5 << 6; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); // bucket + pq.push(lpq_test_data{ 2, 1 }); // bucket pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {4, 1}); // overflow + pq.push(lpq_test_data{ 4, 1 }); // overflow pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 1}); // bucket - pq.push(lpq_test_data {6, 1}); // bucket + pq.push(lpq_test_data{ 5, 1 }); // bucket + pq.push(lpq_test_data{ 6, 1 }); // bucket pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 6 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 1 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -1145,31 +1185,32 @@ go_bandit([]() { << 3 << 4 << 5 << 6; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {3, 1}); // overflow + pq.push(lpq_test_data{ 3, 1 }); // overflow pq.setup_next_level(); // 3 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {4, 1}); // bucket - pq.push(lpq_test_data {5, 2}); // bucket + pq.push(lpq_test_data{ 4, 1 }); // bucket + pq.push(lpq_test_data{ 5, 2 }); // bucket pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -1184,43 +1225,44 @@ go_bandit([]() { << 3 << 4 << 5 << 6 << 7; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {1, 1}); // bucket - pq.push(lpq_test_data {5, 1}); // overflow - pq.push(lpq_test_data {7, 2}); // overflow + pq.push(lpq_test_data{ 1, 1 }); // bucket + pq.push(lpq_test_data{ 5, 1 }); // overflow + pq.push(lpq_test_data{ 7, 2 }); // overflow pq.setup_next_level(); // 1 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 5 (relabels) - pq.push(lpq_test_data {6, 1}); // bucket - pq.push(lpq_test_data {7, 1}); // bucket + pq.push(lpq_test_data{ 6, 1 }); // bucket + pq.push(lpq_test_data{ 7, 1 }); // bucket AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 6 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 7 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -1235,39 +1277,40 @@ go_bandit([]() { << 3 << 4 << 5 << 6 << 7; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {5, 1}); // overflow - pq.push(lpq_test_data {6, 1}); // overflow - pq.push(lpq_test_data {7, 2}); // overflow + pq.push(lpq_test_data{ 5, 1 }); // overflow + pq.push(lpq_test_data{ 6, 1 }); // overflow + pq.push(lpq_test_data{ 7, 2 }); // overflow pq.setup_next_level(); // 5 (relabels) - pq.push(lpq_test_data {6, 2}); // bucket - pq.push(lpq_test_data {7, 1}); // bucket + pq.push(lpq_test_data{ 6, 2 }); // bucket + pq.push(lpq_test_data{ 7, 1 }); // bucket AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 6 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 2 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 7 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -1282,83 +1325,86 @@ go_bandit([]() { << 3 << 4 << 5; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {4, 1}); // overflow - pq.push(lpq_test_data {1, 1}); // bucket + pq.push(lpq_test_data{ 4, 1 }); // overflow + pq.push(lpq_test_data{ 1, 1 }); // bucket pq.setup_next_level(); // 1 (at bucket index 0) AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 1}); // overflow + pq.push(lpq_test_data{ 5, 1 }); // overflow pq.setup_next_level(); // 4 (relabels with 5 at index 0) AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 2}); // bucket + pq.push(lpq_test_data{ 5, 2 }); // bucket pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); AssertThat(pq.can_pull(), Is().False()); }); - it("can use buckets after relabelling close to the end (the current read bucket dies)", []() { - shared_file f; + it("can use buckets after relabelling close to the end (the current read bucket dies)", + []() { + shared_file f; - { - label_writer w(f); - w << 0 // skipped - << 1 << 2 << 3 // buckets (after first 'setup_next_level') - << 4 << 5; - } + { + label_writer w(f); + w << 0 // skipped + << 1 << 2 << 3 // buckets (after first 'setup_next_level') + << 4 << 5; + } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {4, 1}); // overflow - pq.push(lpq_test_data {2, 1}); // bucket + pq.push(lpq_test_data{ 4, 1 }); // overflow + pq.push(lpq_test_data{ 2, 1 }); // bucket - pq.setup_next_level(); // 2 (at bucket index 1) + pq.setup_next_level(); // 2 (at bucket index 1) - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); - AssertThat(pq.can_pull(), Is().False()); + AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 2}); // overflow + pq.push(lpq_test_data{ 5, 2 }); // overflow - pq.setup_next_level(); // 4 (5 placed at bucket index 0, and 1 is dead) + pq.setup_next_level(); // 4 (5 placed at bucket index 0, and 1 is dead) - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); - AssertThat(pq.can_pull(), Is().False()); + AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 1}); // bucket + pq.push(lpq_test_data{ 5, 1 }); // bucket - pq.setup_next_level(); // 5 + pq.setup_next_level(); // 5 - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 2})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); - AssertThat(pq.can_pull(), Is().False()); - }); + AssertThat(pq.can_pull(), Is().False()); + }); it("can use buckets after bucket-hitting stop-level", []() { shared_file f; @@ -1370,35 +1416,36 @@ go_bandit([]() { << 3 << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); // buckete + pq.push(lpq_test_data{ 2, 1 }); // buckete pq.setup_next_level(1u); // 1 (which is now a read bucket) AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {2, 2}); // bucket - pq.push(lpq_test_data {3, 2}); // overflow + pq.push(lpq_test_data{ 2, 2 }); // bucket + pq.push(lpq_test_data{ 3, 2 }); // overflow pq.setup_next_level(2u); // 2 (now, 3 is write bucket) AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 2 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {3, 1}); // bucket + pq.push(lpq_test_data{ 3, 1 }); // bucket pq.setup_next_level(3u); // 3 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -1413,70 +1460,74 @@ go_bandit([]() { << 3 << 4 << 5 << 6; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {4, 1}); // overflow + pq.push(lpq_test_data{ 4, 1 }); // overflow pq.setup_next_level(3u); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {4, 2}); // bucket - pq.push(lpq_test_data {5, 1}); // bucket + pq.push(lpq_test_data{ 4, 2 }); // bucket + pq.push(lpq_test_data{ 5, 1 }); // bucket pq.setup_next_level(4u); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 2 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(5u); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().False()); }); - it("can use relabelled bucket of a level that was also a prior bucket due to the stop-level", []() { - shared_file f; + it( + "can use relabelled bucket of a level that was also a prior bucket due to the stop-level", + []() { + shared_file f; - { - label_writer w(f); - w << 0 // skipped - << 1 << 2 // buckets - << 3 << 4; // overflow - } + { + label_writer w(f); + w << 0 // skipped + << 1 << 2 // buckets + << 3 << 4; // overflow + } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.setup_next_level(1u); // buckets: [2,3] + pq.setup_next_level(1u); // buckets: [2,3] - pq.push(lpq_test_data {2, 1}); // bucket - pq.push(lpq_test_data {3, 2}); // bucket + pq.push(lpq_test_data{ 2, 1 }); // bucket + pq.push(lpq_test_data{ 3, 2 }); // bucket - pq.setup_next_level(); // 2 + pq.setup_next_level(); // 2 - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); - AssertThat(pq.can_pull(), Is().False()); + AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {3, 1}); // bucket + pq.push(lpq_test_data{ 3, 1 }); // bucket - pq.setup_next_level(); // 3 + pq.setup_next_level(); // 3 - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 1})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 1 })); - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 2})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 2 })); - AssertThat(pq.can_pull(), Is().False()); - }); + AssertThat(pq.can_pull(), Is().False()); + }); it("can push after relabelling (with stop-level) that skips levels [1]", []() { shared_file f; @@ -1488,37 +1539,38 @@ go_bandit([]() { << 3 << 4 << 5 << 6 << 7; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {1, 1}); // bucket - pq.push(lpq_test_data {7, 2}); // overflow + pq.push(lpq_test_data{ 1, 1 }); // bucket + pq.push(lpq_test_data{ 7, 2 }); // overflow pq.setup_next_level(); // 1 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(5u); // 5 (relabels) - pq.push(lpq_test_data {6, 1}); // bucket - pq.push(lpq_test_data {7, 1}); // bucket + pq.push(lpq_test_data{ 6, 1 }); // bucket + pq.push(lpq_test_data{ 7, 1 }); // bucket pq.setup_next_level(); // 6 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 7 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -1533,35 +1585,36 @@ go_bandit([]() { << 3 << 4 << 5 << 6 << 7; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {6, 1}); // overflow - pq.push(lpq_test_data {7, 2}); // overflow + pq.push(lpq_test_data{ 6, 1 }); // overflow + pq.push(lpq_test_data{ 7, 2 }); // overflow pq.setup_next_level(5u); // 5 (relabels) AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {6, 2}); // bucket - pq.push(lpq_test_data {7, 1}); // bucket + pq.push(lpq_test_data{ 6, 2 }); // bucket + pq.push(lpq_test_data{ 7, 1 }); // bucket pq.setup_next_level(); // 6 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 2 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 7 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -1576,91 +1629,96 @@ go_bandit([]() { << 3 << 4 << 5; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {1, 1}); // bucket + pq.push(lpq_test_data{ 1, 1 }); // bucket pq.setup_next_level(); // 1 (at bucket index 0) AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 1}); // overflow + pq.push(lpq_test_data{ 5, 1 }); // overflow pq.setup_next_level(4u); // 4 (relabels with 5 at index 0) AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 2}); // bucket + pq.push(lpq_test_data{ 5, 2 }); // bucket pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); AssertThat(pq.can_pull(), Is().False()); }); - it("can use buckets after relabelling (with stop-level) close to the end (the current read bucket dies)", []() { - shared_file f; + it("can use buckets after relabelling (with stop-level) close to the end (the current read " + "bucket dies)", + []() { + shared_file f; - { - label_writer w(f); - w << 0 // skipped - << 1 << 2 << 3 // buckets (after first 'setup_next_level') - << 4 << 5; - } + { + label_writer w(f); + w << 0 // skipped + << 1 << 2 << 3 // buckets (after first 'setup_next_level') + << 4 << 5; + } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); // bucket + pq.push(lpq_test_data{ 2, 1 }); // bucket - pq.setup_next_level(); // 2 (at bucket index 1) + pq.setup_next_level(); // 2 (at bucket index 1) - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); - AssertThat(pq.can_pull(), Is().False()); + AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 2}); // overflow + pq.push(lpq_test_data{ 5, 2 }); // overflow - pq.setup_next_level(4u); // 4 (5 placed at bucket index 0, and 1 is dead) + pq.setup_next_level(4u); // 4 (5 placed at bucket index 0, and 1 is dead) - AssertThat(pq.can_pull(), Is().False()); + AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 1}); // bucket + pq.push(lpq_test_data{ 5, 1 }); // bucket - pq.setup_next_level(); // 5 + pq.setup_next_level(); // 5 - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 2})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); - AssertThat(pq.can_pull(), Is().False()); - }); + AssertThat(pq.can_pull(), Is().False()); + }); }); - describe(".pop()", []{ + describe(".pop()", [] { it("can pop from bucket [1]", []() { shared_file f; { label_writer w(f); - w << 0 // skipped - << 1 << 2 // buckets - << 3; // overflow + w << 0 // skipped + << 1 << 2 // buckets + << 3; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2,1}); + pq.push(lpq_test_data{ 2, 1 }); pq.setup_next_level(); // 2 @@ -1676,15 +1734,16 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped - << 1 << 2 // buckets - << 3; // overflow + w << 0 // skipped + << 1 << 2 // buckets + << 3; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2,1}); - pq.push(lpq_test_data {2,2}); + pq.push(lpq_test_data{ 2, 1 }); + pq.push(lpq_test_data{ 2, 2 }); pq.setup_next_level(); // 2 @@ -1693,7 +1752,7 @@ go_bandit([]() { pq.pop(); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -1703,14 +1762,15 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped - << 1 << 2 // buckets - << 3 << 4; // overflow + w << 0 // skipped + << 1 << 2 // buckets + << 3 << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {3,1}); // overflow + pq.push(lpq_test_data{ 3, 1 }); // overflow pq.setup_next_level(); // 3 @@ -1726,22 +1786,23 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped - << 1 << 2 // buckets - << 3 << 4; // overflow + w << 0 // skipped + << 1 << 2 // buckets + << 3 << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {3,1}); // overflow - pq.push(lpq_test_data {2,1}); // bucket - pq.push(lpq_test_data {3,3}); // overflow + pq.push(lpq_test_data{ 3, 1 }); // overflow + pq.push(lpq_test_data{ 2, 1 }); // bucket + pq.push(lpq_test_data{ 3, 3 }); // overflow pq.setup_next_level(); // 2 pq.pop(); // {2,1} - pq.push(lpq_test_data {3,2}); // bucket + pq.push(lpq_test_data{ 3, 2 }); // bucket pq.setup_next_level(); // 3 @@ -1750,7 +1811,7 @@ go_bandit([]() { pq.pop(); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 2 })); AssertThat(pq.can_pull(), Is().True()); @@ -1762,7 +1823,7 @@ go_bandit([]() { ////////////////////////////////////////////////////////////////////////// // .can_pull() // - describe(".empty_level() / .can_pull()", []{ + describe(".empty_level() / .can_pull()", [] { shared_file f; { // Garbage collect the writer early @@ -1774,25 +1835,28 @@ go_bandit([]() { } it("cannot pull after initialisation", [&f]() { - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.can_pull(), Is().False()); }); it("shows element after forwarding to level", [&f]() { - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data { 2,1 }); + pq.push(lpq_test_data{ 2, 1 }); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); }); it("shows a level becomes empty", [&f]() { - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data { 2,1 }); + pq.push(lpq_test_data{ 2, 1 }); pq.setup_next_level(); // 2 AssertThat(pq.has_current_level(), Is().True()); @@ -1807,9 +1871,10 @@ go_bandit([]() { }); it("shows forwarding to an empty level", [&f]() { - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data { 3,1 }); + pq.push(lpq_test_data{ 3, 1 }); pq.setup_next_level(2); // 2 AssertThat(pq.has_current_level(), Is().True()); @@ -1818,36 +1883,36 @@ go_bandit([]() { }); }); - describe(".top() / .peek()", []{ + describe(".top() / .peek()", [] { it("can look into bucket without side-effects", []() { lpq_test_file f; { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(6,2u)); // . - fw.push(level_info(5,4u)); // . - fw.push(level_info(4,5u)); // overflow - fw.push(level_info(3,4u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(6, 2u)); // . + fw.push(level_info(5, 4u)); // . + fw.push(level_info(4, 5u)); // overflow + fw.push(level_info(3, 4u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {2, 42}); // bucket + pq.push(lpq_test_data{ 2, 42 }); // bucket AssertThat(pq.size(), Is().EqualTo(1u)); pq.setup_next_level(); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.peek(), Is().EqualTo(lpq_test_data {2, 42})); + AssertThat(pq.peek(), Is().EqualTo(lpq_test_data{ 2, 42 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 42})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 42 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.can_pull(), Is().False()); @@ -1859,27 +1924,27 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(6,2u)); // . - fw.push(level_info(5,2u)); // . - fw.push(level_info(4,3u)); // overflow - fw.push(level_info(3,2u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(6, 2u)); // . + fw.push(level_info(5, 2u)); // . + fw.push(level_info(4, 3u)); // overflow + fw.push(level_info(3, 2u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {5, 3}); // overflow + pq.push(lpq_test_data{ 5, 3 }); // overflow AssertThat(pq.size(), Is().EqualTo(1u)); pq.setup_next_level(); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.peek(), Is().EqualTo(lpq_test_data {5, 3})); + AssertThat(pq.peek(), Is().EqualTo(lpq_test_data{ 5, 3 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 3 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.can_pull(), Is().False()); @@ -1891,30 +1956,30 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(6,2u)); // . - fw.push(level_info(5,2u)); // . - fw.push(level_info(4,3u)); // overflow - fw.push(level_info(3,2u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(6, 2u)); // . + fw.push(level_info(5, 2u)); // . + fw.push(level_info(4, 3u)); // overflow + fw.push(level_info(3, 2u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); // bucket + pq.push(lpq_test_data{ 2, 1 }); // bucket AssertThat(pq.size(), Is().EqualTo(1u)); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.top(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.top(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {3, 1}); // bucket + pq.push(lpq_test_data{ 3, 1 }); // bucket AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.top(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.top(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.size(), Is().EqualTo(2u)); }); @@ -1924,41 +1989,41 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(6,2u)); // . - fw.push(level_info(5,2u)); // . - fw.push(level_info(4,3u)); // overflow - fw.push(level_info(3,2u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(6, 2u)); // . + fw.push(level_info(5, 2u)); // . + fw.push(level_info(4, 3u)); // overflow + fw.push(level_info(3, 2u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); // bucket + pq.push(lpq_test_data{ 2, 1 }); // bucket AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {2, 2}); // bucket + pq.push(lpq_test_data{ 2, 2 }); // bucket AssertThat(pq.size(), Is().EqualTo(2u)); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.top(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.top(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.top(), Is().EqualTo(lpq_test_data {2, 2})); + AssertThat(pq.top(), Is().EqualTo(lpq_test_data{ 2, 2 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); }); }); - describe(".size()", []{ + describe(".size()", [] { it("increments on push to bucket [1]", []() { shared_file f; @@ -1968,14 +2033,15 @@ go_bandit([]() { << 1 << 2; // buckets } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {1, 1}); + pq.push(lpq_test_data{ 1, 1 }); AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); AssertThat(pq.size(), Is().EqualTo(2u)); }); @@ -1988,16 +2054,17 @@ go_bandit([]() { << 1 << 2; // buckets } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {1, 1}); + pq.push(lpq_test_data{ 1, 1 }); AssertThat(pq.size(), Is().EqualTo(1u)); pq.setup_next_level(); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); AssertThat(pq.size(), Is().EqualTo(2u)); }); @@ -2009,17 +2076,17 @@ go_bandit([]() { fw << 0 // skipped << 1 << 2 // buckets << 3 << 4; // overflow - } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {5, 1}); + pq.push(lpq_test_data{ 5, 1 }); AssertThat(pq.size(), Is().EqualTo(2u)); }); @@ -2032,16 +2099,17 @@ go_bandit([]() { << 1 << 2; // buckets } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {1, 1}); - pq.push(lpq_test_data {1, 2}); + pq.push(lpq_test_data{ 1, 1 }); + pq.push(lpq_test_data{ 1, 2 }); pq.setup_next_level(); AssertThat(pq.size(), Is().EqualTo(2u)); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 2 })); AssertThat(pq.size(), Is().EqualTo(0u)); }); @@ -2055,16 +2123,17 @@ go_bandit([]() { << 3 << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {4, 1}); - pq.push(lpq_test_data {4, 2}); + pq.push(lpq_test_data{ 4, 1 }); + pq.push(lpq_test_data{ 4, 2 }); pq.setup_next_level(); AssertThat(pq.size(), Is().EqualTo(2u)); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 2 })); AssertThat(pq.size(), Is().EqualTo(0u)); }); @@ -2077,10 +2146,11 @@ go_bandit([]() { << 1 << 2; // buckets } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {1, 1}); - pq.push(lpq_test_data {1, 2}); + pq.push(lpq_test_data{ 1, 1 }); + pq.push(lpq_test_data{ 1, 2 }); pq.setup_next_level(); AssertThat(pq.size(), Is().EqualTo(2u)); @@ -2100,10 +2170,11 @@ go_bandit([]() { << 3 << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {4, 1}); - pq.push(lpq_test_data {4, 2}); + pq.push(lpq_test_data{ 4, 1 }); + pq.push(lpq_test_data{ 4, 2 }); pq.setup_next_level(); AssertThat(pq.size(), Is().EqualTo(2u)); @@ -2122,14 +2193,15 @@ go_bandit([]() { << 1 << 2; // buckets } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {1, 1}); - pq.push(lpq_test_data {1, 2}); + pq.push(lpq_test_data{ 1, 1 }); + pq.push(lpq_test_data{ 1, 2 }); pq.setup_next_level(); AssertThat(pq.size(), Is().EqualTo(2u)); - AssertThat(pq.top(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.top(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.size(), Is().EqualTo(2u)); }); @@ -2143,14 +2215,15 @@ go_bandit([]() { << 3 << 4; // overflow } - test_priority_queue, 1> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 1> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {4, 1}); - pq.push(lpq_test_data {4, 2}); + pq.push(lpq_test_data{ 4, 1 }); + pq.push(lpq_test_data{ 4, 2 }); pq.setup_next_level(); AssertThat(pq.size(), Is().EqualTo(2u)); - AssertThat(pq.top(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.top(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.size(), Is().EqualTo(2u)); }); }); @@ -2162,7 +2235,7 @@ go_bandit([]() { it("initialises correctly", []() { lpq_test_file f; - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_current_level(), Is().False()); @@ -2183,15 +2256,16 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 0 // skipped + fw << 0 // skipped << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -2211,15 +2285,16 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped + fw << 1 // skipped << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -2239,15 +2314,16 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped + fw << 1 // skipped << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -2269,16 +2345,17 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped + fw << 1 // skipped << 2 << 3 << 4 << 5 << 6; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {3, 1}); - pq.push(lpq_test_data {4, 2}); + pq.push(lpq_test_data{ 3, 1 }); + pq.push(lpq_test_data{ 4, 2 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -2308,16 +2385,17 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped + fw << 1 // skipped << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {2, 1}); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 2, 1 }); + pq.push(lpq_test_data{ 3, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -2351,16 +2429,17 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped + fw << 1 // skipped << 2 << 3 << 4 << 5; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {2, 1}); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 2, 1 }); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -2394,15 +2473,16 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped + fw << 1 // skipped << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {6, 1}); + pq.push(lpq_test_data{ 6, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -2422,16 +2502,17 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped - << 2 << 3 << 4 << 5 << 6 << 7 << 8; // overflow that will have relabelled bucket(s) + fw << 1 // skipped + << 2 << 3 << 4 << 5 << 6 << 7 << 8; // overflow that will have relabelled bucket(s) } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {7, 1}); - pq.push(lpq_test_data {3, 2}); + pq.push(lpq_test_data{ 7, 1 }); + pq.push(lpq_test_data{ 3, 2 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -2465,15 +2546,16 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped + fw << 1 // skipped << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -2496,15 +2578,16 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped + fw << 1 // skipped << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -2524,15 +2607,16 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped + fw << 1 // skipped << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -2550,15 +2634,16 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped + fw << 1 // skipped << 2 << 4 << 5; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -2579,15 +2664,16 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped + fw << 1 // skipped << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -2610,16 +2696,17 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped + fw << 1 // skipped << 2 << 3 << 4 << 5 << 6; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.has_next_level(), Is().True()); @@ -2639,20 +2726,21 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 1 // skipped + fw << 1 // skipped << 2 << 3 << 4 << 5 << 6 << 7 << 9 << 10 << 11; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); pq.setup_next_level(); pq.pop(); AssertThat(pq.has_current_level(), Is().True()); AssertThat(pq.current_level(), Is().EqualTo(2u)); - pq.push(lpq_test_data {9, 2}); + pq.push(lpq_test_data{ 9, 2 }); pq.setup_next_level(8u); @@ -2666,29 +2754,29 @@ go_bandit([]() { ////////////////////////////////////////////////////////////////////////// // .push / pull // - describe(".push(elem_t &) + pull()", []{ + describe(".push(elem_t &) + pull()", [] { it("can push [1]", []() { lpq_test_file f; { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(2,2u)); - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(2, 2u)); + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); - pq.push(lpq_test_data {2, 2}); + pq.push(lpq_test_data{ 2, 1 }); + pq.push(lpq_test_data{ 2, 2 }); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -2699,47 +2787,47 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(4,2u)); - fw.push(level_info(3,3u)); - fw.push(level_info(2,2u)); - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(4, 2u)); + fw.push(level_info(3, 3u)); + fw.push(level_info(2, 2u)); + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); - pq.push(lpq_test_data {2, 2}); + pq.push(lpq_test_data{ 2, 1 }); + pq.push(lpq_test_data{ 2, 2 }); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); - pq.push(lpq_test_data {3, 2}); + pq.push(lpq_test_data{ 3, 2 }); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 2 })); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 1 }); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 3 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 1 })); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 2 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -2750,20 +2838,20 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(4,1u)); - fw.push(level_info(3,3u)); - fw.push(level_info(2,2u)); - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(4, 1u)); + fw.push(level_info(3, 3u)); + fw.push(level_info(2, 2u)); + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -2774,28 +2862,28 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(4,2u)); - fw.push(level_info(3,3u)); - fw.push(level_info(2,2u)); - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(4, 2u)); + fw.push(level_info(3, 3u)); + fw.push(level_info(2, 2u)); + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {3, 1}); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 3, 1 }); + pq.push(lpq_test_data{ 4, 1 }); pq.setup_next_level(); // 3 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -2806,33 +2894,33 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(5,1u)); - fw.push(level_info(4,2u)); - fw.push(level_info(3,3u)); - fw.push(level_info(2,2u)); - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(5, 1u)); + fw.push(level_info(4, 2u)); + fw.push(level_info(3, 3u)); + fw.push(level_info(2, 2u)); + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {5, 2}); - pq.push(lpq_test_data {5, 1}); - pq.push(lpq_test_data {3, 3}); + pq.push(lpq_test_data{ 5, 2 }); + pq.push(lpq_test_data{ 5, 1 }); + pq.push(lpq_test_data{ 3, 3 }); pq.setup_next_level(); // 3 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 3 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -2843,35 +2931,35 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(5,2u)); - fw.push(level_info(4,2u)); - fw.push(level_info(3,3u)); - fw.push(level_info(2,2u)); - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(5, 2u)); + fw.push(level_info(4, 2u)); + fw.push(level_info(3, 3u)); + fw.push(level_info(2, 2u)); + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {5, 2}); + pq.push(lpq_test_data{ 5, 2 }); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); pq.setup_next_level(); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); - pq.push(lpq_test_data {5, 1}); + pq.push(lpq_test_data{ 5, 1 }); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -2882,17 +2970,17 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(4,2u)); - fw.push(level_info(3,4u)); - fw.push(level_info(2,2u)); - fw.push(level_info(1,1)); + fw.push(level_info(4, 2u)); + fw.push(level_info(3, 4u)); + fw.push(level_info(2, 2u)); + fw.push(level_info(1, 1)); } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); pq.setup_next_level(3u); // 3 @@ -2901,7 +2989,7 @@ go_bandit([]() { pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -2912,18 +3000,18 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(5,2u)); - fw.push(level_info(4,4u)); - fw.push(level_info(3,4u)); - fw.push(level_info(2,2u)); - fw.push(level_info(1,1u)); + fw.push(level_info(5, 2u)); + fw.push(level_info(4, 4u)); + fw.push(level_info(3, 4u)); + fw.push(level_info(2, 2u)); + fw.push(level_info(1, 1u)); } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 1}); + pq.push(lpq_test_data{ 5, 1 }); pq.setup_next_level(4u); // 3 @@ -2932,7 +3020,7 @@ go_bandit([]() { pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -2942,44 +3030,45 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3 << 4 << 5 << 6; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 1}); - pq.push(lpq_test_data {6, 1}); + pq.push(lpq_test_data{ 5, 1 }); + pq.push(lpq_test_data{ 6, 1 }); pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 6 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 1 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -2989,35 +3078,36 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3 << 4 << 5 << 6; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 1 }); pq.setup_next_level(); // 3 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {4, 1}); - pq.push(lpq_test_data {5, 2}); + pq.push(lpq_test_data{ 4, 1 }); + pq.push(lpq_test_data{ 5, 2 }); pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -3027,47 +3117,48 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3 << 4 << 5 << 6 << 7; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {1, 1}); - pq.push(lpq_test_data {5, 1}); - pq.push(lpq_test_data {7, 2}); + pq.push(lpq_test_data{ 1, 1 }); + pq.push(lpq_test_data{ 5, 1 }); + pq.push(lpq_test_data{ 7, 2 }); pq.setup_next_level(); // 1 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 5 - pq.push(lpq_test_data {6, 1}); - pq.push(lpq_test_data {7, 1}); + pq.push(lpq_test_data{ 6, 1 }); + pq.push(lpq_test_data{ 7, 1 }); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 6 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 7 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -3077,43 +3168,44 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3 << 4 << 5 << 6 << 7; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {5, 1}); - pq.push(lpq_test_data {6, 1}); - pq.push(lpq_test_data {7, 2}); + pq.push(lpq_test_data{ 5, 1 }); + pq.push(lpq_test_data{ 6, 1 }); + pq.push(lpq_test_data{ 7, 2 }); pq.setup_next_level(); // 5 - pq.push(lpq_test_data {6, 2}); - pq.push(lpq_test_data {7, 1}); + pq.push(lpq_test_data{ 6, 2 }); + pq.push(lpq_test_data{ 7, 1 }); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 6 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 2 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 7 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -3123,40 +3215,41 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3 << 4 << 5; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {4, 1}); - pq.push(lpq_test_data {1, 1}); + pq.push(lpq_test_data{ 4, 1 }); + pq.push(lpq_test_data{ 1, 1 }); pq.setup_next_level(); // 1 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 1}); // overflow + pq.push(lpq_test_data{ 5, 1 }); // overflow pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 2}); + pq.push(lpq_test_data{ 5, 2 }); pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -3166,40 +3259,41 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3 << 4 << 5; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {4, 1}); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 4, 1 }); + pq.push(lpq_test_data{ 2, 1 }); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 2}); + pq.push(lpq_test_data{ 5, 2 }); pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 1}); + pq.push(lpq_test_data{ 5, 1 }); pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -3209,39 +3303,40 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); pq.setup_next_level(1u); // 1 AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {2, 2}); - pq.push(lpq_test_data {3, 2}); + pq.push(lpq_test_data{ 2, 2 }); + pq.push(lpq_test_data{ 3, 2 }); pq.setup_next_level(2u); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 2 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 1 }); pq.setup_next_level(3u); // 3 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -3251,34 +3346,35 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3 << 4 << 5 << 6; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); pq.setup_next_level(3u); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {4, 2}); - pq.push(lpq_test_data {5, 1}); + pq.push(lpq_test_data{ 4, 2 }); + pq.push(lpq_test_data{ 5, 1 }); pq.setup_next_level(4u); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 2 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(5u); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -3288,31 +3384,32 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); - pq.push(lpq_test_data {3, 2}); + pq.push(lpq_test_data{ 2, 1 }); + pq.push(lpq_test_data{ 3, 2 }); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 1 }); pq.setup_next_level(); // 3 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -3322,41 +3419,42 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3 << 4 << 5 << 6 << 7; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {1, 1}); - pq.push(lpq_test_data {7, 2}); + pq.push(lpq_test_data{ 1, 1 }); + pq.push(lpq_test_data{ 7, 2 }); pq.setup_next_level(); // 1 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(5u); // 5 - pq.push(lpq_test_data {6, 1}); - pq.push(lpq_test_data {7, 1}); + pq.push(lpq_test_data{ 6, 1 }); + pq.push(lpq_test_data{ 7, 1 }); pq.setup_next_level(); // 6 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 1 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 7 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -3366,39 +3464,40 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3 << 4 << 5 << 6 << 7; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {6, 1}); - pq.push(lpq_test_data {7, 2}); + pq.push(lpq_test_data{ 6, 1 }); + pq.push(lpq_test_data{ 7, 2 }); pq.setup_next_level(5u); // 5 AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {6, 2}); - pq.push(lpq_test_data {7, 1}); + pq.push(lpq_test_data{ 6, 2 }); + pq.push(lpq_test_data{ 7, 1 }); pq.setup_next_level(); // 6 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 2 })); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 7 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -3408,36 +3507,37 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3 << 4 << 5; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {1, 1}); + pq.push(lpq_test_data{ 1, 1 }); pq.setup_next_level(); // 1 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 1}); + pq.push(lpq_test_data{ 5, 1 }); pq.setup_next_level(4u); // 4 AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 2}); + pq.push(lpq_test_data{ 5, 2 }); pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -3447,54 +3547,56 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3 << 4 << 5; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 2}); + pq.push(lpq_test_data{ 5, 2 }); pq.setup_next_level(4u); // 4 AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {5, 1}); + pq.push(lpq_test_data{ 5, 1 }); pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); AssertThat(pq.can_pull(), Is().False()); }); }); - describe(".pop()", []{ + describe(".pop()", [] { it("can pop [1]", []() { shared_file f; { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2,1}); + pq.push(lpq_test_data{ 2, 1 }); pq.setup_next_level(); // 2 @@ -3510,14 +3612,15 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2,1}); - pq.push(lpq_test_data {2,2}); + pq.push(lpq_test_data{ 2, 1 }); + pq.push(lpq_test_data{ 2, 2 }); pq.setup_next_level(); // 2 @@ -3526,7 +3629,7 @@ go_bandit([]() { pq.pop(); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -3536,13 +3639,14 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {3,1}); + pq.push(lpq_test_data{ 3, 1 }); pq.setup_next_level(); // 3 @@ -3558,21 +3662,22 @@ go_bandit([]() { { label_writer w(f); - w << 0 // skipped + w << 0 // skipped << 1 << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {3,1}); // overflow - pq.push(lpq_test_data {2,1}); // bucket - pq.push(lpq_test_data {3,3}); // overflow + pq.push(lpq_test_data{ 3, 1 }); // overflow + pq.push(lpq_test_data{ 2, 1 }); // bucket + pq.push(lpq_test_data{ 3, 3 }); // overflow pq.setup_next_level(); // 2 pq.pop(); // {2,1} - pq.push(lpq_test_data {3,2}); + pq.push(lpq_test_data{ 3, 2 }); pq.setup_next_level(); // 3 @@ -3581,7 +3686,7 @@ go_bandit([]() { pq.pop(); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 2 })); AssertThat(pq.can_pull(), Is().True()); @@ -3593,7 +3698,7 @@ go_bandit([]() { ////////////////////////////////////////////////////////////////////////// // .can_pull() // - describe(".empty_level() / .can_pull()", []{ + describe(".empty_level() / .can_pull()", [] { shared_file f; { // Garbage collect the writer early @@ -3605,25 +3710,28 @@ go_bandit([]() { } it("cannot pull after initialisation", [&f]() { - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.can_pull(), Is().False()); }); it("shows element after forwarding to level", [&f]() { - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data { 2,1 }); + pq.push(lpq_test_data{ 2, 1 }); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); }); it("shows a level becomes empty", [&f]() { - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data { 2,1 }); + pq.push(lpq_test_data{ 2, 1 }); pq.setup_next_level(); // 2 AssertThat(pq.has_current_level(), Is().True()); @@ -3638,9 +3746,10 @@ go_bandit([]() { }); it("shows forwarding to an empty level", [&f]() { - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data { 3,1 }); + pq.push(lpq_test_data{ 3, 1 }); pq.setup_next_level(2); // 2 AssertThat(pq.empty_level(), Is().True()); @@ -3648,36 +3757,36 @@ go_bandit([]() { }); }); - describe(".top() / .peek()", []{ + describe(".top() / .peek()", [] { it("can look into priority queue without side-effects [1]", []() { lpq_test_file f; { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(6,2u)); - fw.push(level_info(5,4u)); - fw.push(level_info(4,5u)); - fw.push(level_info(3,4u)); - fw.push(level_info(2,2u)); - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(6, 2u)); + fw.push(level_info(5, 4u)); + fw.push(level_info(4, 5u)); + fw.push(level_info(3, 4u)); + fw.push(level_info(2, 2u)); + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {2, 42}); + pq.push(lpq_test_data{ 2, 42 }); AssertThat(pq.size(), Is().EqualTo(1u)); pq.setup_next_level(); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.peek(), Is().EqualTo(lpq_test_data {2, 42})); + AssertThat(pq.peek(), Is().EqualTo(lpq_test_data{ 2, 42 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 42})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 42 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.can_pull(), Is().False()); @@ -3689,27 +3798,27 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(6,2u)); - fw.push(level_info(5,2u)); - fw.push(level_info(4,3u)); - fw.push(level_info(3,2u)); - fw.push(level_info(2,2u)); - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(6, 2u)); + fw.push(level_info(5, 2u)); + fw.push(level_info(4, 3u)); + fw.push(level_info(3, 2u)); + fw.push(level_info(2, 2u)); + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {5, 3}); + pq.push(lpq_test_data{ 5, 3 }); AssertThat(pq.size(), Is().EqualTo(1u)); pq.setup_next_level(); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.peek(), Is().EqualTo(lpq_test_data {5, 3})); + AssertThat(pq.peek(), Is().EqualTo(lpq_test_data{ 5, 3 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 3 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.can_pull(), Is().False()); @@ -3721,30 +3830,30 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(6,2u)); - fw.push(level_info(5,2u)); - fw.push(level_info(4,3u)); - fw.push(level_info(3,2u)); - fw.push(level_info(2,2u)); - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(6, 2u)); + fw.push(level_info(5, 2u)); + fw.push(level_info(4, 3u)); + fw.push(level_info(3, 2u)); + fw.push(level_info(2, 2u)); + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); AssertThat(pq.size(), Is().EqualTo(1u)); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.top(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.top(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 1 }); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.top(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.top(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.size(), Is().EqualTo(2u)); }); @@ -3754,58 +3863,59 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(6,2u)); - fw.push(level_info(5,2u)); - fw.push(level_info(4,3u)); - fw.push(level_info(3,2u)); - fw.push(level_info(2,2u)); - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(6, 2u)); + fw.push(level_info(5, 2u)); + fw.push(level_info(4, 3u)); + fw.push(level_info(3, 2u)); + fw.push(level_info(2, 2u)); + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {2, 2}); + pq.push(lpq_test_data{ 2, 2 }); AssertThat(pq.size(), Is().EqualTo(2u)); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.top(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.top(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.top(), Is().EqualTo(lpq_test_data {2, 2})); + AssertThat(pq.top(), Is().EqualTo(lpq_test_data{ 2, 2 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); }); }); - describe(".size()", []{ + describe(".size()", [] { it("increments on push to priority queue [1]", []() { shared_file f; { // Garbage collect the writer early label_writer fw(f); - fw << 0 // skipped + fw << 0 // skipped << 1 << 2; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {1, 1}); + pq.push(lpq_test_data{ 1, 1 }); AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); AssertThat(pq.size(), Is().EqualTo(2u)); }); @@ -3814,20 +3924,21 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 0 // skipped + fw << 0 // skipped << 1 << 2; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {1, 1}); + pq.push(lpq_test_data{ 1, 1 }); AssertThat(pq.size(), Is().EqualTo(1u)); pq.setup_next_level(); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); AssertThat(pq.size(), Is().EqualTo(2u)); }); @@ -3836,18 +3947,19 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 0 // skipped + fw << 0 // skipped << 1 << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {5, 1}); + pq.push(lpq_test_data{ 5, 1 }); AssertThat(pq.size(), Is().EqualTo(2u)); }); @@ -3856,20 +3968,21 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 0 // skipped + fw << 0 // skipped << 1 << 2; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {1, 1}); - pq.push(lpq_test_data {1, 2}); + pq.push(lpq_test_data{ 1, 1 }); + pq.push(lpq_test_data{ 1, 2 }); pq.setup_next_level(); AssertThat(pq.size(), Is().EqualTo(2u)); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 2 })); AssertThat(pq.size(), Is().EqualTo(0u)); }); @@ -3878,20 +3991,21 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 0 // skipped + fw << 0 // skipped << 1 << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {4, 1}); - pq.push(lpq_test_data {4, 2}); + pq.push(lpq_test_data{ 4, 1 }); + pq.push(lpq_test_data{ 4, 2 }); pq.setup_next_level(); AssertThat(pq.size(), Is().EqualTo(2u)); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 2 })); AssertThat(pq.size(), Is().EqualTo(0u)); }); @@ -3900,14 +4014,15 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 0 // skipped + fw << 0 // skipped << 1 << 2; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {1, 1}); - pq.push(lpq_test_data {1, 2}); + pq.push(lpq_test_data{ 1, 1 }); + pq.push(lpq_test_data{ 1, 2 }); pq.setup_next_level(); AssertThat(pq.size(), Is().EqualTo(2u)); @@ -3922,14 +4037,15 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 0 // skipped - << 1 << 2 << 3 << 4; + fw << 0 // skipped + << 1 << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {4, 1}); - pq.push(lpq_test_data {4, 2}); + pq.push(lpq_test_data{ 4, 1 }); + pq.push(lpq_test_data{ 4, 2 }); pq.setup_next_level(); AssertThat(pq.size(), Is().EqualTo(2u)); @@ -3944,18 +4060,19 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 0 // skipped + fw << 0 // skipped << 1 << 2; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {1, 1}); - pq.push(lpq_test_data {1, 2}); + pq.push(lpq_test_data{ 1, 1 }); + pq.push(lpq_test_data{ 1, 2 }); pq.setup_next_level(); AssertThat(pq.size(), Is().EqualTo(2u)); - AssertThat(pq.top(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.top(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.size(), Is().EqualTo(2u)); }); @@ -3964,18 +4081,19 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 0 // skipped + fw << 0 // skipped << 1 << 2 << 3 << 4; } - test_priority_queue, 0> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 0> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {4, 1}); - pq.push(lpq_test_data {4, 2}); + pq.push(lpq_test_data{ 4, 1 }); + pq.push(lpq_test_data{ 4, 2 }); pq.setup_next_level(); AssertThat(pq.size(), Is().EqualTo(2u)); - AssertThat(pq.top(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.top(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.size(), Is().EqualTo(2u)); }); }); @@ -3987,238 +4105,272 @@ go_bandit([]() { { // Garbage collect the writer early label_writer fw(f); - fw << 3 // skipped - << 2 << 1 << 0 - ; + fw << 3 // skipped + << 2 << 1 << 0; } it("can sort elements from buckets", [&f]() { - levelized_priority_queue, 1u, std::greater<>, false, + shared_file, + 1u, + std::greater<>, + false, 1u> - pq({f}, memory_available(), 32, stats_lpq_tests); + pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); - pq.push(lpq_test_data {1, 1}); - pq.push(lpq_test_data {2, 2}); + pq.push(lpq_test_data{ 2, 1 }); + pq.push(lpq_test_data{ 1, 1 }); + pq.push(lpq_test_data{ 2, 2 }); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2,2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 2 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2,1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {1, 2}); + pq.push(lpq_test_data{ 1, 2 }); pq.setup_next_level(); // 1 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1,2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 2 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1,1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.can_pull(), Is().False()); }); it("can sort elements in overflow priority queue", [&f]() { - levelized_priority_queue, 1u, std::greater<>, false, + shared_file, + 1u, + std::greater<>, + false, 1u> - pq({f}, memory_available(), 32, stats_lpq_tests); + pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {0, 1}); - pq.push(lpq_test_data {0, 2}); + pq.push(lpq_test_data{ 0, 1 }); + pq.push(lpq_test_data{ 0, 2 }); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 0 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {0,2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 0, 2 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {0,1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 0, 1 })); AssertThat(pq.can_pull(), Is().False()); }); it("can merge elements from buckets and overflow", [&f]() { - levelized_priority_queue, 1u, std::greater<>, false, + shared_file, + 1u, + std::greater<>, + false, 1u> - pq({f}, memory_available(), 32, stats_lpq_tests); + pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {2, 1}); // bucket + pq.push(lpq_test_data{ 2, 1 }); // bucket AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2,1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {1,1}); // bucket - pq.push(lpq_test_data {0,2}); // overflow + pq.push(lpq_test_data{ 1, 1 }); // bucket + pq.push(lpq_test_data{ 0, 2 }); // overflow pq.setup_next_level(); // 1 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1,1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {0,1}); // bucket + pq.push(lpq_test_data{ 0, 1 }); // bucket pq.setup_next_level(); // 0 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {0,2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 0, 2 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {0,1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 0, 1 })); AssertThat(pq.can_pull(), Is().False()); }); }); - //Fixed (ub) - describe("levelized_priority_queue<..., look_ahead=0, lpq_test_gt, ..., std::greater<>, ...>", []() { - shared_file f; + // Fixed (ub) + describe("levelized_priority_queue<..., look_ahead=0, lpq_test_gt, ..., std::greater<>, ...>", + []() { + shared_file f; - { // Garbage collect the writer early - label_writer fw(f); + { // Garbage collect the writer early + label_writer fw(f); - fw << 3 // skipped - << 2 << 1 << 0 - ; - } + fw << 3 // skipped + << 2 << 1 << 0; + } - it("can sort elements from the priority queue [1]", [&f]() { - levelized_priority_queue, 1u, std::greater<>, false, - 1u> - pq({f}, memory_available(), 32, stats_lpq_tests); + it("can sort elements from the priority queue [1]", [&f]() { + levelized_priority_queue, + 1u, + std::greater<>, + false, + 1u> + pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {2, 1}); - pq.push(lpq_test_data {1, 1}); - pq.push(lpq_test_data {2, 2}); + pq.push(lpq_test_data{ 2, 1 }); + pq.push(lpq_test_data{ 1, 1 }); + pq.push(lpq_test_data{ 2, 2 }); - AssertThat(pq.can_pull(), Is().False()); + AssertThat(pq.can_pull(), Is().False()); - pq.setup_next_level(); // 2 + pq.setup_next_level(); // 2 - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2,2})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 2 })); - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2,1})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); - AssertThat(pq.can_pull(), Is().False()); + AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {1, 2}); + pq.push(lpq_test_data{ 1, 2 }); - pq.setup_next_level(); // 1 + pq.setup_next_level(); // 1 - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1,2})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 2 })); - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1,1})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); - AssertThat(pq.can_pull(), Is().False()); - }); + AssertThat(pq.can_pull(), Is().False()); + }); - it("can sort elements from the priority queue [2]", [&f]() { - levelized_priority_queue, 1u, std::greater<>, false, - 1u> - pq({f}, memory_available(), 32, stats_lpq_tests); + it("can sort elements from the priority queue [2]", [&f]() { + levelized_priority_queue, + 1u, + std::greater<>, + false, + 1u> + pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {0, 1}); - pq.push(lpq_test_data {0, 2}); + pq.push(lpq_test_data{ 0, 1 }); + pq.push(lpq_test_data{ 0, 2 }); - AssertThat(pq.can_pull(), Is().False()); + AssertThat(pq.can_pull(), Is().False()); - pq.setup_next_level(); // 0 + pq.setup_next_level(); // 0 - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {0,2})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 0, 2 })); - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {0,1})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 0, 1 })); - AssertThat(pq.can_pull(), Is().False()); - }); + AssertThat(pq.can_pull(), Is().False()); + }); - it("can sort elements from the priority queue [3]", [&f]() { - levelized_priority_queue, 1u, std::greater<>, false, - 1u> - pq({f}, memory_available(), 32, stats_lpq_tests); + it("can sort elements from the priority queue [3]", [&f]() { + levelized_priority_queue, + 1u, + std::greater<>, + false, + 1u> + pq({ f }, memory_available(), 32, stats_lpq_tests); - AssertThat(pq.has_current_level(), Is().False()); + AssertThat(pq.has_current_level(), Is().False()); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 2, 1 }); - AssertThat(pq.can_pull(), Is().False()); + AssertThat(pq.can_pull(), Is().False()); - pq.setup_next_level(); // 2 + pq.setup_next_level(); // 2 - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2,1})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); - AssertThat(pq.can_pull(), Is().False()); + AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {1,1}); - pq.push(lpq_test_data {0,2}); + pq.push(lpq_test_data{ 1, 1 }); + pq.push(lpq_test_data{ 0, 2 }); - pq.setup_next_level(); // 1 + pq.setup_next_level(); // 1 - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1,1})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); - AssertThat(pq.can_pull(), Is().False()); + AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {0,1}); + pq.push(lpq_test_data{ 0, 1 }); - pq.setup_next_level(); // 0 + pq.setup_next_level(); // 0 - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {0,2})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 0, 2 })); - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {0,1})); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 0, 1 })); - AssertThat(pq.can_pull(), Is().False()); - }); - }); + AssertThat(pq.can_pull(), Is().False()); + }); + }); describe("levelized_priority_queue<..., look_ahead=1, ..., init_level=0>", []() { it("initialises #levels = 0", []() { shared_file f; - levelized_priority_queue, 1u, std::less<>, false, + shared_file, + 1u, + std::less<>, + false, 0u> - pq({f}, memory_available(), 32, stats_lpq_tests); + pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_current_level(), Is().False()); @@ -4235,11 +4387,16 @@ go_bandit([]() { fw << 2; } - levelized_priority_queue, 1u, std::less<>, false, + shared_file, + 1u, + std::less<>, + false, 0u> - pq({f}, memory_available(), 32, stats_lpq_tests); + pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -4256,11 +4413,16 @@ go_bandit([]() { fw << 1 << 3 << 4; } - levelized_priority_queue, 1u, std::less<>, false, + shared_file, + 1u, + std::less<>, + false, 0u> - pq({f}, memory_available(), 32, stats_lpq_tests); + pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_current_level(), Is().False()); @@ -4276,31 +4438,36 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(1,1u)); // bucket + fw.push(level_info(1, 1u)); // bucket } - levelized_priority_queue, false, + lpq_test_file, + 1u, + std::less<>, + false, 0u> - pq({f}, memory_available(), 32, stats_lpq_tests); + pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {1, 1}); + pq.push(lpq_test_data{ 1, 1 }); AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {1, 2}); + pq.push(lpq_test_data{ 1, 2 }); AssertThat(pq.size(), Is().EqualTo(2u)); pq.setup_next_level(); // 1 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 2 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.has_next_level(), Is().False()); @@ -4312,34 +4479,39 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(4,2u)); // . - fw.push(level_info(3,3u)); // overflow - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // bucket + fw.push(level_info(4, 2u)); // . + fw.push(level_info(3, 3u)); // overflow + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // bucket } - levelized_priority_queue, false, + lpq_test_file, + 1u, + std::less<>, + false, 0u> - pq({f}, memory_available(), 32, stats_lpq_tests); + pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {1, 1}); + pq.push(lpq_test_data{ 1, 1 }); AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {1, 2}); + pq.push(lpq_test_data{ 1, 2 }); AssertThat(pq.size(), Is().EqualTo(2u)); pq.setup_next_level(); // 1 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 2 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.has_next_level(), Is().True()); @@ -4355,17 +4527,22 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(4,2u)); // bucket - fw.push(level_info(3,3u)); // bucket - fw.push(level_info(2,2u)); // overflow - fw.push(level_info(1,1u)); // . + fw.push(level_info(4, 2u)); // bucket + fw.push(level_info(3, 3u)); // bucket + fw.push(level_info(2, 2u)); // overflow + fw.push(level_info(1, 1u)); // . } - levelized_priority_queue, true, + lpq_test_file, + 1u, + std::greater<>, + true, 0u> - pq({f}, memory_available(), 32, stats_lpq_tests); + pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_next_level(), Is().True()); AssertThat(pq.next_level(), Is().EqualTo(4u)); @@ -4405,24 +4582,29 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(4,2u)); // bucket - fw.push(level_info(3,3u)); // bucket - fw.push(level_info(2,2u)); // overflow - fw.push(level_info(1,1u)); // . + fw.push(level_info(4, 2u)); // bucket + fw.push(level_info(3, 3u)); // bucket + fw.push(level_info(2, 2u)); // overflow + fw.push(level_info(1, 1u)); // . } - levelized_priority_queue, true, + lpq_test_file, + 1u, + std::greater<>, + true, 0u> - pq({f}, memory_available(), 32, stats_lpq_tests); + pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {4, 2}); + pq.push(lpq_test_data{ 4, 2 }); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.has_next_level(), Is().True()); @@ -4433,15 +4615,15 @@ go_bandit([]() { AssertThat(pq.empty_level(), Is().False()); - pq.push(lpq_test_data {3, 3}); + pq.push(lpq_test_data{ 3, 3 }); AssertThat(pq.size(), Is().EqualTo(3u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 2 })); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.empty_level(), Is().True()); @@ -4455,7 +4637,7 @@ go_bandit([]() { AssertThat(pq.empty_level(), Is().False()); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 3 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.empty_level(), Is().True()); @@ -4467,31 +4649,36 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f1); - fw.push(level_info(4,2u)); // bucket - fw.push(level_info(2,2u)); // overflow - fw.push(level_info(1,1u)); // . + fw.push(level_info(4, 2u)); // bucket + fw.push(level_info(2, 2u)); // overflow + fw.push(level_info(1, 1u)); // . } lpq_test_file f2; { // Garbage collect the writer early lpq_test_writer fw(f2); - fw.push(level_info(3,3u)); // bucket - fw.push(level_info(2,2u)); // overflow + fw.push(level_info(3, 3u)); // bucket + fw.push(level_info(2, 2u)); // overflow } - levelized_priority_queue, true, + lpq_test_file, + 2u, + std::greater<>, + true, 0u> - pq({f1,f2}, memory_available(), 32, stats_lpq_tests); + pq({ f1, f2 }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {4, 1}); // bucket + pq.push(lpq_test_data{ 4, 1 }); // bucket AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {4, 2}); // bucket + pq.push(lpq_test_data{ 4, 2 }); // bucket AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.has_next_level(), Is().True()); @@ -4502,18 +4689,18 @@ go_bandit([]() { AssertThat(pq.empty_level(), Is().False()); - pq.push(lpq_test_data {3, 3}); // bucket + pq.push(lpq_test_data{ 3, 3 }); // bucket AssertThat(pq.size(), Is().EqualTo(3u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 2 })); AssertThat(pq.size(), Is().EqualTo(2u)); - pq.push(lpq_test_data {2, 4}); // overflow + pq.push(lpq_test_data{ 2, 4 }); // overflow AssertThat(pq.size(), Is().EqualTo(3u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.empty_level(), Is().True()); @@ -4524,13 +4711,13 @@ go_bandit([]() { pq.setup_next_level(); // 3 AssertThat(pq.current_level(), Is().EqualTo(3u)); - pq.push(lpq_test_data {2, 5}); // bucket + pq.push(lpq_test_data{ 2, 5 }); // bucket AssertThat(pq.size(), Is().EqualTo(3u)); AssertThat(pq.empty_level(), Is().False()); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 3 })); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.empty_level(), Is().True()); @@ -4539,11 +4726,11 @@ go_bandit([]() { AssertThat(pq.current_level(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 5})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 5 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 4})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 4 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.empty_level(), Is().True()); @@ -4554,11 +4741,16 @@ go_bandit([]() { it("initialises correctly", []() { shared_file f; - levelized_priority_queue, 1u, std::less<>, false, + shared_file, + 1u, + std::less<>, + false, 0u> - pq({f}, memory_available(), 32, stats_lpq_tests); + pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_current_level(), Is().False()); @@ -4572,31 +4764,36 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(1,1u)); + fw.push(level_info(1, 1u)); } - levelized_priority_queue, false, + lpq_test_file, + 1u, + std::less<>, + false, 0u> - pq({f}, memory_available(), 32, stats_lpq_tests); + pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {1, 1}); + pq.push(lpq_test_data{ 1, 1 }); AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {1, 2}); + pq.push(lpq_test_data{ 1, 2 }); AssertThat(pq.size(), Is().EqualTo(2u)); pq.setup_next_level(); // 1 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 2 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.has_next_level(), Is().False()); @@ -4608,34 +4805,39 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(4,2u)); - fw.push(level_info(3,3u)); - fw.push(level_info(2,2u)); - fw.push(level_info(1,1u)); + fw.push(level_info(4, 2u)); + fw.push(level_info(3, 3u)); + fw.push(level_info(2, 2u)); + fw.push(level_info(1, 1u)); } - levelized_priority_queue, false, + lpq_test_file, + 1u, + std::less, + false, 0u> - pq({f}, memory_available(), 32, stats_lpq_tests); + pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {1, 1}); + pq.push(lpq_test_data{ 1, 1 }); AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {1, 2}); + pq.push(lpq_test_data{ 1, 2 }); AssertThat(pq.size(), Is().EqualTo(2u)); pq.setup_next_level(); // 1 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 2 })); AssertThat(pq.size(), Is().EqualTo(0u)); }); }); @@ -4648,21 +4850,26 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw1(f1); - fw1.push(level_info(4,2u)); - fw1.push(level_info(3,3u)); - fw1.push(level_info(1,1u)); + fw1.push(level_info(4, 2u)); + fw1.push(level_info(3, 3u)); + fw1.push(level_info(1, 1u)); lpq_test_writer fw2(f2); - fw2.push(level_info(2,1u)); - fw2.push(level_info(1,2u)); + fw2.push(level_info(2, 1u)); + fw2.push(level_info(1, 2u)); } - levelized_priority_queue, false, + lpq_test_file, + 2u, + std::less<>, + false, 0u> - pq({f1,f2}, memory_available(), 32, stats_lpq_tests); + pq({ f1, f2 }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -4670,13 +4877,13 @@ go_bandit([]() { AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {1, 1}); + pq.push(lpq_test_data{ 1, 1 }); AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {1, 2}); + pq.push(lpq_test_data{ 1, 2 }); AssertThat(pq.size(), Is().EqualTo(2u)); - pq.push(lpq_test_data {2, 3}); + pq.push(lpq_test_data{ 2, 3 }); AssertThat(pq.size(), Is().EqualTo(3u)); AssertThat(pq.can_pull(), Is().False()); @@ -4687,11 +4894,11 @@ go_bandit([]() { AssertThat(pq.current_level(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 2 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().False()); @@ -4703,7 +4910,7 @@ go_bandit([]() { AssertThat(pq.current_level(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 3 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.has_next_level(), Is().True()); @@ -4718,21 +4925,26 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw1(f1); - fw1.push(level_info(4,2u)); - fw1.push(level_info(3,3u)); - fw1.push(level_info(1,1u)); + fw1.push(level_info(4, 2u)); + fw1.push(level_info(3, 3u)); + fw1.push(level_info(1, 1u)); lpq_test_writer fw2(f2); - fw2.push(level_info(2,1u)); - fw2.push(level_info(1,2u)); + fw2.push(level_info(2, 1u)); + fw2.push(level_info(1, 2u)); } - levelized_priority_queue, false, + lpq_test_file, + 2u, + std::less<>, + false, 0u> - pq({f1,f2}, memory_available(), 32, stats_lpq_tests); + pq({ f1, f2 }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.has_current_level(), Is().False()); @@ -4740,13 +4952,13 @@ go_bandit([]() { AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {1, 1}); + pq.push(lpq_test_data{ 1, 1 }); AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {1, 2}); + pq.push(lpq_test_data{ 1, 2 }); AssertThat(pq.size(), Is().EqualTo(2u)); - pq.push(lpq_test_data {2, 3}); + pq.push(lpq_test_data{ 2, 3 }); AssertThat(pq.size(), Is().EqualTo(3u)); AssertThat(pq.can_pull(), Is().False()); @@ -4757,11 +4969,11 @@ go_bandit([]() { AssertThat(pq.current_level(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 2 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().False()); @@ -4773,7 +4985,7 @@ go_bandit([]() { AssertThat(pq.current_level(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 3 })); AssertThat(pq.size(), Is().EqualTo(0u)); }); }); @@ -4784,7 +4996,7 @@ go_bandit([]() { it("initialises with #levels = 0", []() { lpq_test_file f; - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_next_level(), Is().False()); @@ -4801,10 +5013,10 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); @@ -4818,12 +5030,12 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(4,1u)); // bucket - fw.push(level_info(3,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(4, 1u)); // bucket + fw.push(level_info(3, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); @@ -4838,17 +5050,17 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(8,1u)); // . - fw.push(level_info(7,3u)); // . - fw.push(level_info(6,4u)); // . - fw.push(level_info(5,6u)); // . - fw.push(level_info(4,5u)); // overflow - fw.push(level_info(3,4u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(8, 1u)); // . + fw.push(level_info(7, 3u)); // . + fw.push(level_info(6, 4u)); // . + fw.push(level_info(5, 6u)); // . + fw.push(level_info(4, 5u)); // overflow + fw.push(level_info(3, 4u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); @@ -4857,93 +5069,93 @@ go_bandit([]() { AssertThat(pq.next_level(), Is().EqualTo(2u)); }); - describe(".push(elem_t &) + pull()", []{ + describe(".push(elem_t &) + pull()", [] { it("can push into and pull from buckets", []() { lpq_test_file f; { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(7,2u)); // . - fw.push(level_info(6,3u)); // overflow - fw.push(level_info(5,6u)); // bucket - fw.push(level_info(4,8u)); // bucket - fw.push(level_info(3,4u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(7, 2u)); // . + fw.push(level_info(6, 3u)); // overflow + fw.push(level_info(5, 6u)); // bucket + fw.push(level_info(4, 8u)); // bucket + fw.push(level_info(3, 4u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {2, 1}); - pq.push(lpq_test_data {2, 2}); - pq.push(lpq_test_data {3, 42}); - pq.push(lpq_test_data {3, 21}); - pq.push(lpq_test_data {5, 3}); + pq.push(lpq_test_data{ 2, 1 }); + pq.push(lpq_test_data{ 2, 2 }); + pq.push(lpq_test_data{ 3, 42 }); + pq.push(lpq_test_data{ 3, 21 }); + pq.push(lpq_test_data{ 5, 3 }); AssertThat(pq.size(), Is().EqualTo(5u)); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.size(), Is().EqualTo(4u)); - pq.push(lpq_test_data {3, 2}); - pq.push(lpq_test_data {6, 2}); - pq.push(lpq_test_data {4, 2}); + pq.push(lpq_test_data{ 3, 2 }); + pq.push(lpq_test_data{ 6, 2 }); + pq.push(lpq_test_data{ 4, 2 }); AssertThat(pq.size(), Is().EqualTo(7u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 2 })); AssertThat(pq.size(), Is().EqualTo(6u)); AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {3, 3}); - pq.push(lpq_test_data {5, 2}); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 3 }); + pq.push(lpq_test_data{ 5, 2 }); + pq.push(lpq_test_data{ 3, 1 }); AssertThat(pq.size(), Is().EqualTo(9u)); pq.setup_next_level(); // 3 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 1 })); AssertThat(pq.size(), Is().EqualTo(8u)); - pq.push(lpq_test_data {5, 1}); - pq.push(lpq_test_data {4, 3}); + pq.push(lpq_test_data{ 5, 1 }); + pq.push(lpq_test_data{ 4, 3 }); AssertThat(pq.size(), Is().EqualTo(10u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 2 })); AssertThat(pq.size(), Is().EqualTo(9u)); - pq.push(lpq_test_data {6, 3}); + pq.push(lpq_test_data{ 6, 3 }); AssertThat(pq.size(), Is().EqualTo(10u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 3 })); AssertThat(pq.size(), Is().EqualTo(9u)); - pq.push(lpq_test_data {7, 4}); + pq.push(lpq_test_data{ 7, 4 }); AssertThat(pq.size(), Is().EqualTo(10u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 21})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 21 })); AssertThat(pq.size(), Is().EqualTo(9u)); - pq.push(lpq_test_data {6, 1}); - pq.push(lpq_test_data {7, 3}); + pq.push(lpq_test_data{ 6, 1 }); + pq.push(lpq_test_data{ 7, 3 }); AssertThat(pq.size(), Is().EqualTo(11u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 42})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 42 })); AssertThat(pq.size(), Is().EqualTo(10u)); - pq.push(lpq_test_data {7, 5}); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 7, 5 }); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.size(), Is().EqualTo(12u)); AssertThat(pq.can_pull(), Is().False()); @@ -4951,19 +5163,19 @@ go_bandit([]() { pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.size(), Is().EqualTo(11u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 2 })); AssertThat(pq.size(), Is().EqualTo(10u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 3 })); AssertThat(pq.size(), Is().EqualTo(9u)); - pq.push(lpq_test_data {7, 1}); - pq.push(lpq_test_data {7, 2}); + pq.push(lpq_test_data{ 7, 1 }); + pq.push(lpq_test_data{ 7, 2 }); AssertThat(pq.size(), Is().EqualTo(11u)); AssertThat(pq.can_pull(), Is().False()); @@ -4971,18 +5183,18 @@ go_bandit([]() { pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.size(), Is().EqualTo(10u)); - pq.push(lpq_test_data {6, 4}); + pq.push(lpq_test_data{ 6, 4 }); AssertThat(pq.size(), Is().EqualTo(11u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); AssertThat(pq.size(), Is().EqualTo(10u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 3 })); AssertThat(pq.size(), Is().EqualTo(9u)); AssertThat(pq.can_pull(), Is().False()); @@ -4990,19 +5202,19 @@ go_bandit([]() { pq.setup_next_level(); // 6 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 1 })); AssertThat(pq.size(), Is().EqualTo(8u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 2 })); AssertThat(pq.size(), Is().EqualTo(7u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 3 })); AssertThat(pq.size(), Is().EqualTo(6u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 4})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 4 })); AssertThat(pq.size(), Is().EqualTo(5u)); AssertThat(pq.can_pull(), Is().False()); @@ -5010,23 +5222,23 @@ go_bandit([]() { pq.setup_next_level(); // 7 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 1 })); AssertThat(pq.size(), Is().EqualTo(4u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 2 })); AssertThat(pq.size(), Is().EqualTo(3u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 3 })); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 4})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 4 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 5})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 5 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.can_pull(), Is().False()); @@ -5038,28 +5250,28 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(8,1u)); // . - fw.push(level_info(7,4u)); // . - fw.push(level_info(6,7u)); // overflow - fw.push(level_info(5,10u)); // bucket - fw.push(level_info(4,8u)); // bucket - fw.push(level_info(3,4u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(8, 1u)); // . + fw.push(level_info(7, 4u)); // . + fw.push(level_info(6, 7u)); // overflow + fw.push(level_info(5, 10u)); // bucket + fw.push(level_info(4, 8u)); // bucket + fw.push(level_info(3, 4u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {6, 4}); - pq.push(lpq_test_data {8, 2}); + pq.push(lpq_test_data{ 6, 4 }); + pq.push(lpq_test_data{ 8, 2 }); AssertThat(pq.size(), Is().EqualTo(2u)); pq.setup_next_level(); // 6 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 4})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 4 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().False()); @@ -5067,7 +5279,7 @@ go_bandit([]() { pq.setup_next_level(); // 8 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {8,2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 8, 2 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.can_pull(), Is().False()); @@ -5079,27 +5291,27 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(8,2u)); // . - fw.push(level_info(7,3u)); // . - fw.push(level_info(6,4u)); // overflow - fw.push(level_info(5,5u)); // bucket - fw.push(level_info(4,3u)); // bucket - fw.push(level_info(3,2u)); // bucket - fw.push(level_info(2,1u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(8, 2u)); // . + fw.push(level_info(7, 3u)); // . + fw.push(level_info(6, 4u)); // overflow + fw.push(level_info(5, 5u)); // bucket + fw.push(level_info(4, 3u)); // bucket + fw.push(level_info(3, 2u)); // bucket + fw.push(level_info(2, 1u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {8, 2}); + pq.push(lpq_test_data{ 8, 2 }); AssertThat(pq.size(), Is().EqualTo(1u)); pq.setup_next_level(); // 8 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {8,2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 8, 2 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.can_pull(), Is().False()); @@ -5111,37 +5323,37 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(12,2u)); // . - fw.push(level_info(11,4u)); // . - fw.push(level_info(10,8u)); // . - fw.push(level_info(9,16u)); // . - fw.push(level_info(8,32u)); // . - fw.push(level_info(7,64u)); // . - fw.push(level_info(6,32u)); // overflow - fw.push(level_info(5,16u)); // bucket - fw.push(level_info(4,8u)); // bucket - fw.push(level_info(3,4u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(12, 2u)); // . + fw.push(level_info(11, 4u)); // . + fw.push(level_info(10, 8u)); // . + fw.push(level_info(9, 16u)); // . + fw.push(level_info(8, 32u)); // . + fw.push(level_info(7, 64u)); // . + fw.push(level_info(6, 32u)); // overflow + fw.push(level_info(5, 16u)); // bucket + fw.push(level_info(4, 8u)); // bucket + fw.push(level_info(3, 4u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {10, 2}); - pq.push(lpq_test_data {12, 3}); - pq.push(lpq_test_data {10, 1}); + pq.push(lpq_test_data{ 10, 2 }); + pq.push(lpq_test_data{ 12, 3 }); + pq.push(lpq_test_data{ 10, 1 }); AssertThat(pq.size(), Is().EqualTo(3u)); pq.setup_next_level(); // 10 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {10,1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 10, 1 })); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {10,2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 10, 2 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().False()); @@ -5149,7 +5361,7 @@ go_bandit([]() { pq.setup_next_level(); // 12 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {12,3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 12, 3 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.can_pull(), Is().False()); @@ -5161,32 +5373,32 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(8,2u)); // . - fw.push(level_info(7,2u)); // . - fw.push(level_info(6,4u)); // overflow - fw.push(level_info(5,3u)); // bucket - fw.push(level_info(4,5u)); // bucket - fw.push(level_info(3,4u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(8, 2u)); // . + fw.push(level_info(7, 2u)); // . + fw.push(level_info(6, 4u)); // overflow + fw.push(level_info(5, 3u)); // bucket + fw.push(level_info(4, 5u)); // bucket + fw.push(level_info(3, 4u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_current_level(), Is().False()); AssertThat(pq.size(), Is().EqualTo(0u)); // Push something into overflow - pq.push(lpq_test_data {6, 4}); - pq.push(lpq_test_data {7, 1}); - pq.push(lpq_test_data {8, 2}); - pq.push(lpq_test_data {6, 2}); + pq.push(lpq_test_data{ 6, 4 }); + pq.push(lpq_test_data{ 7, 1 }); + pq.push(lpq_test_data{ 8, 2 }); + pq.push(lpq_test_data{ 6, 2 }); AssertThat(pq.size(), Is().EqualTo(4u)); // And into buckets - pq.push(lpq_test_data {2, 1}); - pq.push(lpq_test_data {3, 2}); + pq.push(lpq_test_data{ 2, 1 }); + pq.push(lpq_test_data{ 3, 2 }); AssertThat(pq.size(), Is().EqualTo(6u)); AssertThat(pq.can_pull(), Is().False()); @@ -5194,13 +5406,13 @@ go_bandit([]() { pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.size(), Is().EqualTo(5u)); - pq.push(lpq_test_data {3, 1}); // Bucket + pq.push(lpq_test_data{ 3, 1 }); // Bucket AssertThat(pq.size(), Is().EqualTo(6u)); - pq.push(lpq_test_data {8, 1}); // Overflow + pq.push(lpq_test_data{ 8, 1 }); // Overflow AssertThat(pq.size(), Is().EqualTo(7u)); AssertThat(pq.can_pull(), Is().False()); @@ -5208,26 +5420,26 @@ go_bandit([]() { pq.setup_next_level(); // 3 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 1 })); AssertThat(pq.size(), Is().EqualTo(6u)); - pq.push(lpq_test_data {4, 1}); // Bucket + pq.push(lpq_test_data{ 4, 1 }); // Bucket AssertThat(pq.size(), Is().EqualTo(7u)); - pq.push(lpq_test_data {5, 2}); // Bucket + pq.push(lpq_test_data{ 5, 2 }); // Bucket AssertThat(pq.size(), Is().EqualTo(8u)); - pq.push(lpq_test_data {4, 2}); // Bucket + pq.push(lpq_test_data{ 4, 2 }); // Bucket AssertThat(pq.size(), Is().EqualTo(9u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 2 })); AssertThat(pq.size(), Is().EqualTo(8u)); - pq.push(lpq_test_data {5, 1}); // Bucket + pq.push(lpq_test_data{ 5, 1 }); // Bucket AssertThat(pq.size(), Is().EqualTo(9u)); - pq.push(lpq_test_data {4, 3}); // Bucket + pq.push(lpq_test_data{ 4, 3 }); // Bucket AssertThat(pq.size(), Is().EqualTo(10u)); AssertThat(pq.can_pull(), Is().False()); @@ -5235,24 +5447,24 @@ go_bandit([]() { pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.size(), Is().EqualTo(9u)); - pq.push(lpq_test_data {5, 3}); // Bucket + pq.push(lpq_test_data{ 5, 3 }); // Bucket AssertThat(pq.size(), Is().EqualTo(10u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 2 })); AssertThat(pq.size(), Is().EqualTo(9u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 3 })); AssertThat(pq.size(), Is().EqualTo(8u)); - pq.push(lpq_test_data {8, 4}); // Bucket + pq.push(lpq_test_data{ 8, 4 }); // Bucket AssertThat(pq.size(), Is().EqualTo(9u)); - pq.push(lpq_test_data {7, 2}); // Bucket + pq.push(lpq_test_data{ 7, 2 }); // Bucket AssertThat(pq.size(), Is().EqualTo(10u)); AssertThat(pq.can_pull(), Is().False()); @@ -5260,53 +5472,53 @@ go_bandit([]() { pq.setup_next_level(); // 5 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 1 })); AssertThat(pq.size(), Is().EqualTo(9u)); - pq.push(lpq_test_data {6, 3}); // Bucket + pq.push(lpq_test_data{ 6, 3 }); // Bucket AssertThat(pq.size(), Is().EqualTo(10u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); AssertThat(pq.size(), Is().EqualTo(9u)); - pq.push(lpq_test_data {6, 1}); // Bucket + pq.push(lpq_test_data{ 6, 1 }); // Bucket AssertThat(pq.size(), Is().EqualTo(10u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 3 })); AssertThat(pq.size(), Is().EqualTo(9u)); - pq.push(lpq_test_data {7, 3}); // Bucket + pq.push(lpq_test_data{ 7, 3 }); // Bucket AssertThat(pq.size(), Is().EqualTo(10u)); AssertThat(pq.can_pull(), Is().False()); - pq.setup_next_level();// 6 + pq.setup_next_level(); // 6 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 1 })); AssertThat(pq.size(), Is().EqualTo(9u)); - pq.push(lpq_test_data {8, 3}); // Bucket + pq.push(lpq_test_data{ 8, 3 }); // Bucket AssertThat(pq.size(), Is().EqualTo(10u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 2 })); AssertThat(pq.size(), Is().EqualTo(9u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 3 })); AssertThat(pq.size(), Is().EqualTo(8u)); - pq.push(lpq_test_data {7, 6}); // Bucket + pq.push(lpq_test_data{ 7, 6 }); // Bucket AssertThat(pq.size(), Is().EqualTo(9u)); - pq.push(lpq_test_data {7, 5}); // Bucket + pq.push(lpq_test_data{ 7, 5 }); // Bucket AssertThat(pq.size(), Is().EqualTo(10u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {6, 4})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 6, 4 })); AssertThat(pq.size(), Is().EqualTo(9u)); AssertThat(pq.can_pull(), Is().False()); @@ -5314,26 +5526,26 @@ go_bandit([]() { pq.setup_next_level(); // 7 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 1 })); AssertThat(pq.size(), Is().EqualTo(8u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 2 })); AssertThat(pq.size(), Is().EqualTo(7u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 3 })); AssertThat(pq.size(), Is().EqualTo(6u)); - pq.push(lpq_test_data {8, 5}); // Bucket + pq.push(lpq_test_data{ 8, 5 }); // Bucket AssertThat(pq.size(), Is().EqualTo(7u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 5})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 5 })); AssertThat(pq.size(), Is().EqualTo(6u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 6})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 6 })); AssertThat(pq.size(), Is().EqualTo(5u)); AssertThat(pq.can_pull(), Is().False()); @@ -5341,23 +5553,23 @@ go_bandit([]() { pq.setup_next_level(); // 8 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {8, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 8, 1 })); AssertThat(pq.size(), Is().EqualTo(4u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {8, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 8, 2 })); AssertThat(pq.size(), Is().EqualTo(3u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {8, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 8, 3 })); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {8, 4})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 8, 4 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {8, 5})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 8, 5 })); AssertThat(pq.size(), Is().EqualTo(0u)); }); @@ -5367,29 +5579,29 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(4,2u)); // bucket - fw.push(level_info(3,3u)); // bucket - fw.push(level_info(2,4u)); // bucket - fw.push(level_info(1,2u)); // bucket - fw.push(level_info(0,1u)); // skipped + fw.push(level_info(4, 2u)); // bucket + fw.push(level_info(3, 3u)); // bucket + fw.push(level_info(2, 4u)); // bucket + fw.push(level_info(1, 2u)); // bucket + fw.push(level_info(0, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {4, 3}); - pq.push(lpq_test_data {2, 1}); + pq.push(lpq_test_data{ 4, 3 }); + pq.push(lpq_test_data{ 2, 1 }); AssertThat(pq.size(), Is().EqualTo(2u)); pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {3, 2}); - pq.push(lpq_test_data {3, 1}); + pq.push(lpq_test_data{ 3, 2 }); + pq.push(lpq_test_data{ 3, 1 }); AssertThat(pq.size(), Is().EqualTo(3u)); AssertThat(pq.can_pull(), Is().False()); @@ -5397,17 +5609,17 @@ go_bandit([]() { pq.setup_next_level(); // 3 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 1 })); AssertThat(pq.size(), Is().EqualTo(2u)); - pq.push(lpq_test_data {4, 1}); + pq.push(lpq_test_data{ 4, 1 }); AssertThat(pq.size(), Is().EqualTo(3u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 2 })); AssertThat(pq.size(), Is().EqualTo(2u)); - pq.push(lpq_test_data {4, 2}); + pq.push(lpq_test_data{ 4, 2 }); AssertThat(pq.size(), Is().EqualTo(3u)); AssertThat(pq.can_pull(), Is().False()); @@ -5415,15 +5627,15 @@ go_bandit([]() { pq.setup_next_level(); // 4 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 1 })); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 2 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {4, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 4, 3 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.can_pull(), Is().False()); @@ -5435,17 +5647,17 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,2u)); // bucket - fw.push(level_info(0,1u)); // skipped + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 2u)); // bucket + fw.push(level_info(0, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {2, 1}); - pq.push(lpq_test_data {1, 1}); + pq.push(lpq_test_data{ 2, 1 }); + pq.push(lpq_test_data{ 1, 1 }); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().False()); @@ -5453,10 +5665,10 @@ go_bandit([]() { pq.setup_next_level(); // 1 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {1, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 1, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {2, 2}); + pq.push(lpq_test_data{ 2, 2 }); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().False()); @@ -5464,10 +5676,10 @@ go_bandit([]() { pq.setup_next_level(); // 2 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 1 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {2, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 2, 2 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -5478,28 +5690,29 @@ go_bandit([]() { { // Garbage collect the writer early label_writer w(f); - w << 0 // skipped - << 1 << 2 << 3 << 4 // buckets - << 5 << 6 << 7 << 8 << 9 << 10; // overflow + w << 0 // skipped + << 1 << 2 << 3 << 4 // buckets + << 5 << 6 << 7 << 8 << 9 << 10; // overflow } - test_priority_queue, 3> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 3> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {5, 2}); // overflow + pq.push(lpq_test_data{ 5, 2 }); // overflow AssertThat(pq.size(), Is().EqualTo(1u)); - pq.push(lpq_test_data {9, 2}); // overflow + pq.push(lpq_test_data{ 9, 2 }); // overflow AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(); // 5 - pq.push(lpq_test_data {9, 1}); // bucket + pq.push(lpq_test_data{ 9, 1 }); // bucket AssertThat(pq.size(), Is().EqualTo(3u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {5,2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 5, 2 })); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().False()); @@ -5507,11 +5720,11 @@ go_bandit([]() { pq.setup_next_level(); // 9 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {9,1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 9, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {9,2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 9, 2 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.can_pull(), Is().False()); @@ -5523,21 +5736,22 @@ go_bandit([]() { { // Garbage collect the writer early label_writer w(f); - w << 0 // skipped - << 1 << 2 << 3 << 4 // buckets - << 5 << 6 << 7 << 8 << 9 << 10; // overflow + w << 0 // skipped + << 1 << 2 << 3 << 4 // buckets + << 5 << 6 << 7 << 8 << 9 << 10; // overflow } - test_priority_queue, 3> pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue, 3> pq( + { f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {9, 2}); // overflow + pq.push(lpq_test_data{ 9, 2 }); // overflow AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().False()); pq.setup_next_level(5u); - pq.push(lpq_test_data {9, 1}); // bucket + pq.push(lpq_test_data{ 9, 1 }); // bucket AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().False()); @@ -5545,58 +5759,60 @@ go_bandit([]() { pq.setup_next_level(); // 9 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {9,1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 9, 1 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {9,2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 9, 2 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.can_pull(), Is().False()); }); - it("can use buckets after relabel (with stop-level) where bucket levels are reused [1]", []() { - lpq_test_file f; + it("can use buckets after relabel (with stop-level) where bucket levels are reused [1]", + []() { + lpq_test_file f; - { // Garbage collect the writer early - lpq_test_writer fw(f); + { // Garbage collect the writer early + lpq_test_writer fw(f); - fw.push(level_info(8,1u)); // . - fw.push(level_info(7,1u)); // . - fw.push(level_info(6,2u)); // overflow - fw.push(level_info(5,3u)); // bucket - fw.push(level_info(4,4u)); // bucket - fw.push(level_info(3,3u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped - } + fw.push(level_info(8, 1u)); // . + fw.push(level_info(7, 1u)); // . + fw.push(level_info(6, 2u)); // overflow + fw.push(level_info(5, 3u)); // bucket + fw.push(level_info(4, 4u)); // bucket + fw.push(level_info(3, 3u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped + } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq( + { f }, memory_available(), 32, stats_lpq_tests); - AssertThat(pq.size(), Is().EqualTo(0u)); + AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {8, 2}); // overflow - AssertThat(pq.size(), Is().EqualTo(1u)); + pq.push(lpq_test_data{ 8, 2 }); // overflow + AssertThat(pq.size(), Is().EqualTo(1u)); - pq.setup_next_level(4u); // 4 (relabels everything, making 8 a bucket) + pq.setup_next_level(4u); // 4 (relabels everything, making 8 a bucket) - AssertThat(pq.can_pull(), Is().False()); + AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {8, 1}); // bucket - AssertThat(pq.size(), Is().EqualTo(2u)); + pq.push(lpq_test_data{ 8, 1 }); // bucket + AssertThat(pq.size(), Is().EqualTo(2u)); - pq.setup_next_level(); // 8 + pq.setup_next_level(); // 8 - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {8,1})); - AssertThat(pq.size(), Is().EqualTo(1u)); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 8, 1 })); + AssertThat(pq.size(), Is().EqualTo(1u)); - AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {8,2})); - AssertThat(pq.size(), Is().EqualTo(0u)); + AssertThat(pq.can_pull(), Is().True()); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 8, 2 })); + AssertThat(pq.size(), Is().EqualTo(0u)); - AssertThat(pq.can_pull(), Is().False()); - }); + AssertThat(pq.can_pull(), Is().False()); + }); it("can forward to stop-level with an empty overflow queue", []() { lpq_test_file f; @@ -5604,67 +5820,67 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(8,2u)); // . - fw.push(level_info(7,4u)); // . - fw.push(level_info(6,2u)); // overflow - fw.push(level_info(5,6u)); // bucket - fw.push(level_info(4,8u)); // bucket - fw.push(level_info(3,4u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(0,1u)); // skipped + fw.push(level_info(8, 2u)); // . + fw.push(level_info(7, 4u)); // . + fw.push(level_info(6, 2u)); // overflow + fw.push(level_info(5, 6u)); // bucket + fw.push(level_info(4, 8u)); // bucket + fw.push(level_info(3, 4u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(0, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); AssertThat(pq.size(), Is().EqualTo(0u)); - pq.push(lpq_test_data {3, 3}); // bucket - pq.push(lpq_test_data {3, 1}); // bucket + pq.push(lpq_test_data{ 3, 3 }); // bucket + pq.push(lpq_test_data{ 3, 1 }); // bucket AssertThat(pq.size(), Is().EqualTo(2u)); pq.setup_next_level(2u); // 2 AssertThat(pq.can_pull(), Is().False()); - pq.push(lpq_test_data {3, 2}); // bucket + pq.push(lpq_test_data{ 3, 2 }); // bucket AssertThat(pq.size(), Is().EqualTo(3u)); pq.setup_next_level(4u); // 3 AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 1})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 1 })); AssertThat(pq.size(), Is().EqualTo(2u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 2})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 2 })); AssertThat(pq.size(), Is().EqualTo(1u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 3 })); AssertThat(pq.size(), Is().EqualTo(0u)); AssertThat(pq.can_pull(), Is().False()); }); }); - describe(".top() / .peek()", []{ + describe(".top() / .peek()", [] { it("can pull after a peek in bucket", []() { lpq_test_file f; { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(6,1u)); // overflow - fw.push(level_info(5,2u)); // bucket - fw.push(level_info(4,4u)); // bucket - fw.push(level_info(3,4u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(6, 1u)); // overflow + fw.push(level_info(5, 2u)); // bucket + fw.push(level_info(4, 4u)); // bucket + fw.push(level_info(3, 4u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {3, 42}); // bucket + pq.push(lpq_test_data{ 3, 42 }); // bucket AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_current_level(), Is().False()); @@ -5674,9 +5890,9 @@ go_bandit([]() { AssertThat(pq.current_level(), Is().EqualTo(3u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.peek(), Is().EqualTo(lpq_test_data {3, 42})); + AssertThat(pq.peek(), Is().EqualTo(lpq_test_data{ 3, 42 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {3, 42})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 3, 42 })); AssertThat(pq.can_pull(), Is().False()); }); @@ -5686,19 +5902,19 @@ go_bandit([]() { { // Garbage collect the writer early lpq_test_writer fw(f); - fw.push(level_info(8,1u)); // . - fw.push(level_info(7,2u)); // . - fw.push(level_info(6,4u)); // overflow - fw.push(level_info(5,8u)); // bucket - fw.push(level_info(4,4u)); // bucket - fw.push(level_info(3,2u)); // bucket - fw.push(level_info(2,2u)); // bucket - fw.push(level_info(1,1u)); // skipped + fw.push(level_info(8, 1u)); // . + fw.push(level_info(7, 2u)); // . + fw.push(level_info(6, 4u)); // overflow + fw.push(level_info(5, 8u)); // bucket + fw.push(level_info(4, 4u)); // bucket + fw.push(level_info(3, 2u)); // bucket + fw.push(level_info(2, 2u)); // bucket + fw.push(level_info(1, 1u)); // skipped } - test_priority_queue pq({f}, memory_available(), 32, stats_lpq_tests); + test_priority_queue pq({ f }, memory_available(), 32, stats_lpq_tests); - pq.push(lpq_test_data {7, 3}); // overflow + pq.push(lpq_test_data{ 7, 3 }); // overflow AssertThat(pq.can_pull(), Is().False()); AssertThat(pq.has_current_level(), Is().False()); @@ -5708,12 +5924,12 @@ go_bandit([]() { AssertThat(pq.current_level(), Is().EqualTo(7u)); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.peek(), Is().EqualTo(lpq_test_data {7, 3})); + AssertThat(pq.peek(), Is().EqualTo(lpq_test_data{ 7, 3 })); AssertThat(pq.can_pull(), Is().True()); - AssertThat(pq.pull(), Is().EqualTo(lpq_test_data {7, 3})); + AssertThat(pq.pull(), Is().EqualTo(lpq_test_data{ 7, 3 })); AssertThat(pq.can_pull(), Is().False()); }); }); }); }); - }); +}); diff --git a/test/adiar/internal/data_types/test_arc.cpp b/test/adiar/internal/data_types/test_arc.cpp index 9ec2114ac..a01afb7d2 100644 --- a/test/adiar/internal/data_types/test_arc.cpp +++ b/test/adiar/internal/data_types/test_arc.cpp @@ -6,18 +6,16 @@ go_bandit([]() { const ptr_uint64 terminal_F = ptr_uint64(false); const ptr_uint64 terminal_T = ptr_uint64(true); - it("should be a POD", []() { - AssertThat(std::is_pod::value, Is().True()); - }); + it("should be a POD", []() { AssertThat(std::is_pod::value, Is().True()); }); it("should take up 16 bytes of memory", [&]() { - const arc arc = { ptr_uint64(42,2), terminal_F }; + const arc arc = { ptr_uint64(42, 2), terminal_F }; AssertThat(sizeof(arc), Is().EqualTo(2u * 8u)); }); describe("arc(pointer_type &s, pointer_type &t)", [&] { it("creates arc (42,2) - -> F", [&]() { - const arc a = { ptr_uint64(42,2,0), terminal_F }; + const arc a = { ptr_uint64(42, 2, 0), terminal_F }; AssertThat(a.source().is_node(), Is().True()); AssertThat(a.source().label(), Is().EqualTo(42u)); @@ -30,7 +28,7 @@ go_bandit([]() { }); it("creates arc '(2,0) ---> T'", [&]() { - const arc a = { ptr_uint64(2,0,1), terminal_T }; + const arc a = { ptr_uint64(2, 0, 1), terminal_T }; AssertThat(a.source().is_node(), Is().True()); AssertThat(a.source().label(), Is().EqualTo(2u)); @@ -43,7 +41,7 @@ go_bandit([]() { }); it("creates arc '(2,0) ---> (3,1)'", [&]() { - const arc a = { ptr_uint64(2,0,1), ptr_uint64(3,1) }; + const arc a = { ptr_uint64(2, 0, 1), ptr_uint64(3, 1) }; AssertThat(a.source().is_node(), Is().True()); AssertThat(a.source().label(), Is().EqualTo(2u)); @@ -59,7 +57,7 @@ go_bandit([]() { describe("arc(pointer_type &s, pointer_type::out_idx o, pointer_type &t)", [&] { it("creates arc '(42,2) - -> F'", [&]() { - const arc a = { uid_uint64(42,2), 0, terminal_F }; + const arc a = { uid_uint64(42, 2), 0, terminal_F }; AssertThat(a.source().is_node(), Is().True()); AssertThat(a.source().label(), Is().EqualTo(42u)); @@ -72,7 +70,7 @@ go_bandit([]() { }); it("creates arc '(2,0) ---> T'", [&]() { - const arc a = { uid_uint64(2,0), 1, terminal_T }; + const arc a = { uid_uint64(2, 0), 1, terminal_T }; AssertThat(a.source().is_node(), Is().True()); AssertThat(a.source().label(), Is().EqualTo(2u)); @@ -85,7 +83,7 @@ go_bandit([]() { }); it("creates arc '(2,0) ---> (3,1)'", [&]() { - const arc a = { uid_uint64(2,0), 1, ptr_uint64(3,1) }; + const arc a = { uid_uint64(2, 0), 1, ptr_uint64(3, 1) }; AssertThat(a.source().is_node(), Is().True()); AssertThat(a.source().label(), Is().EqualTo(2u)); @@ -101,30 +99,30 @@ go_bandit([]() { describe(".out_idx()", [&] { it("should have the out-index stored in source [{ ptr, ptr }]", [&]() { - const arc arc_low = { uid_uint64(0,0).as_ptr(false), ptr_uint64(3,2) }; + const arc arc_low = { uid_uint64(0, 0).as_ptr(false), ptr_uint64(3, 2) }; AssertThat(arc_low.out_idx(), Is().False()); }); it("should have the out-index stored in source [{ uid, idx, ptr }]", [&]() { - const arc arc_low = { uid_uint64(0,0), false, ptr_uint64(3,2) }; + const arc arc_low = { uid_uint64(0, 0), false, ptr_uint64(3, 2) }; AssertThat(arc_low.out_idx(), Is().False()); }); it("should have the out-index stored in source [{ ptr, ptr }]", [&]() { - const arc arc_high = { uid_uint64(3,2).as_ptr(true), ptr_uint64(4,3) }; + const arc arc_high = { uid_uint64(3, 2).as_ptr(true), ptr_uint64(4, 3) }; AssertThat(arc_high.out_idx(), Is().True()); }); it("should have the out-index stored in source [{ uid, idx, ptr }]", [&]() { - const arc arc_high = { uid_uint64(3,2), true, ptr_uint64(4,3) }; + const arc arc_high = { uid_uint64(3, 2), true, ptr_uint64(4, 3) }; AssertThat(arc_high.out_idx(), Is().True()); }); }); describe("equality (== / !=)", [&] { it("should be equal by their content [idx = 0]", [&]() { - const ptr_uint64 s = ptr_uint64(4,2); - const ptr_uint64 t = ptr_uint64(42,3); + const ptr_uint64 s = ptr_uint64(4, 2); + const ptr_uint64 t = ptr_uint64(42, 3); const arc arc_1 = { s, false, t }; const arc arc_2 = { s, false, t }; @@ -134,8 +132,8 @@ go_bandit([]() { }); it("should be equal by their content [idx = 1]", [&]() { - const ptr_uint64 s = ptr_uint64(0,0); - const ptr_uint64 t = ptr_uint64(1,0); + const ptr_uint64 s = ptr_uint64(0, 0); + const ptr_uint64 t = ptr_uint64(1, 0); const arc arc_1 = { s, true, t }; const arc arc_2 = { s, true, t }; @@ -145,9 +143,9 @@ go_bandit([]() { }); it("should unequal by their source", [&]() { - const uid_uint64 u1 = ptr_uint64(4,2); - const uid_uint64 u2 = ptr_uint64(4,3); - const uid_uint64 u3 = ptr_uint64(3,2); + const uid_uint64 u1 = ptr_uint64(4, 2); + const uid_uint64 u2 = ptr_uint64(4, 3); + const uid_uint64 u3 = ptr_uint64(3, 2); const arc arc_1 = { u1, u2 }; const arc arc_2 = { u3, u2 }; @@ -157,8 +155,8 @@ go_bandit([]() { }); it("should unequal based on out index by their content", [&]() { - const uid_uint64 u1 = ptr_uint64(4,2); - const uid_uint64 u2 = ptr_uint64(4,3); + const uid_uint64 u1 = ptr_uint64(4, 2); + const uid_uint64 u2 = ptr_uint64(4, 3); const arc arc_1 = { u1.as_ptr(false), u2 }; const arc arc_2 = { u1.as_ptr(true), u2 }; @@ -168,9 +166,9 @@ go_bandit([]() { }); it("should unequal by their target", [&]() { - const uid_uint64 u1 = ptr_uint64(4,2); - const uid_uint64 u2 = ptr_uint64(4,3); - const uid_uint64 u3 = ptr_uint64(3,2); + const uid_uint64 u1 = ptr_uint64(4, 2); + const uid_uint64 u2 = ptr_uint64(4, 3); + const uid_uint64 u3 = ptr_uint64(3, 2); const arc arc_1 = { u1, u2 }; const arc arc_2 = { u1, u3 }; @@ -182,20 +180,20 @@ go_bandit([]() { describe("not ( ! )", [&] { it("should leave node_ptr target unchanged", [&]() { - const arc a = { ptr_uint64(1,0), ptr_uint64(2,0) }; + const arc a = { ptr_uint64(1, 0), ptr_uint64(2, 0) }; AssertThat(!a, Is().EqualTo(a)); }); it("should negate 'false' terminal target", [&]() { - const arc a = { ptr_uint64(1,0), terminal_F }; - AssertThat(!a, Is().EqualTo(arc { ptr_uint64(1,0), terminal_T })); + const arc a = { ptr_uint64(1, 0), terminal_F }; + AssertThat(!a, Is().EqualTo(arc{ ptr_uint64(1, 0), terminal_T })); }); it("should negate 'true' terminal target", [&]() { - const arc a = { ptr_uint64(1,0), terminal_T }; - AssertThat(!a, Is().EqualTo(arc { ptr_uint64(1,0), terminal_F })); + const arc a = { ptr_uint64(1, 0), terminal_T }; + AssertThat(!a, Is().EqualTo(arc{ ptr_uint64(1, 0), terminal_F })); }); }); }); }); - }); +}); diff --git a/test/adiar/internal/data_types/test_convert.cpp b/test/adiar/internal/data_types/test_convert.cpp index 345b4213c..46749f223 100644 --- a/test/adiar/internal/data_types/test_convert.cpp +++ b/test/adiar/internal/data_types/test_convert.cpp @@ -1,4 +1,5 @@ #include "../../../test.h" + #include go_bandit([]() { @@ -7,7 +8,7 @@ go_bandit([]() { describe("low_arc_of", []() { it("should extract low arc from node", [&]() { - const node n(7,42, ptr_uint64(8,21), ptr_uint64(9,8)); + const node n(7, 42, ptr_uint64(8, 21), ptr_uint64(9, 8)); const arc a = low_arc_of(n); AssertThat(a.source().is_flagged(), Is().False()); @@ -25,7 +26,7 @@ go_bandit([]() { describe("high_arc_of", []() { it("should extract high arc from node", [&]() { - const node n(6,13, ptr_uint64(8,21), ptr_uint64(9,8)); + const node n(6, 13, ptr_uint64(8, 21), ptr_uint64(9, 8)); const arc a = high_arc_of(n); AssertThat(a.source().is_flagged(), Is().False()); @@ -43,30 +44,30 @@ go_bandit([]() { describe("node_of", []() { it("should combine low and high arcs to nodes into single node", [&]() { - const arc l_arc(uid_uint64(17,42), false, ptr_uint64(9,8)); - const arc h_arc(uid_uint64(17,42), true, ptr_uint64(8,21)); + const arc l_arc(uid_uint64(17, 42), false, ptr_uint64(9, 8)); + const arc h_arc(uid_uint64(17, 42), true, ptr_uint64(8, 21)); const node n = node_of(l_arc, h_arc); AssertThat(n.label(), Is().EqualTo(17u)); AssertThat(n.id(), Is().EqualTo(42u)); - AssertThat(n.low(), Is().EqualTo(l_arc.target())); + AssertThat(n.low(), Is().EqualTo(l_arc.target())); AssertThat(n.high(), Is().EqualTo(h_arc.target())); }); it("should combine low and high arcs to terminals into single node", [&]() { - const arc l_arc(uid_uint64(17,42), false, ptr_uint64(false)); - const arc h_arc(uid_uint64(17,42), true, ptr_uint64(true)); + const arc l_arc(uid_uint64(17, 42), false, ptr_uint64(false)); + const arc h_arc(uid_uint64(17, 42), true, ptr_uint64(true)); const node n = node_of(l_arc, h_arc); AssertThat(n.label(), Is().EqualTo(17u)); AssertThat(n.id(), Is().EqualTo(42u)); - AssertThat(n.low(), Is().EqualTo(l_arc.target())); + AssertThat(n.low(), Is().EqualTo(l_arc.target())); AssertThat(n.high(), Is().EqualTo(h_arc.target())); }); }); }); - }); +}); diff --git a/test/adiar/internal/data_types/test_node.cpp b/test/adiar/internal/data_types/test_node.cpp index 346047978..0078ffb8b 100644 --- a/test/adiar/internal/data_types/test_node.cpp +++ b/test/adiar/internal/data_types/test_node.cpp @@ -6,21 +6,19 @@ go_bandit([]() { const ptr_uint64 terminal_F = ptr_uint64(false); const ptr_uint64 terminal_T = ptr_uint64(true); - it("should be a POD", [&]() { - AssertThat(std::is_pod::value, Is().True()); - }); + it("should be a POD", [&]() { AssertThat(std::is_pod::value, Is().True()); }); it("should take up 24 bytes of memory", [&]() { - const ptr_uint64 node_ptr = ptr_uint64(42,2); - const node n = node(1u,8u, node_ptr, terminal_F); + const ptr_uint64 node_ptr = ptr_uint64(42, 2); + const node n = node(1u, 8u, node_ptr, terminal_F); AssertThat(sizeof(n), Is().EqualTo(3u * 8u)); }); describe("node(...), .label(), .id(), .low(), .high()", [&]() { it("should create node [label_type, id_type, ptr_uint64, ptr_uint64] [1]", [&]() { - const node n = node(3u,12u, terminal_F, terminal_T); - AssertThat(n.uid(), Is().EqualTo(ptr_uint64(3,12))); + const node n = node(3u, 12u, terminal_F, terminal_T); + AssertThat(n.uid(), Is().EqualTo(ptr_uint64(3, 12))); AssertThat(n.label(), Is().EqualTo(3u)); AssertThat(n.id(), Is().EqualTo(12u)); @@ -31,8 +29,8 @@ go_bandit([]() { }); it("should create node [label_type, id_type, ptr_uint64, ptr_uint64] [2]", [&]() { - const node n = node(3u,42u, terminal_T, terminal_F); - AssertThat(n.uid(), Is().EqualTo(ptr_uint64(3,42))); + const node n = node(3u, 42u, terminal_T, terminal_F); + AssertThat(n.uid(), Is().EqualTo(ptr_uint64(3, 42))); AssertThat(n.label(), Is().EqualTo(3u)); AssertThat(n.id(), Is().EqualTo(42u)); @@ -43,11 +41,11 @@ go_bandit([]() { }); it("should create node [label_type, id_type, node&, node&]", [&]() { - const node n_child1 = node(3u,12u, terminal_F, terminal_T); - const node n_child2 = node(3u,42u, terminal_T, terminal_F); + const node n_child1 = node(3u, 12u, terminal_F, terminal_T); + const node n_child2 = node(3u, 42u, terminal_T, terminal_F); - const node n = node(2,2, n_child1, n_child2); - AssertThat(n.uid(), Is().EqualTo(ptr_uint64(2,2))); + const node n = node(2, 2, n_child1, n_child2); + AssertThat(n.uid(), Is().EqualTo(ptr_uint64(2, 2))); AssertThat(n.label(), Is().EqualTo(2u)); AssertThat(n.id(), Is().EqualTo(2u)); @@ -58,10 +56,10 @@ go_bandit([]() { }); it("should create node [label_type, id_type, node&, ptr_uint64]", [&]() { - const node n_child = node(2u,2u, terminal_F, terminal_T); + const node n_child = node(2u, 2u, terminal_F, terminal_T); - const node n = node(1u,7u,terminal_T,n_child); - AssertThat(n.uid(), Is().EqualTo(ptr_uint64(1,7))); + const node n = node(1u, 7u, terminal_T, n_child); + AssertThat(n.uid(), Is().EqualTo(ptr_uint64(1, 7))); AssertThat(n.label(), Is().EqualTo(1u)); AssertThat(n.id(), Is().EqualTo(7u)); @@ -72,10 +70,10 @@ go_bandit([]() { }); it("should create node [label_type, id_type, ptr_uint64, node&]", [&]() { - const node n_child = node(2u,2u, terminal_F,terminal_T); + const node n_child = node(2u, 2u, terminal_F, terminal_T); - const node n = node(0u,3u, terminal_T,n_child); - AssertThat(n.uid(), Is().EqualTo(ptr_uint64(0,3))); + const node n = node(0u, 3u, terminal_T, n_child); + AssertThat(n.uid(), Is().EqualTo(ptr_uint64(0, 3))); AssertThat(n.label(), Is().EqualTo(0u)); AssertThat(n.id(), Is().EqualTo(3u)); @@ -101,66 +99,57 @@ go_bandit([]() { }); describe("is_terminal", [&]() { - it("accepts terminal [F]", [&]() { - AssertThat(terminal_node_F.is_terminal(), Is().True()); - }); + it("accepts terminal [F]", + [&]() { AssertThat(terminal_node_F.is_terminal(), Is().True()); }); - it("accepts terminal [T]", [&]() { - AssertThat(terminal_node_T.is_terminal(), Is().True()); - }); + it("accepts terminal [T]", + [&]() { AssertThat(terminal_node_T.is_terminal(), Is().True()); }); it("rejects non-terminal nodes [1]", [&]() { - const node node_1 = node(42u,2u, terminal_F, terminal_T); + const node node_1 = node(42u, 2u, terminal_F, terminal_T); AssertThat(node_1.is_terminal(), Is().False()); }); it("rejects non-terminal nodes [2]", [&]() { - const node almost_F_terminal = node(0u,0u, terminal_T, ptr_uint64(42,2)); + const node almost_F_terminal = node(0u, 0u, terminal_T, ptr_uint64(42, 2)); AssertThat(almost_F_terminal.is_terminal(), Is().False()); }); it("rejects non-terminal nodes [3]", [&]() { - const node almost_T_terminal = node(0u,1u, terminal_T, ptr_uint64(42,2)); + const node almost_T_terminal = node(0u, 1u, terminal_T, ptr_uint64(42, 2)); AssertThat(almost_T_terminal.is_terminal(), Is().False()); }); }); describe("value_of", [&]() { - it("retrieves value of terminal node [T]", [&]() { - AssertThat(terminal_node_T.value(), Is().True()); - }); + it("retrieves value of terminal node [T]", + [&]() { AssertThat(terminal_node_T.value(), Is().True()); }); - it("retrieves value of a terminal node [F]", [&]() { - AssertThat(terminal_node_F.value(), Is().False()); - }); + it("retrieves value of a terminal node [F]", + [&]() { AssertThat(terminal_node_F.value(), Is().False()); }); }); describe("is_false", [&]() { - it("accepts terminal [F]", [&]() { - AssertThat(terminal_node_F.is_false(), Is().True()); - }); + it("accepts terminal [F]", + [&]() { AssertThat(terminal_node_F.is_false(), Is().True()); }); - it("rejects terminal [T]", [&]() { - AssertThat(terminal_node_T.is_false(), Is().False()); - }); + it("rejects terminal [T]", + [&]() { AssertThat(terminal_node_T.is_false(), Is().False()); }); it("rejects non-terminal nodes", [&]() { - const node n = node(0,0, ptr_uint64(42,2), terminal_F); + const node n = node(0, 0, ptr_uint64(42, 2), terminal_F); AssertThat(n.is_false(), Is().False()); }); }); describe("is_true", [&]() { - it("rejects terminal [F]", [&]() { - AssertThat(terminal_node_F.is_true(), Is().False()); - }); + it("rejects terminal [F]", + [&]() { AssertThat(terminal_node_F.is_true(), Is().False()); }); - it("accepts terminal [T]", [&]() { - AssertThat(terminal_node_T.is_true(), Is().True()); - }); + it("accepts terminal [T]", [&]() { AssertThat(terminal_node_T.is_true(), Is().True()); }); it("rejects non-terminal nodes", [&]() { - const node n = node(0,1, terminal_T, ptr_uint64(2,3)); + const node n = node(0, 1, terminal_T, ptr_uint64(2, 3)); AssertThat(n.is_true(), Is().False()); }); }); @@ -168,8 +157,8 @@ go_bandit([]() { describe("comparators [node]", [&]() { it("should primarily sort by label", [&]() { - const node node_1 = node(1u,2u, terminal_F, terminal_T); - const node node_2 = node(2u,1u, terminal_T, terminal_F); + const node node_1 = node(1u, 2u, terminal_F, terminal_T); + const node node_2 = node(2u, 1u, terminal_T, terminal_F); AssertThat(node_1, Is().LessThan(node_2)); AssertThat(node_1, Is().LessThanOrEqualTo(node_2)); @@ -178,8 +167,8 @@ go_bandit([]() { }); it("should secondly sort by id", [&]() { - const node node_1 = node(2u,1u, terminal_F, terminal_T); - const node node_2 = node(2u,2u, terminal_T, terminal_F); + const node node_1 = node(2u, 1u, terminal_F, terminal_T); + const node node_2 = node(2u, 2u, terminal_T, terminal_F); AssertThat(node_1, Is().LessThan(node_2)); AssertThat(node_2, Is().GreaterThan(node_1)); @@ -188,8 +177,8 @@ go_bandit([]() { }); it("should thirdly sort by children [1]", [&]() { - const node node_1 = node(2u,0u, terminal_F, terminal_T); - const node node_2 = node(2u,0u, terminal_T, terminal_F); + const node node_1 = node(2u, 0u, terminal_F, terminal_T); + const node node_2 = node(2u, 0u, terminal_T, terminal_F); AssertThat(node_1, Is().LessThan(node_2)); AssertThat(node_2, Is().GreaterThan(node_1)); @@ -198,8 +187,8 @@ go_bandit([]() { }); it("should thirdly sort by children [2]", [&]() { - const node node_1 = node(2u,0u, terminal_T, terminal_F); - const node node_2 = node(2u,0u, terminal_T, terminal_T); + const node node_1 = node(2u, 0u, terminal_T, terminal_F); + const node node_2 = node(2u, 0u, terminal_T, terminal_T); AssertThat(node_1, Is().LessThan(node_2)); AssertThat(node_2, Is().GreaterThan(node_1)); @@ -208,8 +197,8 @@ go_bandit([]() { }); it("should (not) provide an ordering when equal", [&]() { - const node node_1 = node(2u,1u, terminal_F, terminal_T); - const node node_2 = node(2u,1u, terminal_F, terminal_T); + const node node_1 = node(2u, 1u, terminal_F, terminal_T); + const node node_2 = node(2u, 1u, terminal_F, terminal_T); AssertThat(node_1, Is().Not().LessThan(node_2)); AssertThat(node_2, Is().Not().GreaterThan(node_1)); @@ -219,56 +208,56 @@ go_bandit([]() { }); it("should be equal by if uid, low, and high agree [1]", [&]() { - const node node_1_v1 = node(42u,2u, terminal_F, terminal_T); - const node node_1_v2 = node(42u,2u, terminal_F, terminal_T); + const node node_1_v1 = node(42u, 2u, terminal_F, terminal_T); + const node node_1_v2 = node(42u, 2u, terminal_F, terminal_T); AssertThat(node_1_v1, Is().EqualTo(node_1_v2)); AssertThat(node_1_v1 != node_1_v2, Is().False()); }); it("should be equal by if uid, low, and high agree [2]", [&]() { - const node node_1_v1 = node(0u,0u, terminal_F, terminal_F); - const node node_1_v2 = node(0u,0u, terminal_F, terminal_F); + const node node_1_v1 = node(0u, 0u, terminal_F, terminal_F); + const node node_1_v2 = node(0u, 0u, terminal_F, terminal_F); AssertThat(node_1_v1, Is().EqualTo(node_1_v2)); AssertThat(node_1_v1 != node_1_v2, Is().False()); }); it("should be unequal if uid mismatches [1]", [&]() { - const node node_1 = node(42u,2u, terminal_F, terminal_T); - const node node_2 = node(42u,1u, terminal_F, terminal_T); + const node node_1 = node(42u, 2u, terminal_F, terminal_T); + const node node_2 = node(42u, 1u, terminal_F, terminal_T); AssertThat(node_1, Is().Not().EqualTo(node_2)); AssertThat(node_1 != node_2, Is().True()); }); it("should be unequal if uid mismatches [2]", [&]() { - const node node_1 = node(42u,2u, terminal_F, terminal_T); - const node node_2 = node(21u,2u, terminal_F, terminal_T); + const node node_1 = node(42u, 2u, terminal_F, terminal_T); + const node node_2 = node(21u, 2u, terminal_F, terminal_T); AssertThat(node_1, Is().Not().EqualTo(node_2)); AssertThat(node_1 != node_2, Is().True()); }); it("should be unequal if uid mismatches [3]", [&]() { - const node node_1 = node(42u,2u, terminal_F, terminal_T); - const node node_2 = node(21u,8u, terminal_F, terminal_T); + const node node_1 = node(42u, 2u, terminal_F, terminal_T); + const node node_2 = node(21u, 8u, terminal_F, terminal_T); AssertThat(node_1, Is().Not().EqualTo(node_2)); AssertThat(node_1 != node_2, Is().True()); }); it("should be unequal if low mismatches [1]", [&]() { - const node node_1 = node(42u,2u, terminal_F, terminal_T); - const node node_2 = node(42u,2u, terminal_T, terminal_T); + const node node_1 = node(42u, 2u, terminal_F, terminal_T); + const node node_2 = node(42u, 2u, terminal_T, terminal_T); AssertThat(node_1 == node_2, Is().False()); AssertThat(node_1 != node_2, Is().True()); }); it("should be unequal if high mismatches [1]", [&]() { - const node node_1 = node(42u,2u, terminal_F, terminal_T); - const node node_2 = node(42u,2u, terminal_F, terminal_F); + const node node_1 = node(42u, 2u, terminal_F, terminal_T); + const node node_2 = node(42u, 2u, terminal_F, terminal_F); AssertThat(node_1 == node_2, Is().False()); AssertThat(node_1 != node_2, Is().True()); @@ -277,8 +266,8 @@ go_bandit([]() { describe("comparators [uid]", [&]() { it("should primarily sort by label [ 1]", [&]() { - const node n = node(0u, 1u, terminal_F, terminal_T); - const node::uid_type u = node::uid_type(1u,0u); + const node n = node(0u, 1u, terminal_F, terminal_T); + const node::uid_type u = node::uid_type(1u, 0u); AssertThat(n, Is().LessThan(u)); AssertThat(n, Is().LessThanOrEqualTo(u)); @@ -287,8 +276,8 @@ go_bandit([]() { }); it("should primarily sort by label [!1]", [&]() { - const node n = node(0u, 1u, terminal_F, terminal_T); - const node::uid_type u = node::uid_type(1u,0u); + const node n = node(0u, 1u, terminal_F, terminal_T); + const node::uid_type u = node::uid_type(1u, 0u); AssertThat(u, Is().Not().LessThan(n)); AssertThat(u, Is().Not().LessThanOrEqualTo(n)); @@ -297,8 +286,8 @@ go_bandit([]() { }); it("should primarily sort by label [ 2]", [&]() { - const node n = node(21u, 8u, terminal_F, terminal_T); - const node::uid_type u = node::uid_type(42u,2u); + const node n = node(21u, 8u, terminal_F, terminal_T); + const node::uid_type u = node::uid_type(42u, 2u); AssertThat(n, Is().LessThan(u)); AssertThat(n, Is().LessThanOrEqualTo(u)); @@ -307,8 +296,8 @@ go_bandit([]() { }); it("should primarily sort by label [ 3]", [&]() { - const node n = node(1u, 1u, terminal_F, terminal_T); - const node::uid_type u = node::uid_type(0u,2u); + const node n = node(1u, 1u, terminal_F, terminal_T); + const node::uid_type u = node::uid_type(0u, 2u); AssertThat(u, Is().LessThan(n)); AssertThat(u, Is().LessThanOrEqualTo(n)); @@ -317,8 +306,8 @@ go_bandit([]() { }); it("should primarily sort by label [ 4]", [&]() { - const node n = node(42u, 0u, terminal_F, terminal_T); - const node::uid_type u = node::uid_type(21u,8u); + const node n = node(42u, 0u, terminal_F, terminal_T); + const node::uid_type u = node::uid_type(21u, 8u); AssertThat(u, Is().LessThan(n)); AssertThat(u, Is().LessThanOrEqualTo(n)); @@ -327,8 +316,8 @@ go_bandit([]() { }); it("should primarily sort by label [!4]", [&]() { - const node n = node(42u, 0u, terminal_F, terminal_T); - const node::uid_type u = node::uid_type(21u,8u); + const node n = node(42u, 0u, terminal_F, terminal_T); + const node::uid_type u = node::uid_type(21u, 8u); AssertThat(n, Is().Not().LessThan(u)); AssertThat(n, Is().Not().LessThanOrEqualTo(u)); @@ -337,7 +326,7 @@ go_bandit([]() { }); it("should secondly sort by id [ 1]", [&]() { - const node n = node(42u, 0u, terminal_F, terminal_T); + const node n = node(42u, 0u, terminal_F, terminal_T); const node::uid_type u = node::uid_type(42u, 1u); AssertThat(n, Is().LessThan(u)); @@ -347,7 +336,7 @@ go_bandit([]() { }); it("should secondly sort by id [ 2]", [&]() { - const node n = node(42u, 1u, terminal_F, terminal_T); + const node n = node(42u, 1u, terminal_F, terminal_T); const node::uid_type u = node::uid_type(42u, 0u); AssertThat(u, Is().LessThan(n)); @@ -359,31 +348,29 @@ go_bandit([]() { describe("not ( ~ )", [&]() { it("should leave node_ptr children unchanged", [&]() { - const node n = node(2u,2u, ptr_uint64(42,3), ptr_uint64(8,2)); + const node n = node(2u, 2u, ptr_uint64(42, 3), ptr_uint64(8, 2)); AssertThat(!n, Is().EqualTo(n)); }); it("should negate terminal_ptr child", [&]() { - const node n = node(2u,2u, terminal_F, ptr_uint64(8,2)); + const node n = node(2u, 2u, terminal_F, ptr_uint64(8, 2)); - AssertThat(!n, Is().EqualTo(node(2,2, terminal_T, ptr_uint64(8,2)))); + AssertThat(!n, Is().EqualTo(node(2, 2, terminal_T, ptr_uint64(8, 2)))); }); it("should negate terminal_ptr children while preserving flags", [&]() { - const node n = node(2u,2u, terminal_F, flag(terminal_T)); + const node n = node(2u, 2u, terminal_F, flag(terminal_T)); - AssertThat(!n, Is().EqualTo(node(2,2, terminal_T, flag(terminal_F)))); + AssertThat(!n, Is().EqualTo(node(2, 2, terminal_T, flag(terminal_F)))); }); - it("should negate 'false' terminal node", [&]() { - AssertThat(!node(false), Is().EqualTo(node(true))); - }); + it("should negate 'false' terminal node", + [&]() { AssertThat(!node(false), Is().EqualTo(node(true))); }); - it("should negate 'true' terminal node", [&]() { - AssertThat(!node(true), Is().EqualTo(node(false))); - }); + it("should negate 'true' terminal node", + [&]() { AssertThat(!node(true), Is().EqualTo(node(false))); }); }); }); }); - }); +}); diff --git a/test/adiar/internal/data_types/test_ptr.cpp b/test/adiar/internal/data_types/test_ptr.cpp index 4d20fb21d..6df8f239f 100644 --- a/test/adiar/internal/data_types/test_ptr.cpp +++ b/test/adiar/internal/data_types/test_ptr.cpp @@ -3,23 +3,19 @@ go_bandit([]() { describe("adiar/internal/data_types/ptr.h", []() { describe("ptr_uint64", []() { - it("should take up same amount of space as a 'uint64_t'", [&]() { - AssertThat(sizeof(ptr_uint64), Is().EqualTo(sizeof(uint64_t))); - }); + it("should take up same amount of space as a 'uint64_t'", + [&]() { AssertThat(sizeof(ptr_uint64), Is().EqualTo(sizeof(uint64_t))); }); - describe("nil", [&](){ + describe("nil", [&]() { describe(".is_flagged() and flag(...)/unflag(...)", []() { - it("is not flagged by default", [&]() { - AssertThat(ptr_uint64::nil().is_flagged(), Is().False()); - }); + it("is not flagged by default", + [&]() { AssertThat(ptr_uint64::nil().is_flagged(), Is().False()); }); - it("can be flagged", [&]() { - AssertThat(flag(ptr_uint64::nil()).is_flagged(), Is().True()); - }); + it("can be flagged", + [&]() { AssertThat(flag(ptr_uint64::nil()).is_flagged(), Is().True()); }); - it("can be unflagged", [&]() { - AssertThat(unflag(flag(ptr_uint64::nil())).is_flagged(), Is().False()); - }); + it("can be unflagged", + [&]() { AssertThat(unflag(flag(ptr_uint64::nil())).is_flagged(), Is().False()); }); }); it("level for Nil is larger than Terminals and Labels", [&]() { @@ -77,7 +73,7 @@ go_bandit([]() { }); }); - describe("terminal", [&](){ + describe("terminal", [&]() { it("level for Terminals is larger than Labels", [&]() { AssertThat(ptr_uint64::terminal_level, Is().GreaterThan(ptr_uint64::max_label)); }); @@ -235,16 +231,15 @@ go_bandit([]() { }); it("returns minimal Node ptr as-is", [&]() { - const ptr_uint64 p = ptr_uint64(0,0,0); + const ptr_uint64 p = ptr_uint64(0, 0, 0); AssertThat(!p, Is().EqualTo(p)); AssertThat(!flag(p), Is().EqualTo(flag(p))); }); it("returns maximal Node ptr as-is", [&]() { - const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const ptr_uint64 p = + ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(!p, Is().EqualTo(p)); AssertThat(!flag(p), Is().EqualTo(flag(p))); @@ -279,7 +274,7 @@ go_bandit([]() { it("negates unflagged 'false' into flagged 'true' terminal", [&]() { const ptr_uint64 p = ptr_uint64(false); - AssertThat(~p, Is().EqualTo((flag(ptr_uint64(true))))); + AssertThat(~p, Is().EqualTo(flag(ptr_uint64(true)))); }); it("negates unflagged 'true' into flagged 'false' terminal", [&]() { @@ -312,8 +307,8 @@ go_bandit([]() { const ptr_uint64 p_false = ptr_uint64(false); const ptr_uint64 p_true = ptr_uint64(true); - AssertThat(p_false ^ p_true, Is().EqualTo(ptr_uint64(true))); - AssertThat(p_true ^ p_false, Is().EqualTo(ptr_uint64(true))); + AssertThat(p_false ^ p_true, Is().EqualTo(ptr_uint64(true))); + AssertThat(p_true ^ p_false, Is().EqualTo(ptr_uint64(true))); }); it("computes 'false' for 'true' ^ 'true' terminals", [&]() { @@ -326,9 +321,9 @@ go_bandit([]() { const ptr_uint64 p_false = ptr_uint64(false); const ptr_uint64 p_true = ptr_uint64(true); - AssertThat(p_false ^ p_true, Is().EqualTo(p_true)); - AssertThat(flag(p_false) ^ p_true, Is().EqualTo(flag(p_true))); - AssertThat(p_true ^ flag(p_true), Is().EqualTo(flag(p_false))); + AssertThat(p_false ^ p_true, Is().EqualTo(p_true)); + AssertThat(flag(p_false) ^ p_true, Is().EqualTo(flag(p_true))); + AssertThat(p_true ^ flag(p_true), Is().EqualTo(flag(p_false))); AssertThat(flag(p_false) ^ flag(p_true), Is().EqualTo(p_true)); }); }); @@ -344,8 +339,8 @@ go_bandit([]() { const ptr_uint64 p_false = ptr_uint64(false); const ptr_uint64 p_true = ptr_uint64(true); - AssertThat(p_false & p_true, Is().EqualTo(ptr_uint64(false))); - AssertThat(p_true & p_false, Is().EqualTo(ptr_uint64(false))); + AssertThat(p_false & p_true, Is().EqualTo(ptr_uint64(false))); + AssertThat(p_true & p_false, Is().EqualTo(ptr_uint64(false))); }); it("computes 'true' for 'true' ^ 'true' terminals", [&]() { @@ -358,9 +353,9 @@ go_bandit([]() { const ptr_uint64 p_false = ptr_uint64(false); const ptr_uint64 p_true = ptr_uint64(true); - AssertThat(p_false & p_true, Is().EqualTo(p_false)); - AssertThat(flag(p_false) & p_true, Is().EqualTo(p_false)); - AssertThat(p_true & flag(p_true), Is().EqualTo(p_true)); + AssertThat(p_false & p_true, Is().EqualTo(p_false)); + AssertThat(flag(p_false) & p_true, Is().EqualTo(p_false)); + AssertThat(p_true & flag(p_true), Is().EqualTo(p_true)); AssertThat(flag(p_false) & flag(p_true), Is().EqualTo(flag(p_false))); }); }); @@ -376,8 +371,8 @@ go_bandit([]() { const ptr_uint64 p_false = ptr_uint64(false); const ptr_uint64 p_true = ptr_uint64(true); - AssertThat(p_false | p_true, Is().EqualTo(ptr_uint64(true))); - AssertThat(p_true | p_false, Is().EqualTo(ptr_uint64(true))); + AssertThat(p_false | p_true, Is().EqualTo(ptr_uint64(true))); + AssertThat(p_true | p_false, Is().EqualTo(ptr_uint64(true))); }); it("computes 'true' for 'true' ^ 'true' terminals", [&]() { @@ -390,9 +385,9 @@ go_bandit([]() { const ptr_uint64 p_false = ptr_uint64(false); const ptr_uint64 p_true = ptr_uint64(true); - AssertThat(p_false | p_true, Is().EqualTo(p_true)); - AssertThat(flag(p_false) | p_true, Is().EqualTo(flag(p_true))); - AssertThat(p_false | flag(p_false), Is().EqualTo(flag(p_false))); + AssertThat(p_false | p_true, Is().EqualTo(p_true)); + AssertThat(flag(p_false) | p_true, Is().EqualTo(flag(p_true))); + AssertThat(p_false | flag(p_false), Is().EqualTo(flag(p_false))); AssertThat(flag(p_false) | flag(p_true), Is().EqualTo(flag(p_true))); }); }); @@ -417,40 +412,38 @@ go_bandit([]() { describe("internal nodes", [&]() { describe(".is_flagged() and flag(...), unflag(...)", [&]() { it("is unflagged by default for minimal Node Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(0,0,0); + const ptr_uint64 p = ptr_uint64(0, 0, 0); AssertThat(p.is_flagged(), Is().False()); }); it("is unflagged by default for maximal Node Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const ptr_uint64 p = + ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(p.is_flagged(), Is().False()); }); it("accepts flagged minimal Node Ptr", [&]() { - const ptr_uint64 p = flag(ptr_uint64(0,0,0)); + const ptr_uint64 p = flag(ptr_uint64(0, 0, 0)); AssertThat(p.is_flagged(), Is().True()); }); it("accepts some flagged Node Ptr", [&]() { - const ptr_uint64 p = flag(ptr_uint64(42,2, true)); + const ptr_uint64 p = flag(ptr_uint64(42, 2, true)); AssertThat(p.is_flagged(), Is().True()); }); it("accepts flagged maximal Node Ptr", [&]() { - const ptr_uint64 p = flag(ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx)); + const ptr_uint64 p = + flag(ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx)); AssertThat(p.is_flagged(), Is().True()); }); it("rejects unflagged minimal Node Ptr", [&]() { - const ptr_uint64 p = unflag(flag(ptr_uint64(0,0,0))); + const ptr_uint64 p = unflag(flag(ptr_uint64(0, 0, 0))); AssertThat(p.is_flagged(), Is().False()); }); @@ -461,9 +454,8 @@ go_bandit([]() { }); it("rejects unflagged maximal Node Ptr", [&]() { - const ptr_uint64 p = unflag(flag(ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx))); + const ptr_uint64 p = unflag( + flag(ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx))); AssertThat(p.is_flagged(), Is().False()); }); @@ -471,7 +463,7 @@ go_bandit([]() { describe(".is_nil()", []() { it("rejects minimal Node Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(0,0,0); + const ptr_uint64 p = ptr_uint64(0, 0, 0); AssertThat(p.is_nil(), Is().False()); AssertThat(flag(p).is_nil(), Is().False()); @@ -485,9 +477,8 @@ go_bandit([]() { }); it("rejects maximal Node Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const ptr_uint64 p = + ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(p.is_nil(), Is().False()); AssertThat(flag(p).is_nil(), Is().False()); @@ -496,16 +487,15 @@ go_bandit([]() { describe(".is_terminal()", []() { it("rejects minimal Node Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(0,0,0); + const ptr_uint64 p = ptr_uint64(0, 0, 0); AssertThat(p.is_terminal(), Is().False()); AssertThat(flag(p).is_terminal(), Is().False()); }); it("rejects maximal Node Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const ptr_uint64 p = + ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(p.is_terminal(), Is().False()); AssertThat(flag(p).is_terminal(), Is().False()); @@ -514,16 +504,15 @@ go_bandit([]() { describe(".is_false()", []() { it("rejects minimal Node Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(0,0,0); + const ptr_uint64 p = ptr_uint64(0, 0, 0); AssertThat(p.is_false(), Is().False()); AssertThat(flag(p).is_false(), Is().False()); }); it("rejects maximal Node Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const ptr_uint64 p = + ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(p.is_false(), Is().False()); AssertThat(flag(p).is_false(), Is().False()); @@ -532,16 +521,15 @@ go_bandit([]() { describe(".is_true()", []() { it("rejects minimal Node Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(0,0,0); + const ptr_uint64 p = ptr_uint64(0, 0, 0); AssertThat(p.is_true(), Is().False()); AssertThat(flag(p).is_true(), Is().False()); }); it("rejects maximal Node Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const ptr_uint64 p = + ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(p.is_true(), Is().False()); AssertThat(flag(p).is_true(), Is().False()); @@ -550,7 +538,7 @@ go_bandit([]() { describe(".is_node()", [&]() { it("accepts minimal Node Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(0,0,0); + const ptr_uint64 p = ptr_uint64(0, 0, 0); AssertThat(p.is_node(), Is().True()); AssertThat(flag(p).is_node(), Is().True()); @@ -564,9 +552,8 @@ go_bandit([]() { }); it("accepts maximal Node Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const ptr_uint64 p = + ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(p.is_node(), Is().True()); AssertThat(flag(p).is_node(), Is().True()); @@ -594,7 +581,7 @@ go_bandit([]() { }); it("should store and retrieve for (42, 2) Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(42,2); + const ptr_uint64 p = ptr_uint64(42, 2); AssertThat(p.label(), Is().EqualTo(42u)); AssertThat(flag(p).label(), Is().EqualTo(42u)); @@ -612,8 +599,7 @@ go_bandit([]() { }); it("should store and retrieve for (max_label, max_id) Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id); + const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id); AssertThat(p.label(), Is().EqualTo(ptr_uint64::max_label)); AssertThat(flag(p).label(), Is().EqualTo(ptr_uint64::max_label)); @@ -622,9 +608,8 @@ go_bandit([]() { }); it("should store and retrieve for (max_label, max_id, max_out_idx) Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const ptr_uint64 p = + ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(p.label(), Is().EqualTo(ptr_uint64::max_label)); AssertThat(flag(p).label(), Is().EqualTo(ptr_uint64::max_label)); @@ -634,19 +619,18 @@ go_bandit([]() { }); describe(".out_idx()", [&]() { - it("has maximum out-index be 1", [&]() { - AssertThat(ptr_uint64::max_out_idx, Is().EqualTo(1u)); - }); + it("has maximum out-index be 1", + [&]() { AssertThat(ptr_uint64::max_out_idx, Is().EqualTo(1u)); }); it("has default value of 0 in (0,0)", [&]() { - const ptr_uint64 p = ptr_uint64(2,42); + const ptr_uint64 p = ptr_uint64(2, 42); AssertThat(p.out_idx(), Is().EqualTo(0u)); AssertThat(flag(p).out_idx(), Is().EqualTo(0u)); }); it("has default value of 0 in (2,42)", [&]() { - const ptr_uint64 p = ptr_uint64(2,42); + const ptr_uint64 p = ptr_uint64(2, 42); AssertThat(p.out_idx(), Is().EqualTo(0u)); AssertThat(flag(p).out_idx(), Is().EqualTo(0u)); @@ -661,39 +645,35 @@ go_bandit([]() { }); it("retrieves 0 from (2,42,false)", [&]() { - const ptr_uint64 p = ptr_uint64(2,42,false); + const ptr_uint64 p = ptr_uint64(2, 42, false); AssertThat(p.out_idx(), Is().EqualTo(0u)); AssertThat(flag(p).out_idx(), Is().EqualTo(0u)); }); it("retrieves 0 from (max_label,max_id,false)", [&]() { - const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - false); + const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, false); AssertThat(p.out_idx(), Is().EqualTo(0u)); AssertThat(flag(p).out_idx(), Is().EqualTo(0u)); }); it("retrieves 1 from (0,0,true)", [&]() { - const ptr_uint64 p = ptr_uint64(0,0,true); + const ptr_uint64 p = ptr_uint64(0, 0, true); AssertThat(p.out_idx(), Is().EqualTo(1u)); AssertThat(flag(p).out_idx(), Is().EqualTo(1u)); }); it("retrieves 1 from (2,42,true)", [&]() { - const ptr_uint64 p = ptr_uint64(2,42,true); + const ptr_uint64 p = ptr_uint64(2, 42, true); AssertThat(p.out_idx(), Is().EqualTo(1u)); AssertThat(flag(p).out_idx(), Is().EqualTo(1u)); }); it("retrieves 1 from (max_label,max_id,true)", [&]() { - const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - true); + const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, true); AssertThat(p.out_idx(), Is().EqualTo(1u)); AssertThat(flag(p).out_idx(), Is().EqualTo(1u)); @@ -702,69 +682,64 @@ go_bandit([]() { describe(".id()", [&]() { it("retrieve 0 from (0,0)", [&]() { - const ptr_uint64 p = ptr_uint64(0,0); + const ptr_uint64 p = ptr_uint64(0, 0); AssertThat(p.id(), Is().EqualTo(0u)); AssertThat(flag(p).id(), Is().EqualTo(0u)); }); it("retrieve 0 from (0,0,0)", [&]() { - const ptr_uint64 p = ptr_uint64(0,0,0); + const ptr_uint64 p = ptr_uint64(0, 0, 0); AssertThat(p.id(), Is().EqualTo(0u)); AssertThat(flag(p).id(), Is().EqualTo(0u)); }); it("retrieves 0 from (0,0,max_out_idx)", [&]() { - const ptr_uint64 p = ptr_uint64(0,0, ptr_uint64::max_out_idx); + const ptr_uint64 p = ptr_uint64(0, 0, ptr_uint64::max_out_idx); AssertThat(p.id(), Is().EqualTo(0u)); AssertThat(flag(p).id(), Is().EqualTo(0u)); }); it("retrieve max_id from (0,max_id)", [&]() { - const ptr_uint64 p = ptr_uint64(0,ptr_uint64::max_id); + const ptr_uint64 p = ptr_uint64(0, ptr_uint64::max_id); AssertThat(p.id(), Is().EqualTo(ptr_uint64::max_id)); AssertThat(flag(p).id(), Is().EqualTo(ptr_uint64::max_id)); }); it("retrieves max_id from (0,max_id,max_out_idx)", [&]() { - const ptr_uint64 p = ptr_uint64(0, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const ptr_uint64 p = ptr_uint64(0, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(p.id(), Is().EqualTo(ptr_uint64::max_id)); AssertThat(flag(p).id(), Is().EqualTo(ptr_uint64::max_id)); }); it("retrieves max_id from (max_label,max_id,max_out_idx)", [&]() { - const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const ptr_uint64 p = + ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(p.id(), Is().EqualTo(ptr_uint64::max_id)); AssertThat(flag(p).id(), Is().EqualTo(ptr_uint64::max_id)); }); it("retrieves 0 from (max_label,0,max_out_idx)", [&]() { - const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, - 0, - ptr_uint64::max_out_idx); + const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, 0, ptr_uint64::max_out_idx); AssertThat(p.id(), Is().EqualTo(0u)); AssertThat(flag(p).id(), Is().EqualTo(0u)); }); it("retrieves 42 from (2,42)", [&]() { - const ptr_uint64 p = ptr_uint64(2,42); + const ptr_uint64 p = ptr_uint64(2, 42); AssertThat(p.id(), Is().EqualTo(42u)); AssertThat(flag(p).id(), Is().EqualTo(42u)); }); it("retrieve 21 from (2,21)", [&]() { - const ptr_uint64 p = ptr_uint64(2,21); + const ptr_uint64 p = ptr_uint64(2, 21); AssertThat(p.id(), Is().EqualTo(21u)); AssertThat(flag(p).id(), Is().EqualTo(21u)); @@ -773,23 +748,22 @@ go_bandit([]() { describe("essential(...)", []() { it("strips off flag from minimal Node Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(0,0,0); + const ptr_uint64 p = ptr_uint64(0, 0, 0); AssertThat(essential(p), Is().EqualTo(p)); AssertThat(essential(flag(p)), Is().EqualTo(p)); }); it("keeps out_idx as 0 for minimal Node Ptr", [&]() { - const ptr_uint64 p = ptr_uint64(0,0,0); + const ptr_uint64 p = ptr_uint64(0, 0, 0); AssertThat(essential(p).out_idx(), Is().EqualTo(0u)); }); it("strips off flag from maximal Node Ptr", [&]() { // Use '.is_flagged()' to test it independently of '.out_idx()' - const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const ptr_uint64 p = + ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(essential(p).is_flagged(), Is().False()); AssertThat(essential(flag(p)).is_flagged(), Is().False()); @@ -797,9 +771,8 @@ go_bandit([]() { it("strips off out_idx from maximal Node Ptr", [&]() { // Use '.out_idx()' to test it independently of '.out_idx()' - const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const ptr_uint64 p = + ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(essential(p).out_idx(), Is().EqualTo(0u)); }); @@ -808,17 +781,17 @@ go_bandit([]() { describe("ordering ( < )", [&]() { it("should sort by label, then by id", [&]() { - const ptr_uint64 node_1_2 = ptr_uint64(1,2); - const ptr_uint64 node_2_1 = ptr_uint64(2,1); - const ptr_uint64 node_2_2 = ptr_uint64(2,2); + const ptr_uint64 node_1_2 = ptr_uint64(1, 2); + const ptr_uint64 node_2_1 = ptr_uint64(2, 1); + const ptr_uint64 node_2_2 = ptr_uint64(2, 2); AssertThat(node_1_2 < node_2_1, Is().True()); AssertThat(node_2_1 < node_2_2, Is().True()); }); it("should sort by label and id independent of the flag", [&]() { - const ptr_uint64 node_1_2 = ptr_uint64(1,2); - const ptr_uint64 node_2_1 = ptr_uint64(2,1); + const ptr_uint64 node_1_2 = ptr_uint64(1, 2); + const ptr_uint64 node_2_1 = ptr_uint64(2, 1); AssertThat(node_1_2 < flag(node_2_1), Is().True()); AssertThat(flag(node_1_2) < node_2_1, Is().True()); @@ -826,17 +799,17 @@ go_bandit([]() { }); it("should sort by id, then by out-index", [&]() { - const ptr_uint64 node_1_T = ptr_uint64(0,1,true); - const ptr_uint64 node_2_F = ptr_uint64(0,2,false); - const ptr_uint64 node_2_T = ptr_uint64(0,2,true); + const ptr_uint64 node_1_T = ptr_uint64(0, 1, true); + const ptr_uint64 node_2_F = ptr_uint64(0, 2, false); + const ptr_uint64 node_2_T = ptr_uint64(0, 2, true); AssertThat(node_1_T < node_2_F, Is().True()); AssertThat(node_2_F < node_2_T, Is().True()); }); it("should sort by id and out-index independent of the flag", [&]() { - const ptr_uint64 node_1_T = ptr_uint64(0,1,true); - const ptr_uint64 node_2_F = ptr_uint64(0,2,false); + const ptr_uint64 node_1_T = ptr_uint64(0, 1, true); + const ptr_uint64 node_2_F = ptr_uint64(0, 2, false); AssertThat(node_1_T < flag(node_2_F), Is().True()); AssertThat(flag(node_1_T) < node_2_F, Is().True()); @@ -844,27 +817,27 @@ go_bandit([]() { }); it("should sort by label, then id, and finally out-index", [&]() { - const ptr_uint64 node_a = ptr_uint64(0,3,true); - const ptr_uint64 node_b = ptr_uint64(1,2,false); + const ptr_uint64 node_a = ptr_uint64(0, 3, true); + const ptr_uint64 node_b = ptr_uint64(1, 2, false); AssertThat(node_a < node_b, Is().True()); - const ptr_uint64 node_c = ptr_uint64(2,0,false); - const ptr_uint64 node_d = ptr_uint64(2,0,true); + const ptr_uint64 node_c = ptr_uint64(2, 0, false); + const ptr_uint64 node_d = ptr_uint64(2, 0, true); AssertThat(node_c < node_d, Is().True()); }); it("should sort by label id, and out-index independent of the flag", [&]() { - const ptr_uint64 node_a = ptr_uint64(0,3,true); - const ptr_uint64 node_b = ptr_uint64(1,2,false); + const ptr_uint64 node_a = ptr_uint64(0, 3, true); + const ptr_uint64 node_b = ptr_uint64(1, 2, false); AssertThat(node_a < flag(node_b), Is().True()); AssertThat(flag(node_a) < node_b, Is().True()); AssertThat(flag(node_a) < flag(node_b), Is().True()); - const ptr_uint64 node_c = ptr_uint64(2,0,false); - const ptr_uint64 node_d = ptr_uint64(2,0,true); + const ptr_uint64 node_c = ptr_uint64(2, 0, false); + const ptr_uint64 node_d = ptr_uint64(2, 0, true); AssertThat(flag(node_c) < node_d, Is().True()); AssertThat(node_c < flag(node_d), Is().True()); @@ -875,9 +848,8 @@ go_bandit([]() { const ptr_uint64 p_terminal = ptr_uint64(false); // Create a node pointer with the highest possible raw value - const ptr_uint64 p_node = flag(ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx)); + const ptr_uint64 p_node = + flag(ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx)); AssertThat(p_node < p_terminal, Is().True()); AssertThat(flag(p_node) < p_terminal, Is().True()); @@ -889,9 +861,8 @@ go_bandit([]() { const ptr_uint64 p_terminal = ptr_uint64(true); // Create a node pointer with the highest possible raw value - const ptr_uint64 p_node = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const ptr_uint64 p_node = + ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(p_node < p_terminal, Is().True()); AssertThat(flag(p_node) < p_terminal, Is().True()); @@ -901,4 +872,4 @@ go_bandit([]() { }); }); }); - }); +}); diff --git a/test/adiar/internal/data_types/test_request.cpp b/test/adiar/internal/data_types/test_request.cpp index 0452c6d50..10c660ab4 100644 --- a/test/adiar/internal/data_types/test_request.cpp +++ b/test/adiar/internal/data_types/test_request.cpp @@ -29,47 +29,47 @@ go_bandit([]() { const auto node_carry_size = request<1>::node_carry_size; AssertThat(node_carry_size, Is().EqualTo(0u)); - const request<1> rec({ request<1>::pointer_type(0,0) }, {}); + const request<1> rec({ request<1>::pointer_type(0, 0) }, {}); AssertThat(sizeof(rec), Is().EqualTo(1u * 8u)); }); describe(".level()", []() { it("returns the level of the target [1]", []() { - const request<1> req({request<1>::pointer_type(0u,0u)}, {}); + const request<1> req({ request<1>::pointer_type(0u, 0u) }, {}); AssertThat(req.level(), Is().EqualTo(0u)); }); it("returns the level of the target [2]", []() { - const request<1> req({request<1>::pointer_type(0u,1u)}, {}); + const request<1> req({ request<1>::pointer_type(0u, 1u) }, {}); AssertThat(req.level(), Is().EqualTo(0u)); }); it("returns the level of the target [3]", []() { - const request<1> req({request<1>::pointer_type(1u,0u)}, {}); + const request<1> req({ request<1>::pointer_type(1u, 0u) }, {}); AssertThat(req.level(), Is().EqualTo(1u)); }); it("returns the level of the target [4]", []() { - const request<1> req({request<1>::pointer_type(42u,21u)}, {}); + const request<1> req({ request<1>::pointer_type(42u, 21u) }, {}); AssertThat(req.level(), Is().EqualTo(42u)); }); }); describe(".nodes_carried()", []() { it("does not carry any nodes [1]", []() { - const request<1> req({request<1>::pointer_type(0u,0u)}, {}); + const request<1> req({ request<1>::pointer_type(0u, 0u) }, {}); AssertThat(req.nodes_carried(), Is().EqualTo(0u)); }); it("does not carry any nodes [2]", []() { - const request<1> req({request<1>::pointer_type(42u,21u)}, {}); + const request<1> req({ request<1>::pointer_type(42u, 21u) }, {}); AssertThat(req.nodes_carried(), Is().EqualTo(0u)); }); }); describe(".empty_carry()", []() { it("is true", []() { - const request<1> req(request<1>::pointer_type(0u,0u), {}); + const request<1> req(request<1>::pointer_type(0u, 0u), {}); AssertThat(req.empty_carry(), Is().True()); }); }); @@ -81,12 +81,14 @@ go_bandit([]() { }); it("is 1 for (0,0) target", []() { - const request<1> req(request<1>::pointer_type(0,0), {}); + const request<1> req(request<1>::pointer_type(0, 0), {}); AssertThat(req.targets(), Is().EqualTo(1)); }); it("is 1 for (MAX,MAX) target", []() { - const request<1> req(request<1>::pointer_type(request<1>::pointer_type::max_label,request<1>::pointer_type::max_id), {}); + const request<1> req(request<1>::pointer_type(request<1>::pointer_type::max_label, + request<1>::pointer_type::max_id), + {}); AssertThat(req.targets(), Is().EqualTo(1)); }); @@ -122,10 +124,10 @@ go_bandit([]() { }); it("has the target sorted if number of inputs is 1", []() { - const auto sorted_target = request<2,0,1>::sorted_target; + const auto sorted_target = request<2, 0, 1>::sorted_target; AssertThat(sorted_target, Is().True()); - const auto target__is_sorted = request<2,0,1>::target_t::is_sorted; + const auto target__is_sorted = request<2, 0, 1>::target_t::is_sorted; AssertThat(target__is_sorted, Is().True()); }); @@ -133,139 +135,162 @@ go_bandit([]() { const auto node_carry_size = request<2>::node_carry_size; AssertThat(node_carry_size, Is().EqualTo(0u)); - const request<2,0> rec({ request<2>::pointer_type(0,0), request<2>::pointer_type(0,0) }, { }); + const request<2, 0> rec({ request<2>::pointer_type(0, 0), request<2>::pointer_type(0, 0) }, + {}); AssertThat(sizeof(rec), Is().EqualTo(2u * 8u + 0u * 2u * 8u)); }); it("can have a node carry size of 1 (32 bytes)", []() { - const auto node_carry_size = request<2,1>::node_carry_size; + const auto node_carry_size = request<2, 1>::node_carry_size; AssertThat(node_carry_size, Is().EqualTo(1u)); - const request<2,1> rec({ request<2>::pointer_type(0,0), request<2>::pointer_type(0,0) }, - {{ {request<2>::pointer_type::nil()} }}); + const request<2, 1> rec({ request<2>::pointer_type(0, 0), request<2>::pointer_type(0, 0) }, + { { { request<2>::pointer_type::nil() } } }); AssertThat(sizeof(rec), Is().EqualTo(2u * 8u + 1u * 2u * 8u)); }); describe(".level()", []() { it("returns the level of the first uid in target [1]", []() { - const request<2> req({request<2>::pointer_type(0u,1u), request<2>::pointer_type(1u,0u)}, {}); + const request<2> req( + { request<2>::pointer_type(0u, 1u), request<2>::pointer_type(1u, 0u) }, {}); AssertThat(req.level(), Is().EqualTo(0u)); }); it("returns the level of the first uid in target [2]", []() { - const request<2> req({request<2>::pointer_type(1u,0u), request<2>::pointer_type(0u,1u)}, {}); + const request<2> req( + { request<2>::pointer_type(1u, 0u), request<2>::pointer_type(0u, 1u) }, {}); AssertThat(req.level(), Is().EqualTo(0u)); }); it("returns the level of the first uid in target [3]", []() { - const request<2> req({request<2>::pointer_type(21u,11u), request<2>::pointer_type(42u,8u)}, {}); + const request<2> req( + { request<2>::pointer_type(21u, 11u), request<2>::pointer_type(42u, 8u) }, {}); AssertThat(req.level(), Is().EqualTo(21u)); }); it("returns the level of the first uid in target [4]", []() { - const request<2> req({request<2>::pointer_type(42u,11u), request<2>::pointer_type(21u,42u)}, {}); + const request<2> req( + { request<2>::pointer_type(42u, 11u), request<2>::pointer_type(21u, 42u) }, {}); AssertThat(req.level(), Is().EqualTo(21u)); }); }); describe(".nodes_carried()", []() { it("has no nodes when node_carry_size is 0", []() { - const request<2,0> req({request<2>::pointer_type(1u,1u), request<2>::pointer_type(1u,0u)}, {}); + const request<2, 0> req( + { request<2>::pointer_type(1u, 1u), request<2>::pointer_type(1u, 0u) }, {}); AssertThat(req.nodes_carried(), Is().EqualTo(0u)); }); it("has no nodes when node_carry_size is 1 with manually added nil()", []() { - const request<2,1> req({request<2>::pointer_type(1u,1u), request<2>::pointer_type(1u,0u)}, - {{ request<2>::pointer_type::nil() }}); + const request<2, 1> req( + { request<2>::pointer_type(1u, 1u), request<2>::pointer_type(1u, 0u) }, + { { request<2>::pointer_type::nil() } }); AssertThat(req.nodes_carried(), Is().EqualTo(0u)); }); it("has no nodes when node_carry_size is 1 with NO_CHILDREN()", []() { - const request<2,1> req({request<2>::pointer_type(1u,1u), request<2>::pointer_type(1u,0u)}, - {{ request<2>::NO_CHILDREN() }}); + const request<2, 1> req( + { request<2>::pointer_type(1u, 1u), request<2>::pointer_type(1u, 0u) }, + { { request<2>::NO_CHILDREN() } }); AssertThat(req.nodes_carried(), Is().EqualTo(0u)); }); it("has one nodes when node_carry_size is 1 with non-nil content", []() { - const request<2,1> req({request<2>::pointer_type(1u,1u), request<2>::pointer_type(1u,0u)}, - {{ {request<2>::pointer_type(2u,1u), request<2>::pointer_type(2u,0u)} }}); + const request<2, 1> req( + { request<2>::pointer_type(1u, 1u), request<2>::pointer_type(1u, 0u) }, + { { { request<2>::pointer_type(2u, 1u), request<2>::pointer_type(2u, 0u) } } }); AssertThat(req.nodes_carried(), Is().EqualTo(1u)); }); }); describe(".empty_carry()", []() { it("is true when node_carry_size is 0", []() { - const request<2,0> req({request<2>::pointer_type(1u,1u), request<2>::pointer_type(1u,0u)}, {}); + const request<2, 0> req( + { request<2>::pointer_type(1u, 1u), request<2>::pointer_type(1u, 0u) }, {}); AssertThat(req.empty_carry(), Is().True()); }); it("is true when node_carry_size is 1 with manually added nil()", []() { - const request<2,1> req({request<2>::pointer_type(1u,1u), request<2>::pointer_type(1u,0u)}, - {{ request<2>::pointer_type::nil() }}); + const request<2, 1> req( + { request<2>::pointer_type(1u, 1u), request<2>::pointer_type(1u, 0u) }, + { { request<2>::pointer_type::nil() } }); AssertThat(req.empty_carry(), Is().True()); }); it("is true when node_carry_size is 1 with NO_CHILDREN()", []() { - const request<2,1> req({request<2>::pointer_type(1u,1u), request<2>::pointer_type(1u,0u)}, - {{ request<2>::NO_CHILDREN() }}); + const request<2, 1> req( + { request<2>::pointer_type(1u, 1u), request<2>::pointer_type(1u, 0u) }, + { { request<2>::NO_CHILDREN() } }); AssertThat(req.empty_carry(), Is().True()); }); it("is false when node_carry_size is 1 with non-nil content", []() { - const request<2,1> req({request<2>::pointer_type(1u,1u), request<2>::pointer_type(1u,0u)}, - {{ {request<2>::pointer_type(2u,1u), request<2>::pointer_type(2u,0u)} }}); + const request<2, 1> req( + { request<2>::pointer_type(1u, 1u), request<2>::pointer_type(1u, 0u) }, + { { { request<2>::pointer_type(2u, 1u), request<2>::pointer_type(2u, 0u) } } }); AssertThat(req.empty_carry(), Is().False()); }); }); describe(".targets()", []() { it("is 0 for {nil, nil} target [unsorted]", []() { - const request<2>req({request<2>::pointer_type::nil(), request<2>::pointer_type::nil()}, {}); + const request<2> req({ request<2>::pointer_type::nil(), request<2>::pointer_type::nil() }, + {}); AssertThat(req.targets(), Is().EqualTo(0)); }); it("is 0 for {nil, nil} target [sorted]", []() { - const request<2,0,1> req({request<2>::pointer_type::nil(), request<2>::pointer_type::nil()}, {}); + const request<2, 0, 1> req( + { request<2>::pointer_type::nil(), request<2>::pointer_type::nil() }, {}); AssertThat(req.targets(), Is().EqualTo(0)); }); it("is 1 for {(0,0), nil} target [unsorted]", []() { - const request<2> req({request<2>::pointer_type(0,0), request<2>::pointer_type::nil()}, {}); + const request<2> req({ request<2>::pointer_type(0, 0), request<2>::pointer_type::nil() }, + {}); AssertThat(req.targets(), Is().EqualTo(1)); }); it("is 1 for {nil, (0,0)} target [unsorted]", []() { - const request<2> req({request<2>::pointer_type(0,0), request<2>::pointer_type::nil()}, {}); + const request<2> req({ request<2>::pointer_type(0, 0), request<2>::pointer_type::nil() }, + {}); AssertThat(req.targets(), Is().EqualTo(1)); }); it("is 1 for {(0,0), nil} target [sorted]", []() { - const request<2,0,1> req({request<2>::pointer_type(0,0), request<2>::pointer_type::nil()}, {}); + const request<2, 0, 1> req( + { request<2>::pointer_type(0, 0), request<2>::pointer_type::nil() }, {}); AssertThat(req.targets(), Is().EqualTo(1)); }); it("is 1 for {F, nil} target [unsorted]", []() { - const request<2> req({request<2>::pointer_type(false), request<2>::pointer_type::nil()}, {}); + const request<2> req({ request<2>::pointer_type(false), request<2>::pointer_type::nil() }, + {}); AssertThat(req.targets(), Is().EqualTo(1)); }); it("is 1 for {T, nil} target [sorted]", []() { - const request<2,0,1> req({request<2>::pointer_type(true), request<2>::pointer_type::nil()}, {}); + const request<2, 0, 1> req( + { request<2>::pointer_type(true), request<2>::pointer_type::nil() }, {}); AssertThat(req.targets(), Is().EqualTo(1)); }); it("is 2 for {(0,0), T} target [unsorted]", []() { - const request<2> req({request<2>::pointer_type(0,0), request<2>::pointer_type(true)}, {}); + const request<2> req({ request<2>::pointer_type(0, 0), request<2>::pointer_type(true) }, + {}); AssertThat(req.targets(), Is().EqualTo(2)); }); it("is 2 for {F, (1,0)} target [unsorted]", []() { - const request<2> req({request<2>::pointer_type(false), request<2>::pointer_type(1,0)}, {}); + const request<2> req({ request<2>::pointer_type(false), request<2>::pointer_type(1, 0) }, + {}); AssertThat(req.targets(), Is().EqualTo(2)); }); it("is 2 for {(0,0), T} target [sorted]", []() { - const request<2,0,1> req({request<2>::pointer_type(0,0), request<2>::pointer_type(true)}, {}); + const request<2, 0, 1> req( + { request<2>::pointer_type(0, 0), request<2>::pointer_type(true) }, {}); AssertThat(req.targets(), Is().EqualTo(2)); }); }); @@ -291,10 +316,10 @@ go_bandit([]() { }); it("has the target sorted if number of inputs is 1", []() { - const auto sorted_target = request<3,0,true>::sorted_target; + const auto sorted_target = request<3, 0, true>::sorted_target; AssertThat(sorted_target, Is().True()); - const auto target__is_sorted = request<3,0,true>::target_t::is_sorted; + const auto target__is_sorted = request<3, 0, true>::target_t::is_sorted; AssertThat(target__is_sorted, Is().True()); }); @@ -302,213 +327,302 @@ go_bandit([]() { const auto node_carry_size = request<3>::node_carry_size; AssertThat(node_carry_size, Is().EqualTo(0u)); - const request<3,0> rec({ request<3>::pointer_type(0,0), request<3>::pointer_type(0,0), request<3>::pointer_type(0,0) }, - { }); + const request<3, 0> rec({ request<3>::pointer_type(0, 0), + request<3>::pointer_type(0, 0), + request<3>::pointer_type(0, 0) }, + {}); AssertThat(sizeof(rec), Is().EqualTo(3u * 8u + 0u * 2u * 8u)); }); it("can have a node carry size of 1 (32 bytes)", []() { - const auto node_carry_size = request<3,1>::node_carry_size; + const auto node_carry_size = request<3, 1>::node_carry_size; AssertThat(node_carry_size, Is().EqualTo(1u)); - const request<3,1> rec({ request<3>::pointer_type(0,0), request<3>::pointer_type(0,0), request<3>::pointer_type(0,0) }, - {{ {request<3>::pointer_type::nil()} }}); + const request<3, 1> rec({ request<3>::pointer_type(0, 0), + request<3>::pointer_type(0, 0), + request<3>::pointer_type(0, 0) }, + { { { request<3>::pointer_type::nil() } } }); AssertThat(sizeof(rec), Is().EqualTo(3u * 8u + 1u * 2u * 8u)); }); it("can have a node carry size of 2 (48 bytes)", []() { - const auto node_carry_size = request<3,2>::node_carry_size; + const auto node_carry_size = request<3, 2>::node_carry_size; AssertThat(node_carry_size, Is().EqualTo(2u)); - const request<3,2> rec({ request<3>::pointer_type(0,0), request<3>::pointer_type(0,0), request<3>::pointer_type(0,0) }, - {{ {request<3>::pointer_type::nil()}, - {request<3>::pointer_type::nil()} }}); + const request<3, 2> rec( + { request<3>::pointer_type(0, 0), + request<3>::pointer_type(0, 0), + request<3>::pointer_type(0, 0) }, + { { { request<3>::pointer_type::nil() }, { request<3>::pointer_type::nil() } } }); AssertThat(sizeof(rec), Is().EqualTo(3u * 8u + 2u * 2u * 8u)); }); describe(".level()", []() { it("returns the level of the first uid in target [1]", []() { - const request<3> req({request<3>::pointer_type(0u,2u), request<3>::pointer_type(1u,1u), request<3>::pointer_type(2u,0u)}, {}); + const request<3> req({ request<3>::pointer_type(0u, 2u), + request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(2u, 0u) }, + {}); AssertThat(req.level(), Is().EqualTo(0u)); }); it("returns the level of the first uid in target [2]", []() { - const request<3> req({request<3>::pointer_type(1u,1u), request<3>::pointer_type(0u,2u), request<3>::pointer_type(2u,0u)}, {}); + const request<3> req({ request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(0u, 2u), + request<3>::pointer_type(2u, 0u) }, + {}); AssertThat(req.level(), Is().EqualTo(0u)); }); - it("returns the level of the first uid in target [3]", []() { - const request<3> req({request<3>::pointer_type(1u,1u), request<3>::pointer_type(2u,0u), request<3>::pointer_type(0u,2u)}, {}); + const request<3> req({ request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(2u, 0u), + request<3>::pointer_type(0u, 2u) }, + {}); AssertThat(req.level(), Is().EqualTo(0u)); }); it("returns the level of the first uid in target [4]", []() { - const request<3> req({request<3>::pointer_type(32u,0u), request<3>::pointer_type(21u,11u), request<3>::pointer_type(42u,8u)}, {}); + const request<3> req({ request<3>::pointer_type(32u, 0u), + request<3>::pointer_type(21u, 11u), + request<3>::pointer_type(42u, 8u) }, + {}); AssertThat(req.level(), Is().EqualTo(21u)); }); it("returns the level of the first uid in target [4]", []() { - const request<3> req({request<3>::pointer_type(32u,0u), request<3>::pointer_type(42u,11u), request<3>::pointer_type(21u,42u)}, {}); + const request<3> req({ request<3>::pointer_type(32u, 0u), + request<3>::pointer_type(42u, 11u), + request<3>::pointer_type(21u, 42u) }, + {}); AssertThat(req.level(), Is().EqualTo(21u)); }); }); describe(".nodes_carried()", []() { it("has no nodes when node_carry_size is 0", []() { - const request<3,0> req({request<3>::pointer_type(1u,1u), request<3>::pointer_type(1u,0u), request<3>::pointer_type(1u,2u)}, - {}); + const request<3, 0> req({ request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(1u, 0u), + request<3>::pointer_type(1u, 2u) }, + {}); AssertThat(req.nodes_carried(), Is().EqualTo(0u)); }); it("has no nodes when node_carry_size is 1 with manually added nil()", []() { - const request<3,1> req({request<3>::pointer_type(1u,1u), request<3>::pointer_type(1u,0u), request<3>::pointer_type(1u,2u)}, - {{ {request<3>::pointer_type::nil()} }}); + const request<3, 1> req({ request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(1u, 0u), + request<3>::pointer_type(1u, 2u) }, + { { { request<3>::pointer_type::nil() } } }); AssertThat(req.nodes_carried(), Is().EqualTo(0u)); }); it("has no nodes when node_carry_size is 2 with manually added nil()", []() { - const request<3,2> req({request<3>::pointer_type(1u,1u), request<3>::pointer_type(1u,0u), request<3>::pointer_type(1u,2u)}, - {{ {request<3>::pointer_type::nil()}, - {request<3>::pointer_type::nil()} }}); + const request<3, 2> req( + { request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(1u, 0u), + request<3>::pointer_type(1u, 2u) }, + { { { request<3>::pointer_type::nil() }, { request<3>::pointer_type::nil() } } }); AssertThat(req.nodes_carried(), Is().EqualTo(0u)); }); it("has no nodes when node_carry_size is 1 with NO_CHILDREN()", []() { - const request<3,1> req({request<3>::pointer_type(1u,1u), request<3>::pointer_type(1u,0u), request<3>::pointer_type(1u,2u)}, - {{ request<3>::NO_CHILDREN() }}); + const request<3, 1> req({ request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(1u, 0u), + request<3>::pointer_type(1u, 2u) }, + { { request<3>::NO_CHILDREN() } }); AssertThat(req.nodes_carried(), Is().EqualTo(0u)); }); it("has no nodes when node_carry_size is 2 with NO_CHILDREN()", []() { - const request<3,2> req({request<3>::pointer_type(1u,1u), request<3>::pointer_type(1u,0u), request<3>::pointer_type(1u,2u)}, - {{ request<3>::NO_CHILDREN(), request<3>::NO_CHILDREN() }}); + const request<3, 2> req({ request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(1u, 0u), + request<3>::pointer_type(1u, 2u) }, + { { request<3>::NO_CHILDREN(), request<3>::NO_CHILDREN() } }); AssertThat(req.nodes_carried(), Is().EqualTo(0u)); }); it("has one nodes when node_carry_size is 1 with non-nil content", []() { - const request<3,1> req({request<3>::pointer_type(1u,1u), request<3>::pointer_type(1u,0u), request<3>::pointer_type(1u,2u)}, - {{ {request<3>::pointer_type(2u,1u), request<3>::pointer_type(2u,0u)} }}); + const request<3, 1> req( + { request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(1u, 0u), + request<3>::pointer_type(1u, 2u) }, + { { { request<3>::pointer_type(2u, 1u), request<3>::pointer_type(2u, 0u) } } }); AssertThat(req.nodes_carried(), Is().EqualTo(1u)); }); it("has one nodes when node_carry_size is 2 with non-nil and nil content", []() { - const request<3,2> req({request<3>::pointer_type(1u,1u), request<3>::pointer_type(1u,0u), request<3>::pointer_type(1u,2u)}, - {{ {request<3>::pointer_type(2u,1u), request<3>::pointer_type(2u,0u)}, - request<3>::NO_CHILDREN() }}); + const request<3, 2> req( + { request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(1u, 0u), + request<3>::pointer_type(1u, 2u) }, + { { { request<3>::pointer_type(2u, 1u), request<3>::pointer_type(2u, 0u) }, + request<3>::NO_CHILDREN() } }); AssertThat(req.nodes_carried(), Is().EqualTo(1u)); }); it("has two nodes when node_carry_size is 2 with non-nil content", []() { - const request<3,2> req({request<3>::pointer_type(1u,1u), request<3>::pointer_type(1u,0u), request<3>::pointer_type(1u,2u)}, - {{ {request<3>::pointer_type(2u,1u), request<3>::pointer_type(2u,0u)}, - {request<3>::pointer_type(2u,1u), request<3>::pointer_type(2u,0u)} }}); + const request<3, 2> req( + { request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(1u, 0u), + request<3>::pointer_type(1u, 2u) }, + { { { request<3>::pointer_type(2u, 1u), request<3>::pointer_type(2u, 0u) }, + { request<3>::pointer_type(2u, 1u), request<3>::pointer_type(2u, 0u) } } }); AssertThat(req.nodes_carried(), Is().EqualTo(2u)); }); }); describe(".empty_carry()", []() { it("is true when node_carry_size is 0", []() { - const request<3,0> req({request<3>::pointer_type(1u,1u), request<3>::pointer_type(1u,0u), request<3>::pointer_type(1u,2u)}, - {}); + const request<3, 0> req({ request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(1u, 0u), + request<3>::pointer_type(1u, 2u) }, + {}); AssertThat(req.empty_carry(), Is().True()); }); it("is true when node_carry_size is 1 with NO_CHILDREN()", []() { - const request<3,1> req({request<3>::pointer_type(1u,1u), request<3>::pointer_type(1u,0u), request<3>::pointer_type(1u,2u)}, - { request<3>::NO_CHILDREN() }); + const request<3, 1> req({ request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(1u, 0u), + request<3>::pointer_type(1u, 2u) }, + { request<3>::NO_CHILDREN() }); AssertThat(req.empty_carry(), Is().True()); }); it("is true nodes when node_carry_size is 2 with NO_CHILDREN()", []() { - const request<3,2> req({request<3>::pointer_type(1u,1u), request<3>::pointer_type(1u,0u), request<3>::pointer_type(1u,2u)}, - {{ request<3>::NO_CHILDREN(), - request<3>::NO_CHILDREN() }}); + const request<3, 2> req({ request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(1u, 0u), + request<3>::pointer_type(1u, 2u) }, + { { request<3>::NO_CHILDREN(), request<3>::NO_CHILDREN() } }); AssertThat(req.empty_carry(), Is().True()); }); it("is false nodes when node_carry_size is 1 with non-nil content", []() { - const request<3,1> req({request<3>::pointer_type(1u,1u), request<3>::pointer_type(1u,0u), request<3>::pointer_type(1u,2u)}, - {{ {request<3>::pointer_type(2u,1u), request<3>::pointer_type(2u,0u)} }}); + const request<3, 1> req( + { request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(1u, 0u), + request<3>::pointer_type(1u, 2u) }, + { { { request<3>::pointer_type(2u, 1u), request<3>::pointer_type(2u, 0u) } } }); AssertThat(req.empty_carry(), Is().False()); }); it("is false nodes when node_carry_size is 2 with non-nil and nil content", []() { - const request<3,2> req({request<3>::pointer_type(1u,1u), request<3>::pointer_type(1u,0u), request<3>::pointer_type(1u,2u)}, - {{ {request<3>::pointer_type(2u,1u), request<3>::pointer_type(2u,0u)}, - request<3>::NO_CHILDREN() }}); + const request<3, 2> req( + { request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(1u, 0u), + request<3>::pointer_type(1u, 2u) }, + { { { request<3>::pointer_type(2u, 1u), request<3>::pointer_type(2u, 0u) }, + request<3>::NO_CHILDREN() } }); AssertThat(req.empty_carry(), Is().False()); }); it("is false nodes when node_carry_size is 2 with non-nil content", []() { - const request<3,2> req({request<3>::pointer_type(1u,1u), request<3>::pointer_type(1u,0u), request<3>::pointer_type(1u,2u)}, - {{ {request<3>::pointer_type(2u,1u), request<3>::pointer_type(2u,0u)}, - {request<3>::pointer_type(2u,1u), request<3>::pointer_type(2u,0u)} }}); + const request<3, 2> req( + { request<3>::pointer_type(1u, 1u), + request<3>::pointer_type(1u, 0u), + request<3>::pointer_type(1u, 2u) }, + { { { request<3>::pointer_type(2u, 1u), request<3>::pointer_type(2u, 0u) }, + { request<3>::pointer_type(2u, 1u), request<3>::pointer_type(2u, 0u) } } }); AssertThat(req.empty_carry(), Is().False()); }); }); describe(".targets()", []() { it("is 0 for {nil, nil, nil} target [unsorted]", []() { - const request<3>req({request<3>::pointer_type::nil(), request<3>::pointer_type::nil(), request<3>::pointer_type::nil()}, {}); + const request<3> req({ request<3>::pointer_type::nil(), + request<3>::pointer_type::nil(), + request<3>::pointer_type::nil() }, + {}); AssertThat(req.targets(), Is().EqualTo(0)); }); it("is 0 for {nil, nil, nil} target [sorted]", []() { - const request<3,0,1> req({request<3>::pointer_type::nil(), request<3>::pointer_type::nil(), request<3>::pointer_type::nil()}, {}); + const request<3, 0, 1> req({ request<3>::pointer_type::nil(), + request<3>::pointer_type::nil(), + request<3>::pointer_type::nil() }, + {}); AssertThat(req.targets(), Is().EqualTo(0)); }); it("is 1 for {nil, T, nil} target [unsorted]", []() { - const request<3> req({request<3>::pointer_type::nil(), request<3>::pointer_type(true), request<3>::pointer_type::nil()}, {}); + const request<3> req({ request<3>::pointer_type::nil(), + request<3>::pointer_type(true), + request<3>::pointer_type::nil() }, + {}); AssertThat(req.targets(), Is().EqualTo(1)); }); it("is 1 for {(1,0), nil, nil} target [unsorted]", []() { - const request<3> req({request<3>::pointer_type(1,0), request<3>::pointer_type::nil(), request<3>::pointer_type::nil()}, {}); + const request<3> req({ request<3>::pointer_type(1, 0), + request<3>::pointer_type::nil(), + request<3>::pointer_type::nil() }, + {}); AssertThat(req.targets(), Is().EqualTo(1)); }); it("is 1 for {nil, nil, (0,0)} target [unsorted]", []() { - const request<3> req({request<3>::pointer_type::nil(), request<3>::pointer_type::nil(), request<3>::pointer_type(0,0)}, {}); + const request<3> req({ request<3>::pointer_type::nil(), + request<3>::pointer_type::nil(), + request<3>::pointer_type(0, 0) }, + {}); AssertThat(req.targets(), Is().EqualTo(1)); }); it("is 1 for {T, nil, nil} target [sorted]", []() { - const request<3,0,1> req({request<3>::pointer_type(true), request<3>::pointer_type::nil(), request<3>::pointer_type::nil()}, {}); + const request<3, 0, 1> req({ request<3>::pointer_type(true), + request<3>::pointer_type::nil(), + request<3>::pointer_type::nil() }, + {}); AssertThat(req.targets(), Is().EqualTo(1)); }); it("is 2 for {T, nil, (0,0)} target [unsorted]", []() { - const request<3> req({request<3>::pointer_type(true), request<3>::pointer_type::nil(), request<3>::pointer_type(0,0)}, {}); + const request<3> req({ request<3>::pointer_type(true), + request<3>::pointer_type::nil(), + request<3>::pointer_type(0, 0) }, + {}); AssertThat(req.targets(), Is().EqualTo(2)); }); it("is 2 for {nil, (42,0), (0,0)} target [unsorted]", []() { - const request<3> req({request<3>::pointer_type::nil(), request<3>::pointer_type(42,0), request<3>::pointer_type(0,0)}, {}); + const request<3> req({ request<3>::pointer_type::nil(), + request<3>::pointer_type(42, 0), + request<3>::pointer_type(0, 0) }, + {}); AssertThat(req.targets(), Is().EqualTo(2)); }); it("is 2 for {(42,0), (0,0), nil} target [unsorted]", []() { - const request<3> req({request<3>::pointer_type(42,0), request<3>::pointer_type(0,0), request<3>::pointer_type::nil()}, {}); + const request<3> req({ request<3>::pointer_type(42, 0), + request<3>::pointer_type(0, 0), + request<3>::pointer_type::nil() }, + {}); AssertThat(req.targets(), Is().EqualTo(2)); }); it("is 2 for {(2,8), F, nil} target [sorted]", []() { - const request<3,0,1> req({request<3>::pointer_type(2,8), request<3>::pointer_type(false), request<3>::pointer_type::nil()}, {}); + const request<3, 0, 1> req({ request<3>::pointer_type(2, 8), + request<3>::pointer_type(false), + request<3>::pointer_type::nil() }, + {}); AssertThat(req.targets(), Is().EqualTo(2)); }); it("is 3 for {(2,8), F, (3,0)} target [unsorted]", []() { - const request<3> req({request<3>::pointer_type(2,8), request<3>::pointer_type(false), request<3>::pointer_type(3,0)}, {}); + const request<3> req({ request<3>::pointer_type(2, 8), + request<3>::pointer_type(false), + request<3>::pointer_type(3, 0) }, + {}); AssertThat(req.targets(), Is().EqualTo(3)); }); it("is 3 for {(2,8), (3,0), T} target [sorted]", []() { - const request<3,0,1> req({request<3>::pointer_type(2,8), request<3>::pointer_type(3,0), request<3>::pointer_type(true)}, {}); + const request<3, 0, 1> req({ request<3>::pointer_type(2, 8), + request<3>::pointer_type(3, 0), + request<3>::pointer_type(true) }, + {}); AssertThat(req.targets(), Is().EqualTo(3)); }); }); }); }); - }); +}); diff --git a/test/adiar/internal/data_types/test_tuple.cpp b/test/adiar/internal/data_types/test_tuple.cpp index fc04c63f4..809223699 100644 --- a/test/adiar/internal/data_types/test_tuple.cpp +++ b/test/adiar/internal/data_types/test_tuple.cpp @@ -6,87 +6,87 @@ go_bandit([]() { describe("adiar/internal/data_types/tuple.h", []() { describe("tuple", []() { it("statically provides its cardinality of 1.", []() { - const auto cardinality = tuple::cardinality; + const auto cardinality = tuple::cardinality; AssertThat(cardinality, Is().EqualTo(1u)); }); it("is trivially sorted even though not specified.", []() { - const auto is_sorted = tuple::is_sorted; + const auto is_sorted = tuple::is_sorted; AssertThat(is_sorted, Is().EqualTo(true)); }); describe("unordered access: '[]' operator", []() { it("provides unordered access [42]", []() { - const tuple t = { 42 }; + const tuple t = { 42 }; AssertThat(t[0], Is().EqualTo(42)); }); it("provides unordered access [0]", []() { - const tuple t = { 0 }; + const tuple t = { 0 }; AssertThat(t[0], Is().EqualTo(0)); }); it("provides unordered access [1]", []() { - const tuple t = { 1 }; + const tuple t = { 1 }; AssertThat(t[0], Is().EqualTo(1)); }); it("provides unordered access [-1]", []() { - const tuple t = { -1 }; + const tuple t = { -1 }; AssertThat(t[0], Is().EqualTo(-1)); }); }); describe("ordered access: 'first' function", []() { it("provides ordered access to first element [42]", []() { - const tuple t = { 42 }; + const tuple t = { 42 }; AssertThat(t.first(), Is().EqualTo(42)); }); it("provides ordered access to first element [0]", []() { - const tuple t = { 0 }; + const tuple t = { 0 }; AssertThat(t.first(), Is().EqualTo(0)); }); it("provides ordered access to first element [1]", []() { - const tuple t = { 1 }; + const tuple t = { 1 }; AssertThat(t.first(), Is().EqualTo(1)); }); it("provides ordered access to first element [-1]", []() { - const tuple t = { -1 }; + const tuple t = { -1 }; AssertThat(t.first(), Is().EqualTo(-1)); }); }); describe("Coordinate-wise Equality '=='", []() { it("claims {-1} == {-1}", []() { - const tuple t1 = { -1 }; - const tuple t2 = { -1 }; + const tuple t1 = { -1 }; + const tuple t2 = { -1 }; AssertThat(t1, Is().EqualTo(t2)); AssertThat(t2, Is().EqualTo(t1)); }); it("claims {0} == {0}", []() { - const tuple t1 = { 0 }; - const tuple t2 = { 0 }; + const tuple t1 = { 0 }; + const tuple t2 = { 0 }; AssertThat(t1, Is().EqualTo(t2)); AssertThat(t2, Is().EqualTo(t1)); }); it("claims {1} == {1}", []() { - const tuple t1 = { 1 }; - const tuple t2 = { 1 }; + const tuple t1 = { 1 }; + const tuple t2 = { 1 }; AssertThat(t1, Is().EqualTo(t2)); AssertThat(t2, Is().EqualTo(t1)); }); it("claims {-1} != {1}", []() { - const tuple t1 = { -1 }; - const tuple t2 = { 1 }; + const tuple t1 = { -1 }; + const tuple t2 = { 1 }; AssertThat(t1, Is().Not().EqualTo(t2)); AssertThat(t2, Is().Not().EqualTo(t1)); @@ -95,8 +95,8 @@ go_bandit([]() { describe("Lexicographical Ordering '<'", []() { it("claims {0} < {1}", []() { - const tuple t1 = { 0 }; - const tuple t2 = { 1 }; + const tuple t1 = { 0 }; + const tuple t2 = { 1 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -104,8 +104,8 @@ go_bandit([]() { }); it("claims {-1} < {0}", []() { - const tuple t1 = { -0 }; - const tuple t2 = { 1 }; + const tuple t1 = { -0 }; + const tuple t2 = { 1 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -113,8 +113,8 @@ go_bandit([]() { }); it("claims {21} < {42}", []() { - const tuple t1 = { 21 }; - const tuple t2 = { 42 }; + const tuple t1 = { 21 }; + const tuple t2 = { 42 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -122,8 +122,8 @@ go_bandit([]() { }); it("claims {-1} < {1}", []() { - const tuple t1 = { -1 }; - const tuple t2 = { 1 }; + const tuple t1 = { -1 }; + const tuple t2 = { 1 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -131,8 +131,8 @@ go_bandit([]() { }); it("claims {0} !< {0}", []() { - const tuple t1 = { 0 }; - const tuple t2 = { 0 }; + const tuple t1 = { 0 }; + const tuple t2 = { 0 }; AssertThat(t1, Is().Not().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -140,8 +140,8 @@ go_bandit([]() { }); it("claims {1} !< {1}", []() { - const tuple t1 = { 1 }; - const tuple t2 = { 1 }; + const tuple t1 = { 1 }; + const tuple t2 = { 1 }; AssertThat(t1, Is().Not().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -151,57 +151,57 @@ go_bandit([]() { describe("tuple_first_lt", []() { it("claims {0} < {1}", []() { - const tuple t1 = { 0 }; - const tuple t2 = { 1 }; + const tuple t1 = { 0 }; + const tuple t2 = { 1 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {-1} < {1}", []() { - const tuple t1 = { -1 }; - const tuple t2 = { 1 }; + const tuple t1 = { -1 }; + const tuple t2 = { 1 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {21} < {42}", []() { - const tuple t1 = { 21 }; - const tuple t2 = { 42 }; + const tuple t1 = { 21 }; + const tuple t2 = { 42 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {42} !< {42}", []() { - const tuple t1 = { 42 }; - const tuple t2 = { 42 }; + const tuple t1 = { 42 }; + const tuple t2 = { 42 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0} !< {0}", []() { - const tuple t1 = { 0 }; - const tuple t2 = { 0 }; + const tuple t1 = { 0 }; + const tuple t2 = { 0 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); }); @@ -209,25 +209,25 @@ go_bandit([]() { describe("tuple", []() { it("statically provides its cardinality of 2.", []() { - const auto cardinality = tuple::cardinality; + const auto cardinality = tuple::cardinality; AssertThat(cardinality, Is().EqualTo(2u)); }); it("is not trivially sorted.", []() { - const auto is_sorted = tuple::is_sorted; + const auto is_sorted = tuple::is_sorted; AssertThat(is_sorted, Is().EqualTo(false)); }); describe("unordered access: '[]' operator", []() { it("provides unordered access [42,22]", []() { - const tuple t = { 42,22 }; + const tuple t = { 42, 22 }; AssertThat(t[0], Is().EqualTo(42)); AssertThat(t[1], Is().EqualTo(22)); }); it("provides unordered access [0, -1]", []() { - const tuple t = { 0, -1 }; + const tuple t = { 0, -1 }; AssertThat(t[0], Is().EqualTo(0)); AssertThat(t[1], Is().EqualTo(-1)); @@ -236,89 +236,89 @@ go_bandit([]() { describe("ordered access: 'first' and 'second' function", []() { it("provides ordered access to first element", []() { - const tuple t1 = { 21, 42 }; + const tuple t1 = { 21, 42 }; AssertThat(t1.first(), Is().EqualTo(21)); - const tuple t2 = { 42, 21 }; + const tuple t2 = { 42, 21 }; AssertThat(t2.first(), Is().EqualTo(21)); }); it("provides ordered access to first element [negative value]", []() { - const tuple t = { -2, -1 }; + const tuple t = { -2, -1 }; AssertThat(t.first(), Is().EqualTo(-2)); }); it("provides ordered access to first element [0 vs. 1]", []() { - const tuple t1 = { 1, 0 }; + const tuple t1 = { 1, 0 }; AssertThat(t1.first(), Is().EqualTo(0)); - const tuple t2 = { 0, 1 }; + const tuple t2 = { 0, 1 }; AssertThat(t2.first(), Is().EqualTo(0)); }); it("provides ordered access to first element [tie]", []() { - const tuple t = { 21, 21 }; + const tuple t = { 21, 21 }; AssertThat(t.first(), Is().EqualTo(21)); }); it("provides ordered access to second element", []() { - const tuple t1 = { 21, 42 }; + const tuple t1 = { 21, 42 }; AssertThat(t1.second(), Is().EqualTo(42)); - const tuple t2 = { 42, 21 }; + const tuple t2 = { 42, 21 }; AssertThat(t2.second(), Is().EqualTo(42)); }); it("provides ordered access to second element [negative values]", []() { - const tuple t = { -2, -1 }; + const tuple t = { -2, -1 }; AssertThat(t.second(), Is().EqualTo(-1)); }); it("provides ordered access to second element [0 vs. 1]", []() { - const tuple t1 = { 1, 0 }; + const tuple t1 = { 1, 0 }; AssertThat(t1.second(), Is().EqualTo(1)); - const tuple t2 = { 0, 1 }; + const tuple t2 = { 0, 1 }; AssertThat(t2.second(), Is().EqualTo(1)); }); it("provides ordered access to second element [tie]", []() { - const tuple t = { 21, 21 }; + const tuple t = { 21, 21 }; AssertThat(t.second(), Is().EqualTo(21)); }); }); it("can construct a tuple with copies of a single element [-1]", []() { - const tuple t = { -1 }; + const tuple t = { -1 }; AssertThat(t[0], Is().EqualTo(-1)); AssertThat(t[1], Is().EqualTo(-1)); }); it("can construct a tuple with copies of a single element [0]", []() { - const tuple t = { 0 }; + const tuple t = { 0 }; AssertThat(t[0], Is().EqualTo(0)); AssertThat(t[1], Is().EqualTo(0)); }); it("can construct a tuple with copies of a single element [1]", []() { - const tuple t = { 1 }; + const tuple t = { 1 }; AssertThat(t[0], Is().EqualTo(1)); AssertThat(t[1], Is().EqualTo(1)); }); it("can construct a tuple with copies of a single element [42]", []() { - const tuple t = { 42 }; + const tuple t = { 42 }; AssertThat(t[0], Is().EqualTo(42)); AssertThat(t[1], Is().EqualTo(42)); }); it("can be constructed from a std::array", []() { - const std::array arr = {8, 2}; - const tuple t(arr); + const std::array arr = { 8, 2 }; + const tuple t(arr); AssertThat(t[0], Is().EqualTo(8)); AssertThat(t[1], Is().EqualTo(2)); @@ -326,32 +326,32 @@ go_bandit([]() { describe("Coordinate-wise Equality '=='", []() { it("claims {0, 0} == {0, 0}", []() { - const tuple t1 = { 0, 0 }; - const tuple t2 = { 0, 0 }; + const tuple t1 = { 0, 0 }; + const tuple t2 = { 0, 0 }; AssertThat(t1, Is().EqualTo(t2)); AssertThat(t2, Is().EqualTo(t1)); }); it("claims {1, 0} == {1, 0}", []() { - const tuple t1 = { 1, 0 }; - const tuple t2 = { 1, 0 }; + const tuple t1 = { 1, 0 }; + const tuple t2 = { 1, 0 }; AssertThat(t1, Is().EqualTo(t2)); AssertThat(t2, Is().EqualTo(t1)); }); it("claims {1, 0} != {0, 1}", []() { - const tuple t1 = { 1, 0 }; - const tuple t2 = { 0, 1 }; + const tuple t1 = { 1, 0 }; + const tuple t2 = { 0, 1 }; AssertThat(t1, Is().Not().EqualTo(t2)); AssertThat(t2, Is().Not().EqualTo(t1)); }); it("claims {42, 21} != {42, 20}", []() { - const tuple t1 = { 42, 21 }; - const tuple t2 = { 42, 20 }; + const tuple t1 = { 42, 21 }; + const tuple t2 = { 42, 20 }; AssertThat(t1, Is().Not().EqualTo(t2)); AssertThat(t2, Is().Not().EqualTo(t1)); @@ -360,8 +360,8 @@ go_bandit([]() { describe("Lexicographical Ordering '<'", []() { it("claims {0, 2} < {1, 2}", []() { - const tuple t1 = { 0, 2 }; - const tuple t2 = { 1, 2 }; + const tuple t1 = { 0, 2 }; + const tuple t2 = { 1, 2 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -369,8 +369,8 @@ go_bandit([]() { }); it("claims {1, 2} < {2, 0}", []() { - const tuple t1 = { 0, 2 }; - const tuple t2 = { 1, 0 }; + const tuple t1 = { 0, 2 }; + const tuple t2 = { 1, 0 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -378,8 +378,8 @@ go_bandit([]() { }); it("claims {0, 0} < {0, 1}", []() { - const tuple t1 = { 0, 0 }; - const tuple t2 = { 0, 1 }; + const tuple t1 = { 0, 0 }; + const tuple t2 = { 0, 1 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -387,8 +387,8 @@ go_bandit([]() { }); it("claims {0, 0} < {0, 1}", []() { - const tuple t1 = { 0, 0 }; - const tuple t2 = { 0, 1 }; + const tuple t1 = { 0, 0 }; + const tuple t2 = { 0, 1 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -396,8 +396,8 @@ go_bandit([]() { }); it("claims {0, 0} !< {0, 0}", []() { - const tuple t1 = { 0, 0 }; - const tuple t2 = { 0, 0 }; + const tuple t1 = { 0, 0 }; + const tuple t2 = { 0, 0 }; AssertThat(t1, Is().Not().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -405,8 +405,8 @@ go_bandit([]() { }); it("claims {1, 0} !< {1, 0}", []() { - const tuple t1 = { 1, 0 }; - const tuple t2 = { 1, 0 }; + const tuple t1 = { 1, 0 }; + const tuple t2 = { 1, 0 }; AssertThat(t1, Is().Not().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -414,8 +414,8 @@ go_bandit([]() { }); it("claims {21, 42} !< {21, 42}", []() { - const tuple t1 = { 21, 42 }; - const tuple t2 = { 21, 42 }; + const tuple t1 = { 21, 42 }; + const tuple t2 = { 21, 42 }; AssertThat(t1, Is().Not().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -425,147 +425,147 @@ go_bandit([]() { describe("tuple_first_lt", []() { it("claims {0, 2} < {1, 2}", []() { - const tuple t1 = { 0, 2 }; - const tuple t2 = { 1, 2 }; + const tuple t1 = { 0, 2 }; + const tuple t2 = { 1, 2 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {2, 0} < {1, 2}", []() { - const tuple t1 = { 2, 0 }; - const tuple t2 = { 1, 2 }; + const tuple t1 = { 2, 0 }; + const tuple t2 = { 1, 2 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 1} < {2, 0}", []() { - const tuple t1 = { 0, 1 }; - const tuple t2 = { 2, 0 }; + const tuple t1 = { 0, 1 }; + const tuple t2 = { 2, 0 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 0} !< {0, 0}", []() { - const tuple t1 = { 0, 0 }; - const tuple t2 = { 0, 0 }; + const tuple t1 = { 0, 0 }; + const tuple t2 = { 0, 0 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {1, 0} !< {1, 0}", []() { - const tuple t1 = { 1, 0 }; - const tuple t2 = { 1, 0 }; + const tuple t1 = { 1, 0 }; + const tuple t2 = { 1, 0 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {42, 21} !< {42, 21}", []() { - const tuple t1 = { 42, 21 }; - const tuple t2 = { 42, 21 }; + const tuple t1 = { 42, 21 }; + const tuple t2 = { 42, 21 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); }); describe("tuple_second_lt", []() { it("claims {1, 0} < {2, 0}", []() { - const tuple t1 = { 1, 0 }; - const tuple t2 = { 2, 0 }; + const tuple t1 = { 1, 0 }; + const tuple t2 = { 2, 0 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {2, 1} < {3, 0}", []() { - const tuple t1 = { 2, 1 }; - const tuple t2 = { 3, 0 }; + const tuple t1 = { 2, 1 }; + const tuple t2 = { 3, 0 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {2, 3} < {3, 1}", []() { - const tuple t1 = { 2, 3 }; - const tuple t2 = { 3, 1 }; + const tuple t1 = { 2, 3 }; + const tuple t2 = { 3, 1 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {2, -1} < {2, 0}", []() { - const tuple t1 = { 2, -1 }; - const tuple t2 = { 2, 0 }; + const tuple t1 = { 2, -1 }; + const tuple t2 = { 2, 0 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 0} !< {0, 0}", []() { - const tuple t1 = { 0, 0 }; - const tuple t2 = { 0, 0 }; + const tuple t1 = { 0, 0 }; + const tuple t2 = { 0, 0 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {1, 0} !< {1, 0}", []() { - const tuple t1 = { 1, 0 }; - const tuple t2 = { 1, 0 }; + const tuple t1 = { 1, 0 }; + const tuple t2 = { 1, 0 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {42, 21} !< {42, 21}", []() { - const tuple t1 = { 42, 21 }; - const tuple t2 = { 42, 21 }; + const tuple t1 = { 42, 21 }; + const tuple t2 = { 42, 21 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); }); @@ -577,18 +577,18 @@ go_bandit([]() { describe("tuple", []() { it("statically provides its cardinality of 3.", []() { - const auto cardinality = tuple::cardinality; + const auto cardinality = tuple::cardinality; AssertThat(cardinality, Is().EqualTo(3u)); }); it("is not trivially sorted.", []() { - const auto is_sorted = tuple::is_sorted; + const auto is_sorted = tuple::is_sorted; AssertThat(is_sorted, Is().EqualTo(false)); }); describe("unordered access: '[]' operator", []() { it("provides unordered access [42, 22, -21]", []() { - const tuple t = { 42, 22, -21 }; + const tuple t = { 42, 22, -21 }; AssertThat(t[0], Is().EqualTo(42)); AssertThat(t[1], Is().EqualTo(22)); @@ -596,7 +596,7 @@ go_bandit([]() { }); it("provides unordered access [0, -1, 1]", []() { - const tuple t = { 0, -1, 1 }; + const tuple t = { 0, -1, 1 }; AssertThat(t[0], Is().EqualTo(0)); AssertThat(t[1], Is().EqualTo(-1)); @@ -606,154 +606,154 @@ go_bandit([]() { describe("ordered access: 'first' 'second', and 'third' functions", []() { it("provides ordered access to first element", []() { - const tuple t1 = { 21, 42, 22 }; + const tuple t1 = { 21, 42, 22 }; AssertThat(t1.first(), Is().EqualTo(21)); - const tuple t2 = { 42, 21, 22 }; + const tuple t2 = { 42, 21, 22 }; AssertThat(t2.first(), Is().EqualTo(21)); - const tuple t3 = { 42, 22, 21 }; + const tuple t3 = { 42, 22, 21 }; AssertThat(t3.first(), Is().EqualTo(21)); }); it("provides ordered access to first element [negative value]", []() { - const tuple t = { -2, -1, -3 }; + const tuple t = { -2, -1, -3 }; AssertThat(t.first(), Is().EqualTo(-3)); }); it("provides ordered access to first element [0 vs. 1]", []() { - const tuple t1 = { 1, 0, 1 }; + const tuple t1 = { 1, 0, 1 }; AssertThat(t1.first(), Is().EqualTo(0)); - const tuple t2 = { 0, 1, 1 }; + const tuple t2 = { 0, 1, 1 }; AssertThat(t2.first(), Is().EqualTo(0)); - const tuple t3 = { 1, 1, 0 }; + const tuple t3 = { 1, 1, 0 }; AssertThat(t3.first(), Is().EqualTo(0)); }); it("provides ordered access to first element [tie]", []() { - const tuple t1 = { 42, 21, 21 }; + const tuple t1 = { 42, 21, 21 }; AssertThat(t1.first(), Is().EqualTo(21)); - const tuple t2 = { 22, 41, 22 }; + const tuple t2 = { 22, 41, 22 }; AssertThat(t2.first(), Is().EqualTo(22)); - const tuple t3 = { 20, 20, 40 }; + const tuple t3 = { 20, 20, 40 }; AssertThat(t3.first(), Is().EqualTo(20)); - const tuple t4 = { 16, 16, 16 }; + const tuple t4 = { 16, 16, 16 }; AssertThat(t4.first(), Is().EqualTo(16)); }); it("provides ordered access to second element", []() { - const tuple t1 = { 21, 42, 22 }; + const tuple t1 = { 21, 42, 22 }; AssertThat(t1.second(), Is().EqualTo(22)); - const tuple t2 = { 42, 21, 22 }; + const tuple t2 = { 42, 21, 22 }; AssertThat(t2.second(), Is().EqualTo(22)); - const tuple t3 = { 42, 22, 21 }; + const tuple t3 = { 42, 22, 21 }; AssertThat(t3.second(), Is().EqualTo(22)); }); it("provides ordered access to second element [negative values]", []() { - const tuple t1 = { -2, -1, -3 }; + const tuple t1 = { -2, -1, -3 }; AssertThat(t1.second(), Is().EqualTo(-2)); - const tuple t2 = { -1, -2, -3 }; + const tuple t2 = { -1, -2, -3 }; AssertThat(t2.second(), Is().EqualTo(-2)); - const tuple t3 = { -3, -1, -2 }; + const tuple t3 = { -3, -1, -2 }; AssertThat(t3.second(), Is().EqualTo(-2)); }); it("provides ordered access to second element [0, -1 vs. 1]", []() { - const tuple t1 = { 0, -1, 1 }; + const tuple t1 = { 0, -1, 1 }; AssertThat(t1.second(), Is().EqualTo(0)); - const tuple t2 = { -1, 0, 1 }; + const tuple t2 = { -1, 0, 1 }; AssertThat(t2.second(), Is().EqualTo(0)); - const tuple t3 = { 1, -1, 0 }; + const tuple t3 = { 1, -1, 0 }; AssertThat(t3.second(), Is().EqualTo(0)); }); it("provides ordered access to second element [tie]", []() { - const tuple t1 = { 0, 1, 1 }; + const tuple t1 = { 0, 1, 1 }; AssertThat(t1.second(), Is().EqualTo(1)); - const tuple t2 = { 1, 0, 1 }; + const tuple t2 = { 1, 0, 1 }; AssertThat(t2.second(), Is().EqualTo(1)); - const tuple t3 = { 1, 1, 0 }; + const tuple t3 = { 1, 1, 0 }; AssertThat(t3.second(), Is().EqualTo(1)); - const tuple t4 = { 1, 1, 1 }; + const tuple t4 = { 1, 1, 1 }; AssertThat(t4.second(), Is().EqualTo(1)); }); it("provides ordered access to third element", []() { - const tuple t1 = { 21, 42, 22 }; + const tuple t1 = { 21, 42, 22 }; AssertThat(t1.third(), Is().EqualTo(42)); - const tuple t2 = { 42, 21, 22 }; + const tuple t2 = { 42, 21, 22 }; AssertThat(t2.third(), Is().EqualTo(42)); - const tuple t3 = { 21, 22, 42 }; + const tuple t3 = { 21, 22, 42 }; AssertThat(t3.third(), Is().EqualTo(42)); }); it("provides ordered access to third element [negative values]", []() { - const tuple t1 = { -2, -1, -3 }; + const tuple t1 = { -2, -1, -3 }; AssertThat(t1.third(), Is().EqualTo(-1)); - const tuple t2 = { -1, -2, -3 }; + const tuple t2 = { -1, -2, -3 }; AssertThat(t2.third(), Is().EqualTo(-1)); - const tuple t3 = { -3, -2, -1 }; + const tuple t3 = { -3, -2, -1 }; AssertThat(t3.third(), Is().EqualTo(-1)); }); it("provides ordered access to third element [0, -1 vs. 1]", []() { - const tuple t1 = { 0, -1, 1 }; + const tuple t1 = { 0, -1, 1 }; AssertThat(t1.third(), Is().EqualTo(1)); - const tuple t2 = { -1, 1, 0 }; + const tuple t2 = { -1, 1, 0 }; AssertThat(t2.third(), Is().EqualTo(1)); - const tuple t3 = { 1, -1, 0 }; + const tuple t3 = { 1, -1, 0 }; AssertThat(t3.third(), Is().EqualTo(1)); }); it("provides ordered access to third element [tie for 'second()']", []() { - const tuple t1 = { 0, 0, 1 }; + const tuple t1 = { 0, 0, 1 }; AssertThat(t1.third(), Is().EqualTo(1)); - const tuple t2 = { 1, 0, 0 }; + const tuple t2 = { 1, 0, 0 }; AssertThat(t2.third(), Is().EqualTo(1)); - const tuple t3 = { 0, 0, 1 }; + const tuple t3 = { 0, 0, 1 }; AssertThat(t3.third(), Is().EqualTo(1)); }); it("provides ordered access to third element [tie for 'third()']", []() { - const tuple t1 = { 0, 1, 1 }; + const tuple t1 = { 0, 1, 1 }; AssertThat(t1.third(), Is().EqualTo(1)); - const tuple t2 = { 1, 1, 0 }; + const tuple t2 = { 1, 1, 0 }; AssertThat(t2.third(), Is().EqualTo(1)); - const tuple t3 = { 0, 1, 1 }; + const tuple t3 = { 0, 1, 1 }; AssertThat(t3.third(), Is().EqualTo(1)); - const tuple t4 = { 1, 1, 1 }; + const tuple t4 = { 1, 1, 1 }; AssertThat(t4.third(), Is().EqualTo(1)); }); }); it("can construct a tuple with copies of a single element [-1]", []() { - const tuple t = { -1 }; + const tuple t = { -1 }; AssertThat(t[0], Is().EqualTo(-1)); AssertThat(t[1], Is().EqualTo(-1)); @@ -761,7 +761,7 @@ go_bandit([]() { }); it("can construct a tuple with copies of a single element [0]", []() { - const tuple t = { 0 }; + const tuple t = { 0 }; AssertThat(t[0], Is().EqualTo(0)); AssertThat(t[1], Is().EqualTo(0)); @@ -769,7 +769,7 @@ go_bandit([]() { }); it("can construct a tuple with copies of a single element [1]", []() { - const tuple t = { 1 }; + const tuple t = { 1 }; AssertThat(t[0], Is().EqualTo(1)); AssertThat(t[1], Is().EqualTo(1)); @@ -777,7 +777,7 @@ go_bandit([]() { }); it("can construct a tuple with copies of a single element [42]", []() { - const tuple t = { 42 }; + const tuple t = { 42 }; AssertThat(t[0], Is().EqualTo(42)); AssertThat(t[1], Is().EqualTo(42)); @@ -785,8 +785,8 @@ go_bandit([]() { }); it("can be constructed from a std::array", []() { - const std::array arr = {8, 2, 5}; - const tuple t(arr); + const std::array arr = { 8, 2, 5 }; + const tuple t(arr); AssertThat(t[0], Is().EqualTo(8)); AssertThat(t[1], Is().EqualTo(2)); @@ -795,49 +795,48 @@ go_bandit([]() { describe("Coordinate-wise Equality '=='", []() { it("claims {0, 0, 0} == {0, 0, 0}", []() { - const tuple t1 = { 0, 0, 0 }; - const tuple t2 = { 0, 0, 0 }; + const tuple t1 = { 0, 0, 0 }; + const tuple t2 = { 0, 0, 0 }; AssertThat(t1, Is().EqualTo(t2)); AssertThat(t2, Is().EqualTo(t1)); }); it("claims {1, 0, 1} == {1, 0, 1}", []() { - const tuple t1 = { 1, 0, 1 }; - const tuple t2 = { 1, 0, 1 }; + const tuple t1 = { 1, 0, 1 }; + const tuple t2 = { 1, 0, 1 }; AssertThat(t1, Is().EqualTo(t2)); AssertThat(t2, Is().EqualTo(t1)); }); it("claims {1, 1, 2} != {0, 1, 2}", []() { - const tuple t1 = { 1, 1, 2 }; - const tuple t2 = { 0, 1, 2 }; + const tuple t1 = { 1, 1, 2 }; + const tuple t2 = { 0, 1, 2 }; AssertThat(t1, Is().Not().EqualTo(t2)); AssertThat(t2, Is().Not().EqualTo(t1)); }); it("claims {1, 0, 1} != {1, 1, 1}", []() { - const tuple t1 = { 1, 0, 1 }; - const tuple t2 = { 1, 1, 1 }; + const tuple t1 = { 1, 0, 1 }; + const tuple t2 = { 1, 1, 1 }; AssertThat(t1, Is().Not().EqualTo(t2)); AssertThat(t2, Is().Not().EqualTo(t1)); }); it("claims {2, 1, 0} != {2, 1, 1}", []() { - const tuple t1 = { 2, 1, 0 }; - const tuple t2 = { 2, 1, 1 }; + const tuple t1 = { 2, 1, 0 }; + const tuple t2 = { 2, 1, 1 }; AssertThat(t1, Is().Not().EqualTo(t2)); AssertThat(t2, Is().Not().EqualTo(t1)); }); - it("claims {42, 21, 20} != {42, 20, 20}", []() { - const tuple t1 = { 42, 21, 20 }; - const tuple t2 = { 42, 20, 20 }; + const tuple t1 = { 42, 21, 20 }; + const tuple t2 = { 42, 20, 20 }; AssertThat(t1, Is().Not().EqualTo(t2)); AssertThat(t2, Is().Not().EqualTo(t1)); @@ -846,8 +845,8 @@ go_bandit([]() { describe("Lexicographical Ordering '<'", []() { it("claims {0, 2, 1} < {1, 2, 1}", []() { - const tuple t1 = { 0, 2, 1 }; - const tuple t2 = { 1, 2, 1 }; + const tuple t1 = { 0, 2, 1 }; + const tuple t2 = { 1, 2, 1 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -855,8 +854,8 @@ go_bandit([]() { }); it("claims {1, 2, 1} < {2, 0, 0}", []() { - const tuple t1 = { 0, 2, 1 }; - const tuple t2 = { 1, 0, 0 }; + const tuple t1 = { 0, 2, 1 }; + const tuple t2 = { 1, 0, 0 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -864,8 +863,8 @@ go_bandit([]() { }); it("claims {0, 0, 0} < {0, 1, 0}", []() { - const tuple t1 = { 0, 0, 0 }; - const tuple t2 = { 0, 1, 0 }; + const tuple t1 = { 0, 0, 0 }; + const tuple t2 = { 0, 1, 0 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -873,8 +872,8 @@ go_bandit([]() { }); it("claims {0, 0, 0} < {0, 0, 1}", []() { - const tuple t1 = { 0, 0, 0 }; - const tuple t2 = { 0, 0, 1 }; + const tuple t1 = { 0, 0, 0 }; + const tuple t2 = { 0, 0, 1 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -882,8 +881,8 @@ go_bandit([]() { }); it("claims {0, 1, 0} < {0, 1, 1}", []() { - const tuple t1 = { 0, 1, 0 }; - const tuple t2 = { 0, 1, 1 }; + const tuple t1 = { 0, 1, 0 }; + const tuple t2 = { 0, 1, 1 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -891,8 +890,8 @@ go_bandit([]() { }); it("claims {0, 0, 0} !< {0, 0, 0}", []() { - const tuple t1 = { 0, 0, 0 }; - const tuple t2 = { 0, 0, 0 }; + const tuple t1 = { 0, 0, 0 }; + const tuple t2 = { 0, 0, 0 }; AssertThat(t1, Is().Not().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -900,8 +899,8 @@ go_bandit([]() { }); it("claims {1, 0, 1} !< {1, 0, 1}", []() { - const tuple t1 = { 1, 0, 1 }; - const tuple t2 = { 1, 0, 1 }; + const tuple t1 = { 1, 0, 1 }; + const tuple t2 = { 1, 0, 1 }; AssertThat(t1, Is().Not().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -909,8 +908,8 @@ go_bandit([]() { }); it("claims {21, 42, 16} !< {21, 42, 16}", []() { - const tuple t1 = { 21, 42, 16 }; - const tuple t2 = { 21, 42, 16 }; + const tuple t1 = { 21, 42, 16 }; + const tuple t2 = { 21, 42, 16 }; AssertThat(t1, Is().Not().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -920,259 +919,259 @@ go_bandit([]() { describe("tuple_first_lt", []() { it("claims {0, 2, 2} < {1, 2, 2}", []() { - const tuple t1 = { 0, 2, 2 }; - const tuple t2 = { 1, 2, 0 }; + const tuple t1 = { 0, 2, 2 }; + const tuple t2 = { 1, 2, 0 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {2, 0, 1} < {1, 2, 1}", []() { - const tuple t1 = { 2, 0, 1 }; - const tuple t2 = { 1, 2, 1 }; + const tuple t1 = { 2, 0, 1 }; + const tuple t2 = { 1, 2, 1 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 1, 0} < {2, 0, 0}", []() { - const tuple t1 = { 0, 1, 0 }; - const tuple t2 = { 2, 0, 0 }; + const tuple t1 = { 0, 1, 0 }; + const tuple t2 = { 2, 0, 0 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {2, 0, 0} < {2, 0, 1}", []() { - const tuple t1 = { 2, 0, 0 }; - const tuple t2 = { 2, 0, 1 }; + const tuple t1 = { 2, 0, 0 }; + const tuple t2 = { 2, 0, 1 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 0, 0} !< {0, 0, 0}", []() { - const tuple t1 = { 0, 0, 0 }; - const tuple t2 = { 0, 0, 0 }; + const tuple t1 = { 0, 0, 0 }; + const tuple t2 = { 0, 0, 0 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {1, 0, 1} !< {1, 0, 1}", []() { - const tuple t1 = { 1, 0, 1 }; - const tuple t2 = { 1, 0, 1 }; + const tuple t1 = { 1, 0, 1 }; + const tuple t2 = { 1, 0, 1 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); }); describe("tuple_second_lt", []() { it("claims {1, 0, 4} < {2, 0, 4}", []() { - const tuple t1 = { 1, 0, 4 }; - const tuple t2 = { 2, 0, 4 }; + const tuple t1 = { 1, 0, 4 }; + const tuple t2 = { 2, 0, 4 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {1, 0, 0} < {2, 0, 1}", []() { - const tuple t1 = { 1, 0, 0 }; - const tuple t2 = { 2, 0, 1 }; + const tuple t1 = { 1, 0, 0 }; + const tuple t2 = { 2, 0, 1 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {1, 0, 0} < {2, 0, 0}", []() { - const tuple t1 = { 1, 0, 0 }; - const tuple t2 = { 2, 0, 0 }; + const tuple t1 = { 1, 0, 0 }; + const tuple t2 = { 2, 0, 0 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {2, 1, 5} < {3, 0, 4}", []() { - const tuple t1 = { 2, 1, 5 }; - const tuple t2 = { 3, 0, 4 }; + const tuple t1 = { 2, 1, 5 }; + const tuple t2 = { 3, 0, 4 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {2, 3, 4} < {3, 1, 2}", []() { - const tuple t1 = { 2, 3, 4 }; - const tuple t2 = { 3, 1, 3 }; + const tuple t1 = { 2, 3, 4 }; + const tuple t2 = { 3, 1, 3 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {2, -1, 2} < {2, 0, 2}", []() { - const tuple t1 = { 2, -1, 2 }; - const tuple t2 = { 2, 0, 2 }; + const tuple t1 = { 2, -1, 2 }; + const tuple t2 = { 2, 0, 2 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {2, 1, 3} < {2, 1, 4}", []() { - const tuple t1 = { 2, 1, 3 }; - const tuple t2 = { 2, 1, 4 }; + const tuple t1 = { 2, 1, 3 }; + const tuple t2 = { 2, 1, 4 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 0, 0} !< {0, 0, 0}", []() { - const tuple t1 = { 0, 0, 0 }; - const tuple t2 = { 0, 0, 0 }; + const tuple t1 = { 0, 0, 0 }; + const tuple t2 = { 0, 0, 0 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {1, 0, 1} !< {1, 0, 1}", []() { - const tuple t1 = { 1, 0, 1 }; - const tuple t2 = { 1, 0, 1 }; + const tuple t1 = { 1, 0, 1 }; + const tuple t2 = { 1, 0, 1 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); }); describe("tuple_third_lt", []() { it("claims {2, 0, 1} < {4, 1, 0}", []() { - const tuple t1 = { 2, 0, 0 }; - const tuple t2 = { 4, 1, 0 }; + const tuple t1 = { 2, 0, 0 }; + const tuple t2 = { 4, 1, 0 }; - const bool lt_lr = tuple_third_lt>()(t1,t2); + const bool lt_lr = tuple_third_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_third_lt>()(t2,t1); + const bool lt_rl = tuple_third_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {1, 2, 1} < {1, 3, 1}", []() { - const tuple t1 = { 1, 2, 1 }; - const tuple t2 = { 1, 3, 1 }; + const tuple t1 = { 1, 2, 1 }; + const tuple t2 = { 1, 3, 1 }; - const bool lt_lr = tuple_third_lt>()(t1,t2); + const bool lt_lr = tuple_third_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_third_lt>()(t2,t1); + const bool lt_rl = tuple_third_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {1, 0, 4} < {1, 0, 5}", []() { - const tuple t1 = { 1, 0, 4 }; - const tuple t2 = { 1, 0, 5 }; + const tuple t1 = { 1, 0, 4 }; + const tuple t2 = { 1, 0, 5 }; - const bool lt_lr = tuple_third_lt>()(t1,t2); + const bool lt_lr = tuple_third_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_third_lt>()(t2,t1); + const bool lt_rl = tuple_third_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {1, 0, 4} < {2, 0, 4}", []() { - const tuple t1 = { 1, 0, 4 }; - const tuple t2 = { 2, 0, 4 }; + const tuple t1 = { 1, 0, 4 }; + const tuple t2 = { 2, 0, 4 }; - const bool lt_lr = tuple_third_lt>()(t1,t2); + const bool lt_lr = tuple_third_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_third_lt>()(t2,t1); + const bool lt_rl = tuple_third_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {1, 0, 3} < {1, 1, 3}", []() { - const tuple t1 = { 1, 0, 4 }; - const tuple t2 = { 1, 1, 4 }; + const tuple t1 = { 1, 0, 4 }; + const tuple t2 = { 1, 1, 4 }; - const bool lt_lr = tuple_third_lt>()(t1,t2); + const bool lt_lr = tuple_third_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_third_lt>()(t2,t1); + const bool lt_rl = tuple_third_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {1, 4, 2} < {1, 4, 3}", []() { - const tuple t1 = { 1, 4, 2 }; - const tuple t2 = { 1, 4, 3 }; + const tuple t1 = { 1, 4, 2 }; + const tuple t2 = { 1, 4, 3 }; - const bool lt_lr = tuple_third_lt>()(t1,t2); + const bool lt_lr = tuple_third_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_third_lt>()(t2,t1); + const bool lt_rl = tuple_third_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 0, 0} !< {0, 0, 0}", []() { - const tuple t1 = { 0, 0, 0 }; - const tuple t2 = { 0, 0, 0 }; + const tuple t1 = { 0, 0, 0 }; + const tuple t2 = { 0, 0, 0 }; - const bool lt_lr = tuple_third_lt>()(t1,t2); + const bool lt_lr = tuple_third_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_third_lt>()(t2,t1); + const bool lt_rl = tuple_third_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {1, 0, 1} !< {1, 0, 1}", []() { - const tuple t1 = { 1, 0, 1 }; - const tuple t2 = { 1, 0, 1 }; + const tuple t1 = { 1, 0, 1 }; + const tuple t2 = { 1, 0, 1 }; - const bool lt_lr = tuple_third_lt>()(t1,t2); + const bool lt_lr = tuple_third_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_third_lt>()(t2,t1); + const bool lt_rl = tuple_third_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); }); @@ -1184,18 +1183,18 @@ go_bandit([]() { describe("tuple", []() { it("statically provides its cardinality of 4.", []() { - const auto cardinality = tuple::cardinality; + const auto cardinality = tuple::cardinality; AssertThat(cardinality, Is().EqualTo(4u)); }); it("is not trivially sorted.", []() { - const auto is_sorted = tuple::is_sorted; + const auto is_sorted = tuple::is_sorted; AssertThat(is_sorted, Is().EqualTo(false)); }); describe("unordered access: '[]' operator", []() { it("provides unordered access [42, 22, 7, -21]", []() { - const tuple t = { 42, 22, 7, -21 }; + const tuple t = { 42, 22, 7, -21 }; AssertThat(t[0], Is().EqualTo(42)); AssertThat(t[1], Is().EqualTo(22)); @@ -1204,7 +1203,7 @@ go_bandit([]() { }); it("provides unordered access [0, -1, 1, -2]", []() { - const tuple t = { 0, -1, 1, -2 }; + const tuple t = { 0, -1, 1, -2 }; AssertThat(t[0], Is().EqualTo(0)); AssertThat(t[1], Is().EqualTo(-1)); @@ -1215,178 +1214,178 @@ go_bandit([]() { describe("ordered access: 'first' 'second', 'third', and 'fourth' functions", []() { it("provides ordered access to first element", []() { - const tuple t1 = { 21, 42, 22, 32 }; + const tuple t1 = { 21, 42, 22, 32 }; AssertThat(t1.first(), Is().EqualTo(21)); - const tuple t2 = { 42, 21, 22, 32 }; + const tuple t2 = { 42, 21, 22, 32 }; AssertThat(t2.first(), Is().EqualTo(21)); - const tuple t3 = { 42, 22, 21, 32 }; + const tuple t3 = { 42, 22, 21, 32 }; AssertThat(t3.first(), Is().EqualTo(21)); - const tuple t4 = { 42, 22, 32, 21 }; + const tuple t4 = { 42, 22, 32, 21 }; AssertThat(t4.first(), Is().EqualTo(21)); }); it("provides ordered access to first element [negative value]", []() { - const tuple t = { -2, -1, -4, -3 }; + const tuple t = { -2, -1, -4, -3 }; AssertThat(t.first(), Is().EqualTo(-4)); }); it("provides ordered access to first element [0 vs. 1]", []() { - const tuple t1 = { 0, 1, 1, 1 }; + const tuple t1 = { 0, 1, 1, 1 }; AssertThat(t1.first(), Is().EqualTo(0)); - const tuple t2 = { 1, 0, 1, 1 }; + const tuple t2 = { 1, 0, 1, 1 }; AssertThat(t2.first(), Is().EqualTo(0)); - const tuple t3 = { 1, 1, 0, 1 }; + const tuple t3 = { 1, 1, 0, 1 }; AssertThat(t3.first(), Is().EqualTo(0)); - const tuple t4 = { 1, 1, 1, 0 }; + const tuple t4 = { 1, 1, 1, 0 }; AssertThat(t4.first(), Is().EqualTo(0)); }); it("provides ordered access to first element [tie]", []() { - const tuple t1 = { 42, 21, 21, 32 }; + const tuple t1 = { 42, 21, 21, 32 }; AssertThat(t1.first(), Is().EqualTo(21)); - const tuple t2 = { 22, 41, 22, 32 }; + const tuple t2 = { 22, 41, 22, 32 }; AssertThat(t2.first(), Is().EqualTo(22)); - const tuple t3 = { 20, 32, 40, 20 }; + const tuple t3 = { 20, 32, 40, 20 }; AssertThat(t3.first(), Is().EqualTo(20)); - const tuple t4 = { 16, 16, 16, 16 }; + const tuple t4 = { 16, 16, 16, 16 }; AssertThat(t4.first(), Is().EqualTo(16)); }); it("provides ordered access to second element", []() { - const tuple t1 = { 22, 42, 21, 32 }; + const tuple t1 = { 22, 42, 21, 32 }; AssertThat(t1.second(), Is().EqualTo(22)); - const tuple t2 = { 42, 22, 21, 32 }; + const tuple t2 = { 42, 22, 21, 32 }; AssertThat(t2.second(), Is().EqualTo(22)); - const tuple t3 = { 42, 21, 22, 32 }; + const tuple t3 = { 42, 21, 22, 32 }; AssertThat(t3.second(), Is().EqualTo(22)); - const tuple t4 = { 42, 21, 32, 22 }; + const tuple t4 = { 42, 21, 32, 22 }; AssertThat(t4.second(), Is().EqualTo(22)); }); it("provides ordered access to second element [negative value]", []() { - const tuple t = { -2, -1, -4, -3 }; + const tuple t = { -2, -1, -4, -3 }; AssertThat(t.second(), Is().EqualTo(-3)); }); it("provides ordered access to second element [tie]", []() { - const tuple t1 = { 42, 21, 32, 32 }; + const tuple t1 = { 42, 21, 32, 32 }; AssertThat(t1.second(), Is().EqualTo(32)); - const tuple t2 = { 22, 41, 22, 32 }; + const tuple t2 = { 22, 41, 22, 32 }; AssertThat(t2.second(), Is().EqualTo(22)); - const tuple t3 = { 20, 32, 20, 20 }; + const tuple t3 = { 20, 32, 20, 20 }; AssertThat(t3.second(), Is().EqualTo(20)); - const tuple t4 = { 16, 16, 16, 16 }; + const tuple t4 = { 16, 16, 16, 16 }; AssertThat(t4.second(), Is().EqualTo(16)); }); it("provides ordered access to second element [tie on third/fourth]", []() { - const tuple t1 = { 42, 21, 22, 42 }; + const tuple t1 = { 42, 21, 22, 42 }; AssertThat(t1.second(), Is().EqualTo(22)); }); it("provides ordered access to third element", []() { - const tuple t1 = { 32, 21, 42, 22 }; + const tuple t1 = { 32, 21, 42, 22 }; AssertThat(t1.third(), Is().EqualTo(32)); - const tuple t2 = { 21, 32, 42, 22 }; + const tuple t2 = { 21, 32, 42, 22 }; AssertThat(t2.third(), Is().EqualTo(32)); - const tuple t3 = { 21, 42, 32, 22 }; + const tuple t3 = { 21, 42, 32, 22 }; AssertThat(t3.third(), Is().EqualTo(32)); - const tuple t4 = { 21, 42, 22, 32 }; + const tuple t4 = { 21, 42, 22, 32 }; AssertThat(t4.third(), Is().EqualTo(32)); }); it("provides ordered access to third element [negative value]", []() { - const tuple t = { -2, -1, -4, -3 }; + const tuple t = { -2, -1, -4, -3 }; AssertThat(t.third(), Is().EqualTo(-2)); }); it("provides ordered access to third element [tie]", []() { - const tuple t1 = { 42, 21, 32, 32 }; + const tuple t1 = { 42, 21, 32, 32 }; AssertThat(t1.third(), Is().EqualTo(32)); - const tuple t2 = { 22, 22, 41, 22 }; + const tuple t2 = { 22, 22, 41, 22 }; AssertThat(t2.third(), Is().EqualTo(22)); - const tuple t4 = { 16, 16, 16, 16 }; + const tuple t4 = { 16, 16, 16, 16 }; AssertThat(t4.third(), Is().EqualTo(16)); }); it("provides ordered access to third element [tie on first/second]", []() { - const tuple t2 = { 22, 41, 22, 32 }; + const tuple t2 = { 22, 41, 22, 32 }; AssertThat(t2.third(), Is().EqualTo(32)); }); it("provides ordered access to fourth element", []() { - const tuple t1 = { 42, 21, 22, 32 }; + const tuple t1 = { 42, 21, 22, 32 }; AssertThat(t1.fourth(), Is().EqualTo(42)); - const tuple t2 = { 21, 42, 22, 32 }; + const tuple t2 = { 21, 42, 22, 32 }; AssertThat(t2.fourth(), Is().EqualTo(42)); - const tuple t3 = { 21, 22, 42, 32 }; + const tuple t3 = { 21, 22, 42, 32 }; AssertThat(t3.fourth(), Is().EqualTo(42)); - const tuple t4 = { 21, 22, 32, 42 }; + const tuple t4 = { 21, 22, 32, 42 }; AssertThat(t4.fourth(), Is().EqualTo(42)); }); it("provides ordered access to fourth element [negative value]", []() { - const tuple t = { -2, -1, -4, -3 }; + const tuple t = { -2, -1, -4, -3 }; AssertThat(t.fourth(), Is().EqualTo(-1)); }); it("provides ordered access to fourth element [0 vs. 1]", []() { - const tuple t1 = { 1, 0, 0, 0 }; + const tuple t1 = { 1, 0, 0, 0 }; AssertThat(t1.fourth(), Is().EqualTo(1)); - const tuple t2 = { 0, 1, 0, 0 }; + const tuple t2 = { 0, 1, 0, 0 }; AssertThat(t2.fourth(), Is().EqualTo(1)); - const tuple t3 = { 0, 0, 1, 0 }; + const tuple t3 = { 0, 0, 1, 0 }; AssertThat(t3.fourth(), Is().EqualTo(1)); - const tuple t4 = { 0, 0, 0, 1 }; + const tuple t4 = { 0, 0, 0, 1 }; AssertThat(t4.fourth(), Is().EqualTo(1)); }); it("provides ordered access to fourth element [tie]", []() { - const tuple t1 = { 42, 42, 21, 32 }; + const tuple t1 = { 42, 42, 21, 32 }; AssertThat(t1.fourth(), Is().EqualTo(42)); - const tuple t2 = { 42, 21, 42, 32 }; + const tuple t2 = { 42, 21, 42, 32 }; AssertThat(t2.fourth(), Is().EqualTo(42)); - const tuple t3 = { 42, 21, 32, 42 }; + const tuple t3 = { 42, 21, 32, 42 }; AssertThat(t3.fourth(), Is().EqualTo(42)); - const tuple t4 = { 21, 42, 32, 42 }; + const tuple t4 = { 21, 42, 32, 42 }; AssertThat(t4.fourth(), Is().EqualTo(42)); - const tuple t5 = { 21, 32, 42, 42 }; + const tuple t5 = { 21, 32, 42, 42 }; AssertThat(t5.fourth(), Is().EqualTo(42)); }); }); it("can construct a tuple with copies of a single element [-1]", []() { - const tuple t = { -1 }; + const tuple t = { -1 }; AssertThat(t[0], Is().EqualTo(-1)); AssertThat(t[1], Is().EqualTo(-1)); @@ -1395,7 +1394,7 @@ go_bandit([]() { }); it("can construct a tuple with copies of a single element [0]", []() { - const tuple t = { 0 }; + const tuple t = { 0 }; AssertThat(t[0], Is().EqualTo(0)); AssertThat(t[1], Is().EqualTo(0)); @@ -1404,7 +1403,7 @@ go_bandit([]() { }); it("can construct a tuple with copies of a single element [1]", []() { - const tuple t = { 1 }; + const tuple t = { 1 }; AssertThat(t[0], Is().EqualTo(1)); AssertThat(t[1], Is().EqualTo(1)); @@ -1413,7 +1412,7 @@ go_bandit([]() { }); it("can construct a tuple with copies of a single element [42]", []() { - const tuple t = { 42 }; + const tuple t = { 42 }; AssertThat(t[0], Is().EqualTo(42)); AssertThat(t[1], Is().EqualTo(42)); @@ -1422,8 +1421,8 @@ go_bandit([]() { }); it("can be constructed from a std::array", []() { - const std::array arr = {8, 2, 5, 3}; - const tuple t(arr); + const std::array arr = { 8, 2, 5, 3 }; + const tuple t(arr); AssertThat(t[0], Is().EqualTo(8)); AssertThat(t[1], Is().EqualTo(2)); @@ -1433,56 +1432,56 @@ go_bandit([]() { describe("Coordinate-wise Equality '=='", []() { it("claims {0, 0, 0, 0} == {0, 0, 0, 0}", []() { - const tuple t1 = { 0, 0, 0, 0 }; - const tuple t2 = { 0, 0, 0, 0 }; + const tuple t1 = { 0, 0, 0, 0 }; + const tuple t2 = { 0, 0, 0, 0 }; AssertThat(t1, Is().EqualTo(t2)); AssertThat(t2, Is().EqualTo(t1)); }); it("claims {1, 2, 3, 4} == {1, 2, 3, 4}", []() { - const tuple t1 = { 1, 2, 3, 4 }; - const tuple t2 = { 1, 2, 3, 4 }; + const tuple t1 = { 1, 2, 3, 4 }; + const tuple t2 = { 1, 2, 3, 4 }; AssertThat(t1, Is().EqualTo(t2)); AssertThat(t2, Is().EqualTo(t1)); }); it("claims {0, 0, 0, 0} != {1, 0, 0, 0}", []() { - const tuple t1 = { 0, 0, 0, 0 }; - const tuple t2 = { 1, 0, 0, 0 }; + const tuple t1 = { 0, 0, 0, 0 }; + const tuple t2 = { 1, 0, 0, 0 }; AssertThat(t1, Is().Not().EqualTo(t2)); AssertThat(t2, Is().Not().EqualTo(t1)); }); it("claims {0, 0, 0, 0} != {0, 1, 0, 0}", []() { - const tuple t1 = { 0, 0, 0, 0 }; - const tuple t2 = { 0, 1, 0, 0 }; + const tuple t1 = { 0, 0, 0, 0 }; + const tuple t2 = { 0, 1, 0, 0 }; AssertThat(t1, Is().Not().EqualTo(t2)); AssertThat(t2, Is().Not().EqualTo(t1)); }); it("claims {0, 0, 0, 0} != {0, 0, 1, 0}", []() { - const tuple t1 = { 0, 0, 0, 0 }; - const tuple t2 = { 0, 0, 1, 0 }; + const tuple t1 = { 0, 0, 0, 0 }; + const tuple t2 = { 0, 0, 1, 0 }; AssertThat(t1, Is().Not().EqualTo(t2)); AssertThat(t2, Is().Not().EqualTo(t1)); }); it("claims {0, 0, 0, 0} != {0, 0, 0, 1}", []() { - const tuple t1 = { 0, 0, 0, 0 }; - const tuple t2 = { 0, 0, 0, 1 }; + const tuple t1 = { 0, 0, 0, 0 }; + const tuple t2 = { 0, 0, 0, 1 }; AssertThat(t1, Is().Not().EqualTo(t2)); AssertThat(t2, Is().Not().EqualTo(t1)); }); it("claims {4, 8, 3, 7} != {4, 8, 4, 7}", []() { - const tuple t1 = { 4, 8, 3, 7 }; - const tuple t2 = { 4, 8, 4, 7 }; + const tuple t1 = { 4, 8, 3, 7 }; + const tuple t2 = { 4, 8, 4, 7 }; AssertThat(t1, Is().Not().EqualTo(t2)); AssertThat(t2, Is().Not().EqualTo(t1)); @@ -1491,8 +1490,8 @@ go_bandit([]() { describe("Lexicographical Ordering '<'", []() { it("claims {0, 2, 1, 3} < {1, 2, 1, 3}", []() { - const tuple t1 = { 0, 2, 1, 3 }; - const tuple t2 = { 1, 2, 1, 3 }; + const tuple t1 = { 0, 2, 1, 3 }; + const tuple t2 = { 1, 2, 1, 3 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -1500,8 +1499,8 @@ go_bandit([]() { }); it("claims {0, 2, 4, 8} < {1, 0, 0, 0}", []() { - const tuple t1 = { 0, 2, 4, 8 }; - const tuple t2 = { 1, 0, 0, 0 }; + const tuple t1 = { 0, 2, 4, 8 }; + const tuple t2 = { 1, 0, 0, 0 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -1509,8 +1508,8 @@ go_bandit([]() { }); it("claims {1, 2, 4, 8} < {1, 3, 4, 8}", []() { - const tuple t1 = { 1, 2, 4, 8 }; - const tuple t2 = { 1, 3, 4, 8 }; + const tuple t1 = { 1, 2, 4, 8 }; + const tuple t2 = { 1, 3, 4, 8 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -1518,8 +1517,8 @@ go_bandit([]() { }); it("claims {1, 3, 4, 8} < {1, 4, 3, 2}", []() { - const tuple t1 = { 1, 3, 4, 8 }; - const tuple t2 = { 1, 4, 3, 2 }; + const tuple t1 = { 1, 3, 4, 8 }; + const tuple t2 = { 1, 4, 3, 2 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -1527,8 +1526,8 @@ go_bandit([]() { }); it("claims {1, 3, 4, 8} < {1, 4, 3, 2}", []() { - const tuple t1 = { 1, 3, 4, 8 }; - const tuple t2 = { 1, 4, 3, 2 }; + const tuple t1 = { 1, 3, 4, 8 }; + const tuple t2 = { 1, 4, 3, 2 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -1536,8 +1535,8 @@ go_bandit([]() { }); it("claims {1, 3, 3, 8} < {1, 3, 4, 8}", []() { - const tuple t1 = { 1, 3, 3, 8 }; - const tuple t2 = { 1, 3, 4, 8 }; + const tuple t1 = { 1, 3, 3, 8 }; + const tuple t2 = { 1, 3, 4, 8 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -1545,8 +1544,8 @@ go_bandit([]() { }); it("claims {1, 2, 3, 2} < {1, 2, 4, 8}", []() { - const tuple t1 = { 1, 2, 3, 2 }; - const tuple t2 = { 1, 2, 4, 8 }; + const tuple t1 = { 1, 2, 3, 2 }; + const tuple t2 = { 1, 2, 4, 8 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -1554,8 +1553,8 @@ go_bandit([]() { }); it("claims {0, 0, 0, 0} < {0, 0, 0, 1}", []() { - const tuple t1 = { 0, 0, 0, 0 }; - const tuple t2 = { 0, 0, 0, 1 }; + const tuple t1 = { 0, 0, 0, 0 }; + const tuple t2 = { 0, 0, 0, 1 }; AssertThat(t1, Is().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -1563,8 +1562,8 @@ go_bandit([]() { }); it("claims {0, 0, 0, 0} !< {0, 0, 0, 0}", []() { - const tuple t1 = { 0, 0, 0, 0 }; - const tuple t2 = { 0, 0, 0, 0 }; + const tuple t1 = { 0, 0, 0, 0 }; + const tuple t2 = { 0, 0, 0, 0 }; AssertThat(t1, Is().Not().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -1572,8 +1571,8 @@ go_bandit([]() { }); it("claims {1, 2, 3, 4} !< {1, 2, 3, 4}", []() { - const tuple t1 = { 1, 2, 3, 4 }; - const tuple t2 = { 1, 2, 3, 4 }; + const tuple t1 = { 1, 2, 3, 4 }; + const tuple t2 = { 1, 2, 3, 4 }; AssertThat(t1, Is().Not().LessThan(t2)); AssertThat(t2, Is().Not().LessThan(t1)); @@ -1583,294 +1582,294 @@ go_bandit([]() { describe("tuple_first_lt", []() { it("claims {4, 3, 2, 0} < {1, 2, 3, 4}", []() { - const tuple t1 = { 4, 3, 2, 0 }; - const tuple t2 = { 1, 2, 3, 4 }; + const tuple t1 = { 4, 3, 2, 0 }; + const tuple t2 = { 1, 2, 3, 4 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {4, 3, 0, 2} < {2, 1, 3, 4}", []() { - const tuple t1 = { 4, 3, 0, 2 }; - const tuple t2 = { 2, 1, 3, 4 }; + const tuple t1 = { 4, 3, 0, 2 }; + const tuple t2 = { 2, 1, 3, 4 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {4, 0, 3, 2} < {2, 3, 1, 4}", []() { - const tuple t1 = { 4, 0, 3, 2 }; - const tuple t2 = { 2, 3, 1, 4 }; + const tuple t1 = { 4, 0, 3, 2 }; + const tuple t2 = { 2, 3, 1, 4 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {4, 2, 3, 0} < {4, 3, 2, 1}", []() { - const tuple t1 = { 4, 2, 3, 0 }; - const tuple t2 = { 4, 3, 2, 1 }; + const tuple t1 = { 4, 2, 3, 0 }; + const tuple t2 = { 4, 3, 2, 1 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 2, 3, 4} < {2, 0, 3, 4}", []() { - const tuple t1 = { 0, 2, 3, 4 }; - const tuple t2 = { 2, 0, 3, 4 }; + const tuple t1 = { 0, 2, 3, 4 }; + const tuple t2 = { 2, 0, 3, 4 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 0, 0, 1} < {0, 0, 1, 0}", []() { - const tuple t1 = { 0, 2, 3, 4 }; - const tuple t2 = { 2, 0, 3, 4 }; + const tuple t1 = { 0, 2, 3, 4 }; + const tuple t2 = { 2, 0, 3, 4 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 0, 0, 0} !< {0, 0, 0, 0}", []() { - const tuple t1 = { 0, 0, 0, 0 }; - const tuple t2 = { 0, 0, 0, 0 }; + const tuple t1 = { 0, 0, 0, 0 }; + const tuple t2 = { 0, 0, 0, 0 }; - const bool lt_lr = tuple_first_lt>()(t1,t2); + const bool lt_lr = tuple_first_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_first_lt>()(t2,t1); + const bool lt_rl = tuple_first_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); }); describe("tuple_second_lt", []() { it("claims {4, 3, 1, 0} < {0, 2, 3, 4}", []() { - const tuple t1 = { 4, 3, 1, 0 }; - const tuple t2 = { 0, 2, 3, 4 }; + const tuple t1 = { 4, 3, 1, 0 }; + const tuple t2 = { 0, 2, 3, 4 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {4, 3, 0, 1} < {2, 0, 3, 4}", []() { - const tuple t1 = { 4, 3, 0, 1 }; - const tuple t2 = { 2, 0, 3, 4 }; + const tuple t1 = { 4, 3, 0, 1 }; + const tuple t2 = { 2, 0, 3, 4 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {4, 0, 1, 3} < {2, 3, 0, 4}", []() { - const tuple t1 = { 4, 0, 1, 3 }; - const tuple t2 = { 2, 3, 0, 4 }; + const tuple t1 = { 4, 0, 1, 3 }; + const tuple t2 = { 2, 3, 0, 4 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {4, 3, 1, 0} < {4, 3, 0, 2}", []() { - const tuple t1 = { 4, 3, 1, 0 }; - const tuple t2 = { 4, 3, 0, 2 }; + const tuple t1 = { 4, 3, 1, 0 }; + const tuple t2 = { 4, 3, 0, 2 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 2, 3, 4} < {2, 0, 3, 4}", []() { - const tuple t1 = { 0, 2, 3, 4 }; - const tuple t2 = { 2, 0, 3, 4 }; + const tuple t1 = { 0, 2, 3, 4 }; + const tuple t2 = { 2, 0, 3, 4 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 0, 0, 1} < {0, 0, 1, 0}", []() { - const tuple t1 = { 0, 2, 3, 4 }; - const tuple t2 = { 2, 0, 3, 4 }; + const tuple t1 = { 0, 2, 3, 4 }; + const tuple t2 = { 2, 0, 3, 4 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 0, 0, 0} !< {0, 0, 0, 0}", []() { - const tuple t1 = { 0, 0, 0, 0 }; - const tuple t2 = { 0, 0, 0, 0 }; + const tuple t1 = { 0, 0, 0, 0 }; + const tuple t2 = { 0, 0, 0, 0 }; - const bool lt_lr = tuple_second_lt>()(t1,t2); + const bool lt_lr = tuple_second_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_second_lt>()(t2,t1); + const bool lt_rl = tuple_second_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); }); describe("tuple_third_lt", []() { it("claims {4, 2, 1, 0} < {0, 1, 3, 4}", []() { - const tuple t1 = { 4, 2, 1, 0 }; - const tuple t2 = { 0, 1, 3, 4 }; + const tuple t1 = { 4, 2, 1, 0 }; + const tuple t2 = { 0, 1, 3, 4 }; - const bool lt_lr = tuple_third_lt>()(t1,t2); + const bool lt_lr = tuple_third_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_third_lt>()(t2,t1); + const bool lt_rl = tuple_third_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {4, 1, 2, 0} < {4, 0, 3, 0}", []() { - const tuple t1 = { 4, 1, 2, 0 }; - const tuple t2 = { 4, 0, 3, 0 }; + const tuple t1 = { 4, 1, 2, 0 }; + const tuple t2 = { 4, 0, 3, 0 }; - const bool lt_lr = tuple_third_lt>()(t1,t2); + const bool lt_lr = tuple_third_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_third_lt>()(t2,t1); + const bool lt_rl = tuple_third_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {4, 0, 2, 0} < {4, 0, 0, 3}", []() { - const tuple t1 = { 4, 0, 2, 0 }; - const tuple t2 = { 4, 0, 0, 3 }; + const tuple t1 = { 4, 0, 2, 0 }; + const tuple t2 = { 4, 0, 0, 3 }; - const bool lt_lr = tuple_third_lt>()(t1,t2); + const bool lt_lr = tuple_third_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_third_lt>()(t2,t1); + const bool lt_rl = tuple_third_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 2, 3, 4} < {2, 0, 3, 4}", []() { - const tuple t1 = { 0, 2, 3, 4 }; - const tuple t2 = { 2, 0, 3, 4 }; + const tuple t1 = { 0, 2, 3, 4 }; + const tuple t2 = { 2, 0, 3, 4 }; - const bool lt_lr = tuple_third_lt>()(t1,t2); + const bool lt_lr = tuple_third_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_third_lt>()(t2,t1); + const bool lt_rl = tuple_third_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 0, 0, 1} < {0, 0, 1, 0}", []() { - const tuple t1 = { 0, 2, 3, 4 }; - const tuple t2 = { 2, 0, 3, 4 }; + const tuple t1 = { 0, 2, 3, 4 }; + const tuple t2 = { 2, 0, 3, 4 }; - const bool lt_lr = tuple_third_lt>()(t1,t2); + const bool lt_lr = tuple_third_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_third_lt>()(t2,t1); + const bool lt_rl = tuple_third_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 0, 0, 0} !< {0, 0, 0, 0}", []() { - const tuple t1 = { 0, 0, 0, 0 }; - const tuple t2 = { 0, 0, 0, 0 }; + const tuple t1 = { 0, 0, 0, 0 }; + const tuple t2 = { 0, 0, 0, 0 }; - const bool lt_lr = tuple_third_lt>()(t1,t2); + const bool lt_lr = tuple_third_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_third_lt>()(t2,t1); + const bool lt_rl = tuple_third_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); }); describe("tuple_fourth_lt", []() { it("claims {3, 2, 1, 0} < {0, 1, 2, 4}", []() { - const tuple t1 = { 3, 2, 1, 0 }; - const tuple t2 = { 0, 1, 2, 4 }; + const tuple t1 = { 3, 2, 1, 0 }; + const tuple t2 = { 0, 1, 2, 4 }; - const bool lt_lr = tuple_fourth_lt>()(t1,t2); + const bool lt_lr = tuple_fourth_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_fourth_lt>()(t2,t1); + const bool lt_rl = tuple_fourth_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 2, 1, 3} < {0, 1, 2, 4}", []() { - const tuple t1 = { 0, 2, 1, 3 }; - const tuple t2 = { 0, 1, 2, 4 }; + const tuple t1 = { 0, 2, 1, 3 }; + const tuple t2 = { 0, 1, 2, 4 }; - const bool lt_lr = tuple_fourth_lt>()(t1,t2); + const bool lt_lr = tuple_fourth_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_fourth_lt>()(t2,t1); + const bool lt_rl = tuple_fourth_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 2, 3, 1} < {0, 1, 1, 4}", []() { - const tuple t1 = { 0, 2, 3, 1 }; - const tuple t2 = { 0, 1, 1, 4 }; + const tuple t1 = { 0, 2, 3, 1 }; + const tuple t2 = { 0, 1, 1, 4 }; - const bool lt_lr = tuple_fourth_lt>()(t1,t2); + const bool lt_lr = tuple_fourth_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_fourth_lt>()(t2,t1); + const bool lt_rl = tuple_fourth_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 2, 3, 4} < {2, 0, 3, 4}", []() { - const tuple t1 = { 0, 2, 3, 4 }; - const tuple t2 = { 2, 0, 3, 4 }; + const tuple t1 = { 0, 2, 3, 4 }; + const tuple t2 = { 2, 0, 3, 4 }; - const bool lt_lr = tuple_fourth_lt>()(t1,t2); + const bool lt_lr = tuple_fourth_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_fourth_lt>()(t2,t1); + const bool lt_rl = tuple_fourth_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 0, 0, 1} < {0, 0, 1, 0}", []() { - const tuple t1 = { 0, 2, 3, 4 }; - const tuple t2 = { 2, 0, 3, 4 }; + const tuple t1 = { 0, 2, 3, 4 }; + const tuple t2 = { 2, 0, 3, 4 }; - const bool lt_lr = tuple_fourth_lt>()(t1,t2); + const bool lt_lr = tuple_fourth_lt>()(t1, t2); AssertThat(lt_lr, Is().True()); - const bool lt_rl = tuple_fourth_lt>()(t2,t1); + const bool lt_rl = tuple_fourth_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); it("claims {0, 0, 0, 0} !< {0, 0, 0, 0}", []() { - const tuple t1 = { 0, 0, 0, 0 }; - const tuple t2 = { 0, 0, 0, 0 }; + const tuple t1 = { 0, 0, 0, 0 }; + const tuple t2 = { 0, 0, 0, 0 }; - const bool lt_lr = tuple_fourth_lt>()(t1,t2); + const bool lt_lr = tuple_fourth_lt>()(t1, t2); AssertThat(lt_lr, Is().False()); - const bool lt_rl = tuple_fourth_lt>()(t2,t1); + const bool lt_rl = tuple_fourth_lt>()(t2, t1); AssertThat(lt_rl, Is().False()); }); }); @@ -1880,4 +1879,4 @@ go_bandit([]() { // TODO }); }); - }); +}); diff --git a/test/adiar/internal/data_types/test_uid.cpp b/test/adiar/internal/data_types/test_uid.cpp index abe5e212f..224002e81 100644 --- a/test/adiar/internal/data_types/test_uid.cpp +++ b/test/adiar/internal/data_types/test_uid.cpp @@ -2,11 +2,10 @@ go_bandit([]() { describe("adiar/internal/data_types/uid.h", []() { - it("has same size as the underlying 'ptr_uint64'", []() { - AssertThat(sizeof(uid_uint64), Is().EqualTo(sizeof(ptr_uint64))); - }); + it("has same size as the underlying 'ptr_uint64'", + []() { AssertThat(sizeof(uid_uint64), Is().EqualTo(sizeof(ptr_uint64))); }); - describe("reexposure of underlying pointer (without auxiliary data)", [](){ + describe("reexposure of underlying pointer (without auxiliary data)", []() { it("wraps compile-time constants", []() { // Nil constants AssertThat(ptr_uint64::nil_level, Is().EqualTo(ptr_uint64::nil_level)); @@ -39,7 +38,7 @@ go_bandit([]() { }); it("is 0 for (0,0)", []() { - const uid_uint64 u = ptr_uint64(0,0); + const uid_uint64 u = ptr_uint64(0, 0); AssertThat(u.level(), Is().EqualTo(0u)); }); @@ -59,15 +58,14 @@ go_bandit([]() { }); it("rejects minimal Node Uid", []() { - const uid_uint64 u = ptr_uint64(0,0,0); + const uid_uint64 u = ptr_uint64(0, 0, 0); AssertThat(u.is_terminal(), Is().False()); }); it("rejects maximal Node Uid", []() { - const uid_uint64 u = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const uid_uint64 u = + ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(u.is_terminal(), Is().False()); }); @@ -101,15 +99,14 @@ go_bandit([]() { }); it("rejects minimal Node Uid", []() { - const uid_uint64 u = ptr_uint64(0,0,0); + const uid_uint64 u = ptr_uint64(0, 0, 0); AssertThat(u.is_false(), Is().False()); }); it("rejects maximal Node Uid", []() { - const uid_uint64 u = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const uid_uint64 u = + ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(u.is_false(), Is().False()); }); @@ -129,15 +126,14 @@ go_bandit([]() { }); it("rejects minimal Node Uid", []() { - const uid_uint64 u = ptr_uint64(0,0,0); + const uid_uint64 u = ptr_uint64(0, 0, 0); AssertThat(u.is_true(), Is().False()); }); it("rejects maximal Node Uid", []() { - const uid_uint64 u = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const uid_uint64 u = + ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(u.is_true(), Is().False()); }); @@ -157,15 +153,14 @@ go_bandit([]() { }); it("accepts minimal Node Uid", []() { - const uid_uint64 u = ptr_uint64(0,0,0); + const uid_uint64 u = ptr_uint64(0, 0, 0); AssertThat(u.is_node(), Is().True()); }); it("accepts maximal Node Uid", []() { - const uid_uint64 u = ptr_uint64(ptr_uint64::max_label, - ptr_uint64::max_id, - ptr_uint64::max_out_idx); + const uid_uint64 u = + ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); AssertThat(u.is_node(), Is().True()); }); @@ -239,4 +234,4 @@ go_bandit([]() { }); }); }); - }); +}); diff --git a/test/adiar/internal/io/test_arc_file.cpp b/test/adiar/internal/io/test_arc_file.cpp index e14a31f1f..c6218bdee 100644 --- a/test/adiar/internal/io/test_arc_file.cpp +++ b/test/adiar/internal/io/test_arc_file.cpp @@ -1,6 +1,6 @@ #include "../../../test.h" - #include + #include go_bandit([]() { @@ -10,8 +10,7 @@ go_bandit([]() { levelized_file af; arc_writer aw(af); - aw << (level_info{ 0,1 }) - << (level_info{ 1,2 }); + aw << (level_info{ 0, 1 }) << (level_info{ 1, 2 }); aw.detach(); AssertThat(af.size(), Is().EqualTo(0u)); @@ -22,19 +21,19 @@ go_bandit([]() { AssertThat(af.max_1level_cut, Is().EqualTo(cut::max)); AssertThat(af.number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(af.number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(af.number_of_terminals[true], Is().EqualTo(0u)); }); it("can push internal arcs", []() { levelized_file af; arc_writer aw(af); - aw.push_internal(arc(arc::pointer_type(0,0), false, arc::pointer_type(1,0))); - aw.push_internal(arc(arc::pointer_type(0,0), true, arc::pointer_type(1,0))); - aw.push_internal(arc(arc::pointer_type(1,0), false, arc::pointer_type(2,0))); + aw.push_internal(arc(arc::pointer_type(0, 0), false, arc::pointer_type(1, 0))); + aw.push_internal(arc(arc::pointer_type(0, 0), true, arc::pointer_type(1, 0))); + aw.push_internal(arc(arc::pointer_type(1, 0), false, arc::pointer_type(2, 0))); aw.detach(); - AssertThat(af.size(), Is().EqualTo(3u)); + AssertThat(af.size(), Is().EqualTo(3u)); AssertThat(af.size(0u), Is().EqualTo(3u)); AssertThat(af.size(1u), Is().EqualTo(0u)); AssertThat(af.size(2u), Is().EqualTo(0u)); @@ -46,18 +45,18 @@ go_bandit([]() { AssertThat(af.max_1level_cut, Is().EqualTo(cut::max)); AssertThat(af.number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(af.number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(af.number_of_terminals[true], Is().EqualTo(0u)); }); it("can push terminal arcs [in-order]", []() { levelized_file af; arc_writer aw(af); - aw.push_terminal(arc(arc::pointer_type(0,0), false, arc::pointer_type(true))); - aw.push_terminal(arc(arc::pointer_type(0,0), true, arc::pointer_type(true))); + aw.push_terminal(arc(arc::pointer_type(0, 0), false, arc::pointer_type(true))); + aw.push_terminal(arc(arc::pointer_type(0, 0), true, arc::pointer_type(true))); aw.detach(); - AssertThat(af.size(), Is().EqualTo(2u)); + AssertThat(af.size(), Is().EqualTo(2u)); AssertThat(af.size(0u), Is().EqualTo(0u)); AssertThat(af.size(1u), Is().EqualTo(2u)); AssertThat(af.size(2u), Is().EqualTo(0u)); @@ -65,7 +64,7 @@ go_bandit([]() { AssertThat(af.levels(), Is().EqualTo(0u)); AssertThat(af.number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(af.number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(af.number_of_terminals[true], Is().EqualTo(2u)); // AssertThat(af.semi_transposed, Is().True()); @@ -73,9 +72,11 @@ go_bandit([]() { AssertThat(lfs.can_pull<0>(), Is().False()); AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(arc(arc::pointer_type(0,0), false, arc::pointer_type(true)))); + AssertThat(lfs.pull<1>(), + Is().EqualTo(arc(arc::pointer_type(0, 0), false, arc::pointer_type(true)))); AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(arc(arc::pointer_type(0,0), true, arc::pointer_type(true)))); + AssertThat(lfs.pull<1>(), + Is().EqualTo(arc(arc::pointer_type(0, 0), true, arc::pointer_type(true)))); AssertThat(lfs.can_pull<1>(), Is().False()); AssertThat(lfs.can_pull<2>(), Is().False()); @@ -85,11 +86,11 @@ go_bandit([]() { levelized_file af; arc_writer aw(af); - aw.push_terminal(arc(arc::pointer_type(0,0), true, arc::pointer_type(true))); - aw.push_terminal(arc(arc::pointer_type(0,0), false, arc::pointer_type(false))); + aw.push_terminal(arc(arc::pointer_type(0, 0), true, arc::pointer_type(true))); + aw.push_terminal(arc(arc::pointer_type(0, 0), false, arc::pointer_type(false))); aw.detach(); - AssertThat(af.size(), Is().EqualTo(2u)); + AssertThat(af.size(), Is().EqualTo(2u)); AssertThat(af.size(0u), Is().EqualTo(0u)); AssertThat(af.size(1u), Is().EqualTo(1u)); AssertThat(af.size(2u), Is().EqualTo(1u)); @@ -97,17 +98,19 @@ go_bandit([]() { AssertThat(af.levels(), Is().EqualTo(0u)); AssertThat(af.number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(af.number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(af.number_of_terminals[true], Is().EqualTo(1u)); levelized_file_stream lfs(af); AssertThat(lfs.can_pull<0>(), Is().False()); AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(arc(arc::pointer_type(0,0), true, arc::pointer_type(true)))); + AssertThat(lfs.pull<1>(), + Is().EqualTo(arc(arc::pointer_type(0, 0), true, arc::pointer_type(true)))); AssertThat(lfs.can_pull<1>(), Is().False()); AssertThat(lfs.can_pull<2>(), Is().True()); - AssertThat(lfs.pull<2>(), Is().EqualTo(arc(arc::pointer_type(0,0), false, arc::pointer_type(false)))); + AssertThat(lfs.pull<2>(), + Is().EqualTo(arc(arc::pointer_type(0, 0), false, arc::pointer_type(false)))); AssertThat(lfs.can_pull<2>(), Is().False()); }); @@ -116,18 +119,18 @@ go_bandit([]() { arc_writer aw(af); - aw << arc(arc::pointer_type(0,0), false, arc::pointer_type(1,0)) - << arc(arc::pointer_type(1,0), true, arc::pointer_type(true)) // <-- in-order - << arc(arc::pointer_type(1,1), false, arc::pointer_type(true)) // <-- in-order - << arc(arc::pointer_type(0,0), true, arc::pointer_type(1,1)) - << arc(arc::pointer_type(1,0), false, arc::pointer_type(2,0)) - << arc(arc::pointer_type(2,0), false, arc::pointer_type(false)) // <-- in-order - << arc(arc::pointer_type(2,0), true, arc::pointer_type(true)) // <-- in-order - << arc(arc::pointer_type(1,1), true, arc::pointer_type(true)); // <-- out-of-order + aw << arc(arc::pointer_type(0, 0), false, arc::pointer_type(1, 0)) + << arc(arc::pointer_type(1, 0), true, arc::pointer_type(true)) // <-- in-order + << arc(arc::pointer_type(1, 1), false, arc::pointer_type(true)) // <-- in-order + << arc(arc::pointer_type(0, 0), true, arc::pointer_type(1, 1)) + << arc(arc::pointer_type(1, 0), false, arc::pointer_type(2, 0)) + << arc(arc::pointer_type(2, 0), false, arc::pointer_type(false)) // <-- in-order + << arc(arc::pointer_type(2, 0), true, arc::pointer_type(true)) // <-- in-order + << arc(arc::pointer_type(1, 1), true, arc::pointer_type(true)); // <-- out-of-order aw.detach(); - AssertThat(af.size(), Is().EqualTo(8u)); + AssertThat(af.size(), Is().EqualTo(8u)); AssertThat(af.size(0u), Is().EqualTo(3u)); AssertThat(af.size(1u), Is().EqualTo(4u)); AssertThat(af.size(2u), Is().EqualTo(1u)); @@ -135,29 +138,37 @@ go_bandit([]() { AssertThat(af.levels(), Is().EqualTo(0u)); AssertThat(af.number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(af.number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(af.number_of_terminals[true], Is().EqualTo(4u)); levelized_file_stream lfs(af); AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(arc(arc::pointer_type(0,0), false, arc::pointer_type(1,0)))); + AssertThat(lfs.pull<0>(), + Is().EqualTo(arc(arc::pointer_type(0, 0), false, arc::pointer_type(1, 0)))); AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(arc(arc::pointer_type(0,0), true, arc::pointer_type(1,1)))); + AssertThat(lfs.pull<0>(), + Is().EqualTo(arc(arc::pointer_type(0, 0), true, arc::pointer_type(1, 1)))); AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(arc(arc::pointer_type(1,0), false, arc::pointer_type(2,0)))); + AssertThat(lfs.pull<0>(), + Is().EqualTo(arc(arc::pointer_type(1, 0), false, arc::pointer_type(2, 0)))); AssertThat(lfs.can_pull<0>(), Is().False()); AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(arc(arc::pointer_type(1,0), true, arc::pointer_type(true)))); + AssertThat(lfs.pull<1>(), + Is().EqualTo(arc(arc::pointer_type(1, 0), true, arc::pointer_type(true)))); AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(arc(arc::pointer_type(1,1), false, arc::pointer_type(true)))); + AssertThat(lfs.pull<1>(), + Is().EqualTo(arc(arc::pointer_type(1, 1), false, arc::pointer_type(true)))); AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(arc(arc::pointer_type(2,0), false, arc::pointer_type(false)))); + AssertThat(lfs.pull<1>(), + Is().EqualTo(arc(arc::pointer_type(2, 0), false, arc::pointer_type(false)))); AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(arc(arc::pointer_type(2,0), true, arc::pointer_type(true)))); + AssertThat(lfs.pull<1>(), + Is().EqualTo(arc(arc::pointer_type(2, 0), true, arc::pointer_type(true)))); AssertThat(lfs.can_pull<1>(), Is().False()); AssertThat(lfs.can_pull<2>(), Is().True()); - AssertThat(lfs.pull<2>(), Is().EqualTo(arc(arc::pointer_type(1,1), true, arc::pointer_type(true)))); + AssertThat(lfs.pull<2>(), + Is().EqualTo(arc(arc::pointer_type(1, 1), true, arc::pointer_type(true)))); AssertThat(lfs.can_pull<2>(), Is().False()); }); }); @@ -175,29 +186,34 @@ go_bandit([]() { */ { arc_writer aw(af); - aw << arc(arc::pointer_type(0,0), false, arc::pointer_type(1,0)); - aw << arc(arc::pointer_type(1,0), true, arc::pointer_type(true)); // <-- in-order - aw << arc(arc::pointer_type(1,1), false, arc::pointer_type(true)); // <-- in-order - aw << arc(arc::pointer_type(0,0), true, arc::pointer_type(1,1)); - aw << arc(arc::pointer_type(1,0), false, arc::pointer_type(2,0)); - aw << arc(arc::pointer_type(2,0), false, arc::pointer_type(false)); // <-- in-order - aw << arc(arc::pointer_type(2,0), true, arc::pointer_type(true)); // <-- in-order - aw << arc(arc::pointer_type(1,1), true, arc::pointer_type(true)); // <-- out-of-order + aw << arc(arc::pointer_type(0, 0), false, arc::pointer_type(1, 0)); + aw << arc(arc::pointer_type(1, 0), true, arc::pointer_type(true)); // <-- in-order + aw << arc(arc::pointer_type(1, 1), false, arc::pointer_type(true)); // <-- in-order + aw << arc(arc::pointer_type(0, 0), true, arc::pointer_type(1, 1)); + aw << arc(arc::pointer_type(1, 0), false, arc::pointer_type(2, 0)); + aw << arc(arc::pointer_type(2, 0), false, arc::pointer_type(false)); // <-- in-order + aw << arc(arc::pointer_type(2, 0), true, arc::pointer_type(true)); // <-- in-order + aw << arc(arc::pointer_type(1, 1), true, arc::pointer_type(true)); // <-- out-of-order } it("merges terminal arcs on 'pull' [default: backwards]", [&af]() { arc_stream<> as(af); AssertThat(as.can_pull_terminal(), Is().True()); - AssertThat(as.pull_terminal(), Is().EqualTo(arc(arc::pointer_type(2,0), true, arc::pointer_type(true)))); + AssertThat(as.pull_terminal(), + Is().EqualTo(arc(arc::pointer_type(2, 0), true, arc::pointer_type(true)))); AssertThat(as.can_pull_terminal(), Is().True()); - AssertThat(as.pull_terminal(), Is().EqualTo(arc(arc::pointer_type(2,0), false, arc::pointer_type(false)))); + AssertThat(as.pull_terminal(), + Is().EqualTo(arc(arc::pointer_type(2, 0), false, arc::pointer_type(false)))); AssertThat(as.can_pull_terminal(), Is().True()); - AssertThat(as.pull_terminal(), Is().EqualTo(arc(arc::pointer_type(1,1), true, arc::pointer_type(true)))); + AssertThat(as.pull_terminal(), + Is().EqualTo(arc(arc::pointer_type(1, 1), true, arc::pointer_type(true)))); AssertThat(as.can_pull_terminal(), Is().True()); - AssertThat(as.pull_terminal(), Is().EqualTo(arc(arc::pointer_type(1,1), false, arc::pointer_type(true)))); + AssertThat(as.pull_terminal(), + Is().EqualTo(arc(arc::pointer_type(1, 1), false, arc::pointer_type(true)))); AssertThat(as.can_pull_terminal(), Is().True()); - AssertThat(as.pull_terminal(), Is().EqualTo(arc(arc::pointer_type(1,0), true, arc::pointer_type(true)))); + AssertThat(as.pull_terminal(), + Is().EqualTo(arc(arc::pointer_type(1, 0), true, arc::pointer_type(true)))); AssertThat(as.can_pull_terminal(), Is().False()); }); @@ -205,15 +221,20 @@ go_bandit([]() { arc_stream as(af); AssertThat(as.can_pull_terminal(), Is().True()); - AssertThat(as.pull_terminal(), Is().EqualTo(arc(arc::pointer_type(1,0), true, arc::pointer_type(true)))); + AssertThat(as.pull_terminal(), + Is().EqualTo(arc(arc::pointer_type(1, 0), true, arc::pointer_type(true)))); AssertThat(as.can_pull_terminal(), Is().True()); - AssertThat(as.pull_terminal(), Is().EqualTo(arc(arc::pointer_type(1,1), false, arc::pointer_type(true)))); + AssertThat(as.pull_terminal(), + Is().EqualTo(arc(arc::pointer_type(1, 1), false, arc::pointer_type(true)))); AssertThat(as.can_pull_terminal(), Is().True()); - AssertThat(as.pull_terminal(), Is().EqualTo(arc(arc::pointer_type(1,1), true, arc::pointer_type(true)))); + AssertThat(as.pull_terminal(), + Is().EqualTo(arc(arc::pointer_type(1, 1), true, arc::pointer_type(true)))); AssertThat(as.can_pull_terminal(), Is().True()); - AssertThat(as.pull_terminal(), Is().EqualTo(arc(arc::pointer_type(2,0), false, arc::pointer_type(false)))); + AssertThat(as.pull_terminal(), + Is().EqualTo(arc(arc::pointer_type(2, 0), false, arc::pointer_type(false)))); AssertThat(as.can_pull_terminal(), Is().True()); - AssertThat(as.pull_terminal(), Is().EqualTo(arc(arc::pointer_type(2,0), true, arc::pointer_type(true)))); + AssertThat(as.pull_terminal(), + Is().EqualTo(arc(arc::pointer_type(2, 0), true, arc::pointer_type(true)))); AssertThat(as.can_pull_terminal(), Is().False()); }); @@ -221,15 +242,20 @@ go_bandit([]() { arc_stream<> as(af, true); AssertThat(as.can_pull_terminal(), Is().True()); - AssertThat(as.pull_terminal(), Is().EqualTo(arc(arc::pointer_type(2,0), true, arc::pointer_type(false)))); + AssertThat(as.pull_terminal(), + Is().EqualTo(arc(arc::pointer_type(2, 0), true, arc::pointer_type(false)))); AssertThat(as.can_pull_terminal(), Is().True()); - AssertThat(as.pull_terminal(), Is().EqualTo(arc(arc::pointer_type(2,0), false, arc::pointer_type(true)))); + AssertThat(as.pull_terminal(), + Is().EqualTo(arc(arc::pointer_type(2, 0), false, arc::pointer_type(true)))); AssertThat(as.can_pull_terminal(), Is().True()); - AssertThat(as.pull_terminal(), Is().EqualTo(arc(arc::pointer_type(1,1), true, arc::pointer_type(false)))); + AssertThat(as.pull_terminal(), + Is().EqualTo(arc(arc::pointer_type(1, 1), true, arc::pointer_type(false)))); AssertThat(as.can_pull_terminal(), Is().True()); - AssertThat(as.pull_terminal(), Is().EqualTo(arc(arc::pointer_type(1,1), false, arc::pointer_type(false)))); + AssertThat(as.pull_terminal(), + Is().EqualTo(arc(arc::pointer_type(1, 1), false, arc::pointer_type(false)))); AssertThat(as.can_pull_terminal(), Is().True()); - AssertThat(as.pull_terminal(), Is().EqualTo(arc(arc::pointer_type(1,0), true, arc::pointer_type(false)))); + AssertThat(as.pull_terminal(), + Is().EqualTo(arc(arc::pointer_type(1, 0), true, arc::pointer_type(false)))); AssertThat(as.can_pull_terminal(), Is().False()); }); @@ -237,98 +263,101 @@ go_bandit([]() { arc_stream<> as(af); AssertThat(as.can_pull_internal(), Is().True()); - AssertThat(as.pull_internal(), Is().EqualTo(arc(arc::pointer_type(1,0), false, arc::pointer_type(2,0)))); + AssertThat(as.pull_internal(), + Is().EqualTo(arc(arc::pointer_type(1, 0), false, arc::pointer_type(2, 0)))); AssertThat(as.can_pull_internal(), Is().True()); - AssertThat(as.pull_internal(), Is().EqualTo(arc(arc::pointer_type(0,0), true, arc::pointer_type(1,1)))); + AssertThat(as.pull_internal(), + Is().EqualTo(arc(arc::pointer_type(0, 0), true, arc::pointer_type(1, 1)))); AssertThat(as.can_pull_internal(), Is().True()); - AssertThat(as.pull_internal(), Is().EqualTo(arc(arc::pointer_type(0,0), false, arc::pointer_type(1,0)))); + AssertThat(as.pull_internal(), + Is().EqualTo(arc(arc::pointer_type(0, 0), false, arc::pointer_type(1, 0)))); AssertThat(as.can_pull_internal(), Is().False()); }); it("provides number of unread terminals [negate=false]", [&af]() { arc_stream<> as(af); - AssertThat(as.unread_terminals(), Is().EqualTo(5u)); + AssertThat(as.unread_terminals(), Is().EqualTo(5u)); AssertThat(as.unread_terminals(false), Is().EqualTo(1u)); - AssertThat(as.unread_terminals(true), Is().EqualTo(4u)); + AssertThat(as.unread_terminals(true), Is().EqualTo(4u)); AssertThat(as.can_pull_terminal(), Is().True()); as.pull_terminal(); // 3 ---> T - AssertThat(as.unread_terminals(), Is().EqualTo(4u)); + AssertThat(as.unread_terminals(), Is().EqualTo(4u)); AssertThat(as.unread_terminals(false), Is().EqualTo(1u)); - AssertThat(as.unread_terminals(true), Is().EqualTo(3u)); + AssertThat(as.unread_terminals(true), Is().EqualTo(3u)); AssertThat(as.can_pull_terminal(), Is().True()); as.pull_terminal(); // 3 - -> F - AssertThat(as.unread_terminals(), Is().EqualTo(3u)); + AssertThat(as.unread_terminals(), Is().EqualTo(3u)); AssertThat(as.unread_terminals(false), Is().EqualTo(0u)); - AssertThat(as.unread_terminals(true), Is().EqualTo(3u)); + AssertThat(as.unread_terminals(true), Is().EqualTo(3u)); AssertThat(as.can_pull_terminal(), Is().True()); as.pull_terminal(); // 2 ---> T - AssertThat(as.unread_terminals(), Is().EqualTo(2u)); + AssertThat(as.unread_terminals(), Is().EqualTo(2u)); AssertThat(as.unread_terminals(false), Is().EqualTo(0u)); - AssertThat(as.unread_terminals(true), Is().EqualTo(2u)); + AssertThat(as.unread_terminals(true), Is().EqualTo(2u)); AssertThat(as.can_pull_terminal(), Is().True()); as.pull_terminal(); // 2 - -> T - AssertThat(as.unread_terminals(), Is().EqualTo(1u)); + AssertThat(as.unread_terminals(), Is().EqualTo(1u)); AssertThat(as.unread_terminals(false), Is().EqualTo(0u)); - AssertThat(as.unread_terminals(true), Is().EqualTo(1u)); + AssertThat(as.unread_terminals(true), Is().EqualTo(1u)); AssertThat(as.can_pull_terminal(), Is().True()); as.pull_terminal(); // 1 - -> T - AssertThat(as.unread_terminals(), Is().EqualTo(0u)); + AssertThat(as.unread_terminals(), Is().EqualTo(0u)); AssertThat(as.unread_terminals(false), Is().EqualTo(0u)); - AssertThat(as.unread_terminals(true), Is().EqualTo(0u)); + AssertThat(as.unread_terminals(true), Is().EqualTo(0u)); }); it("provides number of unread terminals [negate=true]", [&af]() { arc_stream<> as(af, true); - AssertThat(as.unread_terminals(), Is().EqualTo(5u)); + AssertThat(as.unread_terminals(), Is().EqualTo(5u)); AssertThat(as.unread_terminals(false), Is().EqualTo(4u)); - AssertThat(as.unread_terminals(true), Is().EqualTo(1u)); + AssertThat(as.unread_terminals(true), Is().EqualTo(1u)); AssertThat(as.can_pull_terminal(), Is().True()); as.pull_terminal(); // 3 ---> F - AssertThat(as.unread_terminals(), Is().EqualTo(4u)); + AssertThat(as.unread_terminals(), Is().EqualTo(4u)); AssertThat(as.unread_terminals(false), Is().EqualTo(3u)); - AssertThat(as.unread_terminals(true), Is().EqualTo(1u)); + AssertThat(as.unread_terminals(true), Is().EqualTo(1u)); AssertThat(as.can_pull_terminal(), Is().True()); as.pull_terminal(); // 3 - -> T - AssertThat(as.unread_terminals(), Is().EqualTo(3u)); + AssertThat(as.unread_terminals(), Is().EqualTo(3u)); AssertThat(as.unread_terminals(false), Is().EqualTo(3u)); - AssertThat(as.unread_terminals(true), Is().EqualTo(0u)); + AssertThat(as.unread_terminals(true), Is().EqualTo(0u)); AssertThat(as.can_pull_terminal(), Is().True()); as.pull_terminal(); // 2 ---> F - AssertThat(as.unread_terminals(), Is().EqualTo(2u)); + AssertThat(as.unread_terminals(), Is().EqualTo(2u)); AssertThat(as.unread_terminals(false), Is().EqualTo(2u)); - AssertThat(as.unread_terminals(true), Is().EqualTo(0u)); + AssertThat(as.unread_terminals(true), Is().EqualTo(0u)); AssertThat(as.can_pull_terminal(), Is().True()); as.pull_terminal(); // 2 - -> F - AssertThat(as.unread_terminals(), Is().EqualTo(1u)); + AssertThat(as.unread_terminals(), Is().EqualTo(1u)); AssertThat(as.unread_terminals(false), Is().EqualTo(1u)); - AssertThat(as.unread_terminals(true), Is().EqualTo(0u)); + AssertThat(as.unread_terminals(true), Is().EqualTo(0u)); AssertThat(as.can_pull_terminal(), Is().True()); as.pull_terminal(); // 1 - -> F - AssertThat(as.unread_terminals(), Is().EqualTo(0u)); + AssertThat(as.unread_terminals(), Is().EqualTo(0u)); AssertThat(as.unread_terminals(false), Is().EqualTo(0u)); - AssertThat(as.unread_terminals(true), Is().EqualTo(0u)); + AssertThat(as.unread_terminals(true), Is().EqualTo(0u)); }); }); @@ -338,10 +367,10 @@ go_bandit([]() { { arc_writer aw(af); - aw.push_terminal(arc(arc::pointer_type(0,0), false, arc::pointer_type(false))); - aw.push_terminal(arc(arc::pointer_type(0,0), true, arc::pointer_type(true))); + aw.push_terminal(arc(arc::pointer_type(0, 0), false, arc::pointer_type(false))); + aw.push_terminal(arc(arc::pointer_type(0, 0), true, arc::pointer_type(true))); - aw.push(level_info(0,1)); + aw.push(level_info(0, 1)); aw.detach(); } @@ -355,17 +384,18 @@ go_bandit([]() { { arc_writer aw(af); - aw.push_terminal(arc(arc::pointer_type(0,0), false, arc::pointer_type(false))); - aw.push_terminal(arc(arc::pointer_type(0,0), true, arc::pointer_type(true))); + aw.push_terminal(arc(arc::pointer_type(0, 0), false, arc::pointer_type(false))); + aw.push_terminal(arc(arc::pointer_type(0, 0), true, arc::pointer_type(true))); - aw.push(level_info(0,1)); + aw.push(level_info(0, 1)); aw.detach(); } node_arc_stream ns(af); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0,0, node::pointer_type(false), node::pointer_type(true)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, 0, node::pointer_type(false), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().False()); }); @@ -375,17 +405,18 @@ go_bandit([]() { { arc_writer aw(af); - aw.push_terminal(arc(arc::pointer_type(0,0), true, arc::pointer_type(true))); - aw.push_terminal(arc(arc::pointer_type(0,0), false, arc::pointer_type(false))); + aw.push_terminal(arc(arc::pointer_type(0, 0), true, arc::pointer_type(true))); + aw.push_terminal(arc(arc::pointer_type(0, 0), false, arc::pointer_type(false))); - aw.push(level_info(0,1)); + aw.push(level_info(0, 1)); aw.detach(); } node_arc_stream ns(af); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0,0, node::pointer_type(false), node::pointer_type(true)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, 0, node::pointer_type(false), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().False()); }); @@ -407,27 +438,27 @@ go_bandit([]() { { arc_writer aw(af); - aw.push(level_info(0,1)); + aw.push(level_info(0, 1)); - aw.push_internal(arc(arc::pointer_type(0,0), false, arc::pointer_type(1,0))); - aw.push_terminal(arc(arc::pointer_type(1,0), false, arc::pointer_type(false))); + aw.push_internal(arc(arc::pointer_type(0, 0), false, arc::pointer_type(1, 0))); + aw.push_terminal(arc(arc::pointer_type(1, 0), false, arc::pointer_type(false))); - aw.push(level_info(1,1)); + aw.push(level_info(1, 1)); - aw.push_internal(arc(arc::pointer_type(0,0), true, arc::pointer_type(2,0))); - aw.push_internal(arc(arc::pointer_type(1,0), true, arc::pointer_type(2,0))); + aw.push_internal(arc(arc::pointer_type(0, 0), true, arc::pointer_type(2, 0))); + aw.push_internal(arc(arc::pointer_type(1, 0), true, arc::pointer_type(2, 0))); - aw.push(level_info(2,1)); + aw.push(level_info(2, 1)); - aw.push_internal(arc(arc::pointer_type(2,0), false, arc::pointer_type(3,0))); - aw.push_terminal(arc(arc::pointer_type(3,0), false, arc::pointer_type(false))); - aw.push_terminal(arc(arc::pointer_type(3,0), true, arc::pointer_type(true))); + aw.push_internal(arc(arc::pointer_type(2, 0), false, arc::pointer_type(3, 0))); + aw.push_terminal(arc(arc::pointer_type(3, 0), false, arc::pointer_type(false))); + aw.push_terminal(arc(arc::pointer_type(3, 0), true, arc::pointer_type(true))); - aw.push_internal(arc(arc::pointer_type(2,0), true, arc::pointer_type(3,1))); - aw.push_terminal(arc(arc::pointer_type(3,1), false, arc::pointer_type(true))); - aw.push_terminal(arc(arc::pointer_type(3,1), true, arc::pointer_type(false))); + aw.push_internal(arc(arc::pointer_type(2, 0), true, arc::pointer_type(3, 1))); + aw.push_terminal(arc(arc::pointer_type(3, 1), false, arc::pointer_type(true))); + aw.push_terminal(arc(arc::pointer_type(3, 1), true, arc::pointer_type(false))); - aw.push(level_info(3,2)); + aw.push(level_info(3, 2)); aw.detach(); } @@ -435,19 +466,24 @@ go_bandit([]() { node_arc_stream ns(af); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0,0, node::pointer_type(1,0), node::pointer_type(2,0)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, 0, node::pointer_type(1, 0), node::pointer_type(2, 0)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1,0, node::pointer_type(false), node::pointer_type(2,0)))); + AssertThat(ns.pull(), + Is().EqualTo(node(1, 0, node::pointer_type(false), node::pointer_type(2, 0)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2,0, node::pointer_type(3,0), node::pointer_type(3,1)))); + AssertThat(ns.pull(), + Is().EqualTo(node(2, 0, node::pointer_type(3, 0), node::pointer_type(3, 1)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3,0, node::pointer_type(false), node::pointer_type(true)))); + AssertThat(ns.pull(), + Is().EqualTo(node(3, 0, node::pointer_type(false), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3,1, node::pointer_type(true), node::pointer_type(false)))); + AssertThat(ns.pull(), + Is().EqualTo(node(3, 1, node::pointer_type(true), node::pointer_type(false)))); AssertThat(ns.can_pull(), Is().False()); }); @@ -467,19 +503,19 @@ go_bandit([]() { { arc_writer aw(af); - aw.push(level_info(0,1)); + aw.push(level_info(0, 1)); - aw.push_internal(arc(arc::pointer_type(0,0), true, arc::pointer_type(1,0))); - aw.push_terminal(arc(arc::pointer_type(1,0), true, arc::pointer_type(true))); + aw.push_internal(arc(arc::pointer_type(0, 0), true, arc::pointer_type(1, 0))); + aw.push_terminal(arc(arc::pointer_type(1, 0), true, arc::pointer_type(true))); - aw.push(level_info(1,1)); + aw.push(level_info(1, 1)); - aw.push_internal(arc(arc::pointer_type(0,0), false, arc::pointer_type(2,0))); - aw.push_internal(arc(arc::pointer_type(1,0), false, arc::pointer_type(2,0))); - aw.push_terminal(arc(arc::pointer_type(2,0), false, arc::pointer_type(false))); - aw.push_terminal(arc(arc::pointer_type(2,0), true, arc::pointer_type(true))); + aw.push_internal(arc(arc::pointer_type(0, 0), false, arc::pointer_type(2, 0))); + aw.push_internal(arc(arc::pointer_type(1, 0), false, arc::pointer_type(2, 0))); + aw.push_terminal(arc(arc::pointer_type(2, 0), false, arc::pointer_type(false))); + aw.push_terminal(arc(arc::pointer_type(2, 0), true, arc::pointer_type(true))); - aw.push(level_info(2,1)); + aw.push(level_info(2, 1)); aw.detach(); } @@ -487,13 +523,16 @@ go_bandit([]() { node_arc_stream ns(af); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0,0, node::pointer_type(2,0), node::pointer_type(1,0)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, 0, node::pointer_type(2, 0), node::pointer_type(1, 0)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1,0, node::pointer_type(2,0), node::pointer_type(true)))); + AssertThat(ns.pull(), + Is().EqualTo(node(1, 0, node::pointer_type(2, 0), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2,0, node::pointer_type(false), node::pointer_type(true)))); + AssertThat(ns.pull(), + Is().EqualTo(node(2, 0, node::pointer_type(false), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().False()); }); @@ -503,17 +542,18 @@ go_bandit([]() { { arc_writer aw(af); - aw.push_terminal(arc(arc::pointer_type(0,0), false, arc::pointer_type(false))); - aw.push_terminal(arc(arc::pointer_type(0,0), true, arc::pointer_type(true))); + aw.push_terminal(arc(arc::pointer_type(0, 0), false, arc::pointer_type(false))); + aw.push_terminal(arc(arc::pointer_type(0, 0), true, arc::pointer_type(true))); - aw.push(level_info(0,1)); + aw.push(level_info(0, 1)); aw.detach(); } node_arc_stream ns(af, true); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0,0, node::pointer_type(true), node::pointer_type(false)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, 0, node::pointer_type(true), node::pointer_type(false)))); AssertThat(ns.can_pull(), Is().False()); }); @@ -523,17 +563,18 @@ go_bandit([]() { { arc_writer aw(af); - aw.push_terminal(arc(arc::pointer_type(0,0), false, arc::pointer_type(false))); - aw.push_terminal(arc(arc::pointer_type(0,0), true, arc::pointer_type(true))); + aw.push_terminal(arc(arc::pointer_type(0, 0), false, arc::pointer_type(false))); + aw.push_terminal(arc(arc::pointer_type(0, 0), true, arc::pointer_type(true))); - aw.push(level_info(0,1)); + aw.push(level_info(0, 1)); aw.detach(); } node_arc_stream ns(af); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0,0, node::pointer_type(false), node::pointer_type(true)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, 0, node::pointer_type(false), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().False()); }); @@ -555,26 +596,26 @@ go_bandit([]() { { arc_writer aw(af); - aw.push(level_info(0,1)); + aw.push(level_info(0, 1)); - aw.push_internal(arc(arc::pointer_type(0,0), true, arc::pointer_type(1,0))); - aw.push_terminal(arc(arc::pointer_type(1,0), false, arc::pointer_type(false))); + aw.push_internal(arc(arc::pointer_type(0, 0), true, arc::pointer_type(1, 0))); + aw.push_terminal(arc(arc::pointer_type(1, 0), false, arc::pointer_type(false))); - aw.push(level_info(1,1)); + aw.push(level_info(1, 1)); - aw.push_internal(arc(arc::pointer_type(0,0), false, arc::pointer_type(2,0))); - aw.push_terminal(arc(arc::pointer_type(2,0), false, arc::pointer_type(false))); + aw.push_internal(arc(arc::pointer_type(0, 0), false, arc::pointer_type(2, 0))); + aw.push_terminal(arc(arc::pointer_type(2, 0), false, arc::pointer_type(false))); - aw.push_internal(arc(arc::pointer_type(1,0), true, arc::pointer_type(2,1))); - aw.push_terminal(arc(arc::pointer_type(2,1), true, arc::pointer_type(true))); + aw.push_internal(arc(arc::pointer_type(1, 0), true, arc::pointer_type(2, 1))); + aw.push_terminal(arc(arc::pointer_type(2, 1), true, arc::pointer_type(true))); - aw.push(level_info(2,2)); + aw.push(level_info(2, 2)); - aw.push_internal(arc(arc::pointer_type(2,0), true, arc::pointer_type(3,0))); - aw.push_internal(arc(arc::pointer_type(2,1), false, arc::pointer_type(3,0))); + aw.push_internal(arc(arc::pointer_type(2, 0), true, arc::pointer_type(3, 0))); + aw.push_internal(arc(arc::pointer_type(2, 1), false, arc::pointer_type(3, 0))); - aw.push_terminal(arc(arc::pointer_type(3,0), false, arc::pointer_type(false))); - aw.push_terminal(arc(arc::pointer_type(3,0), true, arc::pointer_type(true))); + aw.push_terminal(arc(arc::pointer_type(3, 0), false, arc::pointer_type(false))); + aw.push_terminal(arc(arc::pointer_type(3, 0), true, arc::pointer_type(true))); aw.detach(); } @@ -582,19 +623,24 @@ go_bandit([]() { node_arc_stream ns(af, true); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3,0, node::pointer_type(true), node::pointer_type(false)))); + AssertThat(ns.pull(), + Is().EqualTo(node(3, 0, node::pointer_type(true), node::pointer_type(false)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2,1, node::pointer_type(3,0), node::pointer_type(false)))); + AssertThat(ns.pull(), + Is().EqualTo(node(2, 1, node::pointer_type(3, 0), node::pointer_type(false)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2,0, node::pointer_type(true), node::pointer_type(3,0)))); + AssertThat(ns.pull(), + Is().EqualTo(node(2, 0, node::pointer_type(true), node::pointer_type(3, 0)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1,0, node::pointer_type(true), node::pointer_type(2,1)))); + AssertThat(ns.pull(), + Is().EqualTo(node(1, 0, node::pointer_type(true), node::pointer_type(2, 1)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0,0, node::pointer_type(2,0), node::pointer_type(1,0)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, 0, node::pointer_type(2, 0), node::pointer_type(1, 0)))); AssertThat(ns.can_pull(), Is().False()); }); @@ -604,10 +650,10 @@ go_bandit([]() { { arc_writer aw(af); - aw.push_terminal(arc(arc::pointer_type(0,0), false, arc::pointer_type(false))); - aw.push_terminal(arc(arc::pointer_type(0,0), true, arc::pointer_type(true))); + aw.push_terminal(arc(arc::pointer_type(0, 0), false, arc::pointer_type(false))); + aw.push_terminal(arc(arc::pointer_type(0, 0), true, arc::pointer_type(true))); - aw.push(level_info(0,1)); + aw.push(level_info(0, 1)); aw.detach(); } @@ -615,7 +661,8 @@ go_bandit([]() { node_arc_stream ns(af); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0,0, node::pointer_type(false), node::pointer_type(true)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, 0, node::pointer_type(false), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().False()); } @@ -624,11 +671,12 @@ go_bandit([]() { node_arc_stream ns(af); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0,0, node::pointer_type(false), node::pointer_type(true)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, 0, node::pointer_type(false), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().False()); } }); }); }); - }); +}); diff --git a/test/adiar/internal/io/test_file.cpp b/test/adiar/internal/io/test_file.cpp index c0d32ed27..22be45db0 100644 --- a/test/adiar/internal/io/test_file.cpp +++ b/test/adiar/internal/io/test_file.cpp @@ -1,5 +1,4 @@ #include "../../../test.h" - #include go_bandit([]() { @@ -13,7 +12,7 @@ go_bandit([]() { // the '/tmp/' folder and also to './'. // // HACK: get the temporary folder itself directly from TPIE. - const std::string tmp_path = tpie::tempname::get_actual_path() + "/"; + const std::string tmp_path = tpie::tempname::get_actual_path() + "/"; const std::string curr_path = "./"; describe("file() [empty]", [&tmp_path, &curr_path]() { @@ -218,9 +217,7 @@ go_bandit([]() { AssertThat(std::filesystem::exists(path), Is().True()); } // Clean up for this test - if (std::filesystem::exists(path)) { - std::filesystem::remove(path); - } + if (std::filesystem::exists(path)) { std::filesystem::remove(path); } }); }); @@ -705,10 +702,8 @@ go_bandit([]() { }); describe("file(path)", []() { - it("throws exception on path to non-existing file", []() { - AssertThrows(runtime_error, - file("./non-existing-file.adiar")); - }); + it("throws exception on path to non-existing file", + []() { AssertThrows(runtime_error, file("./non-existing-file.adiar")); }); std::string path; { @@ -759,9 +754,7 @@ go_bandit([]() { }); // Clean up for above tests - if (std::filesystem::exists(path)) { - std::filesystem::remove(path); - } + if (std::filesystem::exists(path)) { std::filesystem::remove(path); } { file f; @@ -774,9 +767,7 @@ go_bandit([]() { f.make_persistent(); } - it("can reopen a non-empty persisted file", [&path]() { - file f(path); - }); + it("can reopen a non-empty persisted file", [&path]() { file f(path); }); it("has expected size after reopening a persisted non-empty file", [&path]() { file f(path); @@ -846,9 +837,7 @@ go_bandit([]() { }); // Clean up for above tests - if (std::filesystem::exists(path)) { - std::filesystem::remove(path); - } + if (std::filesystem::exists(path)) { std::filesystem::remove(path); } }); describe("file.sort(const pred_t&)", []() { @@ -1137,4 +1126,4 @@ go_bandit([]() { }); }); }); - }); +}); diff --git a/test/adiar/internal/io/test_levelized_file.cpp b/test/adiar/internal/io/test_levelized_file.cpp index 4bb57d257..037526f87 100644 --- a/test/adiar/internal/io/test_levelized_file.cpp +++ b/test/adiar/internal/io/test_levelized_file.cpp @@ -1,1723 +1,1722 @@ #include "../../../test.h" - #include #include go_bandit([]() { - describe("adiar/internal/io/levelized_file.h , levelized_file_stream.h , levelized_file_writer.h", []() { - // The default folder for temporary files is '/tmp/' on Ubuntu and '/var/tmp/' - // on Fedora. Both of these are to the OS not on the same drive and so you get - // a 'cross-device link' error when using std::filesystem::rename(...) to move - // it to './'. - // - // To ensure our tests properly cover BOTH cases, we have to move it inside of - // the '/tmp/' folder and also to './'. - // - // HACK: get the temporary folder itself directly from TPIE. - const std::string tmp_path = tpie::tempname::get_actual_path() + "/"; - const std::string curr_path = "./"; - - it("levelized_file::FILES exposes the file_traits", []() { - AssertThat(levelized_file::FILES, Is().EqualTo(2u)); - }); - - describe("levelized_file()", [&tmp_path, &curr_path]() { - it("creates a file marked as 'temporary'", []() { - levelized_file lf; - AssertThat(lf.is_persistent(), Is().False()); - AssertThat(lf.is_temp(), Is().True()); - }); - - it("has no content", []() { - levelized_file lf; - AssertThat(lf.size(), Is().EqualTo(0u)); - AssertThat(lf.empty(), Is().True()); - }); - - it("has no levels", []() { - levelized_file lf; - AssertThat(lf.levels(), Is().EqualTo(0u)); - }); - - it("has non-canonical paths", []() { - levelized_file lf; - AssertThat(lf.canonical_paths(), Is().False()); - }); - - it("has FILES+1 different paths", []() { - levelized_file lf; - auto paths = lf.paths(); - - // Check array has expected size. - AssertThat(paths.size(), Is().EqualTo(2u + 1u)); - - // Check array has non-trivial values - AssertThat(paths[0], Is().Not().EqualTo("")); - AssertThat(paths[1], Is().Not().EqualTo("")); - AssertThat(paths[2], Is().Not().EqualTo("")); - - // Check all are different - AssertThat(paths[0], Is().Not().EqualTo(paths[1])); - AssertThat(paths[0], Is().Not().EqualTo(paths[2])); - AssertThat(paths[1], Is().Not().EqualTo(paths[2])); - }); + describe( + "adiar/internal/io/levelized_file.h , levelized_file_stream.h , levelized_file_writer.h", []() { + // The default folder for temporary files is '/tmp/' on Ubuntu and '/var/tmp/' + // on Fedora. Both of these are to the OS not on the same drive and so you get + // a 'cross-device link' error when using std::filesystem::rename(...) to move + // it to './'. + // + // To ensure our tests properly cover BOTH cases, we have to move it inside of + // the '/tmp/' folder and also to './'. + // + // HACK: get the temporary folder itself directly from TPIE. + const std::string tmp_path = tpie::tempname::get_actual_path() + "/"; + const std::string curr_path = "./"; + + it("levelized_file::FILES exposes the file_traits", + []() { AssertThat(levelized_file::FILES, Is().EqualTo(2u)); }); + + describe("levelized_file()", [&tmp_path, &curr_path]() { + it("creates a file marked as 'temporary'", []() { + levelized_file lf; + AssertThat(lf.is_persistent(), Is().False()); + AssertThat(lf.is_temp(), Is().True()); + }); - it("does not (yet) 'exist' on disk", []() { - levelized_file lf; - AssertThat(lf.exists(), Is().False()); + it("has no content", []() { + levelized_file lf; + AssertThat(lf.size(), Is().EqualTo(0u)); + AssertThat(lf.empty(), Is().True()); + }); - auto paths = lf.paths(); - AssertThat(std::filesystem::exists(paths[0]), Is().False()); - AssertThat(std::filesystem::exists(paths[1]), Is().False()); - AssertThat(std::filesystem::exists(paths[2]), Is().False()); - }); + it("has no levels", []() { + levelized_file lf; + AssertThat(lf.levels(), Is().EqualTo(0u)); + }); - it("'exists' after a 'touch'", []() { - levelized_file lf; - AssertThat(lf.exists(), Is().False()); + it("has non-canonical paths", []() { + levelized_file lf; + AssertThat(lf.canonical_paths(), Is().False()); + }); - auto paths = lf.paths(); + it("has FILES+1 different paths", []() { + levelized_file lf; + auto paths = lf.paths(); - lf.touch(); - AssertThat(lf.exists(), Is().True()); + // Check array has expected size. + AssertThat(paths.size(), Is().EqualTo(2u + 1u)); - AssertThat(std::filesystem::exists(paths[0]), Is().True()); - AssertThat(std::filesystem::exists(paths[1]), Is().True()); - AssertThat(std::filesystem::exists(paths[2]), Is().True()); - }); + // Check array has non-trivial values + AssertThat(paths[0], Is().Not().EqualTo("")); + AssertThat(paths[1], Is().Not().EqualTo("")); + AssertThat(paths[2], Is().Not().EqualTo("")); - it("is a fresh file", []() { - levelized_file lf1; - auto paths1 = lf1.paths(); + // Check all are different + AssertThat(paths[0], Is().Not().EqualTo(paths[1])); + AssertThat(paths[0], Is().Not().EqualTo(paths[2])); + AssertThat(paths[1], Is().Not().EqualTo(paths[2])); + }); - levelized_file lf2; - auto paths2 = lf2.paths(); + it("does not (yet) 'exist' on disk", []() { + levelized_file lf; + AssertThat(lf.exists(), Is().False()); - AssertThat(paths1[0], Is().Not().EqualTo(paths2[0])); - AssertThat(paths1[0], Is().Not().EqualTo(paths2[1])); - AssertThat(paths1[0], Is().Not().EqualTo(paths2[2])); + auto paths = lf.paths(); + AssertThat(std::filesystem::exists(paths[0]), Is().False()); + AssertThat(std::filesystem::exists(paths[1]), Is().False()); + AssertThat(std::filesystem::exists(paths[2]), Is().False()); + }); - AssertThat(paths1[1], Is().Not().EqualTo(paths2[0])); - AssertThat(paths1[1], Is().Not().EqualTo(paths2[1])); - AssertThat(paths1[1], Is().Not().EqualTo(paths2[2])); + it("'exists' after a 'touch'", []() { + levelized_file lf; + AssertThat(lf.exists(), Is().False()); - AssertThat(paths1[2], Is().Not().EqualTo(paths2[0])); - AssertThat(paths1[2], Is().Not().EqualTo(paths2[1])); - AssertThat(paths1[2], Is().Not().EqualTo(paths2[2])); - }); + auto paths = lf.paths(); - it("is temporary (removed from disk after destruct)", []() { - std::array paths; - { - levelized_file lf; - paths = lf.paths(); lf.touch(); + AssertThat(lf.exists(), Is().True()); AssertThat(std::filesystem::exists(paths[0]), Is().True()); AssertThat(std::filesystem::exists(paths[1]), Is().True()); AssertThat(std::filesystem::exists(paths[2]), Is().True()); - } - AssertThat(std::filesystem::exists(paths[0]), Is().False()); - AssertThat(std::filesystem::exists(paths[1]), Is().False()); - AssertThat(std::filesystem::exists(paths[2]), Is().False()); - }); - - it("can be 'moved' when not existing [/tmp/]", [&tmp_path]() { - const std::string path_prefix = tmp_path + "after-move-path.adiar"; - - // Clean up after prior test run - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - - levelized_file lf; - std::array old_paths = lf.paths(); - - AssertThat(std::filesystem::exists(old_paths[0]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[1]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[2]), Is().False()); - - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().False()); - - lf.move(path_prefix); - - AssertThat(std::filesystem::exists(old_paths[0]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[1]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[2]), Is().False()); - - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().False()); - - lf.touch(); - - AssertThat(std::filesystem::exists(old_paths[0]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[1]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[2]), Is().False()); - - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().True()); - }); - - it("can be 'moved' when not existing [./]", [&curr_path]() { - const std::string path_prefix = curr_path + "after-move-path.adiar"; - - // Clean up after prior test run - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - - levelized_file lf; - std::array old_paths = lf.paths(); - - AssertThat(std::filesystem::exists(old_paths[0]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[1]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[2]), Is().False()); - - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().False()); + }); + + it("is a fresh file", []() { + levelized_file lf1; + auto paths1 = lf1.paths(); + + levelized_file lf2; + auto paths2 = lf2.paths(); + + AssertThat(paths1[0], Is().Not().EqualTo(paths2[0])); + AssertThat(paths1[0], Is().Not().EqualTo(paths2[1])); + AssertThat(paths1[0], Is().Not().EqualTo(paths2[2])); + + AssertThat(paths1[1], Is().Not().EqualTo(paths2[0])); + AssertThat(paths1[1], Is().Not().EqualTo(paths2[1])); + AssertThat(paths1[1], Is().Not().EqualTo(paths2[2])); + + AssertThat(paths1[2], Is().Not().EqualTo(paths2[0])); + AssertThat(paths1[2], Is().Not().EqualTo(paths2[1])); + AssertThat(paths1[2], Is().Not().EqualTo(paths2[2])); + }); + + it("is temporary (removed from disk after destruct)", []() { + std::array paths; + { + levelized_file lf; + paths = lf.paths(); + lf.touch(); + + AssertThat(std::filesystem::exists(paths[0]), Is().True()); + AssertThat(std::filesystem::exists(paths[1]), Is().True()); + AssertThat(std::filesystem::exists(paths[2]), Is().True()); + } + AssertThat(std::filesystem::exists(paths[0]), Is().False()); + AssertThat(std::filesystem::exists(paths[1]), Is().False()); + AssertThat(std::filesystem::exists(paths[2]), Is().False()); + }); - lf.move(path_prefix); + it("can be 'moved' when not existing [/tmp/]", [&tmp_path]() { + const std::string path_prefix = tmp_path + "after-move-path.adiar"; - AssertThat(std::filesystem::exists(old_paths[0]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[1]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[2]), Is().False()); + // Clean up after prior test run + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().False()); + levelized_file lf; + std::array old_paths = lf.paths(); - lf.touch(); + AssertThat(std::filesystem::exists(old_paths[0]), Is().False()); + AssertThat(std::filesystem::exists(old_paths[1]), Is().False()); + AssertThat(std::filesystem::exists(old_paths[2]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[0]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[1]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[2]), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().True()); - }); + lf.move(path_prefix); - it("has canonical paths after 'move' [/tmp/]", [&tmp_path]() { - const std::string path_prefix = tmp_path + "after-move-path.adiar"; + AssertThat(std::filesystem::exists(old_paths[0]), Is().False()); + AssertThat(std::filesystem::exists(old_paths[1]), Is().False()); + AssertThat(std::filesystem::exists(old_paths[2]), Is().False()); - // Clean up after prior test run - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().False()); - levelized_file lf; - std::array old_paths = lf.paths(); + lf.touch(); - AssertThat(lf.canonical_paths(), Is().False()); - lf.move(path_prefix); - AssertThat(lf.canonical_paths(), Is().True()); - }); + AssertThat(std::filesystem::exists(old_paths[0]), Is().False()); + AssertThat(std::filesystem::exists(old_paths[1]), Is().False()); + AssertThat(std::filesystem::exists(old_paths[2]), Is().False()); - it("can be 'moved' when existing [/tmp/]", [&tmp_path]() { - const std::string path_prefix = tmp_path + "after-move-path.adiar"; + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().True()); + }); - // Clean up after prior test run - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); + it("can be 'moved' when not existing [./]", [&curr_path]() { + const std::string path_prefix = curr_path + "after-move-path.adiar"; - levelized_file lf; - lf.touch(); - std::array old_paths = lf.paths(); + // Clean up after prior test run + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); - AssertThat(std::filesystem::exists(old_paths[0]), Is().True()); - AssertThat(std::filesystem::exists(old_paths[1]), Is().True()); - AssertThat(std::filesystem::exists(old_paths[2]), Is().True()); + levelized_file lf; + std::array old_paths = lf.paths(); - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().False()); + AssertThat(std::filesystem::exists(old_paths[0]), Is().False()); + AssertThat(std::filesystem::exists(old_paths[1]), Is().False()); + AssertThat(std::filesystem::exists(old_paths[2]), Is().False()); - lf.move(path_prefix); + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().False()); - AssertThat(std::filesystem::exists(old_paths[0]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[1]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[2]), Is().False()); + lf.move(path_prefix); - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().True()); - }); + AssertThat(std::filesystem::exists(old_paths[0]), Is().False()); + AssertThat(std::filesystem::exists(old_paths[1]), Is().False()); + AssertThat(std::filesystem::exists(old_paths[2]), Is().False()); - it("can be 'moved' when existing [./]", [&curr_path]() { - const std::string path_prefix = curr_path + "after-move-path.adiar"; + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().False()); - // Clean up after prior test run - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); + lf.touch(); - levelized_file lf; - lf.touch(); - std::array old_paths = lf.paths(); + AssertThat(std::filesystem::exists(old_paths[0]), Is().False()); + AssertThat(std::filesystem::exists(old_paths[1]), Is().False()); + AssertThat(std::filesystem::exists(old_paths[2]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[0]), Is().True()); - AssertThat(std::filesystem::exists(old_paths[1]), Is().True()); - AssertThat(std::filesystem::exists(old_paths[2]), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().True()); + }); - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().False()); + it("has canonical paths after 'move' [/tmp/]", [&tmp_path]() { + const std::string path_prefix = tmp_path + "after-move-path.adiar"; - lf.move(path_prefix); + // Clean up after prior test run + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); - AssertThat(std::filesystem::exists(old_paths[0]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[1]), Is().False()); - AssertThat(std::filesystem::exists(old_paths[2]), Is().False()); + levelized_file lf; + std::array old_paths = lf.paths(); - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().True()); - }); + AssertThat(lf.canonical_paths(), Is().False()); + lf.move(path_prefix); + AssertThat(lf.canonical_paths(), Is().True()); + }); - it("is still temporary after move [/tmp/]", [&tmp_path]() { - const std::string path_prefix = tmp_path + "after-move-path.adiar"; + it("can be 'moved' when existing [/tmp/]", [&tmp_path]() { + const std::string path_prefix = tmp_path + "after-move-path.adiar"; - // Clean up after prior test run - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); + // Clean up after prior test run + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); - { levelized_file lf; lf.touch(); - lf.move(path_prefix); + std::array old_paths = lf.paths(); - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().True()); + AssertThat(std::filesystem::exists(old_paths[0]), Is().True()); + AssertThat(std::filesystem::exists(old_paths[1]), Is().True()); + AssertThat(std::filesystem::exists(old_paths[2]), Is().True()); - AssertThat(lf.is_persistent(), Is().False()); - AssertThat(lf.is_temp(), Is().True()); - } - - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().False()); - }); - - it("is still temporary after move [./]", [&curr_path]() { - const std::string path_prefix = curr_path + "after-move-path.adiar"; + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().False()); - // Clean up after prior test run - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - - { - levelized_file lf; - lf.touch(); lf.move(path_prefix); - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().True()); - - AssertThat(lf.is_persistent(), Is().False()); - AssertThat(lf.is_temp(), Is().True()); - } + AssertThat(std::filesystem::exists(old_paths[0]), Is().False()); + AssertThat(std::filesystem::exists(old_paths[1]), Is().False()); + AssertThat(std::filesystem::exists(old_paths[2]), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().False()); - }); + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().True()); + }); - it("cannot be 'moved' on-top of the path prefix itself [/tmp/]", [&tmp_path]() { - const std::string path_prefix = tmp_path + "after-move-path.adiar"; + it("can be 'moved' when existing [./]", [&curr_path]() { + const std::string path_prefix = curr_path + "after-move-path.adiar"; - // Clean up after prior test run - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - - { - file f; - f.move(path_prefix); - f.touch(); + // Clean up after prior test run + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); levelized_file lf; + lf.touch(); + std::array old_paths = lf.paths(); - AssertThrows(runtime_error, lf.move(path_prefix)); - } - - // Clean up of this test - if (std::filesystem::exists(path_prefix)) - std::filesystem::remove(path_prefix); - }); - - it("cannot be 'moved' on-top of another existing underlying file [/tmp/]", [&tmp_path]() { - const std::string path_prefix = tmp_path + "after-move-path.adiar"; - - // Clean up after prior test run - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); + AssertThat(std::filesystem::exists(old_paths[0]), Is().True()); + AssertThat(std::filesystem::exists(old_paths[1]), Is().True()); + AssertThat(std::filesystem::exists(old_paths[2]), Is().True()); - levelized_file lf1; - lf1.move(path_prefix); - lf1.touch(); + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().True()); + lf.move(path_prefix); - levelized_file lf2; + AssertThat(std::filesystem::exists(old_paths[0]), Is().False()); + AssertThat(std::filesystem::exists(old_paths[1]), Is().False()); + AssertThat(std::filesystem::exists(old_paths[2]), Is().False()); + + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().True()); + }); + + it("is still temporary after move [/tmp/]", [&tmp_path]() { + const std::string path_prefix = tmp_path + "after-move-path.adiar"; + + // Clean up after prior test run + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + { + levelized_file lf; + lf.touch(); + lf.move(path_prefix); + + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().True()); + + AssertThat(lf.is_persistent(), Is().False()); + AssertThat(lf.is_temp(), Is().True()); + } + + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().False()); + }); + + it("is still temporary after move [./]", [&curr_path]() { + const std::string path_prefix = curr_path + "after-move-path.adiar"; + + // Clean up after prior test run + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + { + levelized_file lf; + lf.touch(); + lf.move(path_prefix); + + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().True()); + + AssertThat(lf.is_persistent(), Is().False()); + AssertThat(lf.is_temp(), Is().True()); + } + + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().False()); + }); + + it("cannot be 'moved' on-top of the path prefix itself [/tmp/]", [&tmp_path]() { + const std::string path_prefix = tmp_path + "after-move-path.adiar"; + + // Clean up after prior test run + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + { + file f; + f.move(path_prefix); + f.touch(); + + levelized_file lf; + + AssertThrows(runtime_error, lf.move(path_prefix)); + } + + // Clean up of this test + if (std::filesystem::exists(path_prefix)) std::filesystem::remove(path_prefix); + }); + + it("cannot be 'moved' on-top of another existing underlying file [/tmp/]", [&tmp_path]() { + const std::string path_prefix = tmp_path + "after-move-path.adiar"; + + // Clean up after prior test run + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + levelized_file lf1; + lf1.move(path_prefix); + lf1.touch(); + + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().True()); + + levelized_file lf2; + + AssertThrows(runtime_error, lf2.move(path_prefix)); + }); + + it("can be made persistent (not removed from disk)", [&curr_path]() { + const std::string path_prefix = curr_path + "after-move-path.adiar"; + + // Clean up after prior test run + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + { + levelized_file lf; + std::array paths = lf.paths(); + lf.touch(); + + AssertThat(std::filesystem::exists(paths[0]), Is().True()); + AssertThat(std::filesystem::exists(paths[1]), Is().True()); + AssertThat(std::filesystem::exists(paths[2]), Is().True()); + + lf.make_persistent(path_prefix); + + AssertThat(std::filesystem::exists(paths[0]), Is().False()); + AssertThat(std::filesystem::exists(paths[1]), Is().False()); + AssertThat(std::filesystem::exists(paths[2]), Is().False()); + } + + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().True()); + + // Clean up for this test + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + }); + + it("exists on disk after being made persistent", [&tmp_path]() { + const std::string path_prefix = tmp_path + "after-move-path.adiar"; + + // Clean up after prior test run + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + { + levelized_file lf; + std::array paths = lf.paths(); + + AssertThat(std::filesystem::exists(paths[0]), Is().False()); + AssertThat(std::filesystem::exists(paths[1]), Is().False()); + AssertThat(std::filesystem::exists(paths[2]), Is().False()); + + lf.make_persistent(path_prefix); + + AssertThat(std::filesystem::exists(paths[0]), Is().False()); + AssertThat(std::filesystem::exists(paths[1]), Is().False()); + AssertThat(std::filesystem::exists(paths[2]), Is().False()); + } + + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().True()); + + // Clean up for this test + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + }); + + it("cannot 'move' file marked persisted [/tmp/]", [&tmp_path]() { + const std::string path_prefix = tmp_path + "after-move-path.adiar"; + + // Clean up after prior test run + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + { + levelized_file lf; + lf.make_persistent(path_prefix); + AssertThrows(runtime_error, lf.move(path_prefix)); + } + + // Clean up for this test + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + }); + }); + + describe("levelized_file() + levelized_file_stream", []() { + it("it can attach to and detach from an empty file [con-/destructor]", []() { + levelized_file lf; + levelized_file_stream lfs(lf); + }); - AssertThrows(runtime_error, lf2.move(path_prefix)); - }); + it("it can attach to and detach from an empty file [member functions]", []() { + levelized_file lf; + levelized_file_stream lfs; + lfs.attach(lf); + lfs.detach(); + }); - it("can be made persistent (not removed from disk)", [&curr_path]() { - const std::string path_prefix = curr_path + "after-move-path.adiar"; + it("it remembers it was attached", []() { + levelized_file lf; + levelized_file_stream lfs(lf); - // Clean up after prior test run - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); + AssertThat(lfs.attached(), Is().True()); + lfs.detach(); + AssertThat(lfs.attached(), Is().False()); + }); - { + it("it cannot be pulled from", []() { levelized_file lf; - std::array paths = lf.paths(); - lf.touch(); - - AssertThat(std::filesystem::exists(paths[0]), Is().True()); - AssertThat(std::filesystem::exists(paths[1]), Is().True()); - AssertThat(std::filesystem::exists(paths[2]), Is().True()); + levelized_file_stream lfs(lf); - lf.make_persistent(path_prefix); + AssertThat(lfs.template can_pull<0>(), Is().False()); + AssertThat(lfs.template can_pull<1>(), Is().False()); + }); - AssertThat(std::filesystem::exists(paths[0]), Is().False()); - AssertThat(std::filesystem::exists(paths[1]), Is().False()); - AssertThat(std::filesystem::exists(paths[2]), Is().False()); - } + it("it can be reset", []() { + levelized_file lf; + levelized_file_stream lfs(lf); - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().True()); - - // Clean up for this test - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); + lfs.reset(); + AssertThat(lfs.attached(), Is().True()); + AssertThat(lfs.template can_pull<0>(), Is().False()); + AssertThat(lfs.template can_pull<1>(), Is().False()); + }); }); - it("exists on disk after being made persistent", [&tmp_path]() { - const std::string path_prefix = tmp_path + "after-move-path.adiar"; - - // Clean up after prior test run - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - - { + describe("levelized_file() + levelized_file_writer", [&tmp_path, &curr_path]() { + it("it can attach to and detach from an empty file [con-/destructor]", []() { levelized_file lf; - std::array paths = lf.paths(); + levelized_file_writer lfw(lf); + }); - AssertThat(std::filesystem::exists(paths[0]), Is().False()); - AssertThat(std::filesystem::exists(paths[1]), Is().False()); - AssertThat(std::filesystem::exists(paths[2]), Is().False()); + it("it can attach to and detach from an empty file [member functions]", []() { + levelized_file lf; + levelized_file_writer lfw; + lfw.attach(lf); + lfw.detach(); + }); - lf.make_persistent(path_prefix); + it("it remembers it was attached", []() { + levelized_file lf; + levelized_file_writer lfw(lf); - AssertThat(std::filesystem::exists(paths[0]), Is().False()); - AssertThat(std::filesystem::exists(paths[1]), Is().False()); - AssertThat(std::filesystem::exists(paths[2]), Is().False()); - } + AssertThat(lfw.attached(), Is().True()); + lfw.detach(); + AssertThat(lfw.attached(), Is().False()); + }); - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().True()); - - // Clean up for this test - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - }); + it("exists after writer attach", []() { + levelized_file lf; + AssertThat(lf.exists(), Is().False()); - it("cannot 'move' file marked persisted [/tmp/]", [&tmp_path]() { - const std::string path_prefix = tmp_path + "after-move-path.adiar"; + levelized_file_writer lfw(lf); + lfw.detach(); - // Clean up after prior test run - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); + AssertThat(lf.exists(), Is().True()); + }); - { + it("reports whether elements were pushed [int<0>]", []() { levelized_file lf; - lf.make_persistent(path_prefix); - AssertThrows(runtime_error, lf.move(path_prefix)); - } - // Clean up for this test - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - }); - }); + levelized_file_writer lfw(lf); - describe("levelized_file() + levelized_file_stream", []() { - it("it can attach to and detach from an empty file [con-/destructor]", []() { - levelized_file lf; - levelized_file_stream lfs(lf); - }); + AssertThat(lfw.has_pushed(), Is().False()); + AssertThat(lfw.empty(), Is().True()); - it("it can attach to and detach from an empty file [member functions]", []() { - levelized_file lf; - levelized_file_stream lfs; - lfs.attach(lf); - lfs.detach(); - }); + lfw.push<0>(42); - it("it remembers it was attached", []() { - levelized_file lf; - levelized_file_stream lfs(lf); + AssertThat(lfw.has_pushed(), Is().True()); + AssertThat(lfw.empty(), Is().False()); + }); - AssertThat(lfs.attached(), Is().True()); - lfs.detach(); - AssertThat(lfs.attached(), Is().False()); - }); + it("reports whether elements were pushed [int<1>]", []() { + levelized_file lf; - it("it cannot be pulled from", []() { - levelized_file lf; - levelized_file_stream lfs(lf); + levelized_file_writer lfw(lf); - AssertThat(lfs.template can_pull<0>(), Is().False()); - AssertThat(lfs.template can_pull<1>(), Is().False()); - }); + AssertThat(lfw.has_pushed(), Is().False()); + AssertThat(lfw.empty(), Is().True()); - it("it can be reset", []() { - levelized_file lf; - levelized_file_stream lfs(lf); + lfw.push<1>(42); - lfs.reset(); - AssertThat(lfs.attached(), Is().True()); - AssertThat(lfs.template can_pull<0>(), Is().False()); - AssertThat(lfs.template can_pull<1>(), Is().False()); - }); - }); + AssertThat(lfw.has_pushed(), Is().True()); + AssertThat(lfw.empty(), Is().False()); + }); - describe("levelized_file() + levelized_file_writer", [&tmp_path, &curr_path]() { - it("it can attach to and detach from an empty file [con-/destructor]", []() { - levelized_file lf; - levelized_file_writer lfw(lf); - }); + it("reports whether elements were pushed [level_info]", []() { + levelized_file lf; - it("it can attach to and detach from an empty file [member functions]", []() { - levelized_file lf; - levelized_file_writer lfw; - lfw.attach(lf); - lfw.detach(); - }); + levelized_file_writer lfw(lf); - it("it remembers it was attached", []() { - levelized_file lf; - levelized_file_writer lfw(lf); + AssertThat(lfw.has_pushed(), Is().False()); + AssertThat(lfw.empty(), Is().True()); - AssertThat(lfw.attached(), Is().True()); - lfw.detach(); - AssertThat(lfw.attached(), Is().False()); - }); + lfw << level_info{ 0, 2 }; - it("exists after writer attach", []() { - levelized_file lf; - AssertThat(lf.exists(), Is().False()); + AssertThat(lfw.has_pushed(), Is().True()); + AssertThat(lfw.empty(), Is().False()); + }); - levelized_file_writer lfw(lf); - lfw.detach(); + it("changes size when writing content to '.file_0'", []() { + levelized_file lf; + levelized_file_writer lfw(lf); - AssertThat(lf.exists(), Is().True()); - }); + AssertThat(lfw.size(), Is().EqualTo(0u)); + AssertThat(lfw.size(0), Is().EqualTo(0u)); + AssertThat(lfw.size(1), Is().EqualTo(0u)); + AssertThat(lfw.levels(), Is().EqualTo(0u)); - it("reports whether elements were pushed [int<0>]", []() { - levelized_file lf; + lfw.push<0>(42); - levelized_file_writer lfw(lf); + AssertThat(lfw.size(), Is().EqualTo(1u)); + AssertThat(lfw.size(0), Is().EqualTo(1u)); + AssertThat(lfw.size(1), Is().EqualTo(0u)); + AssertThat(lfw.levels(), Is().EqualTo(0u)); - AssertThat(lfw.has_pushed(), Is().False()); - AssertThat(lfw.empty(), Is().True()); + lfw.push<0>(21); - lfw.push<0>(42); + AssertThat(lfw.size(), Is().EqualTo(2u)); + AssertThat(lfw.size(0), Is().EqualTo(2u)); + AssertThat(lfw.size(1), Is().EqualTo(0u)); + AssertThat(lfw.levels(), Is().EqualTo(0u)); - AssertThat(lfw.has_pushed(), Is().True()); - AssertThat(lfw.empty(), Is().False()); - }); + lfw.detach(); - it("reports whether elements were pushed [int<1>]", []() { - levelized_file lf; + AssertThat(lf.size(), Is().EqualTo(2u)); + AssertThat(lf.size(0), Is().EqualTo(2u)); + AssertThat(lf.size(1), Is().EqualTo(0u)); + AssertThat(lf.levels(), Is().EqualTo(0u)); + }); - levelized_file_writer lfw(lf); + it("changes size when writing content to '.file_1'", []() { + levelized_file lf; + levelized_file_writer lfw(lf); - AssertThat(lfw.has_pushed(), Is().False()); - AssertThat(lfw.empty(), Is().True()); + AssertThat(lfw.size(), Is().EqualTo(0u)); + AssertThat(lfw.size(0), Is().EqualTo(0u)); + AssertThat(lfw.size(1), Is().EqualTo(0u)); - lfw.push<1>(42); + lfw.push<1>(42); - AssertThat(lfw.has_pushed(), Is().True()); - AssertThat(lfw.empty(), Is().False()); - }); + AssertThat(lfw.size(), Is().EqualTo(1u)); + AssertThat(lfw.size(0), Is().EqualTo(0u)); + AssertThat(lfw.size(1), Is().EqualTo(1u)); - it("reports whether elements were pushed [level_info]", []() { - levelized_file lf; + lfw.push<1>(21); - levelized_file_writer lfw(lf); + AssertThat(lfw.size(), Is().EqualTo(2u)); + AssertThat(lfw.size(0), Is().EqualTo(0u)); + AssertThat(lfw.size(1), Is().EqualTo(2u)); - AssertThat(lfw.has_pushed(), Is().False()); - AssertThat(lfw.empty(), Is().True()); + lfw.detach(); - lfw << level_info { 0, 2 }; + AssertThat(lf.size(), Is().EqualTo(2u)); + AssertThat(lf.size(0), Is().EqualTo(0u)); + AssertThat(lf.size(1), Is().EqualTo(2u)); + AssertThat(lf.levels(), Is().EqualTo(0u)); + }); - AssertThat(lfw.has_pushed(), Is().True()); - AssertThat(lfw.empty(), Is().False()); - }); + it("changes size when writing content to both '.file_0' and '.file_1'", []() { + levelized_file lf; + levelized_file_writer lfw(lf); + AssertThat(lfw.size(), Is().EqualTo(0u)); + AssertThat(lfw.size(0), Is().EqualTo(0u)); + AssertThat(lfw.size(1), Is().EqualTo(0u)); + AssertThat(lfw.levels(), Is().EqualTo(0u)); - it("changes size when writing content to '.file_0'", []() { - levelized_file lf; - levelized_file_writer lfw(lf); + lfw.push<0>(5); - AssertThat(lfw.size(), Is().EqualTo(0u)); - AssertThat(lfw.size(0), Is().EqualTo(0u)); - AssertThat(lfw.size(1), Is().EqualTo(0u)); - AssertThat(lfw.levels(), Is().EqualTo(0u)); + AssertThat(lfw.size(), Is().EqualTo(1u)); + AssertThat(lfw.size(0), Is().EqualTo(1u)); + AssertThat(lfw.size(1), Is().EqualTo(0u)); + AssertThat(lfw.levels(), Is().EqualTo(0u)); - lfw.push<0>(42); + lfw.push<1>(2); - AssertThat(lfw.size(), Is().EqualTo(1u)); - AssertThat(lfw.size(0), Is().EqualTo(1u)); - AssertThat(lfw.size(1), Is().EqualTo(0u)); - AssertThat(lfw.levels(), Is().EqualTo(0u)); + AssertThat(lfw.size(), Is().EqualTo(2u)); + AssertThat(lfw.size(0), Is().EqualTo(1u)); + AssertThat(lfw.size(1), Is().EqualTo(1u)); + AssertThat(lfw.levels(), Is().EqualTo(0u)); - lfw.push<0>(21); + lfw.push<1>(4); - AssertThat(lfw.size(), Is().EqualTo(2u)); - AssertThat(lfw.size(0), Is().EqualTo(2u)); - AssertThat(lfw.size(1), Is().EqualTo(0u)); - AssertThat(lfw.levels(), Is().EqualTo(0u)); + AssertThat(lfw.size(), Is().EqualTo(3u)); + AssertThat(lfw.size(0), Is().EqualTo(1u)); + AssertThat(lfw.size(1), Is().EqualTo(2u)); + AssertThat(lfw.levels(), Is().EqualTo(0u)); - lfw.detach(); + lfw.push<0>(3); - AssertThat(lf.size(), Is().EqualTo(2u)); - AssertThat(lf.size(0), Is().EqualTo(2u)); - AssertThat(lf.size(1), Is().EqualTo(0u)); - AssertThat(lf.levels(), Is().EqualTo(0u)); - }); + AssertThat(lfw.size(), Is().EqualTo(4u)); + AssertThat(lfw.size(0), Is().EqualTo(2u)); + AssertThat(lfw.size(1), Is().EqualTo(2u)); + AssertThat(lfw.levels(), Is().EqualTo(0u)); - it("changes size when writing content to '.file_1'", []() { - levelized_file lf; - levelized_file_writer lfw(lf); + lfw.push<1>(8); - AssertThat(lfw.size(), Is().EqualTo(0u)); - AssertThat(lfw.size(0), Is().EqualTo(0u)); - AssertThat(lfw.size(1), Is().EqualTo(0u)); + AssertThat(lfw.size(), Is().EqualTo(5u)); + AssertThat(lfw.size(0), Is().EqualTo(2u)); + AssertThat(lfw.size(1), Is().EqualTo(3u)); + AssertThat(lfw.levels(), Is().EqualTo(0u)); - lfw.push<1>(42); + lfw.detach(); - AssertThat(lfw.size(), Is().EqualTo(1u)); - AssertThat(lfw.size(0), Is().EqualTo(0u)); - AssertThat(lfw.size(1), Is().EqualTo(1u)); + AssertThat(lf.size(), Is().EqualTo(5u)); + AssertThat(lf.size(0), Is().EqualTo(2u)); + AssertThat(lf.size(1), Is().EqualTo(3u)); + AssertThat(lf.levels(), Is().EqualTo(0u)); + }); - lfw.push<1>(21); + it("changes size when writing content to '.levels'", []() { + levelized_file lf; + levelized_file_writer lfw(lf); - AssertThat(lfw.size(), Is().EqualTo(2u)); - AssertThat(lfw.size(0), Is().EqualTo(0u)); - AssertThat(lfw.size(1), Is().EqualTo(2u)); + AssertThat(lfw.size(), Is().EqualTo(0u)); + AssertThat(lfw.levels(), Is().EqualTo(0u)); - lfw.detach(); + lfw.push(level_info{ 0, 3 }); - AssertThat(lf.size(), Is().EqualTo(2u)); - AssertThat(lf.size(0), Is().EqualTo(0u)); - AssertThat(lf.size(1), Is().EqualTo(2u)); - AssertThat(lf.levels(), Is().EqualTo(0u)); - }); + AssertThat(lfw.size(), Is().EqualTo(0u)); + AssertThat(lfw.levels(), Is().EqualTo(1u)); - it("changes size when writing content to both '.file_0' and '.file_1'", []() { - levelized_file lf; - levelized_file_writer lfw(lf); + lfw.push(level_info{ 1, 2 }); - AssertThat(lfw.size(), Is().EqualTo(0u)); - AssertThat(lfw.size(0), Is().EqualTo(0u)); - AssertThat(lfw.size(1), Is().EqualTo(0u)); - AssertThat(lfw.levels(), Is().EqualTo(0u)); + AssertThat(lfw.size(), Is().EqualTo(0u)); + AssertThat(lfw.levels(), Is().EqualTo(2u)); - lfw.push<0>(5); + lfw.push(level_info{ 2, 1 }); - AssertThat(lfw.size(), Is().EqualTo(1u)); - AssertThat(lfw.size(0), Is().EqualTo(1u)); - AssertThat(lfw.size(1), Is().EqualTo(0u)); - AssertThat(lfw.levels(), Is().EqualTo(0u)); + AssertThat(lfw.size(), Is().EqualTo(0u)); + AssertThat(lfw.levels(), Is().EqualTo(3u)); - lfw.push<1>(2); + lfw.detach(); - AssertThat(lfw.size(), Is().EqualTo(2u)); - AssertThat(lfw.size(0), Is().EqualTo(1u)); - AssertThat(lfw.size(1), Is().EqualTo(1u)); - AssertThat(lfw.levels(), Is().EqualTo(0u)); + AssertThat(lf.size(), Is().EqualTo(0u)); + AssertThat(lf.levels(), Is().EqualTo(3u)); + }); - lfw.push<1>(4); + it("can be 'moved' after write [/tmp/]", [&tmp_path]() { + const std::string path_prefix = tmp_path + "after-move-prefix.adiar"; - AssertThat(lfw.size(), Is().EqualTo(3u)); - AssertThat(lfw.size(0), Is().EqualTo(1u)); - AssertThat(lfw.size(1), Is().EqualTo(2u)); - AssertThat(lfw.levels(), Is().EqualTo(0u)); + // Clean up after prior tests + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); - lfw.push<0>(3); + levelized_file lf; + levelized_file_writer lfw(lf); + lfw.push<0>(42); + lfw.push<1>(2); + lfw.push<0>(21); + lfw.push<1>(3); + lfw.push<1>(1); + lfw.push(level_info{ 0, 2 }); + lfw.push(level_info{ 2, 1 }); + lfw.push(level_info{ 3, 2 }); + lfw.detach(); - AssertThat(lfw.size(), Is().EqualTo(4u)); - AssertThat(lfw.size(0), Is().EqualTo(2u)); - AssertThat(lfw.size(1), Is().EqualTo(2u)); - AssertThat(lfw.levels(), Is().EqualTo(0u)); + std::array paths = lf.paths(); - lfw.push<1>(8); + AssertThat(std::filesystem::exists(paths[0]), Is().True()); + AssertThat(std::filesystem::exists(paths[1]), Is().True()); + AssertThat(std::filesystem::exists(paths[2]), Is().True()); - AssertThat(lfw.size(), Is().EqualTo(5u)); - AssertThat(lfw.size(0), Is().EqualTo(2u)); - AssertThat(lfw.size(1), Is().EqualTo(3u)); - AssertThat(lfw.levels(), Is().EqualTo(0u)); + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().False()); - lfw.detach(); + lf.move(path_prefix); - AssertThat(lf.size(), Is().EqualTo(5u)); - AssertThat(lf.size(0), Is().EqualTo(2u)); - AssertThat(lf.size(1), Is().EqualTo(3u)); - AssertThat(lf.levels(), Is().EqualTo(0u)); - }); + AssertThat(std::filesystem::exists(paths[0]), Is().False()); + AssertThat(std::filesystem::exists(paths[1]), Is().False()); + AssertThat(std::filesystem::exists(paths[2]), Is().False()); - it("changes size when writing content to '.levels'", []() { - levelized_file lf; - levelized_file_writer lfw(lf); + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().True()); + }); - AssertThat(lfw.size(), Is().EqualTo(0u)); - AssertThat(lfw.levels(), Is().EqualTo(0u)); + it("can be 'moved' after write [./]", [&curr_path]() { + const std::string path_prefix = curr_path + "after-move-prefix.adiar"; - lfw.push(level_info{ 0, 3 }); + // Clean up after prior tests + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); - AssertThat(lfw.size(), Is().EqualTo(0u)); - AssertThat(lfw.levels(), Is().EqualTo(1u)); + levelized_file lf; + levelized_file_writer lfw(lf); + lfw.push<1>(42); + lfw.push<0>(2); + lfw.push<0>(21); + lfw.push<0>(3); + lfw.push(level_info{ 0, 1 }); + lfw.push(level_info{ 2, 1 }); + lfw.push(level_info{ 3, 2 }); + lfw.detach(); - lfw.push(level_info{ 1, 2 }); + std::array paths = lf.paths(); - AssertThat(lfw.size(), Is().EqualTo(0u)); - AssertThat(lfw.levels(), Is().EqualTo(2u)); + AssertThat(std::filesystem::exists(paths[0]), Is().True()); + AssertThat(std::filesystem::exists(paths[1]), Is().True()); + AssertThat(std::filesystem::exists(paths[2]), Is().True()); - lfw.push(level_info{ 2, 1 }); + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().False()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().False()); - AssertThat(lfw.size(), Is().EqualTo(0u)); - AssertThat(lfw.levels(), Is().EqualTo(3u)); + lf.move(path_prefix); - lfw.detach(); + AssertThat(std::filesystem::exists(paths[0]), Is().False()); + AssertThat(std::filesystem::exists(paths[1]), Is().False()); + AssertThat(std::filesystem::exists(paths[2]), Is().False()); - AssertThat(lf.size(), Is().EqualTo(0u)); - AssertThat(lf.levels(), Is().EqualTo(3u)); - }); + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().True()); + }); + }); + + describe("levelized_file() + levelized_file_stream + levelized_file_writer", + [&tmp_path /*, &curr_path*/]() { + it("can read written content", []() { + levelized_file lf; + { + levelized_file_writer lfw(lf); + lfw.push<0>(23); + lfw.push<0>(8); + lfw.push<1>(16); + lfw.push<0>(32); + lfw.push<1>(24); + } + { + levelized_file_stream lfs(lf); + AssertThat(lfs.pull<0>(), Is().EqualTo(23)); + AssertThat(lfs.pull<0>(), Is().EqualTo(8)); + AssertThat(lfs.pull<0>(), Is().EqualTo(32)); + AssertThat(lfs.pull<1>(), Is().EqualTo(16)); + AssertThat(lfs.pull<1>(), Is().EqualTo(24)); + } + }); + + it("can read written content in reverse", []() { + levelized_file lf; + { + levelized_file_writer lfw(lf); + lfw.push<0>(18); + lfw.push<1>(24); + lfw.push<0>(32); + lfw.push<1>(21); + lfw.push<1>(23); + lfw.push<0>(16); + } + { + levelized_file_stream lfs(lf); + AssertThat(lfs.pull<0>(), Is().EqualTo(16)); + AssertThat(lfs.pull<0>(), Is().EqualTo(32)); + AssertThat(lfs.pull<0>(), Is().EqualTo(18)); + AssertThat(lfs.pull<1>(), Is().EqualTo(23)); + AssertThat(lfs.pull<1>(), Is().EqualTo(21)); + AssertThat(lfs.pull<1>(), Is().EqualTo(24)); + } + }); + + it("can read written content after move", [&tmp_path]() { + const std::string path_prefix = tmp_path + "after-move-prefix.adiar"; + + // Clean up after prior tests + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + levelized_file lf; + { + levelized_file_writer lfw(lf); + lfw.push<0>(23); + lfw.push<0>(32); + lfw.push<1>(24); + } + lf.move(path_prefix); + { + levelized_file_stream lfs(lf); + AssertThat(lfs.pull<0>(), Is().EqualTo(23)); + AssertThat(lfs.pull<0>(), Is().EqualTo(32)); + AssertThat(lfs.pull<1>(), Is().EqualTo(24)); + } + }); + + it("can read written content in reverse after move", [&tmp_path]() { + const std::string path_prefix = tmp_path + "after-move-prefix.adiar"; + + // Clean up after prior tests + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + levelized_file lf; + { + levelized_file_writer lfw(lf); + lfw.push<0>(0); + lfw.push<1>(1); + lfw.push<0>(2); + lfw.push<1>(3); + lfw.push<0>(4); + lfw.push<1>(5); + lfw.push<0>(6); + lfw.push<1>(7); + } + lf.move(path_prefix); + { + levelized_file_stream lfs(lf); + AssertThat(lfs.pull<0>(), Is().EqualTo(6)); + AssertThat(lfs.pull<0>(), Is().EqualTo(4)); + AssertThat(lfs.pull<0>(), Is().EqualTo(2)); + AssertThat(lfs.pull<0>(), Is().EqualTo(0)); + AssertThat(lfs.pull<1>(), Is().EqualTo(7)); + AssertThat(lfs.pull<1>(), Is().EqualTo(5)); + AssertThat(lfs.pull<1>(), Is().EqualTo(3)); + AssertThat(lfs.pull<1>(), Is().EqualTo(1)); + } + }); + }); + + describe("levelized_file() + levelized_file_writer + level_info_stream", []() { + it("reads by default level information in reverse", []() { + levelized_file lf; + levelized_file_writer lfw(lf); - it("can be 'moved' after write [/tmp/]", [&tmp_path]() { - const std::string path_prefix = tmp_path + "after-move-prefix.adiar"; + lfw.push<0>(-1); + lfw.push<0>(1); + lfw.push<1>(-1); + lfw.push<0>(2); + lfw.push<1>(1); + lfw.push(level_info{ 0u, 2u }); + lfw.push(level_info{ 1u, 3u }); - // Clean up after prior tests - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - - levelized_file lf; - levelized_file_writer lfw(lf); - lfw.push<0>(42); - lfw.push<1>(2); - lfw.push<0>(21); - lfw.push<1>(3); - lfw.push<1>(1); - lfw.push(level_info{ 0,2 }); - lfw.push(level_info{ 2,1 }); - lfw.push(level_info{ 3,2 }); - lfw.detach(); - - std::array paths = lf.paths(); - - AssertThat(std::filesystem::exists(paths[0]), Is().True()); - AssertThat(std::filesystem::exists(paths[1]), Is().True()); - AssertThat(std::filesystem::exists(paths[2]), Is().True()); - - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().False()); - - lf.move(path_prefix); - - AssertThat(std::filesystem::exists(paths[0]), Is().False()); - AssertThat(std::filesystem::exists(paths[1]), Is().False()); - AssertThat(std::filesystem::exists(paths[2]), Is().False()); - - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().True()); - }); + lfw.detach(); - it("can be 'moved' after write [./]", [&curr_path]() { - const std::string path_prefix = curr_path + "after-move-prefix.adiar"; + level_info_stream fs(lf); + AssertThat(fs.can_pull(), Is().True()); + AssertThat(fs.pull(), Is().EqualTo(level_info{ 1u, 3u })); + AssertThat(fs.can_pull(), Is().True()); + AssertThat(fs.pull(), Is().EqualTo(level_info{ 0u, 2u })); + AssertThat(fs.can_pull(), Is().False()); + }); + }); + + describe("levelized_file(path_prefix)", [&tmp_path, &curr_path]() { + it("throws exception on path-prefix to completely non-existing files", [&curr_path]() { + const std::string path_prefix = curr_path + "non-existing-prefix.adiar"; + AssertThrows(runtime_error, levelized_file(path_prefix)); + }); + + it("throws exception on path-prefix to partially non-existing files [missing .file_0]", + [&curr_path]() { + const std::string path_prefix = curr_path + "non-existing-prefix.adiar"; + { // Create the 'existing' files by hand (and clean up after prior tests) + // TODO: take the respective file headers into account + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + + file f_1; + f_1.move(path_prefix + ".file_1"); + f_1.touch(); + f_1.make_persistent(); + + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + file f_levels; + f_levels.move(path_prefix + ".levels"); + f_levels.touch(); + f_levels.make_persistent(); + } + + AssertThrows(runtime_error, levelized_file(path_prefix)); + + // Cleanup after this test + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + }); + + it("throws exception on path-prefix to partially non-existing files [missing .file_1]", + [&curr_path]() { + const std::string path_prefix = curr_path + "non-existing-prefix.adiar"; + { // Create the 'existing' files by hand (and clean up after prior tests) + // TODO: take the respective file headers into account + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + + file f_0; + f_0.move(path_prefix + ".file_0"); + f_0.touch(); + f_0.make_persistent(); + + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + file f_levels; + f_levels.move(path_prefix + ".levels"); + f_levels.touch(); + f_levels.make_persistent(); + } + + AssertThrows(runtime_error, levelized_file(path_prefix)); + + // Cleanup after this test + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + }); + + it("throws exception on path-prefix to partially non-existing files [missing .levels]", + [&curr_path]() { + const std::string path_prefix = curr_path + "non-existing-prefix.adiar"; + { // Create the 'existing' files by hand (and clean up after prior tests) + // TODO: take the respective file headers into account + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + + file f_0; + f_0.move(path_prefix + ".file_0"); + f_0.touch(); + f_0.make_persistent(); + + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + + file f_1; + f_1.move(path_prefix + ".file_1"); + f_1.touch(); + f_1.make_persistent(); + + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + } + + AssertThrows(runtime_error, levelized_file(path_prefix)); + + // Cleanup after this test + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + }); + + it("can reopen a persisted empty file", [&tmp_path]() { + const std::string path_prefix = tmp_path + "existing-prefix.adiar"; + + // Clean up after prior tests + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + { + levelized_file lf; + lf.make_persistent(path_prefix); + } + { + levelized_file lf(path_prefix); + } + + // Cleanup after this test + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + }); + + it("has a persisted empty file still marked persistnt", [&tmp_path]() { + const std::string path_prefix = tmp_path + "existing-prefix.adiar"; + + // Clean up after prior tests + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + { + levelized_file lf; + lf.make_persistent(path_prefix); + } + { + levelized_file lf(path_prefix); + + AssertThat(lf.is_persistent(), Is().True()); + AssertThat(lf.is_temp(), Is().False()); + } + + // Cleanup after this test + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + }); + + it("has expected size(s) after reopening a persisted empty file", [&tmp_path]() { + const std::string path_prefix = tmp_path + "existing-prefix.adiar"; + + // Clean up after prior tests + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + { + levelized_file lf; + lf.make_persistent(path_prefix); + } + { + levelized_file lf(path_prefix); + + AssertThat(lf.size(), Is().EqualTo(0u)); + AssertThat(lf.size(0), Is().EqualTo(0u)); + AssertThat(lf.size(1), Is().EqualTo(0u)); + AssertThat(lf.levels(), Is().EqualTo(0u)); + } + + // Cleanup after this test + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + }); + + // Customly construct a non-empty levelized file without using the + // 'levelized_file_writer'. + const std::string path_prefix = tmp_path + "existing-prefix.adiar"; // Clean up after prior tests - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - - levelized_file lf; - levelized_file_writer lfw(lf); - lfw.push<1>(42); - lfw.push<0>(2); - lfw.push<0>(21); - lfw.push<0>(3); - lfw.push(level_info{ 0,1 }); - lfw.push(level_info{ 2,1 }); - lfw.push(level_info{ 3,2 }); - lfw.detach(); - - std::array paths = lf.paths(); - - AssertThat(std::filesystem::exists(paths[0]), Is().True()); - AssertThat(std::filesystem::exists(paths[1]), Is().True()); - AssertThat(std::filesystem::exists(paths[2]), Is().True()); - - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().False()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().False()); - - lf.move(path_prefix); - - AssertThat(std::filesystem::exists(paths[0]), Is().False()); - AssertThat(std::filesystem::exists(paths[1]), Is().False()); - AssertThat(std::filesystem::exists(paths[2]), Is().False()); - - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().True()); - }); - }); + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); - describe("levelized_file() + levelized_file_stream + levelized_file_writer", [&tmp_path/*, &curr_path*/]() { - it("can read written content", []() { - levelized_file lf; - { - levelized_file_writer lfw(lf); - lfw.push<0>(23); - lfw.push<0>(8); - lfw.push<1>(16); - lfw.push<0>(32); - lfw.push<1>(24); - } - { - levelized_file_stream lfs(lf); - AssertThat(lfs.pull<0>(), Is().EqualTo(23)); - AssertThat(lfs.pull<0>(), Is().EqualTo(8)); - AssertThat(lfs.pull<0>(), Is().EqualTo(32)); - AssertThat(lfs.pull<1>(), Is().EqualTo(16)); - AssertThat(lfs.pull<1>(), Is().EqualTo(24)); - } - }); - - it("can read written content in reverse", []() { - levelized_file lf; - { - levelized_file_writer lfw(lf); - lfw.push<0>(18); - lfw.push<1>(24); - lfw.push<0>(32); - lfw.push<1>(21); - lfw.push<1>(23); - lfw.push<0>(16); - } - { - levelized_file_stream lfs(lf); - AssertThat(lfs.pull<0>(), Is().EqualTo(16)); - AssertThat(lfs.pull<0>(), Is().EqualTo(32)); - AssertThat(lfs.pull<0>(), Is().EqualTo(18)); - AssertThat(lfs.pull<1>(), Is().EqualTo(23)); - AssertThat(lfs.pull<1>(), Is().EqualTo(21)); - AssertThat(lfs.pull<1>(), Is().EqualTo(24)); - } - }); - - it("can read written content after move", [&tmp_path]() { - const std::string path_prefix = tmp_path + "after-move-prefix.adiar"; - - // Clean up after prior tests - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - - levelized_file lf; { + levelized_file lf; levelized_file_writer lfw(lf); - lfw.push<0>(23); - lfw.push<0>(32); - lfw.push<1>(24); - } - lf.move(path_prefix); - { - levelized_file_stream lfs(lf); - AssertThat(lfs.pull<0>(), Is().EqualTo(23)); - AssertThat(lfs.pull<0>(), Is().EqualTo(32)); - AssertThat(lfs.pull<1>(), Is().EqualTo(24)); - } - }); - it("can read written content in reverse after move", [&tmp_path]() { - const std::string path_prefix = tmp_path + "after-move-prefix.adiar"; - - // Clean up after prior tests - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - - levelized_file lf; - { - levelized_file_writer lfw(lf); lfw.push<0>(0); - lfw.push<1>(1); + lfw.push<1>(42); lfw.push<0>(2); - lfw.push<1>(3); - lfw.push<0>(4); - lfw.push<1>(5); - lfw.push<0>(6); - lfw.push<1>(7); - } - lf.move(path_prefix); - { - levelized_file_stream lfs(lf); - AssertThat(lfs.pull<0>(), Is().EqualTo(6)); - AssertThat(lfs.pull<0>(), Is().EqualTo(4)); - AssertThat(lfs.pull<0>(), Is().EqualTo(2)); - AssertThat(lfs.pull<0>(), Is().EqualTo(0)); - AssertThat(lfs.pull<1>(), Is().EqualTo(7)); - AssertThat(lfs.pull<1>(), Is().EqualTo(5)); - AssertThat(lfs.pull<1>(), Is().EqualTo(3)); - AssertThat(lfs.pull<1>(), Is().EqualTo(1)); - } - }); - }); - - describe("levelized_file() + levelized_file_writer + level_info_stream", []() { - it("reads by default level information in reverse", []() { - levelized_file lf; - levelized_file_writer lfw(lf); - - lfw.push<0>(-1); - lfw.push<0>(1); - lfw.push<1>(-1); - lfw.push<0>(2); - lfw.push<1>(1); - lfw.push(level_info{ 0u,2u }); - lfw.push(level_info{ 1u,3u }); - - lfw.detach(); - - level_info_stream fs(lf); - AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(level_info{1u,3u})); - AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(level_info{0u,2u})); - AssertThat(fs.can_pull(), Is().False()); - }); - }); - - describe("levelized_file(path_prefix)", [&tmp_path, &curr_path]() { - it("throws exception on path-prefix to completely non-existing files", [&curr_path]() { - const std::string path_prefix = curr_path + "non-existing-prefix.adiar"; - AssertThrows(runtime_error, levelized_file(path_prefix)); - }); - - - it("throws exception on path-prefix to partially non-existing files [missing .file_0]", [&curr_path]() { - const std::string path_prefix = curr_path + "non-existing-prefix.adiar"; - { // Create the 'existing' files by hand (and clean up after prior tests) - // TODO: take the respective file headers into account - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - - file f_1; - f_1.move(path_prefix+".file_1"); - f_1.touch(); - f_1.make_persistent(); - - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - - file f_levels; - f_levels.move(path_prefix+".levels"); - f_levels.touch(); - f_levels.make_persistent(); - } - - AssertThrows(runtime_error, levelized_file(path_prefix)); - - // Cleanup after this test - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - }); - - it("throws exception on path-prefix to partially non-existing files [missing .file_1]", [&curr_path]() { - const std::string path_prefix = curr_path + "non-existing-prefix.adiar"; - { // Create the 'existing' files by hand (and clean up after prior tests) - // TODO: take the respective file headers into account - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - - file f_0; - f_0.move(path_prefix+".file_0"); - f_0.touch(); - f_0.make_persistent(); - - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - - file f_levels; - f_levels.move(path_prefix+".levels"); - f_levels.touch(); - f_levels.make_persistent(); - } - - AssertThrows(runtime_error, levelized_file(path_prefix)); - - // Cleanup after this test - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - }); - - it("throws exception on path-prefix to partially non-existing files [missing .levels]", [&curr_path]() { - const std::string path_prefix = curr_path + "non-existing-prefix.adiar"; - { // Create the 'existing' files by hand (and clean up after prior tests) - // TODO: take the respective file headers into account - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - - file f_0; - f_0.move(path_prefix+".file_0"); - f_0.touch(); - f_0.make_persistent(); - - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - - file f_1; - f_1.move(path_prefix+".file_1"); - f_1.touch(); - f_1.make_persistent(); - - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - } - - AssertThrows(runtime_error, levelized_file(path_prefix)); - - // Cleanup after this test - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - }); - - it("can reopen a persisted empty file", [&tmp_path]() { - const std::string path_prefix = tmp_path + "existing-prefix.adiar"; - - // Clean up after prior tests - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); + lfw.push<0>(8); + lfw.push(level_info{ 0, 4 }); + lfw.detach(); - { - levelized_file lf; lf.make_persistent(path_prefix); } - { - levelized_file lf(path_prefix); - } - - // Cleanup after this test - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - }); - - it("has a persisted empty file still marked persistnt", [&tmp_path]() { - const std::string path_prefix = tmp_path + "existing-prefix.adiar"; - // Clean up after prior tests - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); + it("can reopen a persisted non-empty file", + [&path_prefix]() { levelized_file lf(path_prefix); }); - { - levelized_file lf; - lf.make_persistent(path_prefix); - } - { + it("has expected size(s) after reopening a persisted non-empty file", [&path_prefix]() { levelized_file lf(path_prefix); + AssertThat(lf.size(), Is().EqualTo(4u)); + AssertThat(lf.size(0), Is().EqualTo(3u)); + AssertThat(lf.size(1), Is().EqualTo(1u)); + AssertThat(lf.levels(), Is().EqualTo(1u)); + }); + it("has the non-empty file still marked persistent", [&path_prefix]() { + levelized_file lf(path_prefix); AssertThat(lf.is_persistent(), Is().True()); AssertThat(lf.is_temp(), Is().False()); - } + }); - // Cleanup after this test - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - }); - - it("has expected size(s) after reopening a persisted empty file", [&tmp_path]() { - const std::string path_prefix = tmp_path + "existing-prefix.adiar"; - - // Clean up after prior tests - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - - { - levelized_file lf; - lf.make_persistent(path_prefix); - } - { + it("can read content with a stream", [&path_prefix]() { levelized_file lf(path_prefix); + levelized_file_stream lfs(lf); - AssertThat(lf.size(), Is().EqualTo(0u)); - AssertThat(lf.size(0), Is().EqualTo(0u)); - AssertThat(lf.size(1), Is().EqualTo(0u)); - AssertThat(lf.levels(), Is().EqualTo(0u)); - } - - // Cleanup after this test - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - }); - - // Customly construct a non-empty levelized file without using the - // 'levelized_file_writer'. - const std::string path_prefix = tmp_path + "existing-prefix.adiar"; - - // Clean up after prior tests - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - - { - levelized_file lf; - levelized_file_writer lfw(lf); - - lfw.push<0>(0); - lfw.push<1>(42); - lfw.push<0>(2); - lfw.push<0>(8); - lfw.push(level_info{ 0, 4 }); - lfw.detach(); - - lf.make_persistent(path_prefix); - } - - it("can reopen a persisted non-empty file", [&path_prefix]() { - levelized_file lf(path_prefix); - }); - - it("has expected size(s) after reopening a persisted non-empty file", [&path_prefix]() { - levelized_file lf(path_prefix); - AssertThat(lf.size(), Is().EqualTo(4u)); - AssertThat(lf.size(0), Is().EqualTo(3u)); - AssertThat(lf.size(1), Is().EqualTo(1u)); - AssertThat(lf.levels(), Is().EqualTo(1u)); - }); + AssertThat(lfs.pull<0>(), Is().EqualTo(0)); + AssertThat(lfs.pull<0>(), Is().EqualTo(2)); + AssertThat(lfs.pull<0>(), Is().EqualTo(8)); + AssertThat(lfs.pull<1>(), Is().EqualTo(42)); + }); - it("has the non-empty file still marked persistent", [&path_prefix]() { - levelized_file lf(path_prefix); - AssertThat(lf.is_persistent(), Is().True()); - AssertThat(lf.is_temp(), Is().False()); - }); + it("cannot reattach a writer to a persisted file", [&path_prefix]() { + levelized_file lf(path_prefix); + levelized_file_writer lfw; + AssertThrows(runtime_error, lfw.attach(lf)); + }); - it("can read content with a stream", [&path_prefix]() { - levelized_file lf(path_prefix); - levelized_file_stream lfs(lf); + it("is unchanged after marking it persistent once more", [&path_prefix]() { + { + levelized_file lf(path_prefix); + lf.make_persistent(); - AssertThat(lfs.pull<0>(), Is().EqualTo(0)); - AssertThat(lfs.pull<0>(), Is().EqualTo(2)); - AssertThat(lfs.pull<0>(), Is().EqualTo(8)); - AssertThat(lfs.pull<1>(), Is().EqualTo(42)); - }); + AssertThat(lf.is_persistent(), Is().True()); + AssertThat(lf.is_temp(), Is().False()); + } - it("cannot reattach a writer to a persisted file", [&path_prefix]() { - levelized_file lf(path_prefix); - levelized_file_writer lfw; - AssertThrows(runtime_error, lfw.attach(lf)); - }); + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().True()); + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().True()); + }); - it("is unchanged after marking it persistent once more", [&path_prefix]() { - { + it("cannot be 'moved'", [&tmp_path, &path_prefix]() { levelized_file lf(path_prefix); lf.make_persistent(); - AssertThat(lf.is_persistent(), Is().True()); - AssertThat(lf.is_temp(), Is().False()); - } - - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().True()); - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().True()); - }); + AssertThat(lf.can_move(), Is().False()); + AssertThrows(runtime_error, lf.move(tmp_path + "alternative-prefix.adiar")); + }); - it("cannot be 'moved'", [&tmp_path, &path_prefix]() { - levelized_file lf(path_prefix); - lf.make_persistent(); + // TODO: test data is persisted. - AssertThat(lf.can_move(), Is().False()); - AssertThrows(runtime_error, lf.move(tmp_path+"alternative-prefix.adiar")); + // Clean up customly constructed persisted non-empty file after its tests + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); }); - // TODO: test data is persisted. - - // Clean up customly constructed persisted non-empty file after its tests - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - }); - - describe("levelized_file.sort(const pred&, size_t idx)", [&tmp_path]() { - it("can sort an empty subfile [0]", []() { - levelized_file lf; - lf.touch(); - - AssertThat(lf.empty(), Is().True()); - - lf.sort>(0); - - AssertThat(lf.empty(), Is().True()); - }); - - it("can sort an empty subfile [1]", []() { - levelized_file lf; - lf.touch(); - - AssertThat(lf.empty(), Is().True()); - - lf.sort>(1); - - AssertThat(lf.empty(), Is().True()); - }); - - it("cannot sort an index out of bounds", []() { - levelized_file lf; - lf.touch(); + describe("levelized_file.sort(const pred&, size_t idx)", [&tmp_path]() { + it("can sort an empty subfile [0]", []() { + levelized_file lf; + lf.touch(); - AssertThrows(out_of_range, lf.sort>(2)); - }); + AssertThat(lf.empty(), Is().True()); - it("can sort a temporary non-empty file", []() { - levelized_file lf; - - levelized_file_writer lfw(lf); - lfw.push<0>(-1); - lfw.push<1>(0); - lfw.push<0>(2); - lfw.push<0>(1); - lfw.push<1>(-1); - lfw.push<1>(2); - lfw.push<0>(0); - lfw.push<1>(1); - lfw.push(level_info{ 0,1 }); - lfw.push(level_info{ 1,2 }); - lfw.push(level_info{ 2,4 }); - lfw.push(level_info{ 3,1 }); - lfw.detach(); - - { // Check is unsorted first - levelized_file_stream lfs(lf); - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(-1)); - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(2)); - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(1)); - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(0)); - AssertThat(lfs.can_pull<0>(), Is().False()); - - AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(0)); - AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(-1)); - AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(2)); - AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(1)); - AssertThat(lfs.can_pull<1>(), Is().False()); - } + lf.sort>(0); - lf.sort>(0); - { // Check has (only) the first file sorted - levelized_file_stream lfs(lf); + AssertThat(lf.empty(), Is().True()); + }); - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(-1)); - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(0)); - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(1)); - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(2)); - AssertThat(lfs.can_pull<0>(), Is().False()); - - AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(0)); - AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(-1)); - AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(2)); - AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(1)); - AssertThat(lfs.can_pull<1>(), Is().False()); - } + it("can sort an empty subfile [1]", []() { + levelized_file lf; + lf.touch(); - lf.sort>(1); - { // Check has both files sorted - levelized_file_stream lfs(lf); + AssertThat(lf.empty(), Is().True()); - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(-1)); - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(0)); - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(1)); - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(2)); - AssertThat(lfs.can_pull<0>(), Is().False()); - - AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(-1)); - AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(0)); - AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(1)); - AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(2)); - AssertThat(lfs.can_pull<1>(), Is().False()); - } - }); + lf.sort>(1); - it("cannot sort a persisted empty file", [&tmp_path]() { - const std::string path_prefix = tmp_path + "sort-prefix.adiar"; + AssertThat(lf.empty(), Is().True()); + }); - // Clean up after prior tests - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - - { // Scope to destruct 'lf' early + it("cannot sort an index out of bounds", []() { levelized_file lf; - lf.make_persistent(path_prefix); - - AssertThrows(runtime_error, lf.sort>(0)); - AssertThrows(runtime_error, lf.sort>(1)); - } - AssertThat(std::filesystem::exists(path_prefix+".file_0"), Is().True()); - std::filesystem::remove(path_prefix+".file_0"); - - AssertThat(std::filesystem::exists(path_prefix+".file_1"), Is().True()); - std::filesystem::remove(path_prefix+".file_1"); - - AssertThat(std::filesystem::exists(path_prefix+".levels"), Is().True()); - std::filesystem::remove(path_prefix+".levels"); - }); + lf.touch(); - it("cannot sort a persisted non-empty file", [&tmp_path]() { - const std::string path_prefix = tmp_path + "sort-prefix.adiar"; + AssertThrows(out_of_range, lf.sort>(2)); + }); - // Clean up after prior tests - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - - { // Construct a persisted non-empty levelized file by hand + it("can sort a temporary non-empty file", []() { levelized_file lf; - levelized_file_writer lfw(lf); + levelized_file_writer lfw(lf); lfw.push<0>(-1); - lfw.push<0>(8); - lfw.push<1>(4); - lfw.push<0>(3); + lfw.push<1>(0); + lfw.push<0>(2); + lfw.push<0>(1); + lfw.push<1>(-1); lfw.push<1>(2); - lfw.push(level_info{ 2,1 }); - lfw.push(level_info{ 1,1 }); - + lfw.push<0>(0); + lfw.push<1>(1); + lfw.push(level_info{ 0, 1 }); + lfw.push(level_info{ 1, 2 }); + lfw.push(level_info{ 2, 4 }); + lfw.push(level_info{ 3, 1 }); lfw.detach(); - lf.make_persistent(path_prefix); - } - - { // Try to sort it - levelized_file lf(path_prefix); - AssertThrows(runtime_error, lf.sort>(0)); - AssertThrows(runtime_error, lf.sort>(1)); - } - - { // Check content is not sorted - levelized_file lf(path_prefix); - - levelized_file_stream lfs(lf); - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(-1)); - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(8)); - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(3)); - AssertThat(lfs.can_pull<0>(), Is().False()); - - AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(4)); - AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(2)); - AssertThat(lfs.can_pull<1>(), Is().False()); - - level_info_stream fs_lvls(lf); - AssertThat(fs_lvls.can_pull(), Is().True()); - AssertThat(fs_lvls.pull(), Is().EqualTo(level_info{2,1})); - AssertThat(fs_lvls.can_pull(), Is().True()); - AssertThat(fs_lvls.pull(), Is().EqualTo(level_info{1,1})); - AssertThat(fs_lvls.can_pull(), Is().False()); - } - - // Clean up for this test - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - }); - }); - - describe("levelized_file::copy(const levelized_file&)", [&tmp_path]() { - it("can copy over non-existing file", []() { - levelized_file lf1; - - // Set stats content - lf1.meta_value = 42; - - const std::array paths1 = lf1.paths(); - - levelized_file lf2 = levelized_file::copy(lf1); - const std::array paths2 = lf2.paths(); - - // Check stats content - AssertThat(lf2.meta_value, Is().EqualTo(42)); - - // Check paths are unique - AssertThat(paths1[0], Is().Not().EqualTo(paths2[0])); - AssertThat(paths1[0], Is().Not().EqualTo(paths2[1])); - AssertThat(paths1[0], Is().Not().EqualTo(paths2[2])); - - AssertThat(paths1[1], Is().Not().EqualTo(paths2[0])); - AssertThat(paths1[1], Is().Not().EqualTo(paths2[1])); - AssertThat(paths1[1], Is().Not().EqualTo(paths2[2])); - - AssertThat(paths1[2], Is().Not().EqualTo(paths2[0])); - AssertThat(paths1[2], Is().Not().EqualTo(paths2[1])); - AssertThat(paths1[2], Is().Not().EqualTo(paths2[2])); - }); - - it("is unaffected by orginal file being 'touched'", []() { - levelized_file lf1; - levelized_file lf2 = levelized_file::copy(lf1); - - lf1.touch(); - AssertThat(lf1.exists(), Is().True()); - AssertThat(lf2.exists(), Is().False()); - }); - - it("can copy an existing file [empty]", []() { - levelized_file lf1; - - // Set stats content and state - lf1.meta_value = 7; - lf1.touch(); - - // Check file state - AssertThat(lf1.exists(), Is().True()); - AssertThat(lf1.empty(), Is().True()); - AssertThat(lf1.size(), Is().EqualTo(0u)); - - levelized_file lf2 = levelized_file::copy(lf1); - - // Check stats content - AssertThat(lf2.meta_value, Is().EqualTo(7)); - - // Check file state - AssertThat(lf2.exists(), Is().True()); - AssertThat(lf2.empty(), Is().True()); - AssertThat(lf2.size(), Is().EqualTo(0u)); - - // Check paths are unique - const std::array paths1 = lf1.paths(); - const std::array paths2 = lf2.paths(); - - AssertThat(paths1[0], Is().Not().EqualTo(paths2[0])); - AssertThat(paths1[0], Is().Not().EqualTo(paths2[1])); - AssertThat(paths1[0], Is().Not().EqualTo(paths2[2])); - - AssertThat(paths1[1], Is().Not().EqualTo(paths2[0])); - AssertThat(paths1[1], Is().Not().EqualTo(paths2[1])); - AssertThat(paths1[1], Is().Not().EqualTo(paths2[2])); - - AssertThat(paths1[2], Is().Not().EqualTo(paths2[0])); - AssertThat(paths1[2], Is().Not().EqualTo(paths2[1])); - AssertThat(paths1[2], Is().Not().EqualTo(paths2[2])); - }); - - it("can copy an existing file [non-empty]", []() { - levelized_file lf1; - // Set file and stats content - { - levelized_file_writer lfw(lf1); - - lfw.push<0>(21); - lfw.push<1>(42); - lfw.push<0>(21); - lfw.push(level_info{ 0,1 }); - lfw.push(level_info{ 1,2 }); - } - - lf1.meta_value = 4; // <- very random number - - // Check state - AssertThat(lf1.exists(), Is().True()); - AssertThat(lf1.empty(), Is().False()); - AssertThat(lf1.size(), Is().EqualTo(3u)); - AssertThat(lf1.size(0), Is().EqualTo(2u)); - AssertThat(lf1.size(1), Is().EqualTo(1u)); - AssertThat(lf1.levels(), Is().EqualTo(2u)); - - levelized_file lf2 = levelized_file::copy(lf1); - - // Check stats content - AssertThat(lf2.meta_value, Is().EqualTo(4)); - - // Check state - AssertThat(lf2.exists(), Is().True()); - AssertThat(lf2.empty(), Is().False()); - AssertThat(lf2.size(), Is().EqualTo(3u)); - AssertThat(lf2.size(0), Is().EqualTo(2u)); - AssertThat(lf2.size(1), Is().EqualTo(1u)); - AssertThat(lf2.levels(), Is().EqualTo(2u)); - - // Check file content - { - levelized_file_stream lfs(lf2); - - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(21)); - AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(21)); - AssertThat(lfs.can_pull<0>(), Is().False()); - - AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(42)); - AssertThat(lfs.can_pull<1>(), Is().False()); - - level_info_stream fs_lvls(lf2); - AssertThat(fs_lvls.can_pull(), Is().True()); - AssertThat(fs_lvls.pull(), Is().EqualTo(level_info{0,1})); - AssertThat(fs_lvls.can_pull(), Is().True()); - AssertThat(fs_lvls.pull(), Is().EqualTo(level_info{1,2})); - AssertThat(fs_lvls.can_pull(), Is().False()); - } - - // Check paths are unique - const std::array paths1 = lf1.paths(); - const std::array paths2 = lf2.paths(); - - AssertThat(paths1[0], Is().Not().EqualTo(paths2[0])); - AssertThat(paths1[0], Is().Not().EqualTo(paths2[1])); - AssertThat(paths1[0], Is().Not().EqualTo(paths2[2])); - - AssertThat(paths1[1], Is().Not().EqualTo(paths2[0])); - AssertThat(paths1[1], Is().Not().EqualTo(paths2[1])); - AssertThat(paths1[1], Is().Not().EqualTo(paths2[2])); - - AssertThat(paths1[2], Is().Not().EqualTo(paths2[0])); - AssertThat(paths1[2], Is().Not().EqualTo(paths2[1])); - AssertThat(paths1[2], Is().Not().EqualTo(paths2[2])); - }); - - it("can copy an existing persistent file", [&tmp_path]() { - const std::string path_prefix = tmp_path + "sort-prefix.adiar"; - - // Clean up after prior tests - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); - - levelized_file lf1; - - // Set stats content and state - { - levelized_file_writer lfw(lf1); - - lfw.push<0>(21); - lfw.push<1>(42); - lfw.push<1>(21); - lfw.push(level_info{ 0,1 }); - lfw.push(level_info{ 1,2 }); - } - lf1.meta_value = 21; - lf1.make_persistent(path_prefix); - - // Check state - AssertThat(lf1.is_persistent(), Is().True()); - AssertThat(lf1.is_temp(), Is().False()); - - AssertThat(lf1.exists(), Is().True()); - AssertThat(lf1.empty(), Is().False()); - - AssertThat(lf1.size(), Is().EqualTo(3u)); - AssertThat(lf1.size(0), Is().EqualTo(1u)); - AssertThat(lf1.size(1), Is().EqualTo(2u)); - AssertThat(lf1.levels(), Is().EqualTo(2u)); - - levelized_file lf2 = levelized_file::copy(lf1); - - // Check stats content - AssertThat(lf2.meta_value, Is().EqualTo(21)); - - // Check state - AssertThat(lf2.is_persistent(), Is().False()); - AssertThat(lf2.is_temp(), Is().True()); - - AssertThat(lf2.exists(), Is().True()); - AssertThat(lf2.empty(), Is().False()); - - AssertThat(lf2.size(), Is().EqualTo(3u)); - AssertThat(lf2.size(0), Is().EqualTo(1u)); - AssertThat(lf2.size(1), Is().EqualTo(2u)); - AssertThat(lf2.levels(), Is().EqualTo(2u)); - - // Check paths are unique - const std::array paths1 = lf1.paths(); - const std::array paths2 = lf2.paths(); - - AssertThat(paths1[0], Is().Not().EqualTo(paths2[0])); - AssertThat(paths1[0], Is().Not().EqualTo(paths2[1])); - AssertThat(paths1[0], Is().Not().EqualTo(paths2[2])); - - AssertThat(paths1[1], Is().Not().EqualTo(paths2[0])); - AssertThat(paths1[1], Is().Not().EqualTo(paths2[1])); - AssertThat(paths1[1], Is().Not().EqualTo(paths2[2])); - - AssertThat(paths1[2], Is().Not().EqualTo(paths2[0])); - AssertThat(paths1[2], Is().Not().EqualTo(paths2[1])); - AssertThat(paths1[2], Is().Not().EqualTo(paths2[2])); + { // Check is unsorted first + levelized_file_stream lfs(lf); + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(-1)); + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(2)); + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(1)); + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(0)); + AssertThat(lfs.can_pull<0>(), Is().False()); + + AssertThat(lfs.can_pull<1>(), Is().True()); + AssertThat(lfs.pull<1>(), Is().EqualTo(0)); + AssertThat(lfs.can_pull<1>(), Is().True()); + AssertThat(lfs.pull<1>(), Is().EqualTo(-1)); + AssertThat(lfs.can_pull<1>(), Is().True()); + AssertThat(lfs.pull<1>(), Is().EqualTo(2)); + AssertThat(lfs.can_pull<1>(), Is().True()); + AssertThat(lfs.pull<1>(), Is().EqualTo(1)); + AssertThat(lfs.can_pull<1>(), Is().False()); + } + + lf.sort>(0); + { // Check has (only) the first file sorted + levelized_file_stream lfs(lf); + + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(-1)); + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(0)); + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(1)); + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(2)); + AssertThat(lfs.can_pull<0>(), Is().False()); + + AssertThat(lfs.can_pull<1>(), Is().True()); + AssertThat(lfs.pull<1>(), Is().EqualTo(0)); + AssertThat(lfs.can_pull<1>(), Is().True()); + AssertThat(lfs.pull<1>(), Is().EqualTo(-1)); + AssertThat(lfs.can_pull<1>(), Is().True()); + AssertThat(lfs.pull<1>(), Is().EqualTo(2)); + AssertThat(lfs.can_pull<1>(), Is().True()); + AssertThat(lfs.pull<1>(), Is().EqualTo(1)); + AssertThat(lfs.can_pull<1>(), Is().False()); + } + + lf.sort>(1); + { // Check has both files sorted + levelized_file_stream lfs(lf); + + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(-1)); + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(0)); + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(1)); + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(2)); + AssertThat(lfs.can_pull<0>(), Is().False()); + + AssertThat(lfs.can_pull<1>(), Is().True()); + AssertThat(lfs.pull<1>(), Is().EqualTo(-1)); + AssertThat(lfs.can_pull<1>(), Is().True()); + AssertThat(lfs.pull<1>(), Is().EqualTo(0)); + AssertThat(lfs.can_pull<1>(), Is().True()); + AssertThat(lfs.pull<1>(), Is().EqualTo(1)); + AssertThat(lfs.can_pull<1>(), Is().True()); + AssertThat(lfs.pull<1>(), Is().EqualTo(2)); + AssertThat(lfs.can_pull<1>(), Is().False()); + } + }); + + it("cannot sort a persisted empty file", [&tmp_path]() { + const std::string path_prefix = tmp_path + "sort-prefix.adiar"; + + // Clean up after prior tests + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + { // Scope to destruct 'lf' early + levelized_file lf; + lf.make_persistent(path_prefix); + + AssertThrows(runtime_error, lf.sort>(0)); + AssertThrows(runtime_error, lf.sort>(1)); + } + AssertThat(std::filesystem::exists(path_prefix + ".file_0"), Is().True()); + std::filesystem::remove(path_prefix + ".file_0"); + + AssertThat(std::filesystem::exists(path_prefix + ".file_1"), Is().True()); + std::filesystem::remove(path_prefix + ".file_1"); + + AssertThat(std::filesystem::exists(path_prefix + ".levels"), Is().True()); + std::filesystem::remove(path_prefix + ".levels"); + }); + + it("cannot sort a persisted non-empty file", [&tmp_path]() { + const std::string path_prefix = tmp_path + "sort-prefix.adiar"; + + // Clean up after prior tests + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + { // Construct a persisted non-empty levelized file by hand + levelized_file lf; + levelized_file_writer lfw(lf); + + lfw.push<0>(-1); + lfw.push<0>(8); + lfw.push<1>(4); + lfw.push<0>(3); + lfw.push<1>(2); + lfw.push(level_info{ 2, 1 }); + lfw.push(level_info{ 1, 1 }); + + lfw.detach(); + + lf.make_persistent(path_prefix); + } + + { // Try to sort it + levelized_file lf(path_prefix); + AssertThrows(runtime_error, lf.sort>(0)); + AssertThrows(runtime_error, lf.sort>(1)); + } + + { // Check content is not sorted + levelized_file lf(path_prefix); + + levelized_file_stream lfs(lf); + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(-1)); + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(8)); + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(3)); + AssertThat(lfs.can_pull<0>(), Is().False()); + + AssertThat(lfs.can_pull<1>(), Is().True()); + AssertThat(lfs.pull<1>(), Is().EqualTo(4)); + AssertThat(lfs.can_pull<1>(), Is().True()); + AssertThat(lfs.pull<1>(), Is().EqualTo(2)); + AssertThat(lfs.can_pull<1>(), Is().False()); + + level_info_stream fs_lvls(lf); + AssertThat(fs_lvls.can_pull(), Is().True()); + AssertThat(fs_lvls.pull(), Is().EqualTo(level_info{ 2, 1 })); + AssertThat(fs_lvls.can_pull(), Is().True()); + AssertThat(fs_lvls.pull(), Is().EqualTo(level_info{ 1, 1 })); + AssertThat(fs_lvls.can_pull(), Is().False()); + } + + // Clean up for this test + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + }); + }); + + describe("levelized_file::copy(const levelized_file&)", [&tmp_path]() { + it("can copy over non-existing file", []() { + levelized_file lf1; + + // Set stats content + lf1.meta_value = 42; + + const std::array paths1 = lf1.paths(); + + levelized_file lf2 = levelized_file::copy(lf1); + const std::array paths2 = lf2.paths(); + + // Check stats content + AssertThat(lf2.meta_value, Is().EqualTo(42)); + + // Check paths are unique + AssertThat(paths1[0], Is().Not().EqualTo(paths2[0])); + AssertThat(paths1[0], Is().Not().EqualTo(paths2[1])); + AssertThat(paths1[0], Is().Not().EqualTo(paths2[2])); + + AssertThat(paths1[1], Is().Not().EqualTo(paths2[0])); + AssertThat(paths1[1], Is().Not().EqualTo(paths2[1])); + AssertThat(paths1[1], Is().Not().EqualTo(paths2[2])); + + AssertThat(paths1[2], Is().Not().EqualTo(paths2[0])); + AssertThat(paths1[2], Is().Not().EqualTo(paths2[1])); + AssertThat(paths1[2], Is().Not().EqualTo(paths2[2])); + }); + + it("is unaffected by orginal file being 'touched'", []() { + levelized_file lf1; + levelized_file lf2 = levelized_file::copy(lf1); + + lf1.touch(); + AssertThat(lf1.exists(), Is().True()); + AssertThat(lf2.exists(), Is().False()); + }); + + it("can copy an existing file [empty]", []() { + levelized_file lf1; + + // Set stats content and state + lf1.meta_value = 7; + lf1.touch(); + + // Check file state + AssertThat(lf1.exists(), Is().True()); + AssertThat(lf1.empty(), Is().True()); + AssertThat(lf1.size(), Is().EqualTo(0u)); + + levelized_file lf2 = levelized_file::copy(lf1); + + // Check stats content + AssertThat(lf2.meta_value, Is().EqualTo(7)); + + // Check file state + AssertThat(lf2.exists(), Is().True()); + AssertThat(lf2.empty(), Is().True()); + AssertThat(lf2.size(), Is().EqualTo(0u)); + + // Check paths are unique + const std::array paths1 = lf1.paths(); + const std::array paths2 = lf2.paths(); + + AssertThat(paths1[0], Is().Not().EqualTo(paths2[0])); + AssertThat(paths1[0], Is().Not().EqualTo(paths2[1])); + AssertThat(paths1[0], Is().Not().EqualTo(paths2[2])); + + AssertThat(paths1[1], Is().Not().EqualTo(paths2[0])); + AssertThat(paths1[1], Is().Not().EqualTo(paths2[1])); + AssertThat(paths1[1], Is().Not().EqualTo(paths2[2])); + + AssertThat(paths1[2], Is().Not().EqualTo(paths2[0])); + AssertThat(paths1[2], Is().Not().EqualTo(paths2[1])); + AssertThat(paths1[2], Is().Not().EqualTo(paths2[2])); + }); + + it("can copy an existing file [non-empty]", []() { + levelized_file lf1; + // Set file and stats content + { + levelized_file_writer lfw(lf1); + + lfw.push<0>(21); + lfw.push<1>(42); + lfw.push<0>(21); + lfw.push(level_info{ 0, 1 }); + lfw.push(level_info{ 1, 2 }); + } + + lf1.meta_value = 4; // <- very random number + + // Check state + AssertThat(lf1.exists(), Is().True()); + AssertThat(lf1.empty(), Is().False()); + AssertThat(lf1.size(), Is().EqualTo(3u)); + AssertThat(lf1.size(0), Is().EqualTo(2u)); + AssertThat(lf1.size(1), Is().EqualTo(1u)); + AssertThat(lf1.levels(), Is().EqualTo(2u)); + + levelized_file lf2 = levelized_file::copy(lf1); + + // Check stats content + AssertThat(lf2.meta_value, Is().EqualTo(4)); + + // Check state + AssertThat(lf2.exists(), Is().True()); + AssertThat(lf2.empty(), Is().False()); + AssertThat(lf2.size(), Is().EqualTo(3u)); + AssertThat(lf2.size(0), Is().EqualTo(2u)); + AssertThat(lf2.size(1), Is().EqualTo(1u)); + AssertThat(lf2.levels(), Is().EqualTo(2u)); + + // Check file content + { + levelized_file_stream lfs(lf2); + + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(21)); + AssertThat(lfs.can_pull<0>(), Is().True()); + AssertThat(lfs.pull<0>(), Is().EqualTo(21)); + AssertThat(lfs.can_pull<0>(), Is().False()); + + AssertThat(lfs.can_pull<1>(), Is().True()); + AssertThat(lfs.pull<1>(), Is().EqualTo(42)); + AssertThat(lfs.can_pull<1>(), Is().False()); + + level_info_stream fs_lvls(lf2); + AssertThat(fs_lvls.can_pull(), Is().True()); + AssertThat(fs_lvls.pull(), Is().EqualTo(level_info{ 0, 1 })); + AssertThat(fs_lvls.can_pull(), Is().True()); + AssertThat(fs_lvls.pull(), Is().EqualTo(level_info{ 1, 2 })); + AssertThat(fs_lvls.can_pull(), Is().False()); + } + + // Check paths are unique + const std::array paths1 = lf1.paths(); + const std::array paths2 = lf2.paths(); + + AssertThat(paths1[0], Is().Not().EqualTo(paths2[0])); + AssertThat(paths1[0], Is().Not().EqualTo(paths2[1])); + AssertThat(paths1[0], Is().Not().EqualTo(paths2[2])); + + AssertThat(paths1[1], Is().Not().EqualTo(paths2[0])); + AssertThat(paths1[1], Is().Not().EqualTo(paths2[1])); + AssertThat(paths1[1], Is().Not().EqualTo(paths2[2])); + + AssertThat(paths1[2], Is().Not().EqualTo(paths2[0])); + AssertThat(paths1[2], Is().Not().EqualTo(paths2[1])); + AssertThat(paths1[2], Is().Not().EqualTo(paths2[2])); + }); + + it("can copy an existing persistent file", [&tmp_path]() { + const std::string path_prefix = tmp_path + "sort-prefix.adiar"; + + // Clean up after prior tests + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); + + levelized_file lf1; + + // Set stats content and state + { + levelized_file_writer lfw(lf1); + + lfw.push<0>(21); + lfw.push<1>(42); + lfw.push<1>(21); + lfw.push(level_info{ 0, 1 }); + lfw.push(level_info{ 1, 2 }); + } + lf1.meta_value = 21; + lf1.make_persistent(path_prefix); + + // Check state + AssertThat(lf1.is_persistent(), Is().True()); + AssertThat(lf1.is_temp(), Is().False()); + + AssertThat(lf1.exists(), Is().True()); + AssertThat(lf1.empty(), Is().False()); + + AssertThat(lf1.size(), Is().EqualTo(3u)); + AssertThat(lf1.size(0), Is().EqualTo(1u)); + AssertThat(lf1.size(1), Is().EqualTo(2u)); + AssertThat(lf1.levels(), Is().EqualTo(2u)); + + levelized_file lf2 = levelized_file::copy(lf1); + + // Check stats content + AssertThat(lf2.meta_value, Is().EqualTo(21)); + + // Check state + AssertThat(lf2.is_persistent(), Is().False()); + AssertThat(lf2.is_temp(), Is().True()); + + AssertThat(lf2.exists(), Is().True()); + AssertThat(lf2.empty(), Is().False()); + + AssertThat(lf2.size(), Is().EqualTo(3u)); + AssertThat(lf2.size(0), Is().EqualTo(1u)); + AssertThat(lf2.size(1), Is().EqualTo(2u)); + AssertThat(lf2.levels(), Is().EqualTo(2u)); + + // Check paths are unique + const std::array paths1 = lf1.paths(); + const std::array paths2 = lf2.paths(); + + AssertThat(paths1[0], Is().Not().EqualTo(paths2[0])); + AssertThat(paths1[0], Is().Not().EqualTo(paths2[1])); + AssertThat(paths1[0], Is().Not().EqualTo(paths2[2])); + + AssertThat(paths1[1], Is().Not().EqualTo(paths2[0])); + AssertThat(paths1[1], Is().Not().EqualTo(paths2[1])); + AssertThat(paths1[1], Is().Not().EqualTo(paths2[2])); + + AssertThat(paths1[2], Is().Not().EqualTo(paths2[0])); + AssertThat(paths1[2], Is().Not().EqualTo(paths2[1])); + AssertThat(paths1[2], Is().Not().EqualTo(paths2[2])); + }); }); }); - }); - }); +}); diff --git a/test/adiar/internal/io/test_node_file.cpp b/test/adiar/internal/io/test_node_file.cpp index c0d8e52f5..586f8b019 100644 --- a/test/adiar/internal/io/test_node_file.cpp +++ b/test/adiar/internal/io/test_node_file.cpp @@ -1,9 +1,8 @@ #include "../../../test.h" +#include #include -#include - go_bandit([]() { describe("adiar/internal/io/node_file.h , node_stream.h , node_writer.h", []() { describe("node_writer [ .unsafe_* ] + node_file::stats", []() { @@ -67,7 +66,6 @@ go_bandit([]() { nw << node(42, node::max_id, node::pointer_type(true), node::pointer_type(true)); } - /* 1 ---- x0 / \ @@ -79,7 +77,10 @@ go_bandit([]() { { node_writer nw(nf_0and1); nw << node(1, node::max_id, node::pointer_type(false), node::pointer_type(true)) - << node(0, node::max_id, node::pointer_type(false), node::pointer_type(1, node::pointer_type::max_id)); + << node(0, + node::max_id, + node::pointer_type(false), + node::pointer_type(1, node::pointer_type::max_id)); } /* @@ -95,8 +96,14 @@ go_bandit([]() { { node_writer nw(nf_0and1and2); nw << node(2, node::max_id, node::pointer_type(false), node::pointer_type(true)) - << node(1, node::max_id, node::pointer_type(false), node::pointer_type(2, node::pointer_type::max_id)) - << node(0, node::max_id, node::pointer_type(false), node::pointer_type(1, node::pointer_type::max_id)); + << node(1, + node::max_id, + node::pointer_type(false), + node::pointer_type(2, node::pointer_type::max_id)) + << node(0, + node::max_id, + node::pointer_type(false), + node::pointer_type(1, node::pointer_type::max_id)); } /* @@ -112,8 +119,14 @@ go_bandit([]() { { node_writer nw(nf_0and1_or_2); nw << node(2, node::max_id, node::pointer_type(false), node::pointer_type(true)) - << node(1, node::max_id, node::pointer_type(2, node::pointer_type::max_id), node::pointer_type(true)) - << node(0, node::max_id, node::pointer_type(2, node::pointer_type::max_id), node::pointer_type(1, node::pointer_type::max_id)); + << node(1, + node::max_id, + node::pointer_type(2, node::pointer_type::max_id), + node::pointer_type(true)) + << node(0, + node::max_id, + node::pointer_type(2, node::pointer_type::max_id), + node::pointer_type(1, node::pointer_type::max_id)); } /* @@ -127,8 +140,11 @@ go_bandit([]() { { node_writer nw(nf_21xor42); nw << node(42, node::max_id, node::pointer_type(false), node::pointer_type(true)) - << node(42, node::max_id-1, node::pointer_type(true), node::pointer_type(false)) - << node(21, node::max_id, node::pointer_type(42, node::pointer_type::max_id), node::pointer_type(42, node::pointer_type::max_id-1)); + << node(42, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)) + << node(21, + node::max_id, + node::pointer_type(42, node::pointer_type::max_id), + node::pointer_type(42, node::pointer_type::max_id - 1)); } /* @@ -144,9 +160,18 @@ go_bandit([]() { { node_writer nw(nf_0xnor1_or_2); nw << node(2, node::max_id, node::pointer_type(false), node::pointer_type(true)) - << node(1, node::max_id, node::pointer_type(2, node::pointer_type::max_id), node::pointer_type(true)) - << node(1, node::max_id-1, node::pointer_type(true), node::pointer_type(2, node::pointer_type::max_id)) - << node(0, node::max_id, node::pointer_type(1, node::pointer_type::max_id-1), node::pointer_type(1, node::pointer_type::max_id)); + << node(1, + node::max_id, + node::pointer_type(2, node::pointer_type::max_id), + node::pointer_type(true)) + << node(1, + node::max_id - 1, + node::pointer_type(true), + node::pointer_type(2, node::pointer_type::max_id)) + << node(0, + node::max_id, + node::pointer_type(1, node::pointer_type::max_id - 1), + node::pointer_type(1, node::pointer_type::max_id)); } /* @@ -162,9 +187,18 @@ go_bandit([]() { { node_writer nw(nf_0xor1_or_2); nw << node(2, node::max_id, node::pointer_type(false), node::pointer_type(true)) - << node(1, node::max_id, node::pointer_type(2, node::pointer_type::max_id), node::pointer_type(true)) - << node(1, node::max_id-1, node::pointer_type(true), node::pointer_type(2, node::pointer_type::max_id)) - << node(0, node::max_id, node::pointer_type(1, node::pointer_type::max_id), node::pointer_type(1, node::pointer_type::max_id-1)); + << node(1, + node::max_id, + node::pointer_type(2, node::pointer_type::max_id), + node::pointer_type(true)) + << node(1, + node::max_id - 1, + node::pointer_type(true), + node::pointer_type(2, node::pointer_type::max_id)) + << node(0, + node::max_id, + node::pointer_type(1, node::pointer_type::max_id), + node::pointer_type(1, node::pointer_type::max_id - 1)); } /* @@ -185,15 +219,36 @@ go_bandit([]() { // In comments, we provide the sum (mod 2) before adding the // respective variable. node_writer nw(nf_sum01234_mod2); - nw << node(4, node::max_id, node::pointer_type(false), node::pointer_type(true)) // 0 - << node(4, node::max_id-1, node::pointer_type(true), node::pointer_type(false)) // 1 - << node(3, node::max_id, node::pointer_type(4, node::pointer_type::max_id-1), node::pointer_type(4, node::pointer_type::max_id)) // 1 - << node(3, node::max_id-1, node::pointer_type(4, node::pointer_type::max_id), node::pointer_type(4, node::pointer_type::max_id-1)) // 0 - << node(2, node::max_id, node::pointer_type(3, node::pointer_type::max_id-1), node::pointer_type(3, node::pointer_type::max_id)) // 0 - << node(2, node::max_id-1, node::pointer_type(3, node::pointer_type::max_id), node::pointer_type(3, node::pointer_type::max_id-1)) // 1 - << node(1, node::max_id, node::pointer_type(2, node::pointer_type::max_id-1), node::pointer_type(2, node::pointer_type::max_id)) // 1 - << node(1, node::max_id-1, node::pointer_type(2, node::pointer_type::max_id), node::pointer_type(2, node::pointer_type::max_id-1)) // 0 - << node(0, node::max_id, node::pointer_type(1, node::pointer_type::max_id-1), node::pointer_type(1, node::pointer_type::max_id)); // 0 + nw << node(4, node::max_id, node::pointer_type(false), node::pointer_type(true)) // 0 + << node(4, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)) // 1 + << node(3, + node::max_id, + node::pointer_type(4, node::pointer_type::max_id - 1), + node::pointer_type(4, node::pointer_type::max_id)) // 1 + << node(3, + node::max_id - 1, + node::pointer_type(4, node::pointer_type::max_id), + node::pointer_type(4, node::pointer_type::max_id - 1)) // 0 + << node(2, + node::max_id, + node::pointer_type(3, node::pointer_type::max_id - 1), + node::pointer_type(3, node::pointer_type::max_id)) // 0 + << node(2, + node::max_id - 1, + node::pointer_type(3, node::pointer_type::max_id), + node::pointer_type(3, node::pointer_type::max_id - 1)) // 1 + << node(1, + node::max_id, + node::pointer_type(2, node::pointer_type::max_id - 1), + node::pointer_type(2, node::pointer_type::max_id)) // 1 + << node(1, + node::max_id - 1, + node::pointer_type(2, node::pointer_type::max_id), + node::pointer_type(2, node::pointer_type::max_id - 1)) // 0 + << node(0, + node::max_id, + node::pointer_type(1, node::pointer_type::max_id - 1), + node::pointer_type(1, node::pointer_type::max_id)); // 0 } // ------------------------------------------------------------------- @@ -218,13 +273,28 @@ go_bandit([]() { levelized_file nf_larger_2level_cut_A; { node_writer nw(nf_larger_2level_cut_A); - nw << node(3, node::max_id, node::pointer_type(false), node::pointer_type(true)) - << node(3, node::max_id-1, node::pointer_type(true), node::pointer_type(false)) - << node(2, node::max_id, node::pointer_type(3, node::pointer_type::max_id), node::pointer_type(true)) - << node(2, node::max_id-1, node::pointer_type(3, node::pointer_type::max_id-1), node::pointer_type(3, node::pointer_type::max_id)) - << node(1, node::max_id, node::pointer_type(2, node::pointer_type::max_id-1), node::pointer_type(true)) - << node(1, node::max_id-1, node::pointer_type(2, node::pointer_type::max_id-1), node::pointer_type(2, node::pointer_type::max_id)) - << node(0, node::max_id, node::pointer_type(1, node::pointer_type::max_id-1), node::pointer_type(1, node::pointer_type::max_id)); + nw << node(3, node::max_id, node::pointer_type(false), node::pointer_type(true)) + << node(3, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)) + << node(2, + node::max_id, + node::pointer_type(3, node::pointer_type::max_id), + node::pointer_type(true)) + << node(2, + node::max_id - 1, + node::pointer_type(3, node::pointer_type::max_id - 1), + node::pointer_type(3, node::pointer_type::max_id)) + << node(1, + node::max_id, + node::pointer_type(2, node::pointer_type::max_id - 1), + node::pointer_type(true)) + << node(1, + node::max_id - 1, + node::pointer_type(2, node::pointer_type::max_id - 1), + node::pointer_type(2, node::pointer_type::max_id)) + << node(0, + node::max_id, + node::pointer_type(1, node::pointer_type::max_id - 1), + node::pointer_type(1, node::pointer_type::max_id)); } /* @@ -245,29 +315,30 @@ go_bandit([]() { levelized_file nf_larger_2level_cut_B; { node_writer nw(nf_larger_2level_cut_B); - nw << node(3, node::max_id, node::pointer_type(false), node::pointer_type(true)) - << node(2, node::max_id, node::pointer_type(false), node::pointer_type(true)) - << node(2, node::max_id-1, node::pointer_type(3, node::pointer_type::max_id), node::pointer_type(3, node::pointer_type::max_id)) - << node(1, node::max_id, node::pointer_type(2, node::pointer_type::max_id), node::pointer_type(2, node::pointer_type::max_id-1)) - << node(0, node::max_id, node::pointer_type(1, node::pointer_type::max_id), node::pointer_type(3, node::pointer_type::max_id)); + nw << node(3, node::max_id, node::pointer_type(false), node::pointer_type(true)) + << node(2, node::max_id, node::pointer_type(false), node::pointer_type(true)) + << node(2, + node::max_id - 1, + node::pointer_type(3, node::pointer_type::max_id), + node::pointer_type(3, node::pointer_type::max_id)) + << node(1, + node::max_id, + node::pointer_type(2, node::pointer_type::max_id), + node::pointer_type(2, node::pointer_type::max_id - 1)) + << node(0, + node::max_id, + node::pointer_type(1, node::pointer_type::max_id), + node::pointer_type(3, node::pointer_type::max_id)); } describe("canonicity", [&]() { - it("is true for False terminal", [&]() { - AssertThat(nf_F.canonical, Is().True()); - }); + it("is true for False terminal", [&]() { AssertThat(nf_F.canonical, Is().True()); }); - it("is true for True terminal", [&]() { - AssertThat(nf_T.canonical, Is().True()); - }); + it("is true for True terminal", [&]() { AssertThat(nf_T.canonical, Is().True()); }); - it("is true for single node [1]", [&]() { - AssertThat(nf_42.canonical, Is().True()); - }); + it("is true for single node [1]", [&]() { AssertThat(nf_42.canonical, Is().True()); }); - it("is true for single node [2]", [&]() { - AssertThat(nf_not42.canonical, Is().True()); - }); + it("is true for single node [2]", [&]() { AssertThat(nf_not42.canonical, Is().True()); }); it("is false for single node due to too small Id", [&]() { levelized_file nf; @@ -279,17 +350,18 @@ go_bandit([]() { AssertThat(nf.canonical, Is().False()); }); - it("is true for x21 + x42", [&]() { - AssertThat(nf_21xor42.canonical, Is().True()); - }); + it("is true for x21 + x42", [&]() { AssertThat(nf_21xor42.canonical, Is().True()); }); it("is false if child ordering with terminals are mismatching", [&]() { levelized_file nf; { node_writer nw(nf); nw << node(42, node::max_id, node::pointer_type(true), node::pointer_type(false)) - << node(42, node::max_id-1, node::pointer_type(false), node::pointer_type(true)) - << node(21, node::max_id, node::pointer_type(42, node::pointer_type::max_id), node::pointer_type(42, node::pointer_type::max_id-1)); + << node(42, node::max_id - 1, node::pointer_type(false), node::pointer_type(true)) + << node(21, + node::max_id, + node::pointer_type(42, node::pointer_type::max_id), + node::pointer_type(42, node::pointer_type::max_id - 1)); } AssertThat(nf.canonical, Is().False()); @@ -300,8 +372,11 @@ go_bandit([]() { { node_writer nw(nf); nw << node(42, node::max_id, node::pointer_type(false), node::pointer_type(true)) - << node(42, node::max_id-1, node::pointer_type(true), node::pointer_type(false)) - << node(21, node::max_id-2, node::pointer_type(42, node::pointer_type::max_id), node::pointer_type(42, node::pointer_type::max_id-1)); + << node(42, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)) + << node(21, + node::max_id - 2, + node::pointer_type(42, node::pointer_type::max_id), + node::pointer_type(42, node::pointer_type::max_id - 1)); } AssertThat(nf.canonical, Is().False()); @@ -312,44 +387,67 @@ go_bandit([]() { { node_writer nw(nf); nw << node(42, node::max_id, node::pointer_type(false), node::pointer_type(true)) - << node(42, node::max_id-2, node::pointer_type(true), node::pointer_type(false)) - << node(21, node::max_id, node::pointer_type(42, node::pointer_type::max_id), node::pointer_type(42, node::pointer_type::max_id-2)); + << node(42, node::max_id - 2, node::pointer_type(true), node::pointer_type(false)) + << node(21, + node::max_id, + node::pointer_type(42, node::pointer_type::max_id), + node::pointer_type(42, node::pointer_type::max_id - 2)); } AssertThat(nf.canonical, Is().False()); }); - it("is true for ~(x0 + x1) \\/ x2", [&]() { - AssertThat(nf_0xnor1_or_2.canonical, Is().True()); - }); - - it("is true for (x0 + x1) \\/ x2", [&]() { - AssertThat(nf_0xor1_or_2.canonical, Is().True()); - }); - - it("is false due to internal uid child is out-of-order compared to a terminal child", [&]() { - levelized_file nf; - { - node_writer nw(nf); - nw << node(2, node::max_id, node::pointer_type(false), node::pointer_type(true)) - << node(1, node::max_id, node::pointer_type(true), node::pointer_type(2, node::pointer_type::max_id)) - << node(1, node::max_id-1, node::pointer_type(2, node::pointer_type::max_id), node::pointer_type(false)) - << node(0, node::max_id, node::pointer_type(1, node::pointer_type::max_id), node::pointer_type(1, node::pointer_type::max_id-1)); - } - - AssertThat(nf.canonical, Is().False()); - }); + it("is true for ~(x0 + x1) \\/ x2", + [&]() { AssertThat(nf_0xnor1_or_2.canonical, Is().True()); }); + + it("is true for (x0 + x1) \\/ x2", + [&]() { AssertThat(nf_0xor1_or_2.canonical, Is().True()); }); + + it("is false due to internal uid child is out-of-order compared to a terminal child", + [&]() { + levelized_file nf; + { + node_writer nw(nf); + nw << node(2, node::max_id, node::pointer_type(false), node::pointer_type(true)) + << node(1, + node::max_id, + node::pointer_type(true), + node::pointer_type(2, node::pointer_type::max_id)) + << node(1, + node::max_id - 1, + node::pointer_type(2, node::pointer_type::max_id), + node::pointer_type(false)) + << node(0, + node::max_id, + node::pointer_type(1, node::pointer_type::max_id), + node::pointer_type(1, node::pointer_type::max_id - 1)); + } + + AssertThat(nf.canonical, Is().False()); + }); it("is false due to internal uid low-children are out-of-order", [&]() { levelized_file nf; { node_writer nw(nf); - nw << node(3, node::max_id, node::pointer_type(false), node::pointer_type(true)) - << node(2, node::max_id, node::pointer_type(false), node::pointer_type(true)) - << node(2, node::max_id-1, node::pointer_type(true), node::pointer_type(3, node::pointer_type::max_id)) - << node(1, node::max_id, node::pointer_type(2, node::pointer_type::max_id-1), node::pointer_type(2, node::pointer_type::max_id)) - << node(1, node::max_id-1, node::pointer_type(2, node::pointer_type::max_id), node::pointer_type(2, node::pointer_type::max_id)) - << node(0, node::max_id, node::pointer_type(1, node::pointer_type::max_id), node::pointer_type(1, node::pointer_type::max_id-1)); + nw << node(3, node::max_id, node::pointer_type(false), node::pointer_type(true)) + << node(2, node::max_id, node::pointer_type(false), node::pointer_type(true)) + << node(2, + node::max_id - 1, + node::pointer_type(true), + node::pointer_type(3, node::pointer_type::max_id)) + << node(1, + node::max_id, + node::pointer_type(2, node::pointer_type::max_id - 1), + node::pointer_type(2, node::pointer_type::max_id)) + << node(1, + node::max_id - 1, + node::pointer_type(2, node::pointer_type::max_id), + node::pointer_type(2, node::pointer_type::max_id)) + << node(0, + node::max_id, + node::pointer_type(1, node::pointer_type::max_id), + node::pointer_type(1, node::pointer_type::max_id - 1)); } AssertThat(nf.canonical, Is().False()); @@ -359,12 +457,24 @@ go_bandit([]() { levelized_file nf; { node_writer nw(nf); - nw << node(3, node::max_id, node::pointer_type(false), node::pointer_type(true)) - << node(2, node::max_id, node::pointer_type(false), node::pointer_type(true)) - << node(2, node::max_id-1, node::pointer_type(true), node::pointer_type(3, node::pointer_type::max_id)) - << node(1, node::max_id, node::pointer_type(2, node::pointer_type::max_id-1), node::pointer_type(2, node::pointer_type::max_id-1)) - << node(1, node::max_id-1, node::pointer_type(2, node::pointer_type::max_id-1), node::pointer_type(2, node::pointer_type::max_id)) - << node(0, node::max_id, node::pointer_type(1, node::pointer_type::max_id), node::pointer_type(1, node::pointer_type::max_id-1)); + nw << node(3, node::max_id, node::pointer_type(false), node::pointer_type(true)) + << node(2, node::max_id, node::pointer_type(false), node::pointer_type(true)) + << node(2, + node::max_id - 1, + node::pointer_type(true), + node::pointer_type(3, node::pointer_type::max_id)) + << node(1, + node::max_id, + node::pointer_type(2, node::pointer_type::max_id - 1), + node::pointer_type(2, node::pointer_type::max_id - 1)) + << node(1, + node::max_id - 1, + node::pointer_type(2, node::pointer_type::max_id - 1), + node::pointer_type(2, node::pointer_type::max_id)) + << node(0, + node::max_id, + node::pointer_type(1, node::pointer_type::max_id), + node::pointer_type(1, node::pointer_type::max_id - 1)); } AssertThat(nf.canonical, Is().False()); @@ -372,37 +482,24 @@ go_bandit([]() { }); describe("width", [&]() { - it("is 0 for the False terminal", [&]() { - AssertThat(nf_F.width, Is().EqualTo(0u)); - }); + it("is 0 for the False terminal", [&]() { AssertThat(nf_F.width, Is().EqualTo(0u)); }); - it("is 0 for True terminal", [&]() { - AssertThat(nf_T.width, Is().EqualTo(0u)); - }); + it("is 0 for True terminal", [&]() { AssertThat(nf_T.width, Is().EqualTo(0u)); }); - it("is 1 for single node [1]", [&]() { - AssertThat(nf_42.width, Is().EqualTo(1u)); - }); + it("is 1 for single node [1]", [&]() { AssertThat(nf_42.width, Is().EqualTo(1u)); }); - it("is 1 for single node [2]", [&]() { - AssertThat(nf_not42.width, Is().EqualTo(1u)); - }); + it("is 1 for single node [2]", [&]() { AssertThat(nf_not42.width, Is().EqualTo(1u)); }); - it("is 1 for single node [2]", [&]() { - AssertThat(nf_42andnot42.width, Is().EqualTo(1u)); - }); + it("is 1 for single node [2]", + [&]() { AssertThat(nf_42andnot42.width, Is().EqualTo(1u)); }); - it("is 2 for x21 + x42", [&]() { - AssertThat(nf_21xor42.width, Is().EqualTo(2u)); - }); + it("is 2 for x21 + x42", [&]() { AssertThat(nf_21xor42.width, Is().EqualTo(2u)); }); - it("is 2 for ~(x0 + x1) \\/ x2", [&]() { - AssertThat(nf_0xnor1_or_2.width, Is().EqualTo(2u)); - }); + it("is 2 for ~(x0 + x1) \\/ x2", + [&]() { AssertThat(nf_0xnor1_or_2.width, Is().EqualTo(2u)); }); - it("is 2 for (x0 + x1 + x2 + x3) mod 2", [&]() { - AssertThat(nf_sum01234_mod2.width, Is().EqualTo(2u)); - }); + it("is 2 for (x0 + x1 + x2 + x3) mod 2", + [&]() { AssertThat(nf_sum01234_mod2.width, Is().EqualTo(2u)); }); it("is 3 for (x1 -> !x3) \\/ (x2 /\\ (x1 \\/ x3))", []() { /* @@ -419,53 +516,67 @@ go_bandit([]() { levelized_file nf; { node_writer nw(nf); - nw << node(3, node::max_id, node::pointer_type(false), node::pointer_type(true)) // n6 - << node(2, node::max_id, node::pointer_type(true), node::pointer_type(false)) // n5 (non-canonical) - << node(2, node::max_id-1, node::pointer_type(false), node::pointer_type(true)) // n4 (non-canonical) - << node(2, node::max_id-2, node::pointer_type(false), node::pointer_type(3, node::max_id)) // n3 - << node(1, node::max_id, node::pointer_type(2, node::max_id-2), node::pointer_type(2, node::max_id-1)) // n2 - << node(0, node::max_id, node::pointer_type(1, node::max_id), node::pointer_type(2, node::max_id)); // n1 + nw << node(3, node::max_id, node::pointer_type(false), node::pointer_type(true)) // n6 + << node(2, + node::max_id, + node::pointer_type(true), + node::pointer_type(false)) // n5 (non-canonical) + << node(2, + node::max_id - 1, + node::pointer_type(false), + node::pointer_type(true)) // n4 (non-canonical) + << node(2, + node::max_id - 2, + node::pointer_type(false), + node::pointer_type(3, node::max_id)) // n3 + << node(1, + node::max_id, + node::pointer_type(2, node::max_id - 2), + node::pointer_type(2, node::max_id - 1)) // n2 + << node(0, + node::max_id, + node::pointer_type(1, node::max_id), + node::pointer_type(2, node::max_id)); // n1 } AssertThat(nf.width, Is().EqualTo(3u)); }); - }); describe("number of terminals", [&]() { it("is [1,0] for the False terminal", [&]() { AssertThat(nf_F.number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(nf_F.number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(nf_F.number_of_terminals[true], Is().EqualTo(0u)); }); it("is [0,1] for True terminal", [&]() { AssertThat(nf_T.number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(nf_T.number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(nf_T.number_of_terminals[true], Is().EqualTo(1u)); }); it("is [1,1] for single node [1]", [&]() { AssertThat(nf_42.number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(nf_42.number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(nf_42.number_of_terminals[true], Is().EqualTo(1u)); }); it("is [1,1] for single node [2]", [&]() { AssertThat(nf_not42.number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(nf_not42.number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(nf_not42.number_of_terminals[true], Is().EqualTo(1u)); }); it("is [0,2] for single node [2]", [&]() { AssertThat(nf_42andnot42.number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(nf_42andnot42.number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(nf_42andnot42.number_of_terminals[true], Is().EqualTo(2u)); }); it("is [2,2] for x21 + x42", [&]() { AssertThat(nf_21xor42.number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(nf_21xor42.number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(nf_21xor42.number_of_terminals[true], Is().EqualTo(2u)); }); it("is [1,3] for ~(x0 + x1) \\/ x2", [&]() { AssertThat(nf_0xnor1_or_2.number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(nf_0xnor1_or_2.number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(nf_0xnor1_or_2.number_of_terminals[true], Is().EqualTo(3u)); }); }); @@ -602,11 +713,15 @@ go_bandit([]() { AssertThat(nf_sum01234_mod2.max_2level_cut[cut::Internal], Is().GreaterThanOrEqualTo(4u)); AssertThat(nf_sum01234_mod2.max_2level_cut[cut::Internal], Is().LessThanOrEqualTo(6u)); - AssertThat(nf_sum01234_mod2.max_2level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(4u)); - AssertThat(nf_sum01234_mod2.max_2level_cut[cut::Internal_False], Is().LessThanOrEqualTo(8u)); + AssertThat(nf_sum01234_mod2.max_2level_cut[cut::Internal_False], + Is().GreaterThanOrEqualTo(4u)); + AssertThat(nf_sum01234_mod2.max_2level_cut[cut::Internal_False], + Is().LessThanOrEqualTo(8u)); - AssertThat(nf_sum01234_mod2.max_2level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(4u)); - AssertThat(nf_sum01234_mod2.max_2level_cut[cut::Internal_True], Is().LessThanOrEqualTo(8u)); + AssertThat(nf_sum01234_mod2.max_2level_cut[cut::Internal_True], + Is().GreaterThanOrEqualTo(4u)); + AssertThat(nf_sum01234_mod2.max_2level_cut[cut::Internal_True], + Is().LessThanOrEqualTo(8u)); AssertThat(nf_sum01234_mod2.max_2level_cut[cut::All], Is().GreaterThanOrEqualTo(4u)); AssertThat(nf_sum01234_mod2.max_2level_cut[cut::All], Is().LessThanOrEqualTo(8u)); @@ -614,30 +729,44 @@ go_bandit([]() { // The maximum 2-level cut greater than the maximum 1-level cut. it("is soundly upper bounded when 2-level cut > 1-level cut [A]", [&]() { - AssertThat(nf_larger_2level_cut_A.max_2level_cut[cut::Internal], Is().GreaterThanOrEqualTo(4u)); - AssertThat(nf_larger_2level_cut_A.max_2level_cut[cut::Internal], Is().LessThanOrEqualTo(6u)); - - AssertThat(nf_larger_2level_cut_A.max_2level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(4u)); - AssertThat(nf_larger_2level_cut_A.max_2level_cut[cut::Internal_False], Is().LessThanOrEqualTo(6u)); - - AssertThat(nf_larger_2level_cut_A.max_2level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(5u)); - AssertThat(nf_larger_2level_cut_A.max_2level_cut[cut::Internal_True], Is().LessThanOrEqualTo(8u)); - - AssertThat(nf_larger_2level_cut_A.max_2level_cut[cut::All], Is().GreaterThanOrEqualTo(5u)); + AssertThat(nf_larger_2level_cut_A.max_2level_cut[cut::Internal], + Is().GreaterThanOrEqualTo(4u)); + AssertThat(nf_larger_2level_cut_A.max_2level_cut[cut::Internal], + Is().LessThanOrEqualTo(6u)); + + AssertThat(nf_larger_2level_cut_A.max_2level_cut[cut::Internal_False], + Is().GreaterThanOrEqualTo(4u)); + AssertThat(nf_larger_2level_cut_A.max_2level_cut[cut::Internal_False], + Is().LessThanOrEqualTo(6u)); + + AssertThat(nf_larger_2level_cut_A.max_2level_cut[cut::Internal_True], + Is().GreaterThanOrEqualTo(5u)); + AssertThat(nf_larger_2level_cut_A.max_2level_cut[cut::Internal_True], + Is().LessThanOrEqualTo(8u)); + + AssertThat(nf_larger_2level_cut_A.max_2level_cut[cut::All], + Is().GreaterThanOrEqualTo(5u)); AssertThat(nf_larger_2level_cut_A.max_2level_cut[cut::All], Is().LessThanOrEqualTo(8u)); }); it("is soundly upper bounded when 2-level cut > 1-level cut [B]", [&]() { - AssertThat(nf_larger_2level_cut_B.max_2level_cut[cut::Internal], Is().GreaterThanOrEqualTo(4u)); - AssertThat(nf_larger_2level_cut_B.max_2level_cut[cut::Internal], Is().LessThanOrEqualTo(6u)); - - AssertThat(nf_larger_2level_cut_B.max_2level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(4u)); - AssertThat(nf_larger_2level_cut_B.max_2level_cut[cut::Internal_False], Is().LessThanOrEqualTo(7u)); - - AssertThat(nf_larger_2level_cut_B.max_2level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(4u)); - AssertThat(nf_larger_2level_cut_B.max_2level_cut[cut::Internal_True], Is().LessThanOrEqualTo(7u)); - - AssertThat(nf_larger_2level_cut_B.max_2level_cut[cut::All], Is().GreaterThanOrEqualTo(5u)); + AssertThat(nf_larger_2level_cut_B.max_2level_cut[cut::Internal], + Is().GreaterThanOrEqualTo(4u)); + AssertThat(nf_larger_2level_cut_B.max_2level_cut[cut::Internal], + Is().LessThanOrEqualTo(6u)); + + AssertThat(nf_larger_2level_cut_B.max_2level_cut[cut::Internal_False], + Is().GreaterThanOrEqualTo(4u)); + AssertThat(nf_larger_2level_cut_B.max_2level_cut[cut::Internal_False], + Is().LessThanOrEqualTo(7u)); + + AssertThat(nf_larger_2level_cut_B.max_2level_cut[cut::Internal_True], + Is().GreaterThanOrEqualTo(4u)); + AssertThat(nf_larger_2level_cut_B.max_2level_cut[cut::Internal_True], + Is().LessThanOrEqualTo(7u)); + + AssertThat(nf_larger_2level_cut_B.max_2level_cut[cut::All], + Is().GreaterThanOrEqualTo(5u)); AssertThat(nf_larger_2level_cut_B.max_2level_cut[cut::All], Is().LessThanOrEqualTo(8u)); }); }); @@ -649,8 +778,8 @@ go_bandit([]() { AssertThat(nf.empty(), Is().True()); AssertThat(nf.is_terminal(), Is().False()); - AssertThat(nf.is_false(), Is().False()); - AssertThat(nf.is_true(), Is().False()); + AssertThat(nf.is_false(), Is().False()); + AssertThat(nf.is_true(), Is().False()); }); it("Recognises being the False terminal", [&]() { @@ -661,9 +790,9 @@ go_bandit([]() { } AssertThat(nf.is_terminal(), Is().True()); - AssertThat(nf.value(), Is().False()); - AssertThat(nf.is_false(), Is().True()); - AssertThat(nf.is_true(), Is().False()); + AssertThat(nf.value(), Is().False()); + AssertThat(nf.is_false(), Is().True()); + AssertThat(nf.is_true(), Is().False()); }); it("Recognises being the True terminal", [&]() { @@ -674,34 +803,34 @@ go_bandit([]() { } AssertThat(nf.is_terminal(), Is().True()); - AssertThat(nf.value(), Is().True()); - AssertThat(nf.is_false(), Is().False()); - AssertThat(nf.is_true(), Is().True()); + AssertThat(nf.value(), Is().True()); + AssertThat(nf.is_false(), Is().False()); + AssertThat(nf.is_true(), Is().True()); }); it("Recognises being a non-terminal [x1]", [&]() { levelized_file nf; { node_writer nw(nf); - nw << node(1,0, node::pointer_type(false), node::pointer_type(true)); + nw << node(1, 0, node::pointer_type(false), node::pointer_type(true)); } AssertThat(nf.is_terminal(), Is().False()); - AssertThat(nf.is_false(), Is().False()); - AssertThat(nf.is_true(), Is().False()); + AssertThat(nf.is_false(), Is().False()); + AssertThat(nf.is_true(), Is().False()); }); it("Recognises being a non-terminal [~x0 & x1]", [&]() { levelized_file nf; { node_writer nw(nf); - nw << node(1,0, node::pointer_type(false), node::pointer_type(true)) - << node(0,0, node::pointer_type(1,0), node::pointer_type(false)); + nw << node(1, 0, node::pointer_type(false), node::pointer_type(true)) + << node(0, 0, node::pointer_type(1, 0), node::pointer_type(false)); } AssertThat(nf.is_terminal(), Is().False()); - AssertThat(nf.is_false(), Is().False()); - AssertThat(nf.is_true(), Is().False()); + AssertThat(nf.is_false(), Is().False()); + AssertThat(nf.is_true(), Is().False()); }); }); @@ -719,10 +848,11 @@ go_bandit([]() { node_stream<> ns(nf); - AssertThat(ns.seek(node::uid_type(0,0)), Is().EqualTo(node(false))); - AssertThat(ns.seek(node::uid_type(1,0)), Is().EqualTo(node(false))); - AssertThat(ns.seek(node::uid_type(1,1)), Is().EqualTo(node(false))); - AssertThat(ns.seek(node::uid_type(node::max_label, node::max_id)), Is().EqualTo(node(false))); + AssertThat(ns.seek(node::uid_type(0, 0)), Is().EqualTo(node(false))); + AssertThat(ns.seek(node::uid_type(1, 0)), Is().EqualTo(node(false))); + AssertThat(ns.seek(node::uid_type(1, 1)), Is().EqualTo(node(false))); + AssertThat(ns.seek(node::uid_type(node::max_label, node::max_id)), + Is().EqualTo(node(false))); }); it("can seek in True sink", [&]() { @@ -734,78 +864,85 @@ go_bandit([]() { node_stream<> ns(nf); - AssertThat(ns.seek(node::uid_type(0,0)), Is().EqualTo(node(true))); - AssertThat(ns.seek(node::uid_type(1,0)), Is().EqualTo(node(true))); - AssertThat(ns.seek(node::uid_type(1,1)), Is().EqualTo(node(true))); - AssertThat(ns.seek(node::uid_type(node::max_label, node::max_id)), Is().EqualTo(node(true))); + AssertThat(ns.seek(node::uid_type(0, 0)), Is().EqualTo(node(true))); + AssertThat(ns.seek(node::uid_type(1, 0)), Is().EqualTo(node(true))); + AssertThat(ns.seek(node::uid_type(1, 1)), Is().EqualTo(node(true))); + AssertThat(ns.seek(node::uid_type(node::max_label, node::max_id)), + Is().EqualTo(node(true))); }); it("can seek existing elements", [&]() { levelized_file nf; { node_writer nw(nf); - nw << node(1,1, node::pointer_type(false), node::pointer_type(true)) - << node(1,0, node::pointer_type(true), node::pointer_type(false)) - << node(0,0, node::uid_type(1,0), node::uid_type(1,1)) - ; + nw << node(1, 1, node::pointer_type(false), node::pointer_type(true)) + << node(1, 0, node::pointer_type(true), node::pointer_type(false)) + << node(0, 0, node::uid_type(1, 0), node::uid_type(1, 1)); } node_stream<> ns(nf); - AssertThat(ns.seek(node::uid_type(0,0)), Is().EqualTo(node(0,0, node::uid_type(1,0), node::uid_type(1,1)))); - AssertThat(ns.seek(node::uid_type(1,1)), Is().EqualTo(node(1,1, node::pointer_type(false), node::pointer_type(true)))); + AssertThat(ns.seek(node::uid_type(0, 0)), + Is().EqualTo(node(0, 0, node::uid_type(1, 0), node::uid_type(1, 1)))); + AssertThat(ns.seek(node::uid_type(1, 1)), + Is().EqualTo(node(1, 1, node::pointer_type(false), node::pointer_type(true)))); }); it("can seek non-existing element in the middle ", [&]() { levelized_file nf; { node_writer nw(nf); - nw << node(2,1, node::pointer_type(false), node::pointer_type(true)) - << node(2,0, node::pointer_type(true), node::pointer_type(false)) - << node(0,0, node::pointer_type(1,0), node::pointer_type(1,1)) - ; + nw << node(2, 1, node::pointer_type(false), node::pointer_type(true)) + << node(2, 0, node::pointer_type(true), node::pointer_type(false)) + << node(0, 0, node::pointer_type(1, 0), node::pointer_type(1, 1)); } node_stream<> ns(nf); - AssertThat(ns.seek(node::uid_type(0,0)), Is().EqualTo(node(0,0, node::pointer_type(1,0), node::pointer_type(1,1)))); - AssertThat(ns.seek(node::uid_type(1,1)), Is().EqualTo(node(2,0, node::pointer_type(true), node::pointer_type(false)))); - AssertThat(ns.seek(node::uid_type(1,2)), Is().EqualTo(node(2,0, node::pointer_type(true), node::pointer_type(false)))); - AssertThat(ns.seek(node::uid_type(2,0)), Is().EqualTo(node(2,0, node::pointer_type(true), node::pointer_type(false)))); - AssertThat(ns.seek(node::uid_type(2,1)), Is().EqualTo(node(2,1, node::pointer_type(false), node::pointer_type(true)))); + AssertThat(ns.seek(node::uid_type(0, 0)), + Is().EqualTo(node(0, 0, node::pointer_type(1, 0), node::pointer_type(1, 1)))); + AssertThat(ns.seek(node::uid_type(1, 1)), + Is().EqualTo(node(2, 0, node::pointer_type(true), node::pointer_type(false)))); + AssertThat(ns.seek(node::uid_type(1, 2)), + Is().EqualTo(node(2, 0, node::pointer_type(true), node::pointer_type(false)))); + AssertThat(ns.seek(node::uid_type(2, 0)), + Is().EqualTo(node(2, 0, node::pointer_type(true), node::pointer_type(false)))); + AssertThat(ns.seek(node::uid_type(2, 1)), + Is().EqualTo(node(2, 1, node::pointer_type(false), node::pointer_type(true)))); }); it("can seek past end [1]", [&]() { levelized_file nf; { node_writer nw(nf); - nw << node(1,1, node::pointer_type(false), node::pointer_type(true)) - << node(1,0, node::pointer_type(true), node::pointer_type(false)) - << node(0,0, node::pointer_type(1,0), node::pointer_type(1,1)) - ; + nw << node(1, 1, node::pointer_type(false), node::pointer_type(true)) + << node(1, 0, node::pointer_type(true), node::pointer_type(false)) + << node(0, 0, node::pointer_type(1, 0), node::pointer_type(1, 1)); } node_stream<> ns(nf); AssertThat(ns.seek(node::uid_type(node::max_label, node::max_id)), - Is().EqualTo(node(1,1, node::pointer_type(false), node::pointer_type(true)))); + Is().EqualTo(node(1, 1, node::pointer_type(false), node::pointer_type(true)))); }); it("can seek past end [2]", [&]() { levelized_file nf; { node_writer nw(nf); - nw << node(1,1, node::pointer_type(false), node::pointer_type(true)) - << node(1,0, node::pointer_type(true), node::pointer_type(false)) - << node(0,0, node::pointer_type(1,0), node::pointer_type(1,1)) - ; + nw << node(1, 1, node::pointer_type(false), node::pointer_type(true)) + << node(1, 0, node::pointer_type(true), node::pointer_type(false)) + << node(0, 0, node::pointer_type(1, 0), node::pointer_type(1, 1)); } node_stream<> ns(nf); - AssertThat(ns.seek(node::uid_type(0,0)), Is().EqualTo(node(0,0, node::pointer_type(1,0), node::pointer_type(1,1)))); - AssertThat(ns.seek(node::uid_type(1,1)), Is().EqualTo(node(1,1, node::pointer_type(false), node::pointer_type(true)))); - AssertThat(ns.seek(node::uid_type(2,0)), Is().EqualTo(node(1,1, node::pointer_type(false), node::pointer_type(true)))); + AssertThat(ns.seek(node::uid_type(0, 0)), + Is().EqualTo(node(0, 0, node::pointer_type(1, 0), node::pointer_type(1, 1)))); + AssertThat(ns.seek(node::uid_type(1, 1)), + Is().EqualTo(node(1, 1, node::pointer_type(false), node::pointer_type(true)))); + AssertThat(ns.seek(node::uid_type(2, 0)), + Is().EqualTo(node(1, 1, node::pointer_type(false), node::pointer_type(true)))); }); // TODO: reversed @@ -817,7 +954,8 @@ go_bandit([]() { // / \ // F T */ - const node A_n1 = node(1, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node A_n1 = + node(1, node::max_id, node::pointer_type(false), node::pointer_type(true)); levelized_file nf_A; { @@ -836,13 +974,15 @@ go_bandit([]() { // / \ / \ // T F F T */ - const node B_n7 = node(4, node::max_id, node::pointer_type(false), node::pointer_type(true)); - const node B_n6 = node(4, node::max_id-1, node::pointer_type(true), node::pointer_type(false)); - const node B_n5 = node(2, node::max_id, B_n7.uid(), node::pointer_type(true)); - const node B_n4 = node(2, node::max_id-1, B_n6.uid(), B_n7.uid()); - const node B_n3 = node(2, node::max_id-2, node::pointer_type(false), B_n6.uid()); - const node B_n2 = node(1, node::max_id, B_n3.uid(), B_n4.uid()); - const node B_n1 = node(0, node::max_id, B_n2.uid(), B_n5.uid()); + const node B_n7 = + node(4, node::max_id, node::pointer_type(false), node::pointer_type(true)); + const node B_n6 = + node(4, node::max_id - 1, node::pointer_type(true), node::pointer_type(false)); + const node B_n5 = node(2, node::max_id, B_n7.uid(), node::pointer_type(true)); + const node B_n4 = node(2, node::max_id - 1, B_n6.uid(), B_n7.uid()); + const node B_n3 = node(2, node::max_id - 2, node::pointer_type(false), B_n6.uid()); + const node B_n2 = node(1, node::max_id, B_n3.uid(), B_n4.uid()); + const node B_n1 = node(0, node::max_id, B_n2.uid(), B_n5.uid()); levelized_file nf_B; { @@ -1238,4 +1378,4 @@ go_bandit([]() { }); }); }); - }); +}); diff --git a/test/adiar/internal/io/test_shared_file_ptr.cpp b/test/adiar/internal/io/test_shared_file_ptr.cpp index 1e269f83c..a2a912a11 100644 --- a/test/adiar/internal/io/test_shared_file_ptr.cpp +++ b/test/adiar/internal/io/test_shared_file_ptr.cpp @@ -1,5 +1,4 @@ #include "../../../test.h" - #include #include @@ -14,7 +13,7 @@ go_bandit([]() { // the '/tmp/' folder and also to './'. // // HACK: get the temporary folder itself directly from TPIE. - const std::string tmp_path = tpie::tempname::get_actual_path() + "/"; + const std::string tmp_path = tpie::tempname::get_actual_path() + "/"; const std::string curr_path = "./"; describe("shared_file", [&tmp_path, &curr_path]() { @@ -156,13 +155,13 @@ go_bandit([]() { { file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(1)); + AssertThat(fs.pull(), Is().EqualTo(1)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(2)); + AssertThat(fs.pull(), Is().EqualTo(2)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(3)); + AssertThat(fs.pull(), Is().EqualTo(3)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(4)); + AssertThat(fs.pull(), Is().EqualTo(4)); AssertThat(fs.can_pull(), Is().False()); } }); @@ -176,13 +175,13 @@ go_bandit([]() { { file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(84)); + AssertThat(fs.pull(), Is().EqualTo(84)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(21)); + AssertThat(fs.pull(), Is().EqualTo(21)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(42)); + AssertThat(fs.pull(), Is().EqualTo(42)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(21)); + AssertThat(fs.pull(), Is().EqualTo(21)); AssertThat(fs.can_pull(), Is().False()); } }); @@ -221,15 +220,15 @@ go_bandit([]() { { file_stream fs(f2); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(1)); + AssertThat(fs.pull(), Is().EqualTo(1)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(2)); + AssertThat(fs.pull(), Is().EqualTo(2)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(4)); + AssertThat(fs.pull(), Is().EqualTo(4)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(8)); + AssertThat(fs.pull(), Is().EqualTo(8)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(16)); + AssertThat(fs.pull(), Is().EqualTo(16)); AssertThat(fs.can_pull(), Is().False()); } }); @@ -239,9 +238,7 @@ go_bandit([]() { std::string file_path = tmp_path + "persisted-shared-path.adiar"; // Clean up after prior test run - if (std::filesystem::exists(file_path)) { - std::filesystem::remove(file_path); - } + if (std::filesystem::exists(file_path)) { std::filesystem::remove(file_path); } { // Create a persisted file shared_file f; @@ -261,33 +258,29 @@ go_bandit([]() { file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(0)); + AssertThat(fs.pull(), Is().EqualTo(0)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(2)); + AssertThat(fs.pull(), Is().EqualTo(2)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(4)); + AssertThat(fs.pull(), Is().EqualTo(4)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(6)); + AssertThat(fs.pull(), Is().EqualTo(6)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(8)); + AssertThat(fs.pull(), Is().EqualTo(8)); AssertThat(fs.can_pull(), Is().False()); // TODO: header file content } // Clean up of this test - if (std::filesystem::exists(file_path)) { - std::filesystem::remove(file_path); - } + if (std::filesystem::exists(file_path)) { std::filesystem::remove(file_path); } }); it("can move, persist and reopen file [./]", [&curr_path]() { std::string file_path = curr_path + "persisted-shared-path.adiar"; // Clean up after prior test run - if (std::filesystem::exists(file_path)) { - std::filesystem::remove(file_path); - } + if (std::filesystem::exists(file_path)) { std::filesystem::remove(file_path); } { // Create a persisted file shared_file f; @@ -307,22 +300,20 @@ go_bandit([]() { file_stream fs(f); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(1)); + AssertThat(fs.pull(), Is().EqualTo(1)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(3)); + AssertThat(fs.pull(), Is().EqualTo(3)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(5)); + AssertThat(fs.pull(), Is().EqualTo(5)); AssertThat(fs.can_pull(), Is().True()); - AssertThat(fs.pull(), Is().EqualTo(7)); + AssertThat(fs.pull(), Is().EqualTo(7)); AssertThat(fs.can_pull(), Is().False()); // TODO: header file content } // Clean up of this test - if (std::filesystem::exists(file_path)) { - std::filesystem::remove(file_path); - } + if (std::filesystem::exists(file_path)) { std::filesystem::remove(file_path); } }); }); @@ -548,36 +539,36 @@ go_bandit([]() { lfw.push<0>(21); lfw.push<1>(2); lfw.push<1>(3); - lfw.push(level_info{0,2}); - lfw.push(level_info{1,3}); - lfw.push(level_info{2,1}); + lfw.push(level_info{ 0, 2 }); + lfw.push(level_info{ 1, 3 }); + lfw.push(level_info{ 2, 1 }); } { levelized_file_stream lfs(lf); // <-- default: forwards level_info_stream lis(lf); // <-- default: backwards AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(42)); + AssertThat(lfs.pull<0>(), Is().EqualTo(42)); AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(22)); + AssertThat(lfs.pull<0>(), Is().EqualTo(22)); AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(21)); + AssertThat(lfs.pull<0>(), Is().EqualTo(21)); AssertThat(lfs.can_pull<0>(), Is().False()); AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(1)); + AssertThat(lfs.pull<1>(), Is().EqualTo(1)); AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(2)); + AssertThat(lfs.pull<1>(), Is().EqualTo(2)); AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(3)); + AssertThat(lfs.pull<1>(), Is().EqualTo(3)); AssertThat(lfs.can_pull<1>(), Is().False()); AssertThat(lis.can_pull(), Is().True()); - AssertThat(lis.pull(), Is().EqualTo(level_info{ 2,1 })); + AssertThat(lis.pull(), Is().EqualTo(level_info{ 2, 1 })); AssertThat(lis.can_pull(), Is().True()); - AssertThat(lis.pull(), Is().EqualTo(level_info{ 1,3 })); + AssertThat(lis.pull(), Is().EqualTo(level_info{ 1, 3 })); AssertThat(lis.can_pull(), Is().True()); - AssertThat(lis.pull(), Is().EqualTo(level_info{ 0,2 })); + AssertThat(lis.pull(), Is().EqualTo(level_info{ 0, 2 })); AssertThat(lis.can_pull(), Is().False()); } }); @@ -593,41 +584,41 @@ go_bandit([]() { lfw.push<1>(4); lfw.push<1>(8); lfw.push<0>(1); - lfw.push(level_info{0,2}); - lfw.push(level_info{1,3}); - lfw.push(level_info{2,1}); - lfw.push(level_info{4,1}); + lfw.push(level_info{ 0, 2 }); + lfw.push(level_info{ 1, 3 }); + lfw.push(level_info{ 2, 1 }); + lfw.push(level_info{ 4, 1 }); } { levelized_file_stream lfs(lf); // <-- default: forwards level_info_stream lis(lf); // <-- default: backwards AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(1)); + AssertThat(lfs.pull<0>(), Is().EqualTo(1)); AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(4)); + AssertThat(lfs.pull<0>(), Is().EqualTo(4)); AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(8)); + AssertThat(lfs.pull<0>(), Is().EqualTo(8)); AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(16)); + AssertThat(lfs.pull<0>(), Is().EqualTo(16)); AssertThat(lfs.can_pull<0>(), Is().False()); AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(8)); + AssertThat(lfs.pull<1>(), Is().EqualTo(8)); AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(4)); + AssertThat(lfs.pull<1>(), Is().EqualTo(4)); AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(2)); + AssertThat(lfs.pull<1>(), Is().EqualTo(2)); AssertThat(lfs.can_pull<1>(), Is().False()); AssertThat(lis.can_pull(), Is().True()); - AssertThat(lis.pull(), Is().EqualTo(level_info{ 0,2 })); + AssertThat(lis.pull(), Is().EqualTo(level_info{ 0, 2 })); AssertThat(lis.can_pull(), Is().True()); - AssertThat(lis.pull(), Is().EqualTo(level_info{ 1,3 })); + AssertThat(lis.pull(), Is().EqualTo(level_info{ 1, 3 })); AssertThat(lis.can_pull(), Is().True()); - AssertThat(lis.pull(), Is().EqualTo(level_info{ 2,1 })); + AssertThat(lis.pull(), Is().EqualTo(level_info{ 2, 1 })); AssertThat(lis.can_pull(), Is().True()); - AssertThat(lis.pull(), Is().EqualTo(level_info{ 4,1 })); + AssertThat(lis.pull(), Is().EqualTo(level_info{ 4, 1 })); AssertThat(lis.can_pull(), Is().False()); } }); @@ -672,7 +663,7 @@ go_bandit([]() { lfw.push<0>(2); lfw.push<0>(3); - lfw.push(level_info{ 0,1 }); + lfw.push(level_info{ 0, 1 }); } shared_levelized_file lf2 = shared_levelized_file::copy(lf1); @@ -698,9 +689,9 @@ go_bandit([]() { levelized_file_stream lfs(lf2); AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(2)); + AssertThat(lfs.pull<0>(), Is().EqualTo(2)); AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(3)); + AssertThat(lfs.pull<0>(), Is().EqualTo(3)); AssertThat(lfs.can_pull<0>(), Is().False()); AssertThat(lfs.can_pull<1>(), Is().False()); @@ -708,7 +699,7 @@ go_bandit([]() { level_info_stream<> lis(lf2); AssertThat(lis.can_pull(), Is().True()); - AssertThat(lis.pull(), Is().EqualTo(level_info{ 0,1 })); + AssertThat(lis.pull(), Is().EqualTo(level_info{ 0, 1 })); AssertThat(lis.can_pull(), Is().False()); } }); @@ -718,19 +709,19 @@ go_bandit([]() { std::string path_prefix = tmp_path + "persisted-shared-path-prefix.adiar"; // Clean up after prior test run - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); { // Create a persisted file shared_levelized_file lf; levelized_file_writer lfw(lf); lfw.push<0>(42); - lfw.push(level_info{ 0,1 }); + lfw.push(level_info{ 0, 1 }); // TODO: header file content lfw.detach(); @@ -745,50 +736,49 @@ go_bandit([]() { levelized_file_stream lfs(lf); AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(42)); + AssertThat(lfs.pull<0>(), Is().EqualTo(42)); AssertThat(lfs.can_pull<0>(), Is().False()); AssertThat(lfs.can_pull<1>(), Is().False()); level_info_stream lis(lf); - AssertThat(lis.can_pull(), Is().True()); - AssertThat(lis.pull(), Is().EqualTo(level_info{ 0,1 })); + AssertThat(lis.pull(), Is().EqualTo(level_info{ 0, 1 })); AssertThat(lis.can_pull(), Is().False()); // TODO: header file content } // Clean up of this test - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); }); it("can move, persist and reopen a levelized file [./]", [&curr_path]() { std::string path_prefix = curr_path + "persisted-shared-path-prefix.adiar"; // Clean up after prior test run - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); { // Create a persisted file shared_levelized_file lf; levelized_file_writer lfw(lf); lfw.push<0>(21); - lfw.push(level_info{ 0,1 }); + lfw.push(level_info{ 0, 1 }); lfw.push<1>(7); lfw.push<1>(14); - lfw.push(level_info{ 1,2 }); + lfw.push(level_info{ 1, 2 }); // TODO: header file content lfw.detach(); @@ -803,34 +793,34 @@ go_bandit([]() { levelized_file_stream lfs(lf); AssertThat(lfs.can_pull<0>(), Is().True()); - AssertThat(lfs.pull<0>(), Is().EqualTo(21)); + AssertThat(lfs.pull<0>(), Is().EqualTo(21)); AssertThat(lfs.can_pull<0>(), Is().False()); AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(7)); + AssertThat(lfs.pull<1>(), Is().EqualTo(7)); AssertThat(lfs.can_pull<1>(), Is().True()); - AssertThat(lfs.pull<1>(), Is().EqualTo(14)); + AssertThat(lfs.pull<1>(), Is().EqualTo(14)); AssertThat(lfs.can_pull<1>(), Is().False()); level_info_stream lis(lf); AssertThat(lis.can_pull(), Is().True()); - AssertThat(lis.pull(), Is().EqualTo(level_info{ 1,2 })); + AssertThat(lis.pull(), Is().EqualTo(level_info{ 1, 2 })); AssertThat(lis.can_pull(), Is().True()); - AssertThat(lis.pull(), Is().EqualTo(level_info{ 0,1 })); + AssertThat(lis.pull(), Is().EqualTo(level_info{ 0, 1 })); AssertThat(lis.can_pull(), Is().False()); // TODO: header file content } // Clean up of this test - if (std::filesystem::exists(path_prefix+".file_0")) - std::filesystem::remove(path_prefix+".file_0"); - if (std::filesystem::exists(path_prefix+".file_1")) - std::filesystem::remove(path_prefix+".file_1"); - if (std::filesystem::exists(path_prefix+".levels")) - std::filesystem::remove(path_prefix+".levels"); + if (std::filesystem::exists(path_prefix + ".file_0")) + std::filesystem::remove(path_prefix + ".file_0"); + if (std::filesystem::exists(path_prefix + ".file_1")) + std::filesystem::remove(path_prefix + ".file_1"); + if (std::filesystem::exists(path_prefix + ".levels")) + std::filesystem::remove(path_prefix + ".levels"); }); }); }); - }); +}); diff --git a/test/adiar/internal/test_dd_func.cpp b/test/adiar/internal/test_dd_func.cpp index cf2096c9e..61225c81d 100644 --- a/test/adiar/internal/test_dd_func.cpp +++ b/test/adiar/internal/test_dd_func.cpp @@ -3,7 +3,7 @@ go_bandit([]() { describe("adiar/internal/dd_func.h", []() { const ptr_uint64 false_ptr = ptr_uint64(false); - const ptr_uint64 true_ptr = ptr_uint64(true); + const ptr_uint64 true_ptr = ptr_uint64(true); shared_levelized_file terminal_F; { @@ -41,7 +41,7 @@ go_bandit([]() { shared_levelized_file zdd_file; { node n4 = node(2, node::max_id, true_ptr, true_ptr); - node n3 = node(2, node::max_id-1, false_ptr, true_ptr); + node n3 = node(2, node::max_id - 1, false_ptr, true_ptr); node n2 = node(1, node::max_id, n4.uid(), n4.uid()); node n1 = node(0, node::max_id, n3.uid(), n4.uid()); node_writer writer(zdd_file); @@ -56,8 +56,8 @@ go_bandit([]() { it("does not write anything for BDD false terminal", [&]() { std::vector out(42, -1); - auto it_b = out.begin(); - auto it_e = out.end(); + auto it_b = out.begin(); + auto it_e = out.end(); const auto out_it = bdd_support(terminal_F, it_b, it_e); @@ -68,8 +68,8 @@ go_bandit([]() { it("returns empty file for a ZDD true terminal", [&]() { std::vector out(42, -1); - auto it_b = out.begin(); - auto it_e = out.end(); + auto it_b = out.begin(); + auto it_e = out.end(); const auto out_it = zdd_support(terminal_T, it_b, it_e); @@ -80,12 +80,12 @@ go_bandit([]() { it("returns [0] for a ZDD with one node (label 0)", [&]() { std::vector out(42, -1); - auto it_b = out.begin(); - auto it_e = out.end(); + auto it_b = out.begin(); + auto it_e = out.end(); const auto out_it = zdd_support(x0, it_b, it_e); - AssertThat(out_it, Is().EqualTo(it_b+1)); + AssertThat(out_it, Is().EqualTo(it_b + 1)); AssertThat(*it_b, Is().EqualTo(0)); AssertThat(*out_it, Is().EqualTo(-1)); }); @@ -93,12 +93,12 @@ go_bandit([]() { it("returns [42] for a ZDD with one node (label 42)", [&]() { std::vector out(42, -1); - auto it_b = out.begin(); - auto it_e = out.end(); + auto it_b = out.begin(); + auto it_e = out.end(); const auto out_it = zdd_support(x42, it_b, it_e); - AssertThat(out_it, Is().EqualTo(it_b+1)); + AssertThat(out_it, Is().EqualTo(it_b + 1)); AssertThat(*it_b, Is().EqualTo(42)); AssertThat(*out_it, Is().EqualTo(-1)); }); @@ -106,42 +106,42 @@ go_bandit([]() { it("returns [1,3,4] for a BDD with multiple nodes", [&]() { std::vector out(42, -1); - auto it_b = out.begin(); - auto it_e = out.end(); + auto it_b = out.begin(); + auto it_e = out.end(); const auto out_it = bdd_support(bdd_file, it_b, it_e); - AssertThat(*(it_b+0), Is().EqualTo(1)); - AssertThat(*(it_b+1), Is().EqualTo(3)); - AssertThat(*(it_b+2), Is().EqualTo(4)); + AssertThat(*(it_b + 0), Is().EqualTo(1)); + AssertThat(*(it_b + 1), Is().EqualTo(3)); + AssertThat(*(it_b + 2), Is().EqualTo(4)); - AssertThat(out_it, Is().EqualTo(it_b+3)); + AssertThat(out_it, Is().EqualTo(it_b + 3)); AssertThat(*out_it, Is().EqualTo(-1)); }); it("returns [0,1,2] for a ZDD with multiple nodes", [&]() { std::vector out(42, -1); - auto it_b = out.begin(); - auto it_e = out.end(); + auto it_b = out.begin(); + auto it_e = out.end(); const auto out_it = zdd_support(zdd_file, it_b, it_e); - AssertThat(*(it_b+0), Is().EqualTo(0)); - AssertThat(*(it_b+1), Is().EqualTo(1)); - AssertThat(*(it_b+2), Is().EqualTo(2)); + AssertThat(*(it_b + 0), Is().EqualTo(0)); + AssertThat(*(it_b + 1), Is().EqualTo(1)); + AssertThat(*(it_b + 2), Is().EqualTo(2)); - AssertThat(out_it, Is().EqualTo(it_b+3)); + AssertThat(out_it, Is().EqualTo(it_b + 3)); AssertThat(*out_it, Is().EqualTo(-1)); }); it("throws if range is too small for BDD", [&]() { - std::vector out(1,-1); + std::vector out(1, -1); AssertThrows(out_of_range, bdd_support(bdd_file, out.begin(), out.end())); }); it("throws if range is too small for ZDD", [&]() { - std::vector out(1,-1); + std::vector out(1, -1); AssertThrows(out_of_range, zdd_support(zdd_file, out.begin(), out.end())); }); }); @@ -161,36 +161,32 @@ go_bandit([]() { AssertThat(bdd_isterminal(x0), Is().False()); }); - it("rejects x0 as a ZDD terminal file", [&]() { - AssertThat(zdd_isterminal(x0), Is().False()); - }); + it("rejects x0 as a ZDD terminal file", + [&]() { AssertThat(zdd_isterminal(x0), Is().False()); }); it("rejects larger BDD as being a terminal", [&]() { AssertThat(bdd_isconst(bdd_file), Is().False()); AssertThat(bdd_isterminal(bdd_file), Is().False()); }); - it("rejects larger ZDD as being a terminal", [&]() { - AssertThat(zdd_isterminal(zdd_file), Is().False()); - }); + it("rejects larger ZDD as being a terminal", + [&]() { AssertThat(zdd_isterminal(zdd_file), Is().False()); }); it("accepts a BDD true terminal", [&]() { AssertThat(bdd_isconst(terminal_T), Is().True()); AssertThat(bdd_isterminal(terminal_T), Is().True()); }); - it("accepts a ZDD true terminal", [&]() { - AssertThat(zdd_isterminal(terminal_T), Is().True()); - }); + it("accepts a ZDD true terminal", + [&]() { AssertThat(zdd_isterminal(terminal_T), Is().True()); }); it("accepts a BDD false terminal", [&]() { AssertThat(bdd_isconst(terminal_F), Is().True()); AssertThat(bdd_isterminal(terminal_F), Is().True()); }); - it("accepts a ZDD false terminal", [&]() { - AssertThat(zdd_isterminal(terminal_F), Is().True()); - }); + it("accepts a ZDD false terminal", + [&]() { AssertThat(zdd_isterminal(terminal_F), Is().True()); }); }); describe("dd::value()", [&]() { @@ -198,29 +194,23 @@ go_bandit([]() { }); describe("dd_valueof(...)", [&]() { - it("extracts from a true BDD terminal", [&]() { - AssertThat(dd_valueof(bdd(terminal_T)), Is().True()); - }); + it("extracts from a true BDD terminal", + [&]() { AssertThat(dd_valueof(bdd(terminal_T)), Is().True()); }); - it("extracts from a negation of a true BDD terminal", [&]() { - AssertThat(dd_valueof(~ bdd(terminal_T)), Is().False()); - }); + it("extracts from a negation of a true BDD terminal", + [&]() { AssertThat(dd_valueof(~bdd(terminal_T)), Is().False()); }); - it("extracts from a true ZDD terminal", [&]() { - AssertThat(dd_valueof(zdd(terminal_T)), Is().True()); - }); + it("extracts from a true ZDD terminal", + [&]() { AssertThat(dd_valueof(zdd(terminal_T)), Is().True()); }); - it("extracts from a false BDD terminal", [&]() { - AssertThat(dd_valueof(bdd(terminal_F)), Is().False()); - }); + it("extracts from a false BDD terminal", + [&]() { AssertThat(dd_valueof(bdd(terminal_F)), Is().False()); }); - it("extracts from a negation of a false BDD terminal", [&]() { - AssertThat(dd_valueof(~ bdd(terminal_F)), Is().True()); - }); + it("extracts from a negation of a false BDD terminal", + [&]() { AssertThat(dd_valueof(~bdd(terminal_F)), Is().True()); }); - it("extracts from a false ZDD terminal", [&]() { - AssertThat(dd_valueof(zdd(terminal_F)), Is().False()); - }); + it("extracts from a false ZDD terminal", + [&]() { AssertThat(dd_valueof(zdd(terminal_F)), Is().False()); }); }); describe("dd::is_false()", [&]() { @@ -228,45 +218,38 @@ go_bandit([]() { }); describe("bdd_isfalse / zdd_isfalse / zdd_isempty", [&]() { - it("rejects x0 [BDD]", [&]() { - AssertThat(bdd_isfalse(x0), Is().False()); - }); + it("rejects x0 [BDD]", [&]() { AssertThat(bdd_isfalse(x0), Is().False()); }); it("rejects x0 [ZDD]", [&]() { AssertThat(zdd_isfalse(x0), Is().False()); AssertThat(zdd_isempty(x0), Is().False()); }); - it("rejects x42 [BDD]", [&]() { - AssertThat(bdd_isfalse(x42), Is().False()); - }); + it("rejects x42 [BDD]", [&]() { AssertThat(bdd_isfalse(x42), Is().False()); }); it("rejects x42 [ZDD]", [&]() { AssertThat(zdd_isfalse(x42), Is().False()); AssertThat(zdd_isempty(x42), Is().False()); }); - it("rejects larger decision diagram [BDD]", [&]() { - AssertThat(bdd_isfalse(bdd_file), Is().False()); - }); + it("rejects larger decision diagram [BDD]", + [&]() { AssertThat(bdd_isfalse(bdd_file), Is().False()); }); it("rejects larger decision diagram [ZDD]", [&]() { AssertThat(zdd_isfalse(zdd_file), Is().False()); AssertThat(zdd_isempty(zdd_file), Is().False()); }); - it("rejects true terminal [BDD]", [&]() { - AssertThat(bdd_isfalse(terminal_T), Is().False()); - }); + it("rejects true terminal [BDD]", + [&]() { AssertThat(bdd_isfalse(terminal_T), Is().False()); }); it("rejects true terminal [ZDD]", [&]() { AssertThat(zdd_isfalse(terminal_T), Is().False()); AssertThat(zdd_isempty(terminal_T), Is().False()); }); - it("accepts false terminal [BDD]", [&]() { - AssertThat(bdd_isfalse(terminal_F), Is().True()); - }); + it("accepts false terminal [BDD]", + [&]() { AssertThat(bdd_isfalse(terminal_F), Is().True()); }); it("accepts false terminal [ZDD]", [&]() { AssertThat(zdd_isfalse(terminal_F), Is().True()); @@ -279,45 +262,38 @@ go_bandit([]() { }); describe("bdd_istrue / zdd_istrue / zdd_isnull", [&]() { - it("rejects x0 [BDD]", [&]() { - AssertThat(bdd_istrue(x0), Is().False()); - }); + it("rejects x0 [BDD]", [&]() { AssertThat(bdd_istrue(x0), Is().False()); }); it("rejects x0 [ZDD]", [&]() { AssertThat(zdd_istrue(x0), Is().False()); AssertThat(zdd_isnull(x0), Is().False()); }); - it("rejects x42 [BDD]", [&]() { - AssertThat(bdd_istrue(x42), Is().False()); - }); + it("rejects x42 [BDD]", [&]() { AssertThat(bdd_istrue(x42), Is().False()); }); it("rejects x42 [ZDD]", [&]() { AssertThat(zdd_istrue(x42), Is().False()); AssertThat(zdd_isnull(x42), Is().False()); }); - it("rejects larger decision diagram [BDD]", [&]() { - AssertThat(bdd_istrue(bdd_file), Is().False()); - }); + it("rejects larger decision diagram [BDD]", + [&]() { AssertThat(bdd_istrue(bdd_file), Is().False()); }); it("rejects larger decision diagram [ZDD]", [&]() { AssertThat(zdd_istrue(zdd_file), Is().False()); AssertThat(zdd_isnull(zdd_file), Is().False()); }); - it("rejects false terminal [BDD]", [&]() { - AssertThat(bdd_istrue(terminal_F), Is().False()); - }); + it("rejects false terminal [BDD]", + [&]() { AssertThat(bdd_istrue(terminal_F), Is().False()); }); it("rejects false terminal [ZDD]", [&]() { AssertThat(zdd_istrue(terminal_F), Is().False()); AssertThat(zdd_isnull(terminal_F), Is().False()); }); - it("accepts a true terminal [BDD]", [&]() { - AssertThat(bdd_istrue(terminal_T), Is().True()); - }); + it("accepts a true terminal [BDD]", + [&]() { AssertThat(bdd_istrue(terminal_T), Is().True()); }); it("accepts a true terminal [ZDD]", [&]() { AssertThat(zdd_istrue(terminal_T), Is().True()); @@ -381,45 +357,31 @@ go_bandit([]() { }); describe("bdd_maxvar / zdd_maxvar", [&]() { - it("returns 0 for x0 BDD", [&]() { - AssertThat(bdd_maxvar(x0), Is().EqualTo(0u)); - }); + it("returns 0 for x0 BDD", [&]() { AssertThat(bdd_maxvar(x0), Is().EqualTo(0u)); }); - it("returns 0 for x0 ZDD", [&]() { - AssertThat(zdd_maxvar(x0), Is().EqualTo(0u)); - }); + it("returns 0 for x0 ZDD", [&]() { AssertThat(zdd_maxvar(x0), Is().EqualTo(0u)); }); - it("returns 42 for x42 BDD", [&]() { - AssertThat(bdd_maxvar(x42), Is().EqualTo(42u)); - }); + it("returns 42 for x42 BDD", [&]() { AssertThat(bdd_maxvar(x42), Is().EqualTo(42u)); }); - it("returns 42 for x42 ZDD", [&]() { - AssertThat(zdd_maxvar(x42), Is().EqualTo(42u)); - }); + it("returns 42 for x42 ZDD", [&]() { AssertThat(zdd_maxvar(x42), Is().EqualTo(42u)); }); - it("returns root variable for larger BDD", [&]() { - AssertThat(bdd_maxvar(bdd_file), Is().EqualTo(4u)); - }); + it("returns root variable for larger BDD", + [&]() { AssertThat(bdd_maxvar(bdd_file), Is().EqualTo(4u)); }); - it("returns root variable for larger ZDD", [&]() { - AssertThat(zdd_maxvar(zdd_file), Is().EqualTo(2u)); - }); + it("returns root variable for larger ZDD", + [&]() { AssertThat(zdd_maxvar(zdd_file), Is().EqualTo(2u)); }); - it("throws an exception for F terminal [BDD]", [&]() { - AssertThrows(invalid_argument, bdd_maxvar(terminal_F)); - }); + it("throws an exception for F terminal [BDD]", + [&]() { AssertThrows(invalid_argument, bdd_maxvar(terminal_F)); }); - it("throws an exception for T terminal [BDD]", [&]() { - AssertThrows(invalid_argument, bdd_maxvar(terminal_T)); - }); + it("throws an exception for T terminal [BDD]", + [&]() { AssertThrows(invalid_argument, bdd_maxvar(terminal_T)); }); - it("throws an exception for F terminal [ZDD]", [&]() { - AssertThrows(invalid_argument, zdd_maxvar(terminal_F)); - }); + it("throws an exception for F terminal [ZDD]", + [&]() { AssertThrows(invalid_argument, zdd_maxvar(terminal_F)); }); - it("throws an exception for T terminal [ZDD]", [&]() { - AssertThrows(invalid_argument, zdd_maxvar(terminal_T)); - }); + it("throws an exception for T terminal [ZDD]", + [&]() { AssertThrows(invalid_argument, zdd_maxvar(terminal_T)); }); }); }); }); diff --git a/test/adiar/internal/test_util.cpp b/test/adiar/internal/test_util.cpp index 42eeeac14..8141bbf70 100644 --- a/test/adiar/internal/test_util.cpp +++ b/test/adiar/internal/test_util.cpp @@ -36,41 +36,41 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // n2 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1.uid(), false, n2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1.uid(), false, n2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); // n3 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1.uid(), true, n3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1.uid(), true, n3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2.uid(), true, n3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2.uid(), true, n3.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // n2 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2.uid(), false, true_ptr })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2.uid(), false, true_ptr })); AssertThat(arcs.can_pull_terminal(), Is().True()); // n3 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n3.uid(), false, false_ptr })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n3.uid(), false, false_ptr })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n3.uid(), true, true_ptr })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n3.uid(), true, true_ptr })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out->max_1level_cut, Is().EqualTo(in->max_1level_cut[cut::Internal])); AssertThat(out->number_of_terminals[false], Is().EqualTo(in->number_of_terminals[false])); - AssertThat(out->number_of_terminals[true], Is().EqualTo(in->number_of_terminals[true])); + AssertThat(out->number_of_terminals[true], Is().EqualTo(in->number_of_terminals[true])); }); it("computes the semi-transposition of a BDD [2]", [&]() { @@ -86,11 +86,11 @@ go_bandit([]() { // F T */ - const node n5 = node(3, node::max_id, false_ptr, true_ptr); - const node n4 = node(2, node::max_id, n5.uid(), true_ptr); - const node n3 = node(2, node::max_id-1, false_ptr, n5.uid()); - const node n2 = node(1, node::max_id, n3.uid(), n4.uid()); - const node n1 = node(0, node::max_id, n3.uid(), n2.uid()); + const node n5 = node(3, node::max_id, false_ptr, true_ptr); + const node n4 = node(2, node::max_id, n5.uid(), true_ptr); + const node n3 = node(2, node::max_id - 1, false_ptr, n5.uid()); + const node n2 = node(1, node::max_id, n3.uid(), n4.uid()); + const node n1 = node(0, node::max_id, n3.uid(), n2.uid()); shared_levelized_file in; { @@ -107,55 +107,55 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // n2 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1.uid(), true, n2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1.uid(), true, n2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); // n3 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1.uid(), false, n3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1.uid(), false, n3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2.uid(), false, n3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2.uid(), false, n3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); // n4 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2.uid(), true, n4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2.uid(), true, n4.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); // n5 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n3.uid(), true, n5.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n3.uid(), true, n5.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n4.uid(), false, n5.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n4.uid(), false, n5.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // n3 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n3.uid(), false, false_ptr })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n3.uid(), false, false_ptr })); AssertThat(arcs.can_pull_terminal(), Is().True()); // n4 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n4.uid(), true, true_ptr })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n4.uid(), true, true_ptr })); AssertThat(arcs.can_pull_terminal(), Is().True()); // n5 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5.uid(), false, false_ptr })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5.uid(), false, false_ptr })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5.uid(), true, true_ptr })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5.uid(), true, true_ptr })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out->max_1level_cut, Is().EqualTo(in->max_1level_cut[cut::Internal])); AssertThat(out->number_of_terminals[false], Is().EqualTo(in->number_of_terminals[false])); - AssertThat(out->number_of_terminals[true], Is().EqualTo(in->number_of_terminals[true])); + AssertThat(out->number_of_terminals[true], Is().EqualTo(in->number_of_terminals[true])); }); it("computes the semi-transposition of a ZDD", [&]() { @@ -172,11 +172,11 @@ go_bandit([]() { // F T T T */ - const node n5 = node(2, node::max_id, true_ptr, true_ptr); - const node n4 = node(2, node::max_id-1, false_ptr, true_ptr); - const node n3 = node(1, node::max_id, n4.uid(), n4.uid()); - const node n2 = node(1, node::max_id-1, false_ptr, n5.uid()); - const node n1 = node(0, node::max_id, n2.uid(), n3.uid()); + const node n5 = node(2, node::max_id, true_ptr, true_ptr); + const node n4 = node(2, node::max_id - 1, false_ptr, true_ptr); + const node n3 = node(1, node::max_id, n4.uid(), n4.uid()); + const node n2 = node(1, node::max_id - 1, false_ptr, n5.uid()); + const node n1 = node(0, node::max_id, n2.uid(), n3.uid()); shared_levelized_file in; { @@ -193,52 +193,52 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // n2 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1.uid(), false, n2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1.uid(), false, n2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); // n3 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1.uid(), true, n3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1.uid(), true, n3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); // n4 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n3.uid(), false, n4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n3.uid(), false, n4.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n3.uid(), true, n4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n3.uid(), true, n4.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); // n5 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2.uid(), true, n5.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2.uid(), true, n5.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // n2 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2.uid(), false, false_ptr })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2.uid(), false, false_ptr })); AssertThat(arcs.can_pull_terminal(), Is().True()); // n4 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n4.uid(), false, false_ptr })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n4.uid(), false, false_ptr })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n4.uid(), true, true_ptr })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n4.uid(), true, true_ptr })); AssertThat(arcs.can_pull_terminal(), Is().True()); // n5 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5.uid(), false, true_ptr })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5.uid(), false, true_ptr })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5.uid(), true, true_ptr })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5.uid(), true, true_ptr })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out->max_1level_cut, Is().EqualTo(in->max_1level_cut[cut::Internal])); AssertThat(out->number_of_terminals[false], Is().EqualTo(in->number_of_terminals[false])); - AssertThat(out->number_of_terminals[true], Is().EqualTo(in->number_of_terminals[true])); + AssertThat(out->number_of_terminals[true], Is().EqualTo(in->number_of_terminals[true])); }); }); }); diff --git a/test/adiar/test_bool_op.cpp b/test/adiar/test_bool_op.cpp index d03f74dc3..8093a50f0 100644 --- a/test/adiar/test_bool_op.cpp +++ b/test/adiar/test_bool_op.cpp @@ -196,7 +196,7 @@ go_bandit([]() { describe("flip operator", [&]() { it("resolves commutative operator (and)", [&]() { - const bool_op &flip_and_op = flip(and_op); + const bool_op& flip_and_op = flip(and_op); AssertThat(flip_and_op(terminal_T, terminal_T), Is().EqualTo(terminal_T)); AssertThat(flip_and_op(terminal_T, terminal_F), Is().EqualTo(terminal_F)); @@ -205,7 +205,7 @@ go_bandit([]() { }); it("resolves non-commutative operator (imp)", [&]() { - const bool_op &flip_imp_op = flip(imp_op); + const bool_op& flip_imp_op = flip(imp_op); AssertThat(flip_imp_op(terminal_T, terminal_T), Is().EqualTo(terminal_T)); AssertThat(flip_imp_op(terminal_T, terminal_F), Is().EqualTo(terminal_T)); @@ -214,4 +214,4 @@ go_bandit([]() { }); }); }); - }); +}); diff --git a/test/adiar/test_builder.cpp b/test/adiar/test_builder.cpp index 62f617f64..24341c5f5 100644 --- a/test/adiar/test_builder.cpp +++ b/test/adiar/test_builder.cpp @@ -9,25 +9,23 @@ go_bandit([]() { it("supports copy-construction", [&]() { bdd_builder b; - const bdd_ptr p1 = b.add_node(1,false,true); + const bdd_ptr p1 = b.add_node(1, false, true); const bdd_ptr p2 = p1; - const bdd_ptr p3 = b.add_node(0,p2,true); + const bdd_ptr p3 = b.add_node(0, p2, true); bdd out = b.build(); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(1, ptr_uint64::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); }); @@ -35,22 +33,20 @@ go_bandit([]() { it("supports move-semantics", [&]() { bdd_builder b; - b.add_node(0,b.add_node(1,false,true),true); + b.add_node(0, b.add_node(1, false, true), true); bdd out = b.build(); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(1, ptr_uint64::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); }); @@ -88,7 +84,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(0u)); }); it("can create a true terminal-only BDD", [&]() { @@ -121,7 +117,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("creates the last pushed terminal if no nodes are pushed", [&]() { @@ -158,7 +154,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(0u)); }); it("throws an exception when create is called on an empty file", [&]() { @@ -170,7 +166,7 @@ go_bandit([]() { it("throws an exception when calling create a second time with no new nodes in between", [&]() { bdd_builder b; - b.add_node(0,false,true); + b.add_node(0, false, true); b.build(); AssertThrows(domain_error, b.build()); @@ -185,7 +181,7 @@ go_bandit([]() { bdd_builder b; - b.add_node(0,false,true); + b.add_node(0, false, true); bdd out = b.build(); @@ -194,15 +190,13 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -223,7 +217,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("throws an exception if pointers are used from a different builder [1]", [&]() { @@ -232,80 +226,80 @@ go_bandit([]() { builder_ptr p = b1.add_node(true); - AssertThrows(invalid_argument, b2.add_node(0,false,p)); + AssertThrows(invalid_argument, b2.add_node(0, false, p)); }); it("throws an exception if pointers are used from a different builder [2]", [&]() { bdd_builder b1; bdd_builder b2; - builder_ptr p = b1.add_node(1,true,false); + builder_ptr p = b1.add_node(1, true, false); - AssertThrows(invalid_argument, b2.add_node(0,p,false)); + AssertThrows(invalid_argument, b2.add_node(0, p, false)); }); it("throws an exception if pointers are used after reset", [&]() { bdd_builder b; - builder_ptr p = b.add_node(1,true,false); + builder_ptr p = b.add_node(1, true, false); b.clear(); - AssertThrows(invalid_argument, b.add_node(0,p,false)); + AssertThrows(invalid_argument, b.add_node(0, p, false)); }); it("throws an exception if pointers are used after create", [&]() { bdd_builder b; - builder_ptr p = b.add_node(1,true,false); + builder_ptr p = b.add_node(1, true, false); b.build(); - AssertThrows(invalid_argument, b.add_node(0,p,false)); + AssertThrows(invalid_argument, b.add_node(0, p, false)); }); it("throws an exception when label > max_label", [&]() { bdd_builder b; - AssertThrows(invalid_argument, b.add_node(node::max_label + 1,false,true)); + AssertThrows(invalid_argument, b.add_node(node::max_label + 1, false, true)); }); it("throws an exception when label > last label", [&]() { bdd_builder b; - b.add_node(0,false,true); + b.add_node(0, false, true); - AssertThrows(invalid_argument, b.add_node(1,false,true)); + AssertThrows(invalid_argument, b.add_node(1, false, true)); }); it("throws an exception when low.label() >= label [1]", [&]() { bdd_builder b; - const bdd_ptr p = b.add_node(0,false,true); + const bdd_ptr p = b.add_node(0, false, true); - AssertThrows(invalid_argument, b.add_node(0,p,true)); + AssertThrows(invalid_argument, b.add_node(0, p, true)); }); it("throws an exception when low.label() >= label [2]", [&]() { bdd_builder b; - const bdd_ptr p = b.add_node(3,false,true); + const bdd_ptr p = b.add_node(3, false, true); - AssertThrows(invalid_argument, b.add_node(3,p,true)); + AssertThrows(invalid_argument, b.add_node(3, p, true)); }); it("throws an exception when high.label() >= label [1]", [&]() { bdd_builder b; - const bdd_ptr p = b.add_node(0,false,true); + const bdd_ptr p = b.add_node(0, false, true); - AssertThrows(invalid_argument, b.add_node(0,false,p)); + AssertThrows(invalid_argument, b.add_node(0, false, p)); }); it("throws an exception when high.label() >= label [2]", [&]() { bdd_builder b; - const bdd_ptr p = b.add_node(6,false,true); + const bdd_ptr p = b.add_node(6, false, true); - AssertThrows(invalid_argument, b.add_node(6,false,p)); + AssertThrows(invalid_argument, b.add_node(6, false, p)); }); it("can create nodes on different levels", [&]() { @@ -321,9 +315,9 @@ go_bandit([]() { bdd_builder b; - const bdd_ptr p3 = b.add_node(2,false,true); - const bdd_ptr p2 = b.add_node(1,p3,true); - const bdd_ptr p1 = b.add_node(0,p3,p2); + const bdd_ptr p3 = b.add_node(2, false, true); + const bdd_ptr p2 = b.add_node(1, p3, true); + const bdd_ptr p1 = b.add_node(0, p3, p2); bdd out = b.build(); @@ -333,33 +327,32 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); // n3 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n2 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(1, ptr_uint64::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node( + 0, node::max_id, ptr_uint64(2, ptr_uint64::max_id), ptr_uint64(1, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -380,7 +373,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(5u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("can create several nodes on the same level", [&]() { @@ -396,11 +389,11 @@ go_bandit([]() { bdd_builder b; - const bdd_ptr p5 = b.add_node(2,true,false); - const bdd_ptr p4 = b.add_node(2,false,true); - const bdd_ptr p3 = b.add_node(1,p5,true); - const bdd_ptr p2 = b.add_node(1,p4,p5); - const bdd_ptr p1 = b.add_node(0,p2,p3); + const bdd_ptr p5 = b.add_node(2, true, false); + const bdd_ptr p4 = b.add_node(2, false, true); + const bdd_ptr p3 = b.add_node(1, p5, true); + const bdd_ptr p2 = b.add_node(1, p4, p5); + const bdd_ptr p1 = b.add_node(0, p2, p3); bdd out = b.build(); @@ -414,38 +407,41 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); // n4 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id-1, terminal_F, terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id - 1, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n3 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n2 - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id-1, - ptr_uint64(2, ptr_uint64::max_id-1), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id - 1, + ptr_uint64(2, ptr_uint64::max_id - 1), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(1, ptr_uint64::max_id-1), - ptr_uint64(1, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id - 1), + ptr_uint64(1, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); - level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -466,17 +462,17 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(8u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); it("can reset and create new nodes", [&]() { bdd_builder b; - b.add_node(0,false,true); + b.add_node(0, false, true); b.clear(); - b.add_node(1,true,false); + b.add_node(1, true, false); bdd out = b.build(); @@ -485,15 +481,13 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -514,13 +508,13 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("is empty after reset", [&]() { bdd_builder b; - b.add_node(0,false,true); + b.add_node(0, false, true); b.clear(); @@ -531,7 +525,7 @@ go_bandit([]() { bdd_builder b; { // FIRST - b.add_node(0,false,true); + b.add_node(0, false, true); bdd out = b.build(); // Check it looks all right @@ -539,15 +533,13 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -568,11 +560,11 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); } { // SECOND - b.add_node(1,true,false); + b.add_node(1, true, false); bdd out = b.build(); @@ -581,15 +573,13 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - terminal_T, - terminal_F))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, terminal_T, terminal_F))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -610,15 +600,15 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); } }); it("throws an exception when there is more than one root [1]", [&]() { bdd_builder b; - b.add_node(0,false,true); - b.add_node(0,true,false); + b.add_node(0, false, true); + b.add_node(0, true, false); AssertThrows(domain_error, b.build()); }); @@ -626,8 +616,8 @@ go_bandit([]() { it("throws an exception when there is more than one root [2]", [&]() { bdd_builder b; - b.add_node(4,false,true); - b.add_node(2,true,false); + b.add_node(4, false, true); + b.add_node(2, true, false); AssertThrows(domain_error, b.build()); }); @@ -635,11 +625,11 @@ go_bandit([]() { it("throws an exception when there is more than one root [3]", [&]() { bdd_builder b; - const bdd_ptr p5 = b.add_node(5,true,false); - const bdd_ptr p4 = b.add_node(4,false,true); - const bdd_ptr p3 = b.add_node(4,p5,true); - const bdd_ptr p2 = b.add_node(2,p3,p4); - const bdd_ptr p1 = b.add_node(1,p3,p5); + const bdd_ptr p5 = b.add_node(5, true, false); + const bdd_ptr p4 = b.add_node(4, false, true); + const bdd_ptr p3 = b.add_node(4, p5, true); + const bdd_ptr p2 = b.add_node(2, p3, p4); + const bdd_ptr p1 = b.add_node(1, p3, p5); AssertThrows(domain_error, b.build()); }); @@ -657,11 +647,11 @@ go_bandit([]() { bdd_builder b; - const bdd_ptr p5 = b.add_node(5,true,false); - const bdd_ptr p4 = b.add_node(4,true,false); - const bdd_ptr p3 = b.add_node(4,p5,true); + const bdd_ptr p5 = b.add_node(5, true, false); + const bdd_ptr p4 = b.add_node(4, true, false); + const bdd_ptr p3 = b.add_node(4, p5, true); const bdd_ptr p2 = p3; - const bdd_ptr p1 = b.add_node(2,p2,p4); + const bdd_ptr p1 = b.add_node(2, p2, p4); bdd out = b.build(); @@ -679,15 +669,17 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); // n3 - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id-1, - ptr_uint64(5, ptr_uint64::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(4, node::max_id - 1, ptr_uint64(5, ptr_uint64::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); // n1 - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(4, ptr_uint64::max_id-1), - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id, + ptr_uint64(4, ptr_uint64::max_id - 1), + ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); @@ -695,13 +687,13 @@ go_bandit([]() { AssertThat(out->width, Is().EqualTo(2u)); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(4,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(4, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -720,16 +712,16 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(8u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); describe("bdd_builder", [&]() { it("uses the BDD reduction rule", [&]() { bdd_builder b; - const bdd_ptr p = b.add_node(1,false,true); + const bdd_ptr p = b.add_node(1, false, true); - b.add_node(0,p,p); + b.add_node(0, p, p); bdd out = b.build(); @@ -738,15 +730,13 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -767,14 +757,14 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("can collapse BDD reduction rule to a false terminal", [&]() { bdd_builder b; - const bdd_ptr p2 = b.add_node(2,false,false); - const bdd_ptr p1 = b.add_node(1,false,p2); + const bdd_ptr p2 = b.add_node(2, false, false); + const bdd_ptr p1 = b.add_node(1, false, p2); bdd out = b.build(); @@ -803,14 +793,14 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(0u)); }); it("can collapse BDD reduction rule to a true terminal [1]", [&]() { bdd_builder b; - const bdd_ptr p2 = b.add_node(2,true,true); - const bdd_ptr p1 = b.add_node(1,p2,p2); + const bdd_ptr p2 = b.add_node(2, true, true); + const bdd_ptr p1 = b.add_node(1, p2, p2); bdd out = b.build(); @@ -839,14 +829,14 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("can collapse BDD reduction rule to a true terminal [2]", [&]() { bdd_builder b; - const bdd_ptr p2 = b.add_node(2,true,true); - const bdd_ptr p1 = b.add_node(1,p2,true); + const bdd_ptr p2 = b.add_node(2, true, true); + const bdd_ptr p1 = b.add_node(1, p2, true); bdd out = b.build(); @@ -875,7 +865,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("does not decrement 'id' when applying the BDD reduction rule", [&]() { @@ -902,34 +892,34 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(1, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(1, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -950,16 +940,16 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("uses the BDD reduction rule with copies of nodes", [&]() { bdd_builder b; - const bdd_ptr p1 = b.add_node(1,false,true); + const bdd_ptr p1 = b.add_node(1, false, true); const bdd_ptr p2 = p1; - b.add_node(0,p1,p2); + b.add_node(0, p1, p2); bdd out = b.build(); @@ -968,15 +958,13 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -997,17 +985,17 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("does not allow multiple roots when using BDD reduction rule", [&]() { bdd_builder b; - const bdd_ptr p4 = b.add_node(2,true,false); - const bdd_ptr p3 = b.add_node(2,false,true); - const bdd_ptr p2 = b.add_node(1,p4,true); - const bdd_ptr p1 = b.add_node(1,p3,p4); // root - const bdd_ptr p0 = b.add_node(0,p2,p2); // root + const bdd_ptr p4 = b.add_node(2, true, false); + const bdd_ptr p3 = b.add_node(2, false, true); + const bdd_ptr p2 = b.add_node(1, p4, true); + const bdd_ptr p1 = b.add_node(1, p3, p4); // root + const bdd_ptr p0 = b.add_node(0, p2, p2); // root AssertThrows(domain_error, b.build()); }); @@ -1017,9 +1005,9 @@ go_bandit([]() { it("uses the ZDD reduction rule", [&]() { zdd_builder b; - const zdd_ptr p = b.add_node(1,false,true); + const zdd_ptr p = b.add_node(1, false, true); - b.add_node(0,p,false); + b.add_node(0, p, false); zdd out = b.build(); @@ -1028,15 +1016,13 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1057,14 +1043,14 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("can collapse ZDD reduction rule to a false terminal", [&]() { zdd_builder b; - const zdd_ptr p2 = b.add_node(2,false,false); - const zdd_ptr p1 = b.add_node(1,p2,false); + const zdd_ptr p2 = b.add_node(2, false, false); + const zdd_ptr p1 = b.add_node(1, p2, false); zdd out = b.build(); @@ -1093,14 +1079,14 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(0u)); }); it("can collapse ZDD reduction rule to a true terminal", [&]() { zdd_builder b; - const zdd_ptr p2 = b.add_node(2,true,false); - const zdd_ptr p1 = b.add_node(1,p2,false); + const zdd_ptr p2 = b.add_node(2, true, false); + const zdd_ptr p1 = b.add_node(1, p2, false); zdd out = b.build(); @@ -1129,7 +1115,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("does not decrement 'id' when applying the ZDD reduction rule", [&]() { @@ -1156,34 +1142,36 @@ go_bandit([]() { AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(1, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(1, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1204,17 +1192,17 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().LessThanOrEqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("does not allow multiple roots when using ZDD reduction rule", [&]() { zdd_builder b; - const zdd_ptr p4 = b.add_node(2,true,false); - const zdd_ptr p3 = b.add_node(2,false,true); - const zdd_ptr p2 = b.add_node(1,p4,true); - const zdd_ptr p1 = b.add_node(1,p3,p4); // root - const zdd_ptr p0 = b.add_node(0,p2,false); // root + const zdd_ptr p4 = b.add_node(2, true, false); + const zdd_ptr p3 = b.add_node(2, false, true); + const zdd_ptr p2 = b.add_node(1, p4, true); + const zdd_ptr p1 = b.add_node(1, p3, p4); // root + const zdd_ptr p0 = b.add_node(0, p2, false); // root AssertThrows(domain_error, b.build()); }); diff --git a/test/adiar/test_domain.cpp b/test/adiar/test_domain.cpp index e9c7aff4c..fda243404 100644 --- a/test/adiar/test_domain.cpp +++ b/test/adiar/test_domain.cpp @@ -147,12 +147,10 @@ go_bandit([]() { const auto gen = [&x, &y]() { const domain_var z = x + y; - x = y; - y = z; + x = y; + y = z; - return x > 13 - ? make_optional() - : make_optional(x); + return x > 13 ? make_optional() : make_optional(x); }; domain_set(gen); diff --git a/test/adiar/test_exec_policy.cpp b/test/adiar/test_exec_policy.cpp index ef5634ff0..8e96632eb 100644 --- a/test/adiar/test_exec_policy.cpp +++ b/test/adiar/test_exec_policy.cpp @@ -3,18 +3,16 @@ go_bandit([]() { describe("adiar/exec_policy.h", []() { describe("exec_policy", []() { - it("uses expected number of bytes", []() { - AssertThat(sizeof(exec_policy), Is().EqualTo(12u)); - }); + it("uses expected number of bytes", + []() { AssertThat(sizeof(exec_policy), Is().EqualTo(12u)); }); - const float default__transposition_growth = exec_policy::quantify::transposition_growth(); + const float default__transposition_growth = exec_policy::quantify::transposition_growth(); const unsigned char default__transposition_max = exec_policy::quantify::transposition_max(); const float default__fast_reduce = exec_policy::nested::fast_reduce(); describe("exec_policy::_::number wrapper", [&]() { - it("'quantify::transposition growth' defaults to a non-negative value", [&]() { - AssertThat(default__transposition_growth, Is().GreaterThanOrEqualTo(0.0f)); - }); + it("'quantify::transposition growth' defaults to a non-negative value", + [&]() { AssertThat(default__transposition_growth, Is().GreaterThanOrEqualTo(0.0f)); }); it("'quantify::transposition growth' truncates negative values to '0.0f'", [&]() { const exec_policy::quantify::transposition_growth res(-0.5f); @@ -251,9 +249,9 @@ go_bandit([]() { }); /* TODO - it("throws when setting 'quantify::transposition growth epsilon' to a negative value", []() { - exec_policy ep; - AssertThrows(invalid_argument, ep.set(exec_policy::quantify::transposition_growth(-42.0))); + it("throws when setting 'quantify::transposition growth epsilon' to a negative value", []() + { exec_policy ep; AssertThrows(invalid_argument, + ep.set(exec_policy::quantify::transposition_growth(-42.0))); }); */ @@ -314,11 +312,11 @@ go_bandit([]() { AssertThat(ep.template get(), Is().EqualTo(exec_policy::quantify::Singleton)); AssertThat( - static_cast(ep.template get()), - Is().EqualTo(4.2f)); + static_cast(ep.template get()), + Is().EqualTo(4.2f)); AssertThat( - static_cast(ep.template get()), - Is().EqualTo(42)); + static_cast(ep.template get()), + Is().EqualTo(42)); AssertThat(static_cast(ep.template get()), Is().EqualTo(1.0)); @@ -422,19 +420,19 @@ go_bandit([]() { AssertThat(in.template get(), Is().EqualTo(exec_policy::quantify::Nested)); AssertThat( - static_cast(in.template get()), - Is().EqualTo(default__transposition_growth)); + static_cast(in.template get()), + Is().EqualTo(default__transposition_growth)); AssertThat( - static_cast(in.template get()), - Is().EqualTo(default__transposition_max)); + static_cast(in.template get()), + Is().EqualTo(default__transposition_max)); AssertThat(out.template get(), Is().EqualTo(exec_policy::quantify::Singleton)); AssertThat( - static_cast(out.template get()), - Is().EqualTo(4.2f)); - AssertThat( - static_cast(out.template get()), + static_cast(out.template get()), + Is().EqualTo(4.2f)); + AssertThat(static_cast( + out.template get()), Is().EqualTo(42)); }); diff --git a/test/adiar/test_functional.cpp b/test/adiar/test_functional.cpp index c033924ea..be1d03e39 100644 --- a/test/adiar/test_functional.cpp +++ b/test/adiar/test_functional.cpp @@ -53,11 +53,11 @@ go_bandit([]() { AssertThat(begin, Is().EqualTo(xs.begin())); c(0); - AssertThat(begin, Is().EqualTo(xs.begin()+1)); + AssertThat(begin, Is().EqualTo(xs.begin() + 1)); c(0); - AssertThat(begin, Is().EqualTo(xs.begin()+2)); + AssertThat(begin, Is().EqualTo(xs.begin() + 2)); c(0); - AssertThat(begin, Is().EqualTo(xs.begin()+3)); + AssertThat(begin, Is().EqualTo(xs.begin() + 3)); AssertThat(begin, Is().EqualTo(end)); }); @@ -138,7 +138,7 @@ go_bandit([]() { }); it("wraps std::vector = { 0 }", []() { - const std::vector xs = {0}; + const std::vector xs = { 0 }; auto begin = xs.begin(); auto end = xs.end(); @@ -150,7 +150,7 @@ go_bandit([]() { }); it("wraps std::vector = { 0, 1 }", []() { - const std::vector xs = {0,1}; + const std::vector xs = { 0, 1 }; auto begin = xs.begin(); auto end = xs.end(); @@ -163,7 +163,7 @@ go_bandit([]() { }); it("wraps std::vector = { -1, 0, 1 }", []() { - const std::vector xs = {-1, 0, 1}; + const std::vector xs = { -1, 0, 1 }; auto begin = xs.begin(); auto end = xs.end(); @@ -177,7 +177,7 @@ go_bandit([]() { }); it("wraps std::vector = { 4, 2, 0 }", []() { - const std::vector xs = {4,2,0}; + const std::vector xs = { 4, 2, 0 }; auto begin = xs.begin(); auto end = xs.end(); @@ -191,7 +191,7 @@ go_bandit([]() { }); it("wraps std::vector = { 2, 2 }", []() { - const std::vector xs = {2,2}; + const std::vector xs = { 2, 2 }; auto begin = xs.begin(); auto end = xs.end(); @@ -204,7 +204,7 @@ go_bandit([]() { }); it("wraps std::vector = { 2, -1, 0, 2 }", []() { - const std::vector xs = {2,-1,0,2}; + const std::vector xs = { 2, -1, 0, 2 }; auto begin = xs.begin(); auto end = xs.end(); @@ -229,7 +229,7 @@ go_bandit([]() { }); it("wraps std::vector = { 0 }", []() { - const std::vector xs = {0}; + const std::vector xs = { 0 }; generator g = make_generator(xs.begin(), xs.end()); @@ -238,7 +238,7 @@ go_bandit([]() { }); it("wraps std::vector = { 0, 1 }", []() { - const std::vector xs = {0,1}; + const std::vector xs = { 0, 1 }; generator g = make_generator(xs.begin(), xs.end()); @@ -248,7 +248,7 @@ go_bandit([]() { }); it("wraps std::vector = { -1, 0, 1 }", []() { - const std::vector xs = {-1, 0, 1}; + const std::vector xs = { -1, 0, 1 }; generator g = make_generator(xs.begin(), xs.end()); @@ -259,7 +259,7 @@ go_bandit([]() { }); it("wraps std::vector = { 4, 2, 0 }", []() { - const std::vector xs = {4,2,0}; + const std::vector xs = { 4, 2, 0 }; generator g = make_generator(xs.begin(), xs.end()); @@ -270,7 +270,7 @@ go_bandit([]() { }); it("wraps std::vector = { 2, 2 }", []() { - const std::vector xs = {2,2}; + const std::vector xs = { 2, 2 }; generator g = make_generator(xs.begin(), xs.end()); @@ -280,7 +280,7 @@ go_bandit([]() { }); it("wraps std::vector = { 2, -1, 0, 2 }", []() { - const std::vector xs = {2,-1,0,2}; + const std::vector xs = { 2, -1, 0, 2 }; generator g = make_generator(xs.begin(), xs.end()); @@ -322,4 +322,4 @@ go_bandit([]() { }); }); }); - }); +}); diff --git a/test/adiar/zdd/test_binop.cpp b/test/adiar/zdd/test_binop.cpp index 5d06a2755..f4ad6c28d 100644 --- a/test/adiar/zdd/test_binop.cpp +++ b/test/adiar/zdd/test_binop.cpp @@ -80,13 +80,22 @@ go_bandit([]() { level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("computes { Ø } U Ø", [&]() { @@ -101,13 +110,22 @@ go_bandit([]() { level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("should shortcut on irrelevance for { {0} } U Ø", [&]() { @@ -145,13 +163,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("computes { Ø } ∩ Ø", [&]() { @@ -165,13 +192,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("computes (and shortcut) { {0} } ∩ Ø", [&]() { @@ -192,13 +228,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("computes (and shortcut) Ø ∩ { {0} }", [&]() { @@ -213,13 +258,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); }); @@ -235,13 +289,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("should shortcut to Ø on same file for { {x1} }", [&]() { @@ -255,13 +318,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("computes { Ø } \\ Ø", [&]() { @@ -275,13 +347,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("computes Ø \\ { Ø }", [&]() { @@ -295,13 +376,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("should shortcut on irrelevance on { {x0} } \\ Ø", [&]() { @@ -326,13 +416,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); }); }); @@ -354,24 +453,28 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("computes { {0} } U { {1} }", [&]() { @@ -388,35 +491,40 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("computes { {0,1}, {0,3} } U { {0,2}, {2} }", [&]() { @@ -438,13 +546,14 @@ go_bandit([]() { node_writer nw_a(zdd_a); nw_a << node(3, node::max_id, terminal_F, terminal_T) << node(1, node::max_id, ptr_uint64(3, ptr_uint64::max_id), terminal_T) - << node(0, node::max_id, terminal_F, ptr_uint64(1, ptr_uint64::max_id)) - ; + << node(0, node::max_id, terminal_F, ptr_uint64(1, ptr_uint64::max_id)); node_writer nw_b(zdd_b); nw_b << node(2, node::max_id, terminal_F, terminal_T) - << node(0, node::max_id, ptr_uint64(2, ptr_uint64::max_id), ptr_uint64(2, ptr_uint64::max_id)) - ; + << node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)); } __zdd out = zdd_union(ep, zdd_a, zdd_b); @@ -452,59 +561,68 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(4u)); }); it("computes { {0,1}, {1} } U { {0,2}, {2} }", [&]() { @@ -523,13 +641,17 @@ go_bandit([]() { { // Garbage collect writers early node_writer nw_a(zdd_a); nw_a << node(1, node::max_id, terminal_F, terminal_T) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), ptr_uint64(1, ptr_uint64::max_id)) - ; + << node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id), + ptr_uint64(1, ptr_uint64::max_id)); node_writer nw_b(zdd_b); nw_b << node(2, node::max_id, terminal_F, terminal_T) - << node(0, node::max_id, ptr_uint64(2, ptr_uint64::max_id), ptr_uint64(2, ptr_uint64::max_id)) - ; + << node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)); } __zdd out = zdd_union(ep, zdd_a, zdd_b); @@ -537,44 +659,51 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("computes { {0}, {1,3}, {2,3}, {1} } U { {0,3}, {3} }", [&]() { @@ -598,15 +727,22 @@ go_bandit([]() { { // Garbage collect writers early node_writer nw_a(zdd_a); nw_a << node(3, node::max_id, terminal_F, terminal_T) - << node(2, node::max_id, ptr_uint64(3, ptr_uint64::max_id), ptr_uint64(3, ptr_uint64::max_id)) - << node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), ptr_uint64(3, ptr_uint64::max_id)) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T) - ; + << node(2, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(3, ptr_uint64::max_id)) + << node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(3, ptr_uint64::max_id)) + << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T); node_writer nw_b(zdd_b); nw_b << node(3, node::max_id, terminal_F, terminal_T) - << node(0, node::max_id, ptr_uint64(3, ptr_uint64::max_id), ptr_uint64(3, ptr_uint64::max_id)) - ; + << node(0, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(3, ptr_uint64::max_id)); } __zdd out = zdd_union(ep, zdd_a, zdd_b); @@ -614,62 +750,74 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(3,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(3, 2) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 2), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 3u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(4u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(4u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(4u)); }); }); @@ -692,13 +840,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("computes { Ø, {0} } ∩ { Ø }", [&]() { @@ -725,13 +882,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("computes { {0}, {1} } ∩ { Ø }", [&]() { @@ -748,8 +914,7 @@ go_bandit([]() { { // Garbage collect writers early node_writer nw_a(zdd_a); nw_a << node(1, node::max_id, terminal_F, terminal_T) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T) - ; + << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T); } __zdd out = zdd_intsec(ep, zdd_a, zdd_T); @@ -763,13 +928,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("computes (and shortcut) { {0,1}, {1} } ∩ { {0,1} }", [&]() { @@ -787,14 +961,15 @@ go_bandit([]() { { // Garbage collect writers early node_writer nw_a(zdd_a); nw_a << node(1, node::max_id, terminal_F, terminal_T) - << node(1, node::max_id-1, terminal_T, terminal_T) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id-1), ptr_uint64(1, ptr_uint64::max_id)) - ; + << node(1, node::max_id - 1, terminal_T, terminal_T) + << node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id - 1), + ptr_uint64(1, ptr_uint64::max_id)); node_writer nw_b(zdd_b); nw_b << node(1, node::max_id, terminal_F, terminal_T) - << node(0, node::max_id, terminal_F, ptr_uint64(1, ptr_uint64::max_id)) - ; + << node(0, node::max_id, terminal_F, ptr_uint64(1, ptr_uint64::max_id)); } __zdd out = zdd_intsec(ep, zdd_a, zdd_b); @@ -802,34 +977,40 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("computes (and skip to terminal) { {0}, {1}, {0,1} } ∩ { Ø }", [&]() { @@ -844,13 +1025,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("computes (and skip to terminal) { {0,2}, {0}, {2} } \\ { {1}, {2}, Ø }", [&]() { @@ -874,9 +1064,11 @@ go_bandit([]() { { // Garbage collect writers early node_writer nw_a(zdd_a); nw_a << node(2, node::max_id, terminal_T, terminal_T) - << node(2, node::max_id-1, terminal_F, terminal_T) - << node(0, node::max_id, ptr_uint64(2, ptr_uint64::max_id-1), ptr_uint64(2, ptr_uint64::max_id)) - ; + << node(2, node::max_id - 1, terminal_F, terminal_T) + << node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id - 1), + ptr_uint64(2, ptr_uint64::max_id)); } shared_levelized_file zdd_b; @@ -884,9 +1076,11 @@ go_bandit([]() { { // Garbage collect writers early node_writer nw_b(zdd_b); nw_b << node(2, node::max_id, terminal_T, terminal_F) - << node(2, node::max_id-1, terminal_F, terminal_T) - << node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), ptr_uint64(2, ptr_uint64::max_id-1)) - ; + << node(2, node::max_id - 1, terminal_F, terminal_T) + << node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id - 1)); } __zdd out = zdd_intsec(ep, zdd_a, zdd_b); @@ -900,92 +1094,118 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); - it("computes (and skips in) { {0,1,2}, {0,2}, {0}, {2} } } ∩ { {0,2}, {0}, {1}, {2} }", [&]() { - /* - // 1 1 (1,1) ---- x0 - // / \ / \ / \ - // | _2_ 2 \ / \ - // \/ \ / \ | ==> | | - // 3 4 3 T 4 (3,3) (3,4) - // / \ / \ / \ / \ / \ / \ - // T T F T F T T T F T T T - // - // where (3) and (4) are swapped in order on the left one. - // - // (3,3) : ((2,1), (2,0)) , (3,4) : ((2,1), (2,1)) - // - // so (3,3) is forwarded while (3,4) is not and hence (3,3) is output first. - */ - shared_levelized_file zdd_a; - - { // Garbage collect writers early - node_writer nw_a(zdd_a); - nw_a << node(2, node::max_id, terminal_T, terminal_T) - << node(2, node::max_id-1, terminal_F, terminal_T) - << node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), ptr_uint64(2, ptr_uint64::max_id-1)) - << node(0, node::max_id, ptr_uint64(2, ptr_uint64::max_id), ptr_uint64(1, ptr_uint64::max_id)) - ; - } - - shared_levelized_file zdd_b; - - { // Garbage collect writers early - node_writer nw_b(zdd_b); - nw_b << node(2, node::max_id, terminal_T, terminal_T) - << node(2, node::max_id-1, terminal_F, terminal_T) - << node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id-1), terminal_T) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), ptr_uint64(2, ptr_uint64::max_id)) - ; - } - - __zdd out = zdd_intsec(ep, zdd_a, zdd_b); - - arc_test_stream arcs(out); - - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(2,0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(2,1) })); - - - AssertThat(arcs.can_pull_internal(), Is().False()); - - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); - - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); - - AssertThat(arcs.can_pull_terminal(), Is().False()); - - level_info_test_stream levels(out); - - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); - - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); - - AssertThat(levels.can_pull(), Is().False()); - - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); - - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); - }); + it("computes (and skips in) { {0,1,2}, {0,2}, {0}, {2} } } ∩ { {0,2}, {0}, {1}, {2} }", + [&]() { + /* + // 1 1 (1,1) ---- x0 + // / \ / \ / \ + // | _2_ 2 \ / \ + // \/ \ / \ | ==> | | + // 3 4 3 T 4 (3,3) (3,4) + // / \ / \ / \ / \ / \ / \ + // T T F T F T T T F T T T + // + // where (3) and (4) are swapped in order on the left one. + // + // (3,3) : ((2,1), (2,0)) , (3,4) : ((2,1), (2,1)) + // + // so (3,3) is forwarded while (3,4) is not and hence (3,3) is output + first. + */ + shared_levelized_file zdd_a; + + { // Garbage collect writers early + node_writer nw_a(zdd_a); + nw_a << node(2, node::max_id, terminal_T, terminal_T) + << node(2, node::max_id - 1, terminal_F, terminal_T) + << node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id - 1)) + << node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(1, ptr_uint64::max_id)); + } + + shared_levelized_file zdd_b; + + { // Garbage collect writers early + node_writer nw_b(zdd_b); + nw_b << node(2, node::max_id, terminal_T, terminal_T) + << node(2, node::max_id - 1, terminal_F, terminal_T) + << node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id - 1), terminal_T) + << node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)); + } + + __zdd out = zdd_intsec(ep, zdd_a, zdd_b); + + arc_test_stream arcs(out); + + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(2, 0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(2, 1) })); + + AssertThat(arcs.can_pull_internal(), Is().False()); + + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); + + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); + + AssertThat(arcs.can_pull_terminal(), Is().False()); + + level_info_test_stream levels(out); + + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); + + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); + + AssertThat(levels.can_pull(), Is().False()); + + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); + + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); + }); it("computes (and skip) { {0}, {1} } ∩ { {0,1} }", [&]() { /* @@ -1002,13 +1222,11 @@ go_bandit([]() { { // Garbage collect writers early node_writer nw_a(zdd_a); nw_a << node(1, node::max_id, terminal_F, terminal_T) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T) - ; + << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T); node_writer nw_b(zdd_b); nw_b << node(1, node::max_id, terminal_F, terminal_T) - << node(0, node::max_id, terminal_F, ptr_uint64(1, ptr_uint64::max_id)) - ; + << node(0, node::max_id, terminal_F, ptr_uint64(1, ptr_uint64::max_id)); } __zdd out = zdd_intsec(ep, zdd_a, zdd_b); @@ -1018,96 +1236,120 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(0u)); }); - it("computes (and skip) { {0}, {1}, {2}, {1,2}, {0,2} } ∩ { {0}, {2}, {0,2}, {0,1,2} }", [&]() { - /* - // 1 1 (1,1) ---- x0 - // / \ / \ / \ - // 2 | | 2 / \ ---- x1 - // / \| |/ \ ==> | | - // 3 4 3 4 (3,3) (4,3) ---- x2 - // / \/ \ / \/ \ / \ / \ - // F T T F T T F T F T - // - // Notice, how (2,3) and (4,2) was skipped on the low and high of (1,1) - */ - - shared_levelized_file zdd_a; - shared_levelized_file zdd_b; - - { // Garbage collect writers early - node_writer nw_a(zdd_a); - nw_a << node(2, node::max_id, terminal_T, terminal_T) - << node(2, node::max_id-1, terminal_F, terminal_T) - << node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id-1), ptr_uint64(2, ptr_uint64::max_id)) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), ptr_uint64(2, ptr_uint64::max_id)) - ; - - node_writer nw_b(zdd_b); - nw_b << node(2, node::max_id, terminal_T, terminal_T) - << node(2, node::max_id-1, terminal_F, terminal_T) - << node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id-1), ptr_uint64(2, ptr_uint64::max_id)) - << node(0, node::max_id, ptr_uint64(2, ptr_uint64::max_id-1), ptr_uint64(1, ptr_uint64::max_id)) - ; - } - - __zdd out = zdd_intsec(ep, zdd_a, zdd_b); - - arc_test_stream arcs(out); - - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(2,0) })); - - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(2,1) })); - - AssertThat(arcs.can_pull_internal(), Is().False()); - - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); - - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); - - AssertThat(arcs.can_pull_terminal(), Is().False()); - - level_info_test_stream levels(out); - - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); - - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); - - AssertThat(levels.can_pull(), Is().False()); - - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); - - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); - }); + it("computes (and skip) { {0}, {1}, {2}, {1,2}, {0,2} } ∩ { {0}, {2}, {0,2}, {0,1,2} }", + [&]() { + /* + // 1 1 (1,1) ---- x0 + // / \ / \ / \ + // 2 | | 2 / \ ---- x1 + // / \| |/ \ ==> | | + // 3 4 3 4 (3,3) (4,3) ---- x2 + // / \/ \ / \/ \ / \ / \ + // F T T F T T F T F T + // + // Notice, how (2,3) and (4,2) was skipped on the low and high of (1,1) + */ + + shared_levelized_file zdd_a; + shared_levelized_file zdd_b; + + { // Garbage collect writers early + node_writer nw_a(zdd_a); + nw_a << node(2, node::max_id, terminal_T, terminal_T) + << node(2, node::max_id - 1, terminal_F, terminal_T) + << node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id - 1), + ptr_uint64(2, ptr_uint64::max_id)) + << node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)); + + node_writer nw_b(zdd_b); + nw_b << node(2, node::max_id, terminal_T, terminal_T) + << node(2, node::max_id - 1, terminal_F, terminal_T) + << node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id - 1), + ptr_uint64(2, ptr_uint64::max_id)) + << node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id - 1), + ptr_uint64(1, ptr_uint64::max_id)); + } + + __zdd out = zdd_intsec(ep, zdd_a, zdd_b); + + arc_test_stream arcs(out); + + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(2, 0) })); + + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(2, 1) })); + + AssertThat(arcs.can_pull_internal(), Is().False()); + + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); + + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); + + AssertThat(arcs.can_pull_terminal(), Is().False()); + + level_info_test_stream levels(out); + + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); + + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); + + AssertThat(levels.can_pull(), Is().False()); + + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); + + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); + }); it("computes (and skip) { {0}, {1} } ∩ { {1}, {0,2} }", [&]() { /* @@ -1126,14 +1368,15 @@ go_bandit([]() { { // Garbage collect writers early node_writer nw_a(zdd_a); nw_a << node(1, node::max_id, terminal_F, terminal_T) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T) - ; + << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T); node_writer nw_b(zdd_b); nw_b << node(2, node::max_id, terminal_F, terminal_T) << node(1, node::max_id, terminal_F, terminal_T) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), ptr_uint64(2, ptr_uint64::max_id)) - ; + << node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)); } __zdd out = zdd_intsec(ep, zdd_a, zdd_b); @@ -1141,35 +1384,39 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); - + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("computes (and skip) { {0,2}, {1,2}, Ø } ∩ { {0,1}, {0}, {1} }", [&]() { @@ -1192,13 +1439,14 @@ go_bandit([]() { node_writer nw_a(zdd_a); nw_a << node(2, node::max_id, terminal_F, terminal_T) << node(1, node::max_id, terminal_T, ptr_uint64(2, ptr_uint64::max_id)) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), ptr_uint64(2, ptr_uint64::max_id)) - ; + << node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)); node_writer nw_b(zdd_b); nw_b << node(1, node::max_id, terminal_T, terminal_T) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T) - ; + << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T); } __zdd out = zdd_intsec(ep, zdd_a, zdd_b); @@ -1206,35 +1454,39 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); - + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("computes (and shortcut) { {0,2}, {1,2}, Ø } ∩ { {0,2}, {0} }", [&]() { @@ -1257,13 +1509,14 @@ go_bandit([]() { node_writer nw_a(zdd_a); nw_a << node(2, node::max_id, terminal_F, terminal_T) << node(1, node::max_id, terminal_T, ptr_uint64(2, ptr_uint64::max_id)) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), ptr_uint64(2, ptr_uint64::max_id)) - ; + << node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)); node_writer nw_b(zdd_b); nw_b << node(2, node::max_id, terminal_T, terminal_T) - << node(0, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)) - ; + << node(0, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)); } __zdd out = zdd_intsec(ep, zdd_a, zdd_b); @@ -1271,34 +1524,40 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); }); @@ -1315,13 +1574,22 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("computes { {0} } \\ { Ø }", [&]() { @@ -1337,23 +1605,27 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("computes { {0}, Ø } \\ { Ø }", [&]() { @@ -1376,23 +1648,27 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("computes (and skip) { {0,1}, {1} } \\ { {1}, Ø }", [&]() { @@ -1408,9 +1684,11 @@ go_bandit([]() { { // Garbage collect writers early node_writer nw_a(zdd_a); - nw_a << node(1, node::max_id, terminal_F, terminal_T) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), ptr_uint64(1, ptr_uint64::max_id)) - ; + nw_a << node(1, node::max_id, terminal_F, terminal_T) + << node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id), + ptr_uint64(1, ptr_uint64::max_id)); node_writer nw_b(zdd_b); nw_b << node(1, node::max_id, terminal_T, terminal_T); @@ -1421,34 +1699,40 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("computes { {0,1}, {1,2}, {1} } \\ { {1}, Ø }", [&]() { @@ -1466,11 +1750,13 @@ go_bandit([]() { { // Garbage collect writers early node_writer nw_a(zdd_a); - nw_a << node(2, node::max_id, terminal_T, terminal_T) - << node(1, node::max_id, terminal_F, terminal_T) - << node(1, node::max_id-1, terminal_F, ptr_uint64(2, ptr_uint64::max_id)) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id-1), ptr_uint64(1, ptr_uint64::max_id)) - ; + nw_a << node(2, node::max_id, terminal_T, terminal_T) + << node(1, node::max_id, terminal_F, terminal_T) + << node(1, node::max_id - 1, terminal_F, ptr_uint64(2, ptr_uint64::max_id)) + << node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id - 1), + ptr_uint64(1, ptr_uint64::max_id)); node_writer nw_b(zdd_b); nw_b << node(1, node::max_id, terminal_T, terminal_T); @@ -1481,48 +1767,57 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); }); }); @@ -1561,24 +1856,27 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("computes { {0} } U { {1} } (different levels, random access for first level)", [&]() { @@ -1595,35 +1893,40 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("computes { {1} } U { {0} } (different levels, random access for second level)", [&]() { @@ -1640,35 +1943,40 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); shared_levelized_file zdd_thin; @@ -1753,71 +2061,84 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 3u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(6u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(6u)); }); it("should random access on the thinnest ([wide] U [thin])", [&]() { @@ -1826,71 +2147,84 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 3u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(6u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(6u)); }); shared_levelized_file zdd_canon; @@ -1982,89 +2316,106 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,3) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 3) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,2), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,3), true, ptr_uint64(3,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 3), true, ptr_uint64(3, 2) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,3), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 3), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 2), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,4u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 4u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 3u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(9u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(9u)); }); it("should random access on canonical ([non_canon] U [canon])", [&]() { @@ -2073,89 +2424,106 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,3) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 3) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,2), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 2), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,3), true, ptr_uint64(3,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 3), true, ptr_uint64(3, 2) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,3), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 3), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 2), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,4u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 4u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 3u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(9u)); + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(9u)); }); it("computes { {0}, {1,3}, {2,3}, {1} } U { {0,3}, {3} } in different order", [&]() { @@ -2181,15 +2549,22 @@ go_bandit([]() { { // Garbage collect writers early node_writer nw_a(zdd_a); nw_a << node(3, node::max_id, terminal_F, terminal_T) - << node(2, node::max_id, ptr_uint64(3, ptr_uint64::max_id), ptr_uint64(3, ptr_uint64::max_id)) - << node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), ptr_uint64(3, ptr_uint64::max_id)) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T) - ; + << node(2, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(3, ptr_uint64::max_id)) + << node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(3, ptr_uint64::max_id)) + << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T); node_writer nw_b(zdd_b); nw_b << node(3, node::max_id, terminal_F, terminal_T) - << node(0, node::max_id, ptr_uint64(3, ptr_uint64::max_id), ptr_uint64(3, ptr_uint64::max_id)) - ; + << node(0, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(3, ptr_uint64::max_id)); } // zdd_a->width == 1u @@ -2203,62 +2578,74 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(3,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(3, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 2) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 2), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 3u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(4u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(4u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(4u)); }); it("should correctly generate missing nodes (bottom layers)", [&]() { @@ -2322,41 +2709,47 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); }); it("should correctly generate missing nodes (intermediate layers)", [&]() { @@ -2380,294 +2773,311 @@ go_bandit([]() { { // Garbage collect writers early node_writer nw_a(zdd_a); nw_a << na_3 << na_2 << na_1; - } + } - // zdd_a->width == 1u - // zdd_a->canonical == true + // zdd_a->width == 1u + // zdd_a->canonical == true - shared_levelized_file zdd_b; - /* - // { {0}, {1}, {0, 1} } - // - // 1 ---- x0 - // / \ - // 2 3 ---- x1 - // / \ / \ - // F T T - */ + shared_levelized_file zdd_b; + /* + // { {0}, {1}, {0, 1} } + // + // 1 ---- x0 + // / \ + // 2 3 ---- x1 + // / \ / \ + // F T T + */ - node nb_3 = node(1, node::max_id, terminal_T, terminal_T); - node nb_2 = node(1, node::max_id - 1, terminal_F, terminal_T); - node nb_1 = node(0, node::max_id, nb_2, nb_3); + node nb_3 = node(1, node::max_id, terminal_T, terminal_T); + node nb_2 = node(1, node::max_id - 1, terminal_F, terminal_T); + node nb_1 = node(0, node::max_id, nb_2, nb_3); - { // Garbage collect writers early - node_writer nw_b(zdd_b); - nw_b << nb_3 << nb_2 << nb_1; - } + { // Garbage collect writers early + node_writer nw_b(zdd_b); + nw_b << nb_3 << nb_2 << nb_1; + } - // zdd_b->width == 2u - // zdd_b->canonical == true + // zdd_b->width == 2u + // zdd_b->canonical == true - /* - // { {0}, {1}, {0, 3} } U { {0}, {1}, {0, 1} } - // - // (1,1) ---- x0 - // __/ \__ - // / \ - // (2,2) (3,3) ---- x1 - // / \ / \ - // (F,F) (T,T) (3,T) (F,T) ---- x2 - // | | - // (T,T) - */ + /* + // { {0}, {1}, {0, 3} } U { {0}, {1}, {0, 1} } + // + // (1,1) ---- x0 + // __/ \__ + // / \ + // (2,2) (3,3) ---- x1 + // / \ / \ + // (F,F) (T,T) (3,T) (F,T) ---- x2 + // | | + // (T,T) + */ - __zdd out = zdd_union(ep, zdd_a, zdd_b); + __zdd out = zdd_union(ep, zdd_a, zdd_b); - arc_test_stream arcs(out); + arc_test_stream arcs(out); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 0) })); - AssertThat(arcs.can_pull_internal(), Is().False()); + AssertThat(arcs.can_pull_internal(), Is().False()); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().False()); + AssertThat(arcs.can_pull_terminal(), Is().False()); - level_info_test_stream levels(out); + level_info_test_stream levels(out); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); - AssertThat(levels.can_pull(), Is().False()); + AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(4u)); }); }); describe("zdd_intsec", [&]() { it("should shortcircuit intermediate nodes", [&]() { - shared_levelized_file zdd_a; - /* - // { {0, 1}, {0, 2}, {0, 1, 2} } - // - // 1 ---- x0 - // / \ - // F 2 ---- x1 - // / \ - // 3 4 ---- x2 - // / \ / \ - // F T T T - */ - - node na_4 = node(2, node::max_id, terminal_T, terminal_T); - node na_3 = node(2, node::max_id - 1, terminal_F, terminal_T); - node na_2 = node(1, node::max_id, na_3, na_4); - node na_1 = node(0, node::max_id, terminal_F, na_2); - - { // Garbage collect early and free write-lock - node_writer nw_a(zdd_a); - nw_a << na_4 << na_3 << na_2 << na_1; - } - - // zdd_a->canonical == true - // zdd_a->width == 2u - - shared_levelized_file zdd_b; - /* - // { {1, 2}, {0, 1, 2} } - // - // 1 ---- x0 - // || - // 2 ---- x1 - // / \ - // F 3 ---- x2 - // / \ - // F T - */ - - node nb_3 = node(2, node::max_id, terminal_F, terminal_T); - node nb_2 = node(1, node::max_id, terminal_F, nb_3); - node nb_1 = node(0, node::max_id, nb_2, nb_2); - - { // Garbage collect early and free write-lock - node_writer nw_b(zdd_b); - nw_b << nb_3 << nb_2 << nb_1; - } - - // zdd_b->canonical == true - // zdd_b->width == 1u - - /* - // Result of { {0, 1}, {0, 2}, {0, 1, 2} } ∩ { {1, 2}, {0, 1, 2} } - // - // (1,1) ---- x0 - // / \ - // (F,2) (2,2) ---- x1 - // / \ - // (3,F) (4,3) ---- x2 - // / \ - // (T,F) (T,T) - // - // Shorts on (F,2) and (3,F) - */ - - __zdd out = zdd_intsec(ep, zdd_a, zdd_b); - - arc_test_stream arcs(out); - - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); - - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); - - AssertThat(arcs.can_pull_internal(), Is().False()); - - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); - - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); - - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); - - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); - - AssertThat(arcs.can_pull_terminal(), Is().False()); - - level_info_test_stream levels(out); - - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); - - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); - - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); - - AssertThat(levels.can_pull(), Is().False()); - - AssertThat(out.get>()->max_1level_cut, Is().EqualTo(1u)); + shared_levelized_file zdd_a; + /* + // { {0, 1}, {0, 2}, {0, 1, 2} } + // + // 1 ---- x0 + // / \ + // F 2 ---- x1 + // / \ + // 3 4 ---- x2 + // / \ / \ + // F T T T + */ + + node na_4 = node(2, node::max_id, terminal_T, terminal_T); + node na_3 = node(2, node::max_id - 1, terminal_F, terminal_T); + node na_2 = node(1, node::max_id, na_3, na_4); + node na_1 = node(0, node::max_id, terminal_F, na_2); - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + { // Garbage collect early and free write-lock + node_writer nw_a(zdd_a); + nw_a << na_4 << na_3 << na_2 << na_1; + } + + // zdd_a->canonical == true + // zdd_a->width == 2u + + shared_levelized_file zdd_b; + /* + // { {1, 2}, {0, 1, 2} } + // + // 1 ---- x0 + // || + // 2 ---- x1 + // / \ + // F 3 ---- x2 + // / \ + // F T + */ + + node nb_3 = node(2, node::max_id, terminal_F, terminal_T); + node nb_2 = node(1, node::max_id, terminal_F, nb_3); + node nb_1 = node(0, node::max_id, nb_2, nb_2); + + { // Garbage collect early and free write-lock + node_writer nw_b(zdd_b); + nw_b << nb_3 << nb_2 << nb_1; + } + + // zdd_b->canonical == true + // zdd_b->width == 1u + + /* + // Result of { {0, 1}, {0, 2}, {0, 1, 2} } ∩ { {1, 2}, {0, 1, 2} } + // + // (1,1) ---- x0 + // / \ + // (F,2) (2,2) ---- x1 + // / \ + // (3,F) (4,3) ---- x2 + // / \ + // (T,F) (T,T) + // + // Shorts on (F,2) and (3,F) + */ + + __zdd out = zdd_intsec(ep, zdd_a, zdd_b); + + arc_test_stream arcs(out); + + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); + + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); + + AssertThat(arcs.can_pull_internal(), Is().False()); + + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); + + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); + + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); + + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); + + AssertThat(arcs.can_pull_terminal(), Is().False()); + + level_info_test_stream levels(out); + + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); + + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); + + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); + + AssertThat(levels.can_pull(), Is().False()); + + AssertThat(out.get>()->max_1level_cut, Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("should suppress nodes", [&]() { - shared_levelized_file zdd_a; - /* - // { {0}, {1} } - // - // 1 ---- x0 - // / \ - // 2 T ---- x1 - // / \ - // F T - */ - - node na_2 = node(1, node::max_id, terminal_F, terminal_T); - node na_1 = node(0, node::max_id, na_2, terminal_T); - - { // Garbage collect early and free write-lock - node_writer nw_a(zdd_a); - nw_a << na_2 << na_1; - } - - // zdd_a->canonical == true - // zdd_a->width == 1u - - shared_levelized_file zdd_b; - /* - // { Ø, {0} } - // - // 1 ---- x0 - // || - // T - */ - - node nb_1 = node(0, node::max_id, terminal_T, terminal_T); - - { // Garbage collect early and free write-lock - node_writer nw_b(zdd_b); - nw_b << nb_1; - } - - // zdd_b->canonical == true - // zdd_b->width == 1u - - /* - // Result of { {0}, {1} } ∩ { Ø, {0} } - // - // (1,1) ---- x0 - // / \ - // (2,T) (T,T) ---- x1 - // / \ - // (F,T) (F,F) - // - // Suppresses node (2,T), as F ∩ F = F to - // - // (1,1) ---- x0 - // / \ - // (F,T) (T,T) - */ - - __zdd out = zdd_intsec(ep, zdd_a, zdd_b); - - arc_test_stream arcs(out); - - AssertThat(arcs.can_pull_internal(), Is().False()); - - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); - - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); - - AssertThat(arcs.can_pull_terminal(), Is().False()); - - level_info_test_stream levels(out); - - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); - - AssertThat(levels.can_pull(), Is().False()); - - AssertThat(out.get>()->max_1level_cut, Is().EqualTo(0u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + shared_levelized_file zdd_a; + /* + // { {0}, {1} } + // + // 1 ---- x0 + // / \ + // 2 T ---- x1 + // / \ + // F T + */ + + node na_2 = node(1, node::max_id, terminal_F, terminal_T); + node na_1 = node(0, node::max_id, na_2, terminal_T); + + { // Garbage collect early and free write-lock + node_writer nw_a(zdd_a); + nw_a << na_2 << na_1; + } + + // zdd_a->canonical == true + // zdd_a->width == 1u + + shared_levelized_file zdd_b; + /* + // { Ø, {0} } + // + // 1 ---- x0 + // || + // T + */ + + node nb_1 = node(0, node::max_id, terminal_T, terminal_T); + + { // Garbage collect early and free write-lock + node_writer nw_b(zdd_b); + nw_b << nb_1; + } + + // zdd_b->canonical == true + // zdd_b->width == 1u + + /* + // Result of { {0}, {1} } ∩ { Ø, {0} } + // + // (1,1) ---- x0 + // / \ + // (2,T) (T,T) ---- x1 + // / \ + // (F,T) (F,F) + // + // Suppresses node (2,T), as F ∩ F = F to + // + // (1,1) ---- x0 + // / \ + // (F,T) (T,T) + */ + + __zdd out = zdd_intsec(ep, zdd_a, zdd_b); + + arc_test_stream arcs(out); + + AssertThat(arcs.can_pull_internal(), Is().False()); + + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); + + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); + + AssertThat(arcs.can_pull_terminal(), Is().False()); + + level_info_test_stream levels(out); + + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); + + AssertThat(levels.can_pull(), Is().False()); + + AssertThat(out.get>()->max_1level_cut, Is().EqualTo(0u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("computes (and skip to terminal) { {0}, {1}, {0,1} } ∩ { Ø }", [&]() { @@ -2682,112 +3092,124 @@ go_bandit([]() { AssertThat(out.get>()->levels(), Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); }); describe("zdd_diff", [&]() { it("should flip non-commutative operator", [&]() { - // Note, one of the inputs (`zdd_non_ra`) is not indexable (and - // hence not canonical). Hence, random access should be done on the - // other one (`zdd_ra`) by flipping the arguments. Therefore, the - // operator should be flipped too; otherwise the result would not be - // correct. We can see this on the (non-commutative) '-' operator. - - shared_levelized_file zdd_ra; - /* - // { {0}, {1}, {0, 1} } - // - // 1 ---- x0 - // / \ - // 2 3 ---- x1 - // / \ / \ - // F T T T - */ - - { // Garbage collect early and free write-lock - const node n3 = node(1, node::max_id, terminal_T, terminal_T); - const node n2 = node(1, node::max_id - 1, terminal_F, terminal_T); - const node n1 = node(0, node::max_id, n2.uid(), n3.uid()); - - node_writer nw(zdd_ra); - nw << n3 << n2 << n1; - } - - // zdd_a->canonical == false - // zdd_a->width == 2u - - shared_levelized_file zdd_non_ra; - /* - // { Ø, {1}, {0, 1} } - // - // 1 ---- x0 - // / \ - // 2 3 ---- x1 - // / \ / \ - // T T F T - */ - - { // Garbage collect early and free write-lock - const node n3 = node(1, node::max_id, terminal_F, terminal_T); - const node n2 = node(1, node::max_id - 1, terminal_T, terminal_T); - const node n1 = node(0, node::max_id, n2.uid(), n3.uid()); - - node_writer nw(zdd_non_ra); - nw << n3 << n2 << n1; - } - - // zdd_b->canonical == true - // zdd_b->width == 2u - - /* - // { {0}, {1}, {0, 1} } \ { Ø, {1}, {0, 1} } = { Ø, {0} } - // - // (1,1) ---- x0 - // __/ \__ - // / \ - // (2,2) (3,3) ---- x1 - // / \ / \ - // (F,T) (T,T) (T,F) (T,T) - // - // As T \ T = F, then layer x1 is skipped, to the following figure - // - // (1,1) ---- x0 - // / \ - // F T - */ - - __zdd out = zdd_diff(ep, zdd_ra, zdd_non_ra); - - arc_test_stream arcs(out); - - AssertThat(arcs.can_pull_internal(), Is().False()); - - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); - - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); - - AssertThat(arcs.can_pull_terminal(), Is().False()); - - level_info_test_stream levels(out); - - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); - - AssertThat(levels.can_pull(), Is().False()); - - AssertThat(out.get>()->max_1level_cut, Is().EqualTo(0u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + // Note, one of the inputs (`zdd_non_ra`) is not indexable (and + // hence not canonical). Hence, random access should be done on the + // other one (`zdd_ra`) by flipping the arguments. Therefore, the + // operator should be flipped too; otherwise the result would not be + // correct. We can see this on the (non-commutative) '-' operator. + + shared_levelized_file zdd_ra; + /* + // { {0}, {1}, {0, 1} } + // + // 1 ---- x0 + // / \ + // 2 3 ---- x1 + // / \ / \ + // F T T T + */ + + { // Garbage collect early and free write-lock + const node n3 = node(1, node::max_id, terminal_T, terminal_T); + const node n2 = node(1, node::max_id - 1, terminal_F, terminal_T); + const node n1 = node(0, node::max_id, n2.uid(), n3.uid()); + + node_writer nw(zdd_ra); + nw << n3 << n2 << n1; + } + + // zdd_a->canonical == false + // zdd_a->width == 2u + + shared_levelized_file zdd_non_ra; + /* + // { Ø, {1}, {0, 1} } + // + // 1 ---- x0 + // / \ + // 2 3 ---- x1 + // / \ / \ + // T T F T + */ + + { // Garbage collect early and free write-lock + const node n3 = node(1, node::max_id, terminal_F, terminal_T); + const node n2 = node(1, node::max_id - 1, terminal_T, terminal_T); + const node n1 = node(0, node::max_id, n2.uid(), n3.uid()); + + node_writer nw(zdd_non_ra); + nw << n3 << n2 << n1; + } + + // zdd_b->canonical == true + // zdd_b->width == 2u + + /* + // { {0}, {1}, {0, 1} } \ { Ø, {1}, {0, 1} } = { Ø, {0} } + // + // (1,1) ---- x0 + // __/ \__ + // / \ + // (2,2) (3,3) ---- x1 + // / \ / \ + // (F,T) (T,T) (T,F) (T,T) + // + // As T \ T = F, then layer x1 is skipped, to the following figure + // + // (1,1) ---- x0 + // / \ + // F T + */ + + __zdd out = zdd_diff(ep, zdd_ra, zdd_non_ra); + + arc_test_stream arcs(out); + + AssertThat(arcs.can_pull_internal(), Is().False()); + + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); + + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); + + AssertThat(arcs.can_pull_terminal(), Is().False()); + + level_info_test_stream levels(out); + + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); + + AssertThat(levels.can_pull(), Is().False()); + + AssertThat(out.get>()->max_1level_cut, Is().EqualTo(0u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); }); }); diff --git a/test/adiar/zdd/test_build.cpp b/test/adiar/zdd/test_build.cpp index 9dc8554c4..67245eb91 100644 --- a/test/adiar/zdd/test_build.cpp +++ b/test/adiar/zdd/test_build.cpp @@ -32,7 +32,7 @@ go_bandit([]() { AssertThat(res->canonical, Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create { Ø } [zdd_null]", [&]() { @@ -61,7 +61,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create Ø [zdd_terminal]", [&]() { @@ -90,7 +90,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); }); it("can create Ø [zdd_empty]", [&]() { @@ -119,7 +119,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); }); }); @@ -158,7 +158,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); }); it("creates { { 42 } } for i = 42, dom = {42}", [&]() { @@ -169,15 +169,15 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(42, node::max_id, - node::pointer_type(false), - node::pointer_type(true)))); + AssertThat(ns.pull(), + Is().EqualTo( + node(42, node::max_id, node::pointer_type(false), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(42,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(42, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -196,7 +196,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("creates { { 7 } } for i = 7, dom = {7}", [&]() { @@ -207,15 +207,15 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(7, node::max_id, - node::pointer_type(false), - node::pointer_type(true)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(7, node::max_id, node::pointer_type(false), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(7,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(7, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -234,7 +234,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("creates { { 21 }, { 42,21 } } for i = 21, dom = {21,42}", [&]() { @@ -245,24 +245,24 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(42, node::max_id, - node::pointer_type(true), - node::pointer_type(true)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(42, node::max_id, node::pointer_type(true), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(21, node::max_id, - node::pointer_type(false), - node::pointer_type(42, node::max_id)))); - + AssertThat( + ns.pull(), + Is().EqualTo(node( + 21, node::max_id, node::pointer_type(false), node::pointer_type(42, node::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(42,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(42, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(21,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(21, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -280,7 +280,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); }); it("creates { { 42 }, { 42,21 } } for i = 42, dom = {21,42}", [&]() { @@ -291,23 +291,25 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(42, node::max_id, - node::pointer_type(false), - node::pointer_type(true)))); + AssertThat(ns.pull(), + Is().EqualTo( + node(42, node::max_id, node::pointer_type(false), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(21, node::max_id, - node::pointer_type(42, node::max_id), - node::pointer_type(42, node::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(21, + node::max_id, + node::pointer_type(42, node::max_id), + node::pointer_type(42, node::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(42,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(42, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(21,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(21, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -325,60 +327,64 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); - it("creates { { 21 }, { 42,21 }, { 21,10 }, { 42,21,10 } } for i = 21, dom = {10,21,42}", [&]() { - std::vector dom = { 10, 21, 42 }; + it("creates { { 21 }, { 42,21 }, { 21,10 }, { 42,21,10 } } for i = 21, dom = {10,21,42}", + [&]() { + std::vector dom = { 10, 21, 42 }; - zdd res = zdd_ithvar(21, dom.rbegin(), dom.rend()); + zdd res = zdd_ithvar(21, dom.rbegin(), dom.rend()); - node_test_stream ns(res); + node_test_stream ns(res); - AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(42, node::max_id, - node::pointer_type(true), - node::pointer_type(true)))); + AssertThat(ns.can_pull(), Is().True()); + AssertThat(ns.pull(), + Is().EqualTo(node( + 42, node::max_id, node::pointer_type(true), node::pointer_type(true)))); - AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(21, node::max_id, - node::pointer_type(false), - node::pointer_type(42, node::max_id)))); + AssertThat(ns.can_pull(), Is().True()); + AssertThat( + ns.pull(), + Is().EqualTo(node( + 21, node::max_id, node::pointer_type(false), node::pointer_type(42, node::max_id)))); - AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(10, node::max_id, - node::pointer_type(21, node::max_id), - node::pointer_type(21, node::max_id)))); + AssertThat(ns.can_pull(), Is().True()); + AssertThat(ns.pull(), + Is().EqualTo(node(10, + node::max_id, + node::pointer_type(21, node::max_id), + node::pointer_type(21, node::max_id)))); - AssertThat(ns.can_pull(), Is().False()); + AssertThat(ns.can_pull(), Is().False()); - level_info_test_stream ms(res); + level_info_test_stream ms(res); - AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(42,1u))); - AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(21,1u))); - AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(10,1u))); - AssertThat(ms.can_pull(), Is().False()); + AssertThat(ms.can_pull(), Is().True()); + AssertThat(ms.pull(), Is().EqualTo(level_info(42, 1u))); + AssertThat(ms.can_pull(), Is().True()); + AssertThat(ms.pull(), Is().EqualTo(level_info(21, 1u))); + AssertThat(ms.can_pull(), Is().True()); + AssertThat(ms.pull(), Is().EqualTo(level_info(10, 1u))); + AssertThat(ms.can_pull(), Is().False()); - AssertThat(res->width, Is().EqualTo(1u)); + AssertThat(res->width, Is().EqualTo(1u)); - AssertThat(res->max_1level_cut[cut::Internal], Is().EqualTo(2u)); - AssertThat(res->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); - AssertThat(res->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); - AssertThat(res->max_1level_cut[cut::All], Is().EqualTo(3u)); + AssertThat(res->max_1level_cut[cut::Internal], Is().EqualTo(2u)); + AssertThat(res->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); + AssertThat(res->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); + AssertThat(res->max_1level_cut[cut::All], Is().EqualTo(3u)); - AssertThat(res->max_2level_cut[cut::Internal], Is().EqualTo(2u)); - AssertThat(res->max_2level_cut[cut::Internal_False], Is().EqualTo(2u)); - AssertThat(res->max_2level_cut[cut::Internal_True], Is().EqualTo(2u)); - AssertThat(res->max_2level_cut[cut::All], Is().EqualTo(3u)); + AssertThat(res->max_2level_cut[cut::Internal], Is().EqualTo(2u)); + AssertThat(res->max_2level_cut[cut::Internal_False], Is().EqualTo(2u)); + AssertThat(res->max_2level_cut[cut::Internal_True], Is().EqualTo(2u)); + AssertThat(res->max_2level_cut[cut::All], Is().EqualTo(3u)); - AssertThat(zdd_iscanonical(res), Is().True()); + AssertThat(zdd_iscanonical(res), Is().True()); - AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); - }); + AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); + }); it("throws exception when domain is not in descending order", [&]() { std::vector dom = { 3, 2, 1, 0 }; @@ -398,38 +404,42 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, - node::pointer_type(true), - node::pointer_type(true)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(3, node::max_id, node::pointer_type(true), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - node::pointer_type(3, node::max_id), - node::pointer_type(3, node::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(2, + node::max_id, + node::pointer_type(3, node::max_id), + node::pointer_type(3, node::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(false), - node::pointer_type(2, node::max_id)))); - + AssertThat( + ns.pull(), + Is().EqualTo( + node(1, node::max_id, node::pointer_type(false), node::pointer_type(2, node::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(1, node::max_id), - node::pointer_type(1, node::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(1, node::max_id), + node::pointer_type(1, node::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -447,7 +457,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); }); }); @@ -486,7 +496,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("creates { Ø } for i = 42, dom = {42}", [&]() { @@ -519,7 +529,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("creates { Ø, { 21 } } for i = 42, dom = {21,42}", [&]() { @@ -530,15 +540,15 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(21, zdd::max_id, - node::pointer_type(true), - node::pointer_type(true)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(21, zdd::max_id, node::pointer_type(true), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(21,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(21, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -556,7 +566,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); }); it("creates { Ø, { 42 } } for i = 21, dom = {21,42}", [&]() { @@ -567,15 +577,15 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(42, zdd::max_id, - node::pointer_type(true), - node::pointer_type(true)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(42, zdd::max_id, node::pointer_type(true), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(42,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(42, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -593,7 +603,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); }); it("creates { Ø, { 0 }, { 2 }, { 0,2 } } for i = 1, dom = {0,1,2}", [&]() { @@ -604,22 +614,24 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, zdd::max_id, - node::pointer_type(true), - node::pointer_type(true)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(2, zdd::max_id, node::pointer_type(true), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, zdd::max_id, - node::pointer_type(2, zdd::max_id), - node::pointer_type(2, zdd::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, + zdd::max_id, + node::pointer_type(2, zdd::max_id), + node::pointer_type(2, zdd::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -637,7 +649,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); }); it("throws exception when domain is not in ascending order", [&]() { @@ -659,30 +671,34 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, - node::pointer_type(true), - node::pointer_type(true)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(3, node::max_id, node::pointer_type(true), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(3, node::max_id), - node::pointer_type(3, node::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(3, node::max_id), + node::pointer_type(3, node::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(1, node::max_id), - node::pointer_type(1, node::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(1, node::max_id), + node::pointer_type(1, node::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -700,7 +716,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); }); it("constructs chain for i = 3 global dom = {0,1,2,3}", [&]() { @@ -709,30 +725,34 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - node::pointer_type(true), - node::pointer_type(true)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(2, node::max_id, node::pointer_type(true), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id), - node::pointer_type(2, node::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(2, node::max_id), + node::pointer_type(2, node::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - node::pointer_type(1, node::max_id), - node::pointer_type(1, node::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, + node::max_id, + node::pointer_type(1, node::max_id), + node::pointer_type(1, node::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -750,7 +770,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); }); it("constructs chain for i = 0 global dom = {0,1,2,3}", [&]() { @@ -759,30 +779,34 @@ go_bandit([]() { node_test_stream ns(res); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, - node::pointer_type(true), - node::pointer_type(true)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(3, node::max_id, node::pointer_type(true), node::pointer_type(true)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - node::pointer_type(3, node::max_id), - node::pointer_type(3, node::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(2, + node::max_id, + node::pointer_type(3, node::max_id), + node::pointer_type(3, node::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - node::pointer_type(2, node::max_id), - node::pointer_type(2, node::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(1, + node::max_id, + node::pointer_type(2, node::max_id), + node::pointer_type(2, node::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -800,7 +824,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); }); }); @@ -838,7 +862,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create { {42} }", [&]() { @@ -854,7 +878,7 @@ go_bandit([]() { level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(42,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(42, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -873,7 +897,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create { {1,2,5} }", [&]() { @@ -885,20 +909,24 @@ go_bandit([]() { AssertThat(ns.can_pull(), Is().True()); AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, ptr_uint64(5, ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(2, node::max_id, terminal_F, ptr_uint64(5, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -916,7 +944,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("throws exception when domain is not in ascending order", [&]() { @@ -938,7 +966,7 @@ go_bandit([]() { level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -957,7 +985,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); // TODO: more tests independent of std::vector @@ -993,7 +1021,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create { {4} }", [&]() { @@ -1009,7 +1037,7 @@ go_bandit([]() { level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1028,7 +1056,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create { {0,2,4} }", [&]() { @@ -1040,20 +1068,24 @@ go_bandit([]() { AssertThat(ns.can_pull(), Is().True()); AssertThat(ns.pull(), Is().EqualTo(node(4, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(2, node::max_id, terminal_F, ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(0, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -1071,7 +1103,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("throws exception when domain is not in ascending order", [&]() { @@ -1093,7 +1125,7 @@ go_bandit([]() { level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -1111,7 +1143,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create { {42} }", [&]() { @@ -1125,7 +1157,7 @@ go_bandit([]() { level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(42,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(42, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -1143,12 +1175,11 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); - it("throws exception if the label is too large", [&]() { - AssertThrows(invalid_argument, zdd_singleton(zdd::max_label+1)); - }); + it("throws exception if the label is too large", + [&]() { AssertThrows(invalid_argument, zdd_singleton(zdd::max_label + 1)); }); }); describe("zdd_singletons(vars)", [&]() { @@ -1184,7 +1215,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); }); it("can create { {42} }", [&]() { @@ -1200,7 +1231,7 @@ go_bandit([]() { level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(42,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(42, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -1218,7 +1249,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create { {1}, {2}, {5} }", [&]() { @@ -1230,20 +1261,24 @@ go_bandit([]() { AssertThat(ns.can_pull(), Is().True()); AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, ptr_uint64(5, ptr_uint64::max_id), terminal_T))); + AssertThat( + ns.pull(), + Is().EqualTo(node(2, node::max_id, ptr_uint64(5, ptr_uint64::max_id), terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_T))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_T))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -1261,7 +1296,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(3u)); }); it("throws exception when domain is not in ascending order", [&]() { @@ -1297,7 +1332,7 @@ go_bandit([]() { AssertThat(res->max_1level_cut[cut::All], Is().EqualTo(1u)); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("can create { Ø, {42} }", [&]() { @@ -1313,7 +1348,7 @@ go_bandit([]() { level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(42,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(42, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -1331,7 +1366,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); }); it("can create { Ø, {1}, {2}, {5}, {1,2}, {1,5}, {2,5}, {1,2,5} }", [&]() { @@ -1343,24 +1378,28 @@ go_bandit([]() { AssertThat(ns.can_pull(), Is().True()); AssertThat(ns.pull(), Is().EqualTo(node(5, node::max_id, terminal_T, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(5, ptr_uint64::max_id), - ptr_uint64(5, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(2, + node::max_id, + ptr_uint64(5, ptr_uint64::max_id), + ptr_uint64(5, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -1378,7 +1417,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); }); it("throws exception when domain is not in ascending order", [&]() { @@ -1417,7 +1456,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); }); it("is Ø when given iterators", [&]() { @@ -1448,7 +1487,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); }); it("is Ø when there is no global domain", [&]() { @@ -1480,7 +1519,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); }); it("is Ø when there is a global domain", [&]() { @@ -1512,7 +1551,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(0u)); }); }); @@ -1545,68 +1584,75 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); - it("creates { Ø, {0}, ..., {3}, {0,1}, ..., {2,3}, {0,1,2}, ..., {0,1,2,3} } from generator", [&]() { - int x = 3; - const auto dom = [&x]() -> optional { - if (x < 0) { return make_optional(); } - return x--; - }; - - zdd res = zdd_top(dom); - node_test_stream ns(res); - - AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, terminal_T, terminal_T))); - AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - ptr_uint64(3, ptr_uint64::max_id)))); - AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); - AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(1, ptr_uint64::max_id), - ptr_uint64(1, ptr_uint64::max_id)))); - - AssertThat(ns.can_pull(), Is().False()); - - level_info_test_stream ms(res); - - AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); - AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); - AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); - AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); - AssertThat(ms.can_pull(), Is().False()); - - AssertThat(res->width, Is().EqualTo(1u)); - - AssertThat(res->max_1level_cut[cut::Internal], Is().EqualTo(2u)); - AssertThat(res->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); - AssertThat(res->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); - AssertThat(res->max_1level_cut[cut::All], Is().EqualTo(2u)); - - AssertThat(res->max_2level_cut[cut::Internal], Is().EqualTo(2u)); - AssertThat(res->max_2level_cut[cut::Internal_False], Is().EqualTo(2u)); - AssertThat(res->max_2level_cut[cut::Internal_True], Is().EqualTo(2u)); - AssertThat(res->max_2level_cut[cut::All], Is().EqualTo(2u)); - - AssertThat(zdd_iscanonical(res), Is().True()); - - AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); - }); + it("creates { Ø, {0}, ..., {3}, {0,1}, ..., {2,3}, {0,1,2}, ..., {0,1,2,3} } from generator", + [&]() { + int x = 3; + const auto dom = [&x]() -> optional { + if (x < 0) { return make_optional(); } + return x--; + }; + + zdd res = zdd_top(dom); + node_test_stream ns(res); + + AssertThat(ns.can_pull(), Is().True()); + AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, terminal_T, terminal_T))); + AssertThat(ns.can_pull(), Is().True()); + AssertThat(ns.pull(), + Is().EqualTo(node(2, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(3, ptr_uint64::max_id)))); + AssertThat(ns.can_pull(), Is().True()); + AssertThat(ns.pull(), + Is().EqualTo(node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(ns.can_pull(), Is().True()); + AssertThat(ns.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id), + ptr_uint64(1, ptr_uint64::max_id)))); + + AssertThat(ns.can_pull(), Is().False()); + + level_info_test_stream ms(res); + + AssertThat(ms.can_pull(), Is().True()); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); + AssertThat(ms.can_pull(), Is().True()); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); + AssertThat(ms.can_pull(), Is().True()); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); + AssertThat(ms.can_pull(), Is().True()); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); + AssertThat(ms.can_pull(), Is().False()); + + AssertThat(res->width, Is().EqualTo(1u)); + + AssertThat(res->max_1level_cut[cut::Internal], Is().EqualTo(2u)); + AssertThat(res->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); + AssertThat(res->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); + AssertThat(res->max_1level_cut[cut::All], Is().EqualTo(2u)); + + AssertThat(res->max_2level_cut[cut::Internal], Is().EqualTo(2u)); + AssertThat(res->max_2level_cut[cut::Internal_False], Is().EqualTo(2u)); + AssertThat(res->max_2level_cut[cut::Internal_True], Is().EqualTo(2u)); + AssertThat(res->max_2level_cut[cut::All], Is().EqualTo(2u)); + + AssertThat(zdd_iscanonical(res), Is().True()); + + AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); + }); it("is { Ø } with empty iterator", [&]() { - const std::vector dom = { }; + const std::vector dom = {}; zdd res = zdd_top(dom.rbegin(), dom.rend()); node_test_stream ns(res); @@ -1633,7 +1679,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("creates { Ø, {0}, {2}, {4}, {0,2}, {0,4}, {0,4}, {0,2,4} } from iterator", [&]() { @@ -1645,24 +1691,28 @@ go_bandit([]() { AssertThat(ns.can_pull(), Is().True()); AssertThat(ns.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(4, ptr_uint64::max_id), - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(2, + node::max_id, + ptr_uint64(4, ptr_uint64::max_id), + ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -1680,7 +1730,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); }); it("is { Ø } terminal when there is no global domain", [&]() { @@ -1712,7 +1762,7 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(1u)); }); it("creates { Ø, {0}, {1}, {0,1}, {0,1} } from global domain", [&]() { @@ -1725,18 +1775,20 @@ go_bandit([]() { AssertThat(ns.can_pull(), Is().True()); AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, terminal_T, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(1, ptr_uint64::max_id), - ptr_uint64(1, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id), + ptr_uint64(1, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream ms(res); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(res->width, Is().EqualTo(1u)); @@ -1754,8 +1806,8 @@ go_bandit([]() { AssertThat(zdd_iscanonical(res), Is().True()); AssertThat(res->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(res->number_of_terminals[true], Is().EqualTo(2u)); }); }); }); - }); +}); diff --git a/test/adiar/zdd/test_change.cpp b/test/adiar/zdd/test_change.cpp index 52140ec40..c29ab5658 100644 --- a/test/adiar/zdd/test_change.cpp +++ b/test/adiar/zdd/test_change.cpp @@ -52,11 +52,11 @@ go_bandit([]() { */ shared_levelized_file zdd_1; - const node n1_5 = node(3, node::max_id, terminal_F, terminal_T); - const node n1_4 = node(2, node::max_id, terminal_T, terminal_T); - const node n1_3 = node(2, node::max_id-1, n1_5.uid(), terminal_T); - const node n1_2 = node(1, node::max_id, n1_3.uid(), n1_4.uid()); - const node n1_1 = node(0, node::max_id, n1_2.uid(), n1_4.uid()); + const node n1_5 = node(3, node::max_id, terminal_F, terminal_T); + const node n1_4 = node(2, node::max_id, terminal_T, terminal_T); + const node n1_3 = node(2, node::max_id - 1, n1_5.uid(), terminal_T); + const node n1_2 = node(1, node::max_id, n1_3.uid(), n1_4.uid()); + const node n1_1 = node(0, node::max_id, n1_2.uid(), n1_4.uid()); { // Garbage collect writers to free write-lock node_writer nw(zdd_1); @@ -69,21 +69,21 @@ go_bandit([]() { describe("zdd_change(A, begin, end)", [&]() { it("returns same file for Ø on empty labels", [&]() { - const std::vector vars = { }; + const std::vector vars = {}; __zdd out = zdd_change(zdd_F, vars.begin(), vars.end()); AssertThat(out.get>(), Is().EqualTo(zdd_F)); }); it("returns same file for { Ø } on empty labels", [&]() { - const std::vector vars = { }; + const std::vector vars = {}; __zdd out = zdd_change(zdd_T, vars.begin(), vars.end()); AssertThat(out.get>(), Is().EqualTo(zdd_T)); }); it("returns same file for { {1} } on empty labels", [&]() { - const std::vector vars = { }; + const std::vector vars = {}; __zdd out = zdd_change(zdd_x1, vars.begin(), vars.end()); AssertThat(out.get>(), Is().EqualTo(zdd_x1)); @@ -107,27 +107,37 @@ go_bandit([]() { AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat( + ns.pull(), + Is().EqualTo(node(1, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(3u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(2u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(3u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("adds new root for { {1} } on (0)", [&]() { @@ -138,35 +148,39 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("adds new root chain for { {2} } on (0,1)", [&]() { @@ -184,44 +198,49 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("adds new nodes after root for { {1} } on (2,3)", [&]() { @@ -232,44 +251,49 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("adds a new node before and after root for { {1} } on (0,2)", [&]() { @@ -280,44 +304,49 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("adds new nodes before and after root for { {1} } on (0,2,4)", [&]() { @@ -328,53 +357,59 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(4,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(4, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(4u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(4u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("adds node between root and child for { {1}, {3} } on (2)", [&]() { @@ -383,8 +418,7 @@ go_bandit([]() { { // Garbage collect writer to free write-lock node_writer w(in); w << node(3, node::max_id, terminal_F, terminal_T) - << node(1, node::max_id, ptr_uint64(3, ptr_uint64::max_id), terminal_T) - ; + << node(1, node::max_id, ptr_uint64(3, ptr_uint64::max_id), terminal_T); } const std::vector vars = { 2 }; @@ -394,50 +428,56 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("returns { Ø } for { {0} } on (0)", [&]() { @@ -456,13 +496,21 @@ go_bandit([]() { AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("returns { Ø } for { {1} } on (1)", [&]() { @@ -481,13 +529,21 @@ go_bandit([]() { AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("shortcuts root for { {0,1} } on (0)", [&]() { @@ -508,24 +564,27 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("shortcuts root for { {0,2} } on (0,1)", [&]() { @@ -544,35 +603,39 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("shortcuts root and its child for { {0,2}, {0,2,3} } on (0,2)", [&]() { @@ -594,24 +657,27 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("flips root for { Ø, {0} } on (0)", [&]() { @@ -631,24 +697,27 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("flips root for { {0}, {1} } on (0)", [&]() { @@ -667,35 +736,39 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("flips root for [1] on (0)", [&]() { @@ -706,59 +779,67 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(3u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(4u)); }); it("flips node in the middle for { Ø, {0}, {1,2} } on (1)", [&]() { @@ -778,50 +859,56 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); }); it("flips and adds a node for [1] on (1)", [&]() { @@ -832,65 +919,74 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(3u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(4u)); }); it("collapses to a terminal for { {0,1} } on (0,1)", [&]() { @@ -917,13 +1013,21 @@ go_bandit([]() { AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("bridges over a deleted node for { {0,1,2} } on (1)", [&]() { @@ -933,8 +1037,7 @@ go_bandit([]() { node_writer w(in); w << node(2, node::max_id, terminal_F, terminal_T) << node(1, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)) - << node(0, node::max_id, terminal_F, ptr_uint64(1, ptr_uint64::max_id)) - ; + << node(0, node::max_id, terminal_F, ptr_uint64(1, ptr_uint64::max_id)); } const std::vector vars = { 1 }; @@ -944,35 +1047,39 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("bridges over a deleted node for { {1,2}, {0,1,2} } on (1)", [&]() { @@ -982,8 +1089,10 @@ go_bandit([]() { node_writer w(in); w << node(2, node::max_id, terminal_F, terminal_T) << node(1, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), ptr_uint64(1, ptr_uint64::max_id)) - ; + << node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id), + ptr_uint64(1, ptr_uint64::max_id)); } const std::vector vars = { 1 }; @@ -993,93 +1102,109 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); - it("only adds a one node when cutting arcs to the same node for { {2}, {0,2} } on (1)", [&]() { - shared_levelized_file in; + it( + "only adds a one node when cutting arcs to the same node for { {2}, {0,2} } on (1)", [&]() { + shared_levelized_file in; - { // Garbage collect writer to free write-lock - node_writer w(in); - w << node(2, node::max_id, terminal_F, terminal_T) - << node(0, node::max_id, ptr_uint64(2, ptr_uint64::max_id), ptr_uint64(2, ptr_uint64::max_id)) - ; - } + { // Garbage collect writer to free write-lock + node_writer w(in); + w << node(2, node::max_id, terminal_F, terminal_T) + << node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)); + } - const std::vector vars = { 1 }; + const std::vector vars = { 1 }; - __zdd out = zdd_change(in, vars.begin(), vars.end()); + __zdd out = zdd_change(in, vars.begin(), vars.end()); - arc_test_stream arcs(out); + arc_test_stream arcs(out); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); - AssertThat(arcs.can_pull_internal(), Is().False()); + AssertThat(arcs.can_pull_internal(), Is().False()); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().False()); + AssertThat(arcs.can_pull_terminal(), Is().False()); - level_info_test_stream levels(out); + level_info_test_stream levels(out); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); - AssertThat(levels.can_pull(), Is().False()); + AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); - }); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); + }); it("bridges node before the last label and a terminal for { {0}, {1} } on (0,1)", [&]() { /* @@ -1099,8 +1224,7 @@ go_bandit([]() { { // Garbage collect writer to free write-lock node_writer w(in); w << node(1, node::max_id, terminal_F, terminal_T) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T) - ; + << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T); } const std::vector vars = { 0, 1 }; @@ -1110,35 +1234,39 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("flips, adds and bridges nodes for [1] on (2,3)", [&]() { @@ -1163,116 +1291,134 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(3u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); - it("correctly connects pre-root chain with skipped root for { { 1 }, { 1,2 } } on (0,1)", [&]() { - shared_levelized_file in; - /* - // 1 ---- x1 - // / \ - // F 2 ---- x2 - // / \ - // T T - */ + it( + "correctly connects pre-root chain with skipped root for { { 1 }, { 1,2 } } on (0,1)", + [&]() { + shared_levelized_file in; + /* + // 1 ---- x1 + // / \ + // F 2 ---- x2 + // / \ + // T T + */ - const node n2 = node(2, node::max_id, terminal_T, terminal_T); - const node n1 = node(1, node::max_id, terminal_F, n2.uid()); + const node n2 = node(2, node::max_id, terminal_T, terminal_T); + const node n1 = node(1, node::max_id, terminal_F, n2.uid()); - { - node_writer nw(in); - nw << n2 << n1; - } + { + node_writer nw(in); + nw << n2 << n1; + } - const std::vector vars = { 0, 1 }; + const std::vector vars = { 0, 1 }; - __zdd out = zdd_change(in, vars.begin(), vars.end()); + __zdd out = zdd_change(in, vars.begin(), vars.end()); - arc_test_stream arcs(out); + arc_test_stream arcs(out); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(2, 0) })); - AssertThat(arcs.can_pull_internal(), Is().False()); + AssertThat(arcs.can_pull_internal(), Is().False()); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().False()); + AssertThat(arcs.can_pull_terminal(), Is().False()); - level_info_test_stream levels(out); + level_info_test_stream levels(out); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); - AssertThat(levels.can_pull(), Is().False()); + AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); - }); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); + }); it("cuts collapse of root to a terminal for { { 0 } } on (0,1)", [&]() { shared_levelized_file in; @@ -1295,24 +1441,27 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("cuts collapse to a terminal for { { 0,1 } } on (0,1,2)", [&]() { @@ -1339,66 +1488,75 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); - it("keeps pre-root chain despite collapse to a terminal of the root for { { 1 } } on (0,1)", [&]() { - shared_levelized_file in; - /* - // 1 ---- x1 - // / \ - // F T - */ - { // Garbage collect writer to free write-lock - node_writer nw(in); - nw << node(1, node::max_id, terminal_F, terminal_T); - } + it( + "keeps pre-root chain despite collapse to a terminal of the root for { { 1 } } on (0,1)", + [&]() { + shared_levelized_file in; + /* + // 1 ---- x1 + // / \ + // F T + */ + { // Garbage collect writer to free write-lock + node_writer nw(in); + nw << node(1, node::max_id, terminal_F, terminal_T); + } - const std::vector vars = { 0, 1 }; + const std::vector vars = { 0, 1 }; - __zdd out = zdd_change(in, vars.begin(), vars.end()); + __zdd out = zdd_change(in, vars.begin(), vars.end()); - arc_test_stream arcs(out); + arc_test_stream arcs(out); - AssertThat(arcs.can_pull_internal(), Is().False()); + AssertThat(arcs.can_pull_internal(), Is().False()); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), true, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), true, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().False()); + AssertThat(arcs.can_pull_terminal(), Is().False()); - level_info_test_stream levels(out); + level_info_test_stream levels(out); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); - AssertThat(levels.can_pull(), Is().False()); + AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); - }); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); + }); }); }); - }); +}); diff --git a/test/adiar/zdd/test_complement.cpp b/test/adiar/zdd/test_complement.cpp index e1c012574..693e0c567 100644 --- a/test/adiar/zdd/test_complement.cpp +++ b/test/adiar/zdd/test_complement.cpp @@ -28,8 +28,8 @@ go_bandit([]() { // T T */ { // Garbage collect writer early - const node n2 = node(4, node::max_id, terminal_T, terminal_T); - const node n1 = node(2, node::max_id, n2.uid(), n2.uid()); + const node n2 = node(4, node::max_id, terminal_T, terminal_T); + const node n1 = node(2, node::max_id, n2.uid(), n2.uid()); node_writer nw(zdd_pow_24); nw << n2 << n1; @@ -37,7 +37,7 @@ go_bandit([]() { const std::vector dom_0123 = { 0, 1, 2, 3 }; const std::vector dom_1234 = { 1, 2, 3, 4 }; - const std::vector dom_empty = { }; + const std::vector dom_empty = {}; describe("zdd_complement(A, vars)", [&]() { // TODO @@ -64,50 +64,62 @@ go_bandit([]() { node_test_stream ns(out); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, terminal_T, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - ptr_uint64(3, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(2, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(3, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(1, ptr_uint64::max_id), - ptr_uint64(1, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id), + ptr_uint64(1, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(2u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(2u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(2u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(2u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(2u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("produces pow(U) on F terminal and U = { 1, 2, 3, 4 }", [&]() { @@ -116,50 +128,62 @@ go_bandit([]() { node_test_stream ns(out); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, - ptr_uint64(4, ptr_uint64::max_id), - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(3, + node::max_id, + ptr_uint64(4, ptr_uint64::max_id), + ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - ptr_uint64(3, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(2, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(3, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(2u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(2u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(2u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(2u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(2u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("produces pow(U) \\ Ø on T terminal and U = { 0, 2 }", [&]() { @@ -170,34 +194,42 @@ go_bandit([]() { node_test_stream ns(out); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(2u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(2u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(2u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(2u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(2u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("produces pow(U) \\ Ø on T terminal and U = { 1, 2, 3, 4 }", [&]() { @@ -206,50 +238,62 @@ go_bandit([]() { node_test_stream ns(out); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(4, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(4, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, - ptr_uint64(4, ptr_uint64::max_id), - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(3, + node::max_id, + ptr_uint64(4, ptr_uint64::max_id), + ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - ptr_uint64(3, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(2, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(3, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(2u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(2u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(2u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(2u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(2u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("adds out-of-set chain above root on { { 3 } } and U = { 0, 1, 2, 3 }", [&]() { @@ -280,71 +324,83 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // root chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // root chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // T chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // root chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // T chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), false, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // input node (flipped) - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // T chain - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); }); it("adds out-of-set chain above and below root on { { 2 } } and U = { 0, 1, 2, 3 }", [&]() { @@ -359,168 +415,194 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // root chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // root chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // T chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // original node - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // T chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), false, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // F chain - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); // T chain - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); }); - it("adds out-of-set chain above and below root on { Ø, { 1 } } and U = { 1, 2, 3, 4 }", [&]() { - shared_levelized_file zdd_x1_null; - /* - // 1 ---- x1 - // / \ - // T T - */ - { - node_writer nw(zdd_x1_null); - nw << node(1, node::max_id, terminal_T, terminal_T); - } + it( + "adds out-of-set chain above and below root on { Ø, { 1 } } and U = { 1, 2, 3, 4 }", [&]() { + shared_levelized_file zdd_x1_null; + /* + // 1 ---- x1 + // / \ + // T T + */ + { + node_writer nw(zdd_x1_null); + nw << node(1, node::max_id, terminal_T, terminal_T); + } - __zdd out = zdd_complement(zdd_x1_null, dom_0123.begin(), dom_0123.end()); - /* - // 1 ---- x0 - // / \ - // 2 3 ---- x1 - // || || - // 4_ 5 ---- x2 - // | \|| - // 6_ 7 ---- x3 - // | \|| - // F T - */ + __zdd out = zdd_complement(zdd_x1_null, dom_0123.begin(), dom_0123.end()); + /* + // 1 ---- x0 + // / \ + // 2 3 ---- x1 + // || || + // 4_ 5 ---- x2 + // | \|| + // 6_ 7 ---- x3 + // | \|| + // F T + */ - arc_test_stream arcs(out); + arc_test_stream arcs(out); - AssertThat(arcs.can_pull_internal(), Is().True()); // 2 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); // 2 + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); // 3 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); // 3 + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); - AssertThat(arcs.can_pull_internal(), Is().True()); // 4 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); // 4 + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); // 5 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); // 5 + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 1) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); - AssertThat(arcs.can_pull_internal(), Is().True()); // 6 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); // 6 + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); // 7 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); // 7 + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 1) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), false, ptr_uint64(3,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, ptr_uint64(3, 1) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), true, ptr_uint64(3,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, ptr_uint64(3, 1) })); + AssertThat(arcs.can_pull_internal(), Is().False()); - AssertThat(arcs.can_pull_internal(), Is().False()); + AssertThat(arcs.can_pull_terminal(), Is().True()); // 6 + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); // 6 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); // 7 + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); // 7 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), false, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 1), true, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,1), true, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().False()); - AssertThat(arcs.can_pull_terminal(), Is().False()); + level_info_test_stream levels(out); - level_info_test_stream levels(out); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); - - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 2u))); - AssertThat(levels.can_pull(), Is().False()); + AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(4u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); - }); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); + }); it("computes U \\ { { 2 }, { 3 }, { 4 }, { 2,4 }, { 3,4 } } with U = { 1, 2, 3, 4 }", [&]() { shared_levelized_file in; @@ -535,10 +617,10 @@ go_bandit([]() { // F T T */ { // Garbage collect writer early - const node n4 = node(4, node::max_id, terminal_T, terminal_T); - const node n3 = node(4, node::max_id-1, terminal_F, terminal_T); - const node n2 = node(3, node::max_id, n3.uid(), n4.uid()); - const node n1 = node(2, node::max_id, n2.uid(), n4.uid()); + const node n4 = node(4, node::max_id, terminal_T, terminal_T); + const node n3 = node(4, node::max_id - 1, terminal_F, terminal_T); + const node n2 = node(3, node::max_id, n3.uid(), n4.uid()); + const node n1 = node(2, node::max_id, n2.uid(), n4.uid()); node_writer nw(in); nw << n4 << n3 << n2 << n1; @@ -560,219 +642,257 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // 2 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 3 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 4 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 5 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 6 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), false, ptr_uint64(3,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, ptr_uint64(3, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), true, ptr_uint64(3,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, ptr_uint64(3, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 7 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,0), false, ptr_uint64(4,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, ptr_uint64(4, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 8 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,0), true, ptr_uint64(4,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), true, ptr_uint64(4, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,1), false, ptr_uint64(4,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, ptr_uint64(4, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 9 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,1), true, ptr_uint64(4,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), true, ptr_uint64(4, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,2), false, ptr_uint64(4,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 2), false, ptr_uint64(4, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,2), true, ptr_uint64(4,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 2), true, ptr_uint64(4, 2) })); AssertThat(arcs.can_pull_terminal(), Is().True()); // 7 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // 8 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,1), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 1), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,1), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 1), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // 9 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,2), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 2), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,2), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 2), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 3u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(4,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(4, 3u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(6u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); }); - it("computes pow(U) \\ { Ø, { 1,2 }, { 2,3 }, { 2,4 }, { 1,2,3 }, { 1,2,4 } } with U = { 1, 2, 3, 4 }", [&]() { - shared_levelized_file in; - /* - // _1_ ---- x1 - // / \ - // 2 3 ---- x2 - // / \ / \ - // T 4 F 5 ---- x3 - // / \ / \ - // 6 T 7 T ---- x4 - // / \ / \ - // F T T T - */ - { // Garbage collect writer early - const node n7 = node(4, node::max_id, terminal_T, terminal_T); - const node n6 = node(4, node::max_id-1, terminal_F, terminal_T); - const node n5 = node(3, node::max_id, n7.uid(), terminal_T); - const node n4 = node(3, node::max_id-1, n6.uid(), terminal_T); - const node n3 = node(2, node::max_id, terminal_F, n5.uid()); - const node n2 = node(2, node::max_id-1, terminal_T, n4.uid()); // <-- breaks canonicity - const node n1 = node(1, node::max_id, n2.uid(), n3.uid()); - - node_writer nw(in); - nw << n7 << n6 << n5 << n4 << n3 << n2 << n1; - } + it( + "computes pow(U) \\ { Ø, { 1,2 }, { 2,3 }, { 2,4 }, { 1,2,3 }, { 1,2,4 } } with U = { 1, " + "2, 3, 4 }", + [&]() { + shared_levelized_file in; + /* + // _1_ ---- x1 + // / \ + // 2 3 ---- x2 + // / \ / \ + // T 4 F 5 ---- x3 + // / \ / \ + // 6 T 7 T ---- x4 + // / \ / \ + // F T T T + */ + { // Garbage collect writer early + const node n7 = node(4, node::max_id, terminal_T, terminal_T); + const node n6 = node(4, node::max_id - 1, terminal_F, terminal_T); + const node n5 = node(3, node::max_id, n7.uid(), terminal_T); + const node n4 = node(3, node::max_id - 1, n6.uid(), terminal_T); + const node n3 = node(2, node::max_id, terminal_F, n5.uid()); + const node n2 = + node(2, node::max_id - 1, terminal_T, n4.uid()); // <-- breaks canonicity + const node n1 = node(1, node::max_id, n2.uid(), n3.uid()); + + node_writer nw(in); + nw << n7 << n6 << n5 << n4 << n3 << n2 << n1; + } + + __zdd out = zdd_complement(in, dom_1234.begin(), dom_1234.end()); + /* + // _1_ ---- x1 + // / \ + // 2 3 ---- x2 + // X__ X_______ + // / X____ \ + // / / \ \ + // 4 5 6 7 ---- x3 + // / \ / \___ |\__ || + // / X______\\ \|| + // / / \\\ ||| + // 8 9 10 11 ---- x4 + // / \/ \ / \ || + // T F F F T T + */ - __zdd out = zdd_complement(in, dom_1234.begin(), dom_1234.end()); - /* - // _1_ ---- x1 - // / \ - // 2 3 ---- x2 - // X__ X_______ - // / X____ \ - // / / \ \ - // 4 5 6 7 ---- x3 - // / \ / \___ |\__ || - // / X______\\ \|| - // / / \\\ ||| - // 8 9 10 11 ---- x4 - // / \/ \ / \ || - // T F F F T T - */ + arc_test_stream arcs(out); - arc_test_stream arcs(out); + AssertThat(arcs.can_pull_internal(), Is().True()); // 2 + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); // 2 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); // 3 + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); - AssertThat(arcs.can_pull_internal(), Is().True()); // 3 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); // 4 + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); // 4 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); // 5 + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, ptr_uint64(3, 1) })); - AssertThat(arcs.can_pull_internal(), Is().True()); // 5 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), true, ptr_uint64(3,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); // 6 + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 2) })); - AssertThat(arcs.can_pull_internal(), Is().True()); // 6 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,2) })); + AssertThat(arcs.can_pull_internal(), Is().True()); // 7 + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, ptr_uint64(3, 3) })); - AssertThat(arcs.can_pull_internal(), Is().True()); // 7 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), false, ptr_uint64(3,3) })); + AssertThat(arcs.can_pull_internal(), Is().True()); // 8 + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, ptr_uint64(4, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); // 8 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,0), false, ptr_uint64(4,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); // 9 + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, ptr_uint64(4, 1) })); - AssertThat(arcs.can_pull_internal(), Is().True()); // 9 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,1), false, ptr_uint64(4,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); // 10 + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), true, ptr_uint64(4, 2) })); - AssertThat(arcs.can_pull_internal(), Is().True()); // 10 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,0), true, ptr_uint64(4,2) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), true, ptr_uint64(4, 2) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,1), true, ptr_uint64(4,2) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 2), false, ptr_uint64(4, 2) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,2), false, ptr_uint64(4,2) })); + AssertThat(arcs.can_pull_internal(), Is().True()); // 11 + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 2), true, ptr_uint64(4, 3) })); - AssertThat(arcs.can_pull_internal(), Is().True()); // 11 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,2), true, ptr_uint64(4,3) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 3), false, ptr_uint64(4, 3) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,3), false, ptr_uint64(4,3) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 3), true, ptr_uint64(4, 3) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,3), true, ptr_uint64(4,3) })); + AssertThat(arcs.can_pull_internal(), Is().False()); - AssertThat(arcs.can_pull_internal(), Is().False()); + AssertThat(arcs.can_pull_terminal(), Is().True()); // 8 + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(4, 0), false, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); // 8 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), false, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), true, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), true, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); // 9 + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(4, 1), false, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); // 9 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,1), false, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 1), true, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,1), true, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); // 10 + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(4, 2), false, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); // 10 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,2), false, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 2), true, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,2), true, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); // 11 + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(4, 3), false, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); // 11 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,3), false, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 3), true, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,3), true, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().False()); - AssertThat(arcs.can_pull_terminal(), Is().False()); + level_info_test_stream levels(out); - level_info_test_stream levels(out); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); - - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,4u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 4u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(4,4u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(4, 4u))); - AssertThat(levels.can_pull(), Is().False()); + AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(8u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(8u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(4u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(4u)); - }); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(4u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(4u)); + }); it("computes pow(U) \\ pow(U) with U = { 2, 4 }", [&]() { const std::vector dom = { 2, 4 }; @@ -791,35 +911,39 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // 2 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(4,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(4, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(4,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(4, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // 2 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("computes pow(U) \\ pow({ 2, 4 }) with U = { 1, 2, 3, 4 }", [&]() { @@ -839,71 +963,83 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); // 2 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 3 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 4 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 5 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), false, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,1), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), true, ptr_uint64(3, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 6 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,0), false, ptr_uint64(4,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, ptr_uint64(4, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // 7 - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,0), true, ptr_uint64(4,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), true, ptr_uint64(4, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,1), false, ptr_uint64(4,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, ptr_uint64(4, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,1), true, ptr_uint64(4,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), true, ptr_uint64(4, 1) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); // 6 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); // 7 - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,1), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 1), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,1), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 1), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(4,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(4, 2u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); }); @@ -916,50 +1052,62 @@ go_bandit([]() { node_test_stream ns(out); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, terminal_T, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - ptr_uint64(3, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(2, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(3, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(1, ptr_uint64::max_id), - ptr_uint64(1, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id), + ptr_uint64(1, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(2u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(2u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(2u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(2u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(2u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("produces pow(U) \\ Ø on T terminal with set domain U = { 1, 2, 3, 4 }", [&]() { @@ -970,51 +1118,63 @@ go_bandit([]() { node_test_stream ns(out); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(4, node::max_id, - terminal_F, - terminal_T))); + AssertThat(ns.pull(), Is().EqualTo(node(4, node::max_id, terminal_F, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(3, node::max_id, - ptr_uint64(4, ptr_uint64::max_id), - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(3, + node::max_id, + ptr_uint64(4, ptr_uint64::max_id), + ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - ptr_uint64(3, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(2, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(3, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(2u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(2u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(2u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(2u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(2u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); }); }); - }); +}); diff --git a/test/adiar/zdd/test_contains.cpp b/test/adiar/zdd/test_contains.cpp index 4ffaa2959..c580ac773 100644 --- a/test/adiar/zdd/test_contains.cpp +++ b/test/adiar/zdd/test_contains.cpp @@ -57,11 +57,11 @@ go_bandit([]() { // / \/ \ // F T T */ - const node n1_5 = node(3, node::max_id, terminal_T, terminal_T); - const node n1_4 = node(3, node::max_id-1, terminal_F, terminal_T); - const node n1_3 = node(2, node::max_id, n1_4.uid(), n1_5.uid()); - const node n1_2 = node(1, node::max_id, terminal_T, n1_3.uid()); - const node n1_1 = node(0, node::max_id, n1_2.uid(), n1_3.uid()); + const node n1_5 = node(3, node::max_id, terminal_T, terminal_T); + const node n1_4 = node(3, node::max_id - 1, terminal_F, terminal_T); + const node n1_3 = node(2, node::max_id, n1_4.uid(), n1_5.uid()); + const node n1_2 = node(1, node::max_id, terminal_T, n1_3.uid()); + const node n1_1 = node(0, node::max_id, n1_2.uid(), n1_3.uid()); { // Garbage collect writers to free write-lock node_writer nw(zdd_1); @@ -79,10 +79,10 @@ go_bandit([]() { // / \/ \ // F T T */ - const node n2_4 = node(6, node::max_id, terminal_T, terminal_T); - const node n2_3 = node(6, node::max_id-1, terminal_F, terminal_T); - const node n2_2 = node(4, node::max_id, n2_3.uid(), n2_4.uid()); - const node n2_1 = node(2, node::max_id, n2_3.uid(), n2_2.uid()); + const node n2_4 = node(6, node::max_id, terminal_T, terminal_T); + const node n2_3 = node(6, node::max_id - 1, terminal_F, terminal_T); + const node n2_2 = node(4, node::max_id, n2_3.uid(), n2_4.uid()); + const node n2_1 = node(2, node::max_id, n2_3.uid(), n2_2.uid()); { // Garbage collect writers to free write-lock node_writer nw(zdd_2); @@ -95,13 +95,13 @@ go_bandit([]() { describe("zdd_contains(A, begin, end)", [&]() { it("returns false for Ø on Ø", [&]() { - const std::vector a = { }; + const std::vector a = {}; AssertThat(zdd_contains(zdd_F, a.begin(), a.end()), Is().False()); }); it("returns true for { Ø } on Ø", [&]() { - const std::vector a = { }; + const std::vector a = {}; AssertThat(zdd_contains(zdd_T, a.begin(), a.end()), Is().True()); }); @@ -113,7 +113,7 @@ go_bandit([]() { }); it("returns visited root for [1] on Ø", [&]() { - const std::vector a = { }; + const std::vector a = {}; AssertThat(zdd_contains(zdd_1, a.begin(), a.end()), Is().True()); }); @@ -173,7 +173,7 @@ go_bandit([]() { }); it("returns visited root for [2] on Ø", [&]() { - const std::vector a = { }; + const std::vector a = {}; AssertThat(zdd_contains(zdd_2, a.begin(), a.end()), Is().False()); }); @@ -233,4 +233,4 @@ go_bandit([]() { }); }); }); - }); +}); diff --git a/test/adiar/zdd/test_count.cpp b/test/adiar/zdd/test_count.cpp index a4f04063c..d7744d4ef 100644 --- a/test/adiar/zdd/test_count.cpp +++ b/test/adiar/zdd/test_count.cpp @@ -18,10 +18,10 @@ go_bandit([]() { F T */ { // Garbage collect writer to free write-lock - node n4 = node(3,0, terminal_F, terminal_T); - node n3 = node(2,0, terminal_F, n4.uid()); - node n2 = node(1,0, n3.uid(), n4.uid()); - node n1 = node(0,0, n3.uid(), n2.uid()); + node n4 = node(3, 0, terminal_F, terminal_T); + node n3 = node(2, 0, terminal_F, n4.uid()); + node n2 = node(1, 0, n3.uid(), n4.uid()); + node n1 = node(0, 0, n3.uid(), n2.uid()); node_writer nw_1(zdd_1); nw_1 << n4 << n3 << n2 << n1; @@ -38,8 +38,8 @@ go_bandit([]() { F T */ { // Garbage collect writer to free write-lock - node n2 = node(2,0, terminal_F, terminal_T); - node n1 = node(1,0, n2.uid(), terminal_T); + node n2 = node(2, 0, terminal_F, terminal_T); + node n1 = node(1, 0, n2.uid(), terminal_T); node_writer nw_2(zdd_2); nw_2 << n2 << n1; @@ -77,7 +77,7 @@ go_bandit([]() { { // Garbage collect writer to free write-lock node_writer nw_root_1(zdd_root_1); - nw_root_1 << node(1,0, terminal_F, terminal_T); + nw_root_1 << node(1, 0, terminal_F, terminal_T); } describe("zdd_nodecount", [&]() { @@ -101,25 +101,18 @@ go_bandit([]() { }); describe("zdd_size", [&]() { - it("can count family { {x2, x3}, {x0, x2, x3}, {x0, x1, x3} } [1]", [&]() { - AssertThat(zdd_size(zdd_1), Is().EqualTo(3u)); - }); + it("can count family { {x2, x3}, {x0, x2, x3}, {x0, x1, x3} } [1]", + [&]() { AssertThat(zdd_size(zdd_1), Is().EqualTo(3u)); }); - it("can count family { {x1}, {x2} } [2]", [&]() { - AssertThat(zdd_size(zdd_2), Is().EqualTo(2u)); - }); + it("can count family { {x1}, {x2} } [2]", + [&]() { AssertThat(zdd_size(zdd_2), Is().EqualTo(2u)); }); - it("can count family { Ø } [T]", [&]() { - AssertThat(zdd_size(zdd_T), Is().EqualTo(1u)); - }); + it("can count family { Ø } [T]", [&]() { AssertThat(zdd_size(zdd_T), Is().EqualTo(1u)); }); - it("can count family Ø [F]", [&]() { - AssertThat(zdd_size(zdd_F), Is().EqualTo(0u)); - }); + it("can count family Ø [F]", [&]() { AssertThat(zdd_size(zdd_F), Is().EqualTo(0u)); }); - it("can count family { 1 } [root_1]", [&]() { - AssertThat(zdd_size(zdd_root_1), Is().EqualTo(1u)); - }); + it("can count family { 1 } [root_1]", + [&]() { AssertThat(zdd_size(zdd_root_1), Is().EqualTo(1u)); }); }); }); - }); +}); diff --git a/test/adiar/zdd/test_elem.cpp b/test/adiar/zdd/test_elem.cpp index f25a2b488..c88a4caf6 100644 --- a/test/adiar/zdd/test_elem.cpp +++ b/test/adiar/zdd/test_elem.cpp @@ -70,10 +70,10 @@ go_bandit([]() { // F T */ { - const node n4 = node(4, node::max_id, terminal_F, terminal_T); - const node n3 = node(2, node::max_id, n4.uid(), terminal_T); - const node n2 = node(2, node::max_id-1, terminal_F, n4.uid()); - const node n1 = node(1, node::max_id, n2.uid(), n3.uid()); + const node n4 = node(4, node::max_id, terminal_F, terminal_T); + const node n3 = node(2, node::max_id, n4.uid(), terminal_T); + const node n2 = node(2, node::max_id - 1, terminal_F, n4.uid()); + const node n1 = node(1, node::max_id, n2.uid(), n3.uid()); node_writer nw(zdd_3); nw << n4 << n3 << n2 << n1; @@ -123,7 +123,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("finds { Ø } set on { Ø }", [&]() { @@ -152,7 +152,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("finds { {1} } on [1]", [&]() { @@ -162,14 +162,15 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(zdd::node_type(1, zdd::max_id, terminal_F, terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(zdd::node_type(1, zdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -184,7 +185,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("finds { Ø } on [2]", [&]() { @@ -213,7 +214,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("finds {2,4} on [3]", [&]() { @@ -223,24 +224,22 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(zdd::node_type(4, zdd::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(zdd::node_type(4, zdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(zdd::node_type(2, zdd::max_id, - terminal_F, - zdd::pointer_type(4, zdd::max_id)))); - + AssertThat(out_nodes.pull(), + Is().EqualTo(zdd::node_type( + 2, zdd::max_id, terminal_F, zdd::pointer_type(4, zdd::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -255,7 +254,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("finds {1} on [4]", [&]() { @@ -265,14 +264,15 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(zdd::node_type(1, zdd::max_id, terminal_F, terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(zdd::node_type(1, zdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -287,16 +287,14 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); }); describe("zdd_minelem(A, c)", [&]() { it("makes no calls for { Ø } on { Ø }", [&]() { size_t calls = 0u; - const auto c = [&calls](zdd::label_type) { - calls++; - }; + const auto c = [&calls](zdd::label_type) { calls++; }; zdd_minelem(zdd_T, c); AssertThat(calls, Is().EqualTo(0u)); @@ -304,7 +302,7 @@ go_bandit([]() { it("calls with 1 on [1]", [&]() { size_t calls = 0u; - std::vector expected { 1 }; + std::vector expected{ 1 }; const auto c = [&calls, &expected](zdd::label_type x) { AssertThat(x, Is().EqualTo(expected.at(calls))); @@ -317,9 +315,7 @@ go_bandit([]() { it("makes no calls for { Ø } on [2]", [&]() { size_t calls = 0u; - const auto c = [&calls](zdd::label_type) { - calls++; - }; + const auto c = [&calls](zdd::label_type) { calls++; }; zdd_minelem(zdd_2, c); AssertThat(calls, Is().EqualTo(0u)); @@ -327,7 +323,7 @@ go_bandit([]() { it("calls with 2,4 on [3]", [&]() { size_t calls = 0u; - std::vector expected { 2,4 }; + std::vector expected{ 2, 4 }; const auto c = [&calls, &expected](zdd::label_type x) { AssertThat(x, Is().EqualTo(expected.at(calls))); @@ -340,7 +336,7 @@ go_bandit([]() { it("calls with 1 on [4]", [&]() { size_t calls = 0u; - std::vector expected { 1 }; + std::vector expected{ 1 }; const auto c = [&calls, &expected](zdd::label_type x) { AssertThat(x, Is().EqualTo(expected.at(calls))); @@ -355,7 +351,7 @@ go_bandit([]() { describe("zdd_minelem(A, begin, end)", [&]() { using buffer_type = std::vector; - const buffer_type::value_type buffer_default(zdd::max_label+1); + const buffer_type::value_type buffer_default(zdd::max_label + 1); const size_t buffer_size = 4; it("outputs { } in buffer for { Ø }", [&]() { @@ -363,7 +359,7 @@ go_bandit([]() { auto ret = zdd_minelem(zdd_T, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+0)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 0)); buffer_type expected(buffer_size, buffer_default); @@ -377,7 +373,7 @@ go_bandit([]() { auto ret = zdd_minelem(zdd_1, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+1)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 1)); buffer_type expected(buffer_size, buffer_default); expected.at(0) = 1; @@ -397,7 +393,7 @@ go_bandit([]() { auto ret = zdd_minelem(zdd_2, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+0)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 0)); buffer_type expected(buffer_size, buffer_default); @@ -411,7 +407,7 @@ go_bandit([]() { auto ret = zdd_minelem(zdd_3, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+2)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 2)); buffer_type expected(buffer_size, buffer_default); expected.at(0) = 2; @@ -432,7 +428,7 @@ go_bandit([]() { auto ret = zdd_minelem(zdd_4, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+1)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 1)); buffer_type expected(buffer_size, buffer_default); expected.at(0) = 1; @@ -470,7 +466,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("finds { Ø } on { Ø }", [&]() { @@ -499,7 +495,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("finds {0,2} on [1]", [&]() { @@ -509,24 +505,22 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(zdd::node_type(2, zdd::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(zdd::node_type(2, zdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(zdd::node_type(0, zdd::max_id, - terminal_F, - zdd::pointer_type(2, zdd::max_id)))); - + AssertThat(out_nodes.pull(), + Is().EqualTo(zdd::node_type( + 0, zdd::max_id, terminal_F, zdd::pointer_type(2, zdd::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -541,7 +535,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("finds {1} on [2]", [&]() { @@ -551,14 +545,15 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(zdd::node_type(1, zdd::max_id, terminal_F, terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(zdd::node_type(1, zdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -573,7 +568,7 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); it("finds {0,1} on [4]", [&]() { @@ -583,24 +578,22 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(zdd::node_type(1, zdd::max_id, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(zdd::node_type(1, zdd::max_id, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(zdd::node_type(0, zdd::max_id, - terminal_F, - zdd::pointer_type(1, zdd::max_id)))); - + AssertThat(out_nodes.pull(), + Is().EqualTo(zdd::node_type( + 0, zdd::max_id, terminal_F, zdd::pointer_type(1, zdd::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -615,16 +608,14 @@ go_bandit([]() { AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); }); describe("zdd_maxelem(A, c)", [&]() { it("makes no calls for { Ø } on { Ø }", [&]() { size_t calls = 0u; - const auto c = [&calls](zdd::label_type) { - calls++; - }; + const auto c = [&calls](zdd::label_type) { calls++; }; zdd_maxelem(zdd_T, c); AssertThat(calls, Is().EqualTo(0u)); @@ -634,7 +625,7 @@ go_bandit([]() { it("calls 0,2 on [1]", [&]() { size_t calls = 0u; - std::vector expected { 0,2 }; + std::vector expected{ 0, 2 }; const auto c = [&calls, &expected](zdd::label_type x) { AssertThat(x, Is().EqualTo(expected.at(calls))); @@ -647,7 +638,7 @@ go_bandit([]() { it("calls with 1 on [2]", [&]() { size_t calls = 0u; - std::vector expected { 1 }; + std::vector expected{ 1 }; const auto c = [&calls, &expected](zdd::label_type x) { AssertThat(x, Is().EqualTo(expected.at(calls))); @@ -660,7 +651,7 @@ go_bandit([]() { it("calls with 0,1 on [4]", [&]() { size_t calls = 0u; - std::vector expected { 0,1 }; + std::vector expected{ 0, 1 }; const auto c = [&calls, &expected](zdd::label_type x) { AssertThat(x, Is().EqualTo(expected.at(calls))); @@ -675,7 +666,7 @@ go_bandit([]() { describe("zdd_maxelem(A, begin, end)", [&]() { using buffer_type = std::vector; - const buffer_type::value_type buffer_default(zdd::max_label+1); + const buffer_type::value_type buffer_default(zdd::max_label + 1); const size_t buffer_size = 4; it("outputs { } in buffer for { Ø }", [&]() { @@ -683,7 +674,7 @@ go_bandit([]() { auto ret = zdd_maxelem(zdd_T, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+0)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 0)); buffer_type expected(buffer_size, buffer_default); @@ -697,7 +688,7 @@ go_bandit([]() { auto ret = zdd_maxelem(zdd_1, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+2)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 2)); buffer_type expected(buffer_size, buffer_default); expected.at(0) = 0; @@ -718,7 +709,7 @@ go_bandit([]() { auto ret = zdd_maxelem(zdd_2, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+1)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 1)); buffer_type expected(buffer_size, buffer_default); expected.at(0) = 1; @@ -738,7 +729,7 @@ go_bandit([]() { auto ret = zdd_maxelem(zdd_4, buffer.begin(), buffer.end()); - AssertThat(ret, Is().EqualTo(buffer.begin()+2)); + AssertThat(ret, Is().EqualTo(buffer.begin() + 2)); buffer_type expected(buffer_size, buffer_default); expected.at(0) = 0; @@ -755,4 +746,4 @@ go_bandit([]() { }); }); }); - }); +}); diff --git a/test/adiar/zdd/test_expand.cpp b/test/adiar/zdd/test_expand.cpp index 15cf3c916..ddc3a873b 100644 --- a/test/adiar/zdd/test_expand.cpp +++ b/test/adiar/zdd/test_expand.cpp @@ -43,13 +43,13 @@ go_bandit([]() { // F T */ - const node n1_7 = node(10, zdd::max_id, terminal_F, terminal_T); - const node n1_6 = node(8, zdd::max_id, terminal_T, terminal_T); - const node n1_5 = node(8, zdd::max_id-1, n1_7.uid(), terminal_T); - const node n1_4 = node(6, zdd::max_id, n1_5.uid(), n1_6.uid()); - const node n1_3 = node(4, zdd::max_id, n1_4.uid(), terminal_T); - const node n1_2 = node(4, zdd::max_id-1, terminal_F, n1_4.uid()); - const node n1_1 = node(2, zdd::max_id, n1_2.uid(), n1_3.uid()); + const node n1_7 = node(10, zdd::max_id, terminal_F, terminal_T); + const node n1_6 = node(8, zdd::max_id, terminal_T, terminal_T); + const node n1_5 = node(8, zdd::max_id - 1, n1_7.uid(), terminal_T); + const node n1_4 = node(6, zdd::max_id, n1_5.uid(), n1_6.uid()); + const node n1_3 = node(4, zdd::max_id, n1_4.uid(), terminal_T); + const node n1_2 = node(4, zdd::max_id - 1, terminal_F, n1_4.uid()); + const node n1_1 = node(2, zdd::max_id, n1_2.uid(), n1_3.uid()); { // Garbage collect writers to free write-lock node_writer nw(zdd_1); @@ -62,28 +62,28 @@ go_bandit([]() { describe("zdd_expand(A, begin, end)", [&]() { it("returns same file for Ø on empty labels", [&]() { - const std::vector vars = { }; + const std::vector vars = {}; __zdd out = zdd_expand(zdd_F, vars.begin(), vars.end()); AssertThat(out.get>(), Is().EqualTo(zdd_F)); }); it("returns same file for { Ø } on empty labels", [&]() { - const std::vector vars = { }; + const std::vector vars = {}; __zdd out = zdd_expand(zdd_T, vars.begin(), vars.end()); AssertThat(out.get>(), Is().EqualTo(zdd_T)); }); it("returns same file for { {1} } on empty labels", [&]() { - const std::vector vars = { }; + const std::vector vars = {}; __zdd out = zdd_expand(zdd_x1, vars.begin(), vars.end()); AssertThat(out.get>(), Is().EqualTo(zdd_x1)); }); it("returns same file for [1] on empty labels", [&]() { - const std::vector vars = { }; + const std::vector vars = {}; __zdd out = zdd_expand(zdd_x1, vars.begin(), vars.end()); AssertThat(out.get>(), Is().EqualTo(zdd_x1)); @@ -111,17 +111,25 @@ go_bandit([]() { level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(42,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(42, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(2u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(2u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(2u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("returns don't care chain for { Ø } on (0,2)", [&]() { @@ -135,29 +143,39 @@ go_bandit([]() { AssertThat(ns.pull(), Is().EqualTo(node(2, node::max_id, terminal_T, terminal_T))); AssertThat(ns.can_pull(), Is().True()); - AssertThat(ns.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(ns.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(ns.can_pull(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(2u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(2u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(2u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(2u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(2u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("adds new root for { { 1 } } on (0)", [&]() { @@ -175,35 +193,38 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ ptr_uint64(0, 0), ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("adds node chain for { { 3 }, { 3,4 } } on (0,2)", [&]() { @@ -212,8 +233,7 @@ go_bandit([]() { { // Garbage collect writer to free write-lock node_writer w(in); w << node(4, node::max_id, terminal_F, terminal_T) - << node(3, node::max_id, terminal_T, ptr_uint64(4, ptr_uint64::max_id)) - ; + << node(3, node::max_id, terminal_T, ptr_uint64(4, ptr_uint64::max_id)); } const std::vector vars = { 0, 2 }; @@ -223,53 +243,60 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,0), true, ptr_uint64(4,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), true, ptr_uint64(4, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("adds nodes before and after for { Ø, { 3 } } on (0,2,4)", [&]() { @@ -287,53 +314,61 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,0), false, ptr_uint64(4,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, ptr_uint64(4, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,0), true, ptr_uint64(4,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), true, ptr_uint64(4, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("adds nodes for T terminal but not F terminal for { { 1,2 }, { 1,3 } } on (4,5,6)", [&]() { @@ -355,71 +390,81 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(4,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(4, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,0), true, ptr_uint64(4,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), true, ptr_uint64(4, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(4,0), false, ptr_uint64(5,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(4, 0), false, ptr_uint64(5, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(4,0), true, ptr_uint64(5,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(4, 0), true, ptr_uint64(5, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(5,0), false, ptr_uint64(6,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(5, 0), false, ptr_uint64(6, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(5,0), true, ptr_uint64(6,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(5, 0), true, ptr_uint64(6, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(1,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(1, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(6,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(6, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(6,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(6, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(6,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(6, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("adds node in between levels { { 0,2 } } on (1)", [&]() { @@ -438,44 +483,49 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("adds nodes in between levels { { 0,3 } } on (1,2)", [&]() { @@ -494,123 +544,145 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(0,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(0, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(3,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(3, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); - it("adds different don't care nodes on different arcs cut for { {0}, {2}, { 0,2 } } on (1,2)", [&]() { - shared_levelized_file in; + it( + "adds different don't care nodes on different arcs cut for { {0}, {2}, { 0,2 } } on (1,2)", + [&]() { + shared_levelized_file in; - { // Garbage collect writer to free write-lock - node_writer w(in); - w << node(2, node::max_id, terminal_T, terminal_T) - << node(2, node::max_id-1, terminal_F, terminal_T) - << node(0, node::max_id, ptr_uint64(2, ptr_uint64::max_id-1), ptr_uint64(2, ptr_uint64::max_id)); - } + { // Garbage collect writer to free write-lock + node_writer w(in); + w << node(2, node::max_id, terminal_T, terminal_T) + << node(2, node::max_id - 1, terminal_F, terminal_T) + << node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id - 1), + ptr_uint64(2, ptr_uint64::max_id)); + } - const std::vector vars = { 1 }; + const std::vector vars = { 1 }; - __zdd out = zdd_expand(in, vars.begin(), vars.end()); + __zdd out = zdd_expand(in, vars.begin(), vars.end()); - arc_test_stream arcs(out); + arc_test_stream arcs(out); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 1) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), false, ptr_uint64(2,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), false, ptr_uint64(2, 1) })); - AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,1), true, ptr_uint64(2,1) })); + AssertThat(arcs.can_pull_internal(), Is().True()); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 1), true, ptr_uint64(2, 1) })); - AssertThat(arcs.can_pull_internal(), Is().False()); + AssertThat(arcs.can_pull_internal(), Is().False()); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), false, terminal_F })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, terminal_F })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,0), true, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 0), true, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), false, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), + Is().EqualTo(arc{ ptr_uint64(2, 1), false, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(2,1), true, terminal_T })); + AssertThat(arcs.can_pull_terminal(), Is().True()); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(2, 1), true, terminal_T })); - AssertThat(arcs.can_pull_terminal(), Is().False()); + AssertThat(arcs.can_pull_terminal(), Is().False()); - level_info_test_stream levels(out); + level_info_test_stream levels(out); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,2u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 2u))); - AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,2u))); + AssertThat(levels.can_pull(), Is().True()); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 2u))); - AssertThat(levels.can_pull(), Is().False()); + AssertThat(levels.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(4u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(4u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); - }); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); + }); it("adds don't care nodes before, in between, and after for [1] on (0,1,3,5,7,9,11)", [&]() { const std::vector vars = { 0, 1, 3, 5, 7, 9, 11 }; @@ -621,173 +693,209 @@ go_bandit([]() { // Pre-chain AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), false, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(0,0), true, ptr_uint64(1,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(0, 0), true, ptr_uint64(1, 0) })); // (1) and its x3 cut AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), false, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), false, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(1,0), true, ptr_uint64(2,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(1, 0), true, ptr_uint64(2, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), false, ptr_uint64(3,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), false, ptr_uint64(3, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(2,0), true, ptr_uint64(3,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(2, 0), true, ptr_uint64(3, 1) })); // (2) and (3) and their x5 cut AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,0), false, ptr_uint64(4,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), false, ptr_uint64(4, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,0), true, ptr_uint64(4,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 0), true, ptr_uint64(4, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,1), false, ptr_uint64(4,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), false, ptr_uint64(4, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(3,1), true, ptr_uint64(4,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(3, 1), true, ptr_uint64(4, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(4,0), true, ptr_uint64(5,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(4, 0), true, ptr_uint64(5, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(4,1), false, ptr_uint64(5,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(4, 1), false, ptr_uint64(5, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // T chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(4,1), true, ptr_uint64(5,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(4, 1), true, ptr_uint64(5, 1) })); // (4) and the x7 cuts AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(5,0), false, ptr_uint64(6,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(5, 0), false, ptr_uint64(6, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(5,0), true, ptr_uint64(6,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(5, 0), true, ptr_uint64(6, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(6,0), false, ptr_uint64(7,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(6, 0), false, ptr_uint64(7, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(6,0), true, ptr_uint64(7,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(6, 0), true, ptr_uint64(7, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // T chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(5,1), false, ptr_uint64(7,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(5, 1), false, ptr_uint64(7, 2) })); AssertThat(arcs.can_pull_internal(), Is().True()); // T chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(5,1), true, ptr_uint64(7,2) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(5, 1), true, ptr_uint64(7, 2) })); // (5) and (6) and their x9 cuts AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(7,0), false, ptr_uint64(8,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(7, 0), false, ptr_uint64(8, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(7,0), true, ptr_uint64(8,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(7, 0), true, ptr_uint64(8, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(7,1), false, ptr_uint64(8,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(7, 1), false, ptr_uint64(8, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(7,1), true, ptr_uint64(8,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(7, 1), true, ptr_uint64(8, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(8,0), false, ptr_uint64(9,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(8, 0), false, ptr_uint64(9, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // T chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(7,2), false, ptr_uint64(9,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(7, 2), false, ptr_uint64(9, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // T chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(7,2), true, ptr_uint64(9,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(7, 2), true, ptr_uint64(9, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // T chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(8,0), true, ptr_uint64(9,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(8, 0), true, ptr_uint64(9, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // T chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(8,1), false, ptr_uint64(9,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(8, 1), false, ptr_uint64(9, 1) })); AssertThat(arcs.can_pull_internal(), Is().True()); // T chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(8,1), true, ptr_uint64(9,1) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(8, 1), true, ptr_uint64(9, 1) })); // (7) and the x11 cuts AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(9,0), false, ptr_uint64(10,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(9, 0), false, ptr_uint64(10, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(9,0), true, ptr_uint64(10,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(9, 0), true, ptr_uint64(10, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // T chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(9,1), false, ptr_uint64(11,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(9, 1), false, ptr_uint64(11, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // T chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(9,1), true, ptr_uint64(11,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(9, 1), true, ptr_uint64(11, 0) })); AssertThat(arcs.can_pull_internal(), Is().True()); // T chain - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { ptr_uint64(10,0), true, ptr_uint64(11,0) })); + AssertThat(arcs.pull_internal(), + Is().EqualTo(arc{ ptr_uint64(10, 0), true, ptr_uint64(11, 0) })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(4,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(4, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(10,0), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(10, 0), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(11,0), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(11, 0), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { ptr_uint64(11,0), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ ptr_uint64(11, 0), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream levels(out); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(4,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(4, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(5,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(5, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(6,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(6, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(7,3u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(7, 3u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(8,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(8, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(9,2u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(9, 2u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(10,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(10, 1u))); AssertThat(levels.can_pull(), Is().True()); - AssertThat(levels.pull(), Is().EqualTo(level_info(11,1u))); + AssertThat(levels.pull(), Is().EqualTo(level_info(11, 1u))); AssertThat(levels.can_pull(), Is().False()); AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().EqualTo(6u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); }); }); - }); +}); diff --git a/test/adiar/zdd/test_pred.cpp b/test/adiar/zdd/test_pred.cpp index 105803387..1733780d6 100644 --- a/test/adiar/zdd/test_pred.cpp +++ b/test/adiar/zdd/test_pred.cpp @@ -7,7 +7,8 @@ go_bandit([]() { // Ø shared_levelized_file zdd_empty_nf; - { node_writer nw(zdd_empty_nf); + { + node_writer nw(zdd_empty_nf); nw << node(false); } @@ -15,7 +16,8 @@ go_bandit([]() { // { Ø } shared_levelized_file zdd_null_nf; - { node_writer nw(zdd_null_nf); + { + node_writer nw(zdd_null_nf); nw << node(true); } @@ -23,7 +25,8 @@ go_bandit([]() { // { {1} } shared_levelized_file zdd_A_nf; - { node_writer nw(zdd_A_nf); + { + node_writer nw(zdd_A_nf); nw << node(1, node::max_id, terminal_F, terminal_T); } @@ -31,54 +34,62 @@ go_bandit([]() { // { {1}, {1,2} } shared_levelized_file zdd_B_nf; - { node_writer nw(zdd_B_nf); + { + node_writer nw(zdd_B_nf); nw << node(2, node::max_id, terminal_T, terminal_T) - << node(1, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)) - ; + << node(1, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)); } // { Ø, {1}, {2}, {1,2} } shared_levelized_file zdd_C_nf; - { node_writer nw(zdd_C_nf); - nw << node(2, node::max_id, terminal_T, terminal_T) - << node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), ptr_uint64(2, ptr_uint64::max_id)) - ; + { + node_writer nw(zdd_C_nf); + nw << node(2, node::max_id, terminal_T, terminal_T) + << node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)); } auto zdd_C_nf_copy = shared_levelized_file::copy(zdd_C_nf); // { {1}, {1,2}, {0,1,3} } shared_levelized_file zdd_D_nf; - { node_writer nw(zdd_D_nf); - nw << node(3, node::max_id, terminal_F, terminal_T) - << node(2, node::max_id, terminal_T, terminal_T) - << node(1, node::max_id, terminal_F, ptr_uint64(3, ptr_uint64::max_id)) - << node(1, node::max_id-1, terminal_F, ptr_uint64(2, ptr_uint64::max_id)) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id-1), ptr_uint64(1, ptr_uint64::max_id)) - ; + { + node_writer nw(zdd_D_nf); + nw << node(3, node::max_id, terminal_F, terminal_T) + << node(2, node::max_id, terminal_T, terminal_T) + << node(1, node::max_id, terminal_F, ptr_uint64(3, ptr_uint64::max_id)) + << node(1, node::max_id - 1, terminal_F, ptr_uint64(2, ptr_uint64::max_id)) + << node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id - 1), + ptr_uint64(1, ptr_uint64::max_id)); } auto zdd_D_nf_copy = shared_levelized_file::copy(zdd_D_nf); // { Ø, {0,3} } shared_levelized_file zdd_E_nf; - { node_writer nw(zdd_E_nf); + { + node_writer nw(zdd_E_nf); nw << node(3, node::max_id, terminal_F, terminal_T) - << node(0, node::max_id, terminal_T, ptr_uint64(3, ptr_uint64::max_id)) - ; + << node(0, node::max_id, terminal_T, ptr_uint64(3, ptr_uint64::max_id)); } auto zdd_E_nf_copy = shared_levelized_file::copy(zdd_E_nf); // { {2} } shared_levelized_file zdd_F_nf; - { node_writer nw(zdd_F_nf); + { + node_writer nw(zdd_F_nf); nw << node(2, node::max_id, terminal_F, terminal_T); } // { {0,2,4} } shared_levelized_file zdd_G_nf; - { node_writer nw(zdd_G_nf); + { + node_writer nw(zdd_G_nf); nw << node(4, node::max_id, terminal_F, terminal_T) << node(2, node::max_id, terminal_F, ptr_uint64(4, ptr_uint64::max_id)) << node(0, node::max_id, terminal_F, ptr_uint64(2, ptr_uint64::max_id)); @@ -95,41 +106,25 @@ go_bandit([]() { // ------------------------------------------------------------------------- describe("zdd_ispoint", [&]() { - it("rejects Ø", [&]() { - AssertThat(zdd_ispoint(zdd_empty_nf), Is().False()); - }); + it("rejects Ø", [&]() { AssertThat(zdd_ispoint(zdd_empty_nf), Is().False()); }); - it("accepts { Ø }", [&]() { - AssertThat(zdd_ispoint(zdd_null_nf), Is().True()); - }); + it("accepts { Ø }", [&]() { AssertThat(zdd_ispoint(zdd_null_nf), Is().True()); }); - it("accepts { {1} }", [&]() { - AssertThat(zdd_ispoint(zdd_A_nf), Is().True()); - }); + it("accepts { {1} }", [&]() { AssertThat(zdd_ispoint(zdd_A_nf), Is().True()); }); - it("accepts { {2} }", [&]() { - AssertThat(zdd_ispoint(zdd_E_nf), Is().False()); - }); + it("accepts { {2} }", [&]() { AssertThat(zdd_ispoint(zdd_E_nf), Is().False()); }); - it("rejects { {1}, {1,2} }", [&]() { - AssertThat(zdd_ispoint(zdd_B_nf), Is().False()); - }); + it("rejects { {1}, {1,2} }", [&]() { AssertThat(zdd_ispoint(zdd_B_nf), Is().False()); }); - it("rejects { Ø, {1}, {2}, {1,2} }", [&]() { - AssertThat(zdd_ispoint(zdd_C_nf), Is().False()); - }); + it("rejects { Ø, {1}, {2}, {1,2} }", + [&]() { AssertThat(zdd_ispoint(zdd_C_nf), Is().False()); }); - it("rejects { {1}, {1,2}, {0,1,3} }", [&]() { - AssertThat(zdd_ispoint(zdd_D_nf), Is().False()); - }); + it("rejects { {1}, {1,2}, {0,1,3} }", + [&]() { AssertThat(zdd_ispoint(zdd_D_nf), Is().False()); }); - it("rejects { Ø, {0,3} }", [&]() { - AssertThat(zdd_ispoint(zdd_D_nf), Is().False()); - }); + it("rejects { Ø, {0,3} }", [&]() { AssertThat(zdd_ispoint(zdd_D_nf), Is().False()); }); - it("accepts { {0,2,4} }", [&]() { - AssertThat(zdd_ispoint(zdd_G_nf), Is().True()); - }); + it("accepts { {0,2,4} }", [&]() { AssertThat(zdd_ispoint(zdd_G_nf), Is().True()); }); }); describe("zdd_subseteq", [&]() { @@ -281,13 +276,11 @@ go_bandit([]() { AssertThat(zdd_disjoint(zdd_E_nf, zdd_E_nf), Is().False()); }); - it("accepts same file for Ø", [&]() { - AssertThat(zdd_disjoint(zdd_empty_nf, zdd_empty_nf), Is().True()); - }); + it("accepts same file for Ø", + [&]() { AssertThat(zdd_disjoint(zdd_empty_nf, zdd_empty_nf), Is().True()); }); - it("rejects same file for { Ø }", [&]() { - AssertThat(zdd_disjoint(zdd_null_nf, zdd_null_nf), Is().False()); - }); + it("rejects same file for { Ø }", + [&]() { AssertThat(zdd_disjoint(zdd_null_nf, zdd_null_nf), Is().False()); }); it("rejects on equal ZDDs", [&]() { AssertThat(zdd_disjoint(zdd_A_nf, zdd_A_nf_copy), Is().False()); @@ -301,9 +294,8 @@ go_bandit([]() { AssertThat(zdd_disjoint(zdd_null_nf, zdd_empty_nf), Is().True()); }); - it("accepts Ø and Ø", [&]() { - AssertThat(zdd_disjoint(zdd_empty_nf, zdd_empty_nf_copy), Is().True()); - }); + it("accepts Ø and Ø", + [&]() { AssertThat(zdd_disjoint(zdd_empty_nf, zdd_empty_nf_copy), Is().True()); }); it("rejects { Ø } and { Ø }", [&]() { AssertThat(zdd_disjoint(zdd_empty_nf, zdd_null_nf), Is().True()); @@ -349,9 +341,8 @@ go_bandit([]() { AssertThat(zdd_disjoint(zdd_F_nf, zdd_C_nf), Is().False()); }); - it("accepts non-subsets of { Ø, {1}, {2}, {1,2} }", [&]() { - AssertThat(zdd_disjoint(zdd_empty_nf, zdd_C_nf), Is().True()); - }); + it("accepts non-subsets of { Ø, {1}, {2}, {1,2} }", + [&]() { AssertThat(zdd_disjoint(zdd_empty_nf, zdd_C_nf), Is().True()); }); it("accepts { {2} } and { {1}, {1,2} }", [&]() { AssertThat(zdd_disjoint(zdd_F_nf, zdd_B_nf), Is().True()); @@ -359,4 +350,4 @@ go_bandit([]() { }); }); }); - }); +}); diff --git a/test/adiar/zdd/test_project.cpp b/test/adiar/zdd/test_project.cpp index 5d6b812aa..3e50dd108 100644 --- a/test/adiar/zdd/test_project.cpp +++ b/test/adiar/zdd/test_project.cpp @@ -44,9 +44,9 @@ go_bandit([]() { nw << node(4, node::max_id, terminal_T, terminal_T) << node(3, node::max_id, terminal_F, ptr_uint64(4, ptr_uint64::max_id)) << node(2, node::max_id, ptr_uint64(3, ptr_uint64::max_id), terminal_T) - << node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), ptr_uint64(2, ptr_uint64::max_id)) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T) - ; + << node( + 1, node::max_id, ptr_uint64(2, ptr_uint64::max_id), ptr_uint64(2, ptr_uint64::max_id)) + << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), terminal_T); } // { {0}, {2}, {0,3}, {2,4} } @@ -69,8 +69,10 @@ go_bandit([]() { nw << node(4, node::max_id, terminal_T, terminal_T) << node(3, node::max_id, terminal_T, terminal_T) << node(2, node::max_id, terminal_F, ptr_uint64(4, ptr_uint64::max_id)) - << node(0, node::max_id, ptr_uint64(2, ptr_uint64::max_id), ptr_uint64(3, ptr_uint64::max_id)) - ; + << node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(3, ptr_uint64::max_id)); } // { {0}, {2}, {1,2}, {0,2} } @@ -86,11 +88,16 @@ go_bandit([]() { shared_levelized_file zdd_3; { node_writer nw(zdd_3); - nw << node(2, node::max_id, terminal_T, terminal_T) - << node(2, node::max_id-1, terminal_F, terminal_T) - << node(1, node::max_id, ptr_uint64(2, ptr_uint64::max_id-1), ptr_uint64(2, ptr_uint64::max_id)) - << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), ptr_uint64(2, ptr_uint64::max_id)) - ; + nw << node(2, node::max_id, terminal_T, terminal_T) + << node(2, node::max_id - 1, terminal_F, terminal_T) + << node(1, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id - 1), + ptr_uint64(2, ptr_uint64::max_id)) + << node(0, + node::max_id, + ptr_uint64(1, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)); } // { {4}, {0,2}, {0,4}, {2,4}, {0,2,4} } @@ -106,12 +113,20 @@ go_bandit([]() { shared_levelized_file zdd_4; { node_writer nw(zdd_4); - nw << node(4, node::max_id, terminal_T, terminal_T) - << node(4, node::max_id-1, terminal_F, terminal_T) - << node(2, node::max_id, ptr_uint64(4, ptr_uint64::max_id-1), ptr_uint64(4, ptr_uint64::max_id)) - << node(2, node::max_id-1, ptr_uint64(4, ptr_uint64::max_id-1), ptr_uint64(4, ptr_uint64::max_id-1)) - << node(0, node::max_id, ptr_uint64(2, ptr_uint64::max_id-1), ptr_uint64(2, ptr_uint64::max_id)) - ; + nw << node(4, node::max_id, terminal_T, terminal_T) + << node(4, node::max_id - 1, terminal_F, terminal_T) + << node(2, + node::max_id, + ptr_uint64(4, ptr_uint64::max_id - 1), + ptr_uint64(4, ptr_uint64::max_id)) + << node(2, + node::max_id - 1, + ptr_uint64(4, ptr_uint64::max_id - 1), + ptr_uint64(4, ptr_uint64::max_id - 1)) + << node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id - 1), + ptr_uint64(2, ptr_uint64::max_id)); } // { ... } @@ -172,72 +187,61 @@ go_bandit([]() { // /| |\ // F T T T */ - const node n5_o = node(13, node::max_id, ptr_uint64(true), ptr_uint64(true)); - const node n5_n = node(13, node::max_id-1, ptr_uint64(false), ptr_uint64(true)); + const node n5_o = node(13, node::max_id, ptr_uint64(true), ptr_uint64(true)); + const node n5_n = node(13, node::max_id - 1, ptr_uint64(false), ptr_uint64(true)); - const node n5_17 = node(12, node::max_id, ptr_uint64(true), ptr_uint64(true)); - const node n5_16 = node(12, node::max_id-1, ptr_uint64(false), ptr_uint64(true)); + const node n5_17 = node(12, node::max_id, ptr_uint64(true), ptr_uint64(true)); + const node n5_16 = node(12, node::max_id - 1, ptr_uint64(false), ptr_uint64(true)); - const node n5_m = node(11, node::max_id, n5_o.uid(), n5_n.uid()); - const node n5_l = node(11, node::max_id-1, n5_n.uid(), n5_o.uid()); - const node n5_15 = node(11, node::max_id-2, n5_17.uid(), n5_16.uid()); - const node n5_14 = node(11, node::max_id-3, n5_16.uid(), n5_17.uid()); + const node n5_m = node(11, node::max_id, n5_o.uid(), n5_n.uid()); + const node n5_l = node(11, node::max_id - 1, n5_n.uid(), n5_o.uid()); + const node n5_15 = node(11, node::max_id - 2, n5_17.uid(), n5_16.uid()); + const node n5_14 = node(11, node::max_id - 3, n5_16.uid(), n5_17.uid()); - const node n5_k = node(10, node::max_id, n5_m.uid(), n5_l.uid()); - const node n5_j = node(10, node::max_id-1, n5_l.uid(), n5_m.uid()); - const node n5_13 = node(10, node::max_id-2, n5_15.uid(), n5_14.uid()); - const node n5_12 = node(10, node::max_id-3, n5_14.uid(), n5_15.uid()); + const node n5_k = node(10, node::max_id, n5_m.uid(), n5_l.uid()); + const node n5_j = node(10, node::max_id - 1, n5_l.uid(), n5_m.uid()); + const node n5_13 = node(10, node::max_id - 2, n5_15.uid(), n5_14.uid()); + const node n5_12 = node(10, node::max_id - 3, n5_14.uid(), n5_15.uid()); - const node n5_i = node(9, node::max_id, n5_k.uid(), n5_j.uid()); - const node n5_h = node(9, node::max_id-1, n5_j.uid(), n5_k.uid()); - const node n5_11 = node(9, node::max_id-2, n5_13.uid(), n5_12.uid()); - const node n5_10 = node(9, node::max_id-3, n5_12.uid(), n5_13.uid()); + const node n5_i = node(9, node::max_id, n5_k.uid(), n5_j.uid()); + const node n5_h = node(9, node::max_id - 1, n5_j.uid(), n5_k.uid()); + const node n5_11 = node(9, node::max_id - 2, n5_13.uid(), n5_12.uid()); + const node n5_10 = node(9, node::max_id - 3, n5_12.uid(), n5_13.uid()); - const node n5_g = node(8, node::max_id, n5_i.uid(), n5_h.uid()); - const node n5_f = node(8, node::max_id-1, n5_h.uid(), n5_i.uid()); - const node n5_9 = node(8, node::max_id-2, n5_11.uid(), n5_10.uid()); - const node n5_8 = node(8, node::max_id-3, n5_10.uid(), n5_11.uid()); + const node n5_g = node(8, node::max_id, n5_i.uid(), n5_h.uid()); + const node n5_f = node(8, node::max_id - 1, n5_h.uid(), n5_i.uid()); + const node n5_9 = node(8, node::max_id - 2, n5_11.uid(), n5_10.uid()); + const node n5_8 = node(8, node::max_id - 3, n5_10.uid(), n5_11.uid()); - const node n5_7 = node(7, node::max_id, n5_8.uid(), n5_9.uid()); + const node n5_7 = node(7, node::max_id, n5_8.uid(), n5_9.uid()); - const node n5_d = node(6, node::max_id, n5_f.uid(), n5_g.uid()); - const node n5_6 = node(6, node::max_id-1, n5_7.uid(), n5_9.uid()); - const node n5_5 = node(6, node::max_id-2, n5_8.uid(), n5_7.uid()); + const node n5_d = node(6, node::max_id, n5_f.uid(), n5_g.uid()); + const node n5_6 = node(6, node::max_id - 1, n5_7.uid(), n5_9.uid()); + const node n5_5 = node(6, node::max_id - 2, n5_8.uid(), n5_7.uid()); - const node n5_c = node(5, node::max_id, n5_d.uid(), ptr_uint64(true)); - const node n5_b = node(5, node::max_id-1, ptr_uint64(false), n5_d.uid()); - const node n5_4 = node(5, node::max_id-2, n5_5.uid(), n5_6.uid()); + const node n5_c = node(5, node::max_id, n5_d.uid(), ptr_uint64(true)); + const node n5_b = node(5, node::max_id - 1, ptr_uint64(false), n5_d.uid()); + const node n5_4 = node(5, node::max_id - 2, n5_5.uid(), n5_6.uid()); - const node n5_3 = node(4, node::max_id, n5_4.uid(), ptr_uint64(true)); - const node n5_2 = node(4, node::max_id-1, ptr_uint64(false), n5_4.uid()); + const node n5_3 = node(4, node::max_id, n5_4.uid(), ptr_uint64(true)); + const node n5_2 = node(4, node::max_id - 1, ptr_uint64(false), n5_4.uid()); - const node n5_1 = node(3, node::max_id, n5_2.uid(), n5_3.uid()); + const node n5_1 = node(3, node::max_id, n5_2.uid(), n5_3.uid()); - const node n5_a = node(2, node::max_id, n5_b.uid(), n5_c.uid()); + const node n5_a = node(2, node::max_id, n5_b.uid(), n5_c.uid()); - const node n5_r3 = node(1, node::max_id, n5_5.uid(), n5_d.uid()); - const node n5_r2 = node(1, node::max_id-1, n5_1.uid(), n5_a.uid()); + const node n5_r3 = node(1, node::max_id, n5_5.uid(), n5_d.uid()); + const node n5_r2 = node(1, node::max_id - 1, n5_1.uid(), n5_a.uid()); - const node n5_r1 = node(0, node::max_id, n5_r2.uid(), n5_r3.uid()); + const node n5_r1 = node(0, node::max_id, n5_r2.uid(), n5_r3.uid()); shared_levelized_file zdd_5; { node_writer nw(zdd_5); - nw << n5_o << n5_n - << n5_17 << n5_16 - << n5_m << n5_l << n5_15 << n5_14 - << n5_k << n5_j << n5_13 << n5_12 - << n5_i << n5_h << n5_11 << n5_10 - << n5_g << n5_f << n5_9 << n5_8 - << n5_7 - << n5_d << n5_6 << n5_5 - << n5_c << n5_b << n5_4 - << n5_3 << n5_2 - << n5_1 - << n5_a - << n5_r3 << n5_r2 - << n5_r1 - ; + nw << n5_o << n5_n << n5_17 << n5_16 << n5_m << n5_l << n5_15 << n5_14 << n5_k << n5_j + << n5_13 << n5_12 << n5_i << n5_h << n5_11 << n5_10 << n5_g << n5_f << n5_9 << n5_8 << n5_7 + << n5_d << n5_6 << n5_5 << n5_c << n5_b << n5_4 << n5_3 << n5_2 << n5_1 << n5_a << n5_r3 + << n5_r2 << n5_r1; } // { ... } @@ -263,51 +267,49 @@ go_bandit([]() { shared_levelized_file zdd_6; { - const node nc = node(6, node::max_id, ptr_uint64(false), ptr_uint64(true)); - const node nb = node(5, node::max_id, ptr_uint64(true), ptr_uint64(true)); - const node na = node(5, node::max_id-1, ptr_uint64(false), ptr_uint64(true)); - - const node n9_3 = node(4, node::max_id, na.uid(), nb.uid()); - const node n9_2 = node(4, node::max_id-1, na.uid(), nb.uid()); - const node n9_1 = node(4, node::max_id-2, na.uid(), nb.uid()); - - const node n8 = node(3, node::max_id, n9_2.uid(), n9_3.uid()); - const node n7 = node(3, node::max_id-1, n9_1.uid(), n9_3.uid()); - const node n6 = node(3, node::max_id-2, n9_2.uid(), n9_1.uid()); - const node n5 = node(3, node::max_id-3, n9_1.uid(), n9_2.uid()); - const node n4 = node(2, node::max_id, n7.uid(), n8.uid()); - const node n3 = node(2, node::max_id-1, n5.uid(), n6.uid()); - const node n2 = node(1, node::max_id, n3.uid(), n4.uid()); - const node n1 = node(0, node::max_id, n2.uid(), nc.uid()); + const node nc = node(6, node::max_id, ptr_uint64(false), ptr_uint64(true)); + const node nb = node(5, node::max_id, ptr_uint64(true), ptr_uint64(true)); + const node na = node(5, node::max_id - 1, ptr_uint64(false), ptr_uint64(true)); + + const node n9_3 = node(4, node::max_id, na.uid(), nb.uid()); + const node n9_2 = node(4, node::max_id - 1, na.uid(), nb.uid()); + const node n9_1 = node(4, node::max_id - 2, na.uid(), nb.uid()); + + const node n8 = node(3, node::max_id, n9_2.uid(), n9_3.uid()); + const node n7 = node(3, node::max_id - 1, n9_1.uid(), n9_3.uid()); + const node n6 = node(3, node::max_id - 2, n9_2.uid(), n9_1.uid()); + const node n5 = node(3, node::max_id - 3, n9_1.uid(), n9_2.uid()); + const node n4 = node(2, node::max_id, n7.uid(), n8.uid()); + const node n3 = node(2, node::max_id - 1, n5.uid(), n6.uid()); + const node n2 = node(1, node::max_id, n3.uid(), n4.uid()); + const node n1 = node(0, node::max_id, n2.uid(), nc.uid()); node_writer nw(zdd_6); - nw << nc << nb << na - << n9_3 << n9_2 << n9_1 - << n8 << n7 << n6 << n5 << n4 << n3 << n2 << n1; + nw << nc << nb << na << n9_3 << n9_2 << n9_1 << n8 << n7 << n6 << n5 << n4 << n3 << n2 << n1; } // TODO: Turn 'GreaterThanOrEqualTo' in max 1-level cuts below into an // 'EqualTo'. describe("zdd_project(const zdd&, const predicate)", [&]() { - it("returns same file for Ø with dom = {1,3,5,...} [const &]", [&](){ + it("returns same file for Ø with dom = {1,3,5,...} [const &]", [&]() { zdd out = zdd_project(zdd_empty, [](zdd::label_type x) { return x % 2; }); AssertThat(out.file_ptr(), Is().EqualTo(zdd_empty)); }); - it("returns same file for { Ø } with dom = {0,2,4,...} [&&]", [&](){ + it("returns same file for { Ø } with dom = {0,2,4,...} [&&]", [&]() { zdd out = zdd_project(zdd(zdd_null), [](zdd::label_type x) { return !(x % 2); }); AssertThat(out.file_ptr(), Is().EqualTo(zdd_null)); }); describe("algorithm: Singleton", [&]() { - const exec_policy &ep = exec_policy::quantify::Singleton; + const exec_policy& ep = exec_policy::quantify::Singleton; - it("computes with dom = Ø to be { Ø } for non-empty input [zdd_1] [const &]", [&](){ + it("computes with dom = Ø to be { Ø } for non-empty input [zdd_1] [const &]", [&]() { shared_file dom; const zdd in = zdd_1; - zdd out = zdd_project(ep, in, [](zdd::label_type) { return false; }); + zdd out = zdd_project(ep, in, [](zdd::label_type) { return false; }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); @@ -324,10 +326,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("computes with dom = Ø to be { Ø } for non-empty input [zdd_2] [&&]", [&](){ + it("computes with dom = Ø to be { Ø } for non-empty input [zdd_2] [&&]", [&]() { shared_file dom; zdd out = zdd_project(ep, zdd(zdd_2), [](zdd::label_type) { return false; }); @@ -347,10 +349,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("computes with disjoint dom = { x | x > 2 } to be { Ø } [zdd_3] [&&]", [&](){ + it("computes with disjoint dom = { x | x > 2 } to be { Ø } [zdd_3] [&&]", [&]() { zdd out = zdd_project(ep, zdd(zdd_3), [](zdd::label_type x) { return x > 2; }); node_test_stream out_nodes(out); @@ -368,10 +370,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("computes zdd_3 with dom = { x | x % 2 == 0 }", [&](){ + it("computes zdd_3 with dom = { x | x % 2 == 0 }", [&]() { /* Expected: { {0}, {2}, {0,2} } // // 1 ---- x0 @@ -388,24 +390,24 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -415,19 +417,19 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); }); describe("algorithm: Nested, max: 0", [&]() { - const exec_policy ep = exec_policy::quantify::Nested - & exec_policy::quantify::transposition_max(0); + const exec_policy ep = + exec_policy::quantify::Nested & exec_policy::quantify::transposition_max(0); - it("computes with dom = Ø to be { Ø } for non-empty input [zdd_1]", [&](){ + it("computes with dom = Ø to be { Ø } for non-empty input [zdd_1]", [&]() { shared_file dom; const zdd in = zdd_1; - zdd out = zdd_project(ep, in, [](zdd::label_type) { return false; }); + zdd out = zdd_project(ep, in, [](zdd::label_type) { return false; }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); @@ -444,10 +446,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("computes with disjoint dom = { x | x > 2 } to be { Ø } [zdd_3]", [&](){ + it("computes with disjoint dom = { x | x > 2 } to be { Ø } [zdd_3]", [&]() { zdd out = zdd_project(ep, zdd(zdd_3), [](zdd::label_type x) { return x > 2; }); node_test_stream out_nodes(out); @@ -465,10 +467,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("computes zdd_3 with dom = { x | x % 2 == 0 }", [&](){ + it("computes zdd_3 with dom = { x | x % 2 == 0 }", [&]() { /* Expected: { {0}, {2}, {0,2} } // // 1 ---- x0 @@ -485,24 +487,24 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -512,10 +514,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); - it("bails out of inner sweep for zdd_4 with dom = { x | x % 2 == 0 } [const &]", [&](){ + it("bails out of inner sweep for zdd_4 with dom = { x | x % 2 == 0 } [const &]", [&]() { const zdd in = zdd_1; /* Expected: { Ø, {0}, {2}, {4} } @@ -533,32 +535,30 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(4, ptr_uint64::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, node::max_id, ptr_uint64(4, ptr_uint64::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -568,10 +568,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); }); - it("accounts for number of root arcs from Outer Sweep [const &]", [&](){ + it("accounts for number of root arcs from Outer Sweep [const &]", [&]() { const zdd in = zdd_6; /* Expected: { Ø, {5} } @@ -585,16 +585,14 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -604,7 +602,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); }); @@ -613,7 +611,7 @@ go_bandit([]() { & exec_policy::quantify::transposition_growth(1.5) & exec_policy::quantify::transposition_max(2); - it("computes with dom = Ø to be { Ø } for non-empty input [zdd_2]", [&](){ + it("computes with dom = Ø to be { Ø } for non-empty input [zdd_2]", [&]() { shared_file dom; zdd out = zdd_project(ep, zdd(zdd_2), [](zdd::label_type) { return false; }); @@ -633,10 +631,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("computes with disjoint dom = { x | x > 2 } to be { Ø } [zdd_3]", [&](){ + it("computes with disjoint dom = { x | x > 2 } to be { Ø } [zdd_3]", [&]() { zdd out = zdd_project(ep, zdd(zdd_3), [](zdd::label_type x) { return x > 2; }); node_test_stream out_nodes(out); @@ -654,10 +652,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("finishes during initial transposition in zdd_3 and dom = { x | x % 2 == 0 }", [&](){ + it("finishes during initial transposition in zdd_3 and dom = { x | x % 2 == 0 }", [&]() { /* Expected: { {0}, {2}, {0,2} } // // 1 ---- x0 @@ -678,24 +676,24 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -705,7 +703,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); // Check call history // @@ -722,12 +720,12 @@ go_bandit([]() { AssertThat(call_history.at(2), Is().EqualTo(0u)); // - First top-down sweep - AssertThat(call_history.at(3), Is().EqualTo(0u)); - AssertThat(call_history.at(4), Is().EqualTo(1u)); - AssertThat(call_history.at(5), Is().EqualTo(2u)); + AssertThat(call_history.at(3), Is().EqualTo(0u)); + AssertThat(call_history.at(4), Is().EqualTo(1u)); + AssertThat(call_history.at(5), Is().EqualTo(2u)); }); - it("computes zdd_1 with dom = { x | x % 2 == 1 }", [&](){ + it("computes zdd_1 with dom = { x | x % 2 == 1 }", [&]() { /* Expected: { Ø, {1}, {1,3} } // // 2 ---- x1 @@ -744,24 +742,24 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - ptr_uint64(3, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(3, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -771,10 +769,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); - it("computes zdd_1 with dom = { x | x != 0,2 }", [&](){ + it("computes zdd_1 with dom = { x | x != 0,2 }", [&]() { /* Expected: { Ø, {1}, {1,3}, {1,3,4} } // // 2 ---- x1 @@ -793,32 +791,32 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(3, node::max_id, terminal_T, ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - ptr_uint64(3, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(1, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(3, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -828,10 +826,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); - it("computes zdd_3 with dom = { x | x % 2 == 0 }", [&](){ + it("computes zdd_3 with dom = { x | x % 2 == 0 }", [&]() { /* Expected: { {0}, {2}, {0,2} } // // 1 ---- x0 @@ -848,24 +846,24 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -875,7 +873,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); it("quantifies exploding ZDD 5 with unbounded transpositions", [&]() { @@ -892,274 +890,356 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); // (o) / (n,o) - AssertThat(out_nodes.pull(), Is().EqualTo(node(13, node::max_id, - node::pointer_type(true), - node::pointer_type(true)))); + AssertThat(out_nodes.pull(), + Is().EqualTo( + node(13, node::max_id, node::pointer_type(true), node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); // (n) - AssertThat(out_nodes.pull(), Is().EqualTo(node(13, node::max_id-1, - node::pointer_type(false), - node::pointer_type(true)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node( + 13, node::max_id - 1, node::pointer_type(false), node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); // (17) - AssertThat(out_nodes.pull(), Is().EqualTo(node(12, node::max_id, - node::pointer_type(true), - node::pointer_type(true)))); + AssertThat(out_nodes.pull(), + Is().EqualTo( + node(12, node::max_id, node::pointer_type(true), node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); // (16) - AssertThat(out_nodes.pull(), Is().EqualTo(node(12, node::max_id-1, - node::pointer_type(false), - node::pointer_type(true)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node( + 12, node::max_id - 1, node::pointer_type(false), node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); // (16,o) / (16,o,n) - AssertThat(out_nodes.pull(), Is().EqualTo(node(12, node::max_id-2, - node::pointer_type(13, node::max_id), - node::pointer_type(true)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(12, + node::max_id - 2, + node::pointer_type(13, node::max_id), + node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); // (16,n) - AssertThat(out_nodes.pull(), Is().EqualTo(node(12, node::max_id-3, - node::pointer_type(13, node::max_id-1), - node::pointer_type(true)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(12, + node::max_id - 3, + node::pointer_type(13, node::max_id - 1), + node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); // (l) - AssertThat(out_nodes.pull(), Is().EqualTo(node(11, node::max_id, - node::pointer_type(13, node::max_id-1), - node::pointer_type(13, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(11, + node::max_id, + node::pointer_type(13, node::max_id - 1), + node::pointer_type(13, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (m) - AssertThat(out_nodes.pull(), Is().EqualTo(node(11, node::max_id-1, - node::pointer_type(13, node::max_id), - node::pointer_type(13, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(11, + node::max_id - 1, + node::pointer_type(13, node::max_id), + node::pointer_type(13, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // (14) - AssertThat(out_nodes.pull(), Is().EqualTo(node(11, node::max_id-2, - node::pointer_type(12, node::max_id-1), - node::pointer_type(12, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(11, + node::max_id - 2, + node::pointer_type(12, node::max_id - 1), + node::pointer_type(12, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (15) - AssertThat(out_nodes.pull(), Is().EqualTo(node(11, node::max_id-3, - node::pointer_type(12, node::max_id), - node::pointer_type(12, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(11, + node::max_id - 3, + node::pointer_type(12, node::max_id), + node::pointer_type(12, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // (TODO) - AssertThat(out_nodes.pull(), Is().EqualTo(node(11, node::max_id-4, - node::pointer_type(12, node::max_id-2), - node::pointer_type(12, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(11, + node::max_id - 4, + node::pointer_type(12, node::max_id - 2), + node::pointer_type(12, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (14,l) - AssertThat(out_nodes.pull(), Is().EqualTo(node(11, node::max_id-5, - node::pointer_type(12, node::max_id-3), - node::pointer_type(12, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(11, + node::max_id - 5, + node::pointer_type(12, node::max_id - 3), + node::pointer_type(12, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (15,m) - AssertThat(out_nodes.pull(), Is().EqualTo(node(11, node::max_id-6, - node::pointer_type(12, node::max_id-2), - node::pointer_type(12, node::max_id-3)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(11, + node::max_id - 6, + node::pointer_type(12, node::max_id - 2), + node::pointer_type(12, node::max_id - 3)))); AssertThat(out_nodes.can_pull(), Is().True()); // (k) - AssertThat(out_nodes.pull(), Is().EqualTo(node(10, node::max_id, - node::pointer_type(11, node::max_id-1), - node::pointer_type(11, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(10, + node::max_id, + node::pointer_type(11, node::max_id - 1), + node::pointer_type(11, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (j) - AssertThat(out_nodes.pull(), Is().EqualTo(node(10, node::max_id-1, - node::pointer_type(11, node::max_id), - node::pointer_type(11, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(10, + node::max_id - 1, + node::pointer_type(11, node::max_id), + node::pointer_type(11, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // (13) - AssertThat(out_nodes.pull(), Is().EqualTo(node(10, node::max_id-2, - node::pointer_type(11, node::max_id-3), - node::pointer_type(11, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(10, + node::max_id - 2, + node::pointer_type(11, node::max_id - 3), + node::pointer_type(11, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (12) - AssertThat(out_nodes.pull(), Is().EqualTo(node(10, node::max_id-3, - node::pointer_type(11, node::max_id-2), - node::pointer_type(11, node::max_id-3)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(10, + node::max_id - 3, + node::pointer_type(11, node::max_id - 2), + node::pointer_type(11, node::max_id - 3)))); AssertThat(out_nodes.can_pull(), Is().True()); // (TODO) - AssertThat(out_nodes.pull(), Is().EqualTo(node(10, node::max_id-4, - node::pointer_type(11, node::max_id-4), - node::pointer_type(11, node::max_id-4)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(10, + node::max_id - 4, + node::pointer_type(11, node::max_id - 4), + node::pointer_type(11, node::max_id - 4)))); AssertThat(out_nodes.can_pull(), Is().True()); // (13,k) - AssertThat(out_nodes.pull(), Is().EqualTo(node(10, node::max_id-5, - node::pointer_type(11, node::max_id-6), - node::pointer_type(11, node::max_id-5)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(10, + node::max_id - 5, + node::pointer_type(11, node::max_id - 6), + node::pointer_type(11, node::max_id - 5)))); AssertThat(out_nodes.can_pull(), Is().True()); // (12,j) - AssertThat(out_nodes.pull(), Is().EqualTo(node(10, node::max_id-6, - node::pointer_type(11, node::max_id-5), - node::pointer_type(11, node::max_id-6)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(10, + node::max_id - 6, + node::pointer_type(11, node::max_id - 5), + node::pointer_type(11, node::max_id - 6)))); AssertThat(out_nodes.can_pull(), Is().True()); // (h) - AssertThat(out_nodes.pull(), Is().EqualTo(node(9, node::max_id, - node::pointer_type(10, node::max_id-1), - node::pointer_type(10, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(9, + node::max_id, + node::pointer_type(10, node::max_id - 1), + node::pointer_type(10, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (i) - AssertThat(out_nodes.pull(), Is().EqualTo(node(9, node::max_id-1, - node::pointer_type(10, node::max_id), - node::pointer_type(10, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(9, + node::max_id - 1, + node::pointer_type(10, node::max_id), + node::pointer_type(10, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // (10) - AssertThat(out_nodes.pull(), Is().EqualTo(node(9, node::max_id-2, - node::pointer_type(10, node::max_id-3), - node::pointer_type(10, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(9, + node::max_id - 2, + node::pointer_type(10, node::max_id - 3), + node::pointer_type(10, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (11) - AssertThat(out_nodes.pull(), Is().EqualTo(node(9, node::max_id-3, - node::pointer_type(10, node::max_id-2), - node::pointer_type(10, node::max_id-3)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(9, + node::max_id - 3, + node::pointer_type(10, node::max_id - 2), + node::pointer_type(10, node::max_id - 3)))); AssertThat(out_nodes.can_pull(), Is().True()); // (TODO) - AssertThat(out_nodes.pull(), Is().EqualTo(node(9, node::max_id-4, - node::pointer_type(10, node::max_id-4), - node::pointer_type(10, node::max_id-4)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(9, + node::max_id - 4, + node::pointer_type(10, node::max_id - 4), + node::pointer_type(10, node::max_id - 4)))); AssertThat(out_nodes.can_pull(), Is().True()); // (10,h) - AssertThat(out_nodes.pull(), Is().EqualTo(node(9, node::max_id-5, - node::pointer_type(10, node::max_id-6), - node::pointer_type(10, node::max_id-5)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(9, + node::max_id - 5, + node::pointer_type(10, node::max_id - 6), + node::pointer_type(10, node::max_id - 5)))); AssertThat(out_nodes.can_pull(), Is().True()); // (11,i) - AssertThat(out_nodes.pull(), Is().EqualTo(node(9, node::max_id-6, - node::pointer_type(10, node::max_id-5), - node::pointer_type(10, node::max_id-6)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(9, + node::max_id - 6, + node::pointer_type(10, node::max_id - 5), + node::pointer_type(10, node::max_id - 6)))); AssertThat(out_nodes.can_pull(), Is().True()); // (g) - AssertThat(out_nodes.pull(), Is().EqualTo(node(8, node::max_id, - node::pointer_type(9, node::max_id-1), - node::pointer_type(9, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(8, + node::max_id, + node::pointer_type(9, node::max_id - 1), + node::pointer_type(9, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (f) - AssertThat(out_nodes.pull(), Is().EqualTo(node(8, node::max_id-1, - node::pointer_type(9, node::max_id), - node::pointer_type(9, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(8, + node::max_id - 1, + node::pointer_type(9, node::max_id), + node::pointer_type(9, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // (9) - AssertThat(out_nodes.pull(), Is().EqualTo(node(8, node::max_id-2, - node::pointer_type(9, node::max_id-3), - node::pointer_type(9, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(8, + node::max_id - 2, + node::pointer_type(9, node::max_id - 3), + node::pointer_type(9, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (8) - AssertThat(out_nodes.pull(), Is().EqualTo(node(8, node::max_id-3, - node::pointer_type(9, node::max_id-2), - node::pointer_type(9, node::max_id-3)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(8, + node::max_id - 3, + node::pointer_type(9, node::max_id - 2), + node::pointer_type(9, node::max_id - 3)))); AssertThat(out_nodes.can_pull(), Is().True()); // (8,g) - AssertThat(out_nodes.pull(), Is().EqualTo(node(8, node::max_id-4, - node::pointer_type(9, node::max_id-4), - node::pointer_type(9, node::max_id-4)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(8, + node::max_id - 4, + node::pointer_type(9, node::max_id - 4), + node::pointer_type(9, node::max_id - 4)))); AssertThat(out_nodes.can_pull(), Is().True()); // (8,f) - AssertThat(out_nodes.pull(), Is().EqualTo(node(8, node::max_id-5, - node::pointer_type(9, node::max_id-5), - node::pointer_type(9, node::max_id-6)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(8, + node::max_id - 5, + node::pointer_type(9, node::max_id - 5), + node::pointer_type(9, node::max_id - 6)))); AssertThat(out_nodes.can_pull(), Is().True()); // (7) - AssertThat(out_nodes.pull(), Is().EqualTo(node(7, node::max_id, - node::pointer_type(8, node::max_id-3), - node::pointer_type(8, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(7, + node::max_id, + node::pointer_type(8, node::max_id - 3), + node::pointer_type(8, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (7,g) - AssertThat(out_nodes.pull(), Is().EqualTo(node(7, node::max_id-1, - node::pointer_type(8, node::max_id-4), - node::pointer_type(8, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(7, + node::max_id - 1, + node::pointer_type(8, node::max_id - 4), + node::pointer_type(8, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (d) - AssertThat(out_nodes.pull(), Is().EqualTo(node(6, node::max_id, - node::pointer_type(8, node::max_id-1), - node::pointer_type(8, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(6, + node::max_id, + node::pointer_type(8, node::max_id - 1), + node::pointer_type(8, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (6) - AssertThat(out_nodes.pull(), Is().EqualTo(node(6, node::max_id-1, - node::pointer_type(7, node::max_id), - node::pointer_type(8, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(6, + node::max_id - 1, + node::pointer_type(7, node::max_id), + node::pointer_type(8, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (5) - AssertThat(out_nodes.pull(), Is().EqualTo(node(6, node::max_id-2, - node::pointer_type(8, node::max_id-3), - node::pointer_type(7, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(6, + node::max_id - 2, + node::pointer_type(8, node::max_id - 3), + node::pointer_type(7, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (5,d) - AssertThat(out_nodes.pull(), Is().EqualTo(node(6, node::max_id-3, - node::pointer_type(8, node::max_id-5), - node::pointer_type(7, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(6, + node::max_id - 3, + node::pointer_type(8, node::max_id - 5), + node::pointer_type(7, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // (c) - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, - node::pointer_type(6, node::max_id), - node::pointer_type(true)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node( + 5, node::max_id, node::pointer_type(6, node::max_id), node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); // (b,5,d) - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id-1, - node::pointer_type(6, node::max_id-3), - node::pointer_type(6, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(5, + node::max_id - 1, + node::pointer_type(6, node::max_id - 3), + node::pointer_type(6, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (4,b,5,d) - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id-2, - node::pointer_type(6, node::max_id-2), - node::pointer_type(6, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(5, + node::max_id - 2, + node::pointer_type(6, node::max_id - 2), + node::pointer_type(6, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // (3,b,5,d) - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - node::pointer_type(5, node::max_id-2), - node::pointer_type(true)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node( + 4, node::max_id, node::pointer_type(5, node::max_id - 2), node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); // (2,b,5,d) - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id-1, - node::pointer_type(5, node::max_id-1), - node::pointer_type(5, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(4, + node::max_id - 1, + node::pointer_type(5, node::max_id - 1), + node::pointer_type(5, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (1,b,5,d) - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - node::pointer_type(4, node::max_id-1), - node::pointer_type(4, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(3, + node::max_id, + node::pointer_type(4, node::max_id - 1), + node::pointer_type(4, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (1,a,5,d) - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - node::pointer_type(3, node::max_id), - node::pointer_type(5, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id, + node::pointer_type(3, node::max_id), + node::pointer_type(5, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(13u,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(13u, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(12u,4u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(12u, 4u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(11u,7u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(11u, 7u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(10u,7u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(10u, 7u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(9u,7u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(9u, 7u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(8u,6u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(8u, 6u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(7u,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(7u, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(6u,4u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(6u, 4u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5u,3u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5u, 3u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(4u,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(4u, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3u,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3u, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2u,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2u, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1173,16 +1253,16 @@ go_bandit([]() { AssertThat(call_history.size(), Is().EqualTo(42u)); // - First check for at least one variable satisfying the predicate. - AssertThat(call_history.at(0), Is().EqualTo(13u)); - AssertThat(call_history.at(1), Is().EqualTo(12u)); - AssertThat(call_history.at(2), Is().EqualTo(11u)); - AssertThat(call_history.at(3), Is().EqualTo(10u)); - AssertThat(call_history.at(4), Is().EqualTo(9u)); - AssertThat(call_history.at(5), Is().EqualTo(8u)); - AssertThat(call_history.at(6), Is().EqualTo(7u)); - AssertThat(call_history.at(7), Is().EqualTo(6u)); - AssertThat(call_history.at(8), Is().EqualTo(5u)); - AssertThat(call_history.at(9), Is().EqualTo(4u)); + AssertThat(call_history.at(0), Is().EqualTo(13u)); + AssertThat(call_history.at(1), Is().EqualTo(12u)); + AssertThat(call_history.at(2), Is().EqualTo(11u)); + AssertThat(call_history.at(3), Is().EqualTo(10u)); + AssertThat(call_history.at(4), Is().EqualTo(9u)); + AssertThat(call_history.at(5), Is().EqualTo(8u)); + AssertThat(call_history.at(6), Is().EqualTo(7u)); + AssertThat(call_history.at(7), Is().EqualTo(6u)); + AssertThat(call_history.at(8), Is().EqualTo(5u)); + AssertThat(call_history.at(9), Is().EqualTo(4u)); AssertThat(call_history.at(10), Is().EqualTo(3u)); AssertThat(call_history.at(11), Is().EqualTo(2u)); AssertThat(call_history.at(12), Is().EqualTo(1u)); @@ -1239,274 +1319,356 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); // (o) / (n,o) - AssertThat(out_nodes.pull(), Is().EqualTo(node(13, node::max_id, - node::pointer_type(true), - node::pointer_type(true)))); + AssertThat(out_nodes.pull(), + Is().EqualTo( + node(13, node::max_id, node::pointer_type(true), node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); // (n) - AssertThat(out_nodes.pull(), Is().EqualTo(node(13, node::max_id-1, - node::pointer_type(false), - node::pointer_type(true)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node( + 13, node::max_id - 1, node::pointer_type(false), node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); // (17) - AssertThat(out_nodes.pull(), Is().EqualTo(node(12, node::max_id, - node::pointer_type(true), - node::pointer_type(true)))); + AssertThat(out_nodes.pull(), + Is().EqualTo( + node(12, node::max_id, node::pointer_type(true), node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); // (16) - AssertThat(out_nodes.pull(), Is().EqualTo(node(12, node::max_id-1, - node::pointer_type(false), - node::pointer_type(true)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node( + 12, node::max_id - 1, node::pointer_type(false), node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); // (16,o) / (16,o,n) - AssertThat(out_nodes.pull(), Is().EqualTo(node(12, node::max_id-2, - node::pointer_type(13, node::max_id), - node::pointer_type(true)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(12, + node::max_id - 2, + node::pointer_type(13, node::max_id), + node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); // (16,n) - AssertThat(out_nodes.pull(), Is().EqualTo(node(12, node::max_id-3, - node::pointer_type(13, node::max_id-1), - node::pointer_type(true)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(12, + node::max_id - 3, + node::pointer_type(13, node::max_id - 1), + node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); // (l) - AssertThat(out_nodes.pull(), Is().EqualTo(node(11, node::max_id, - node::pointer_type(13, node::max_id-1), - node::pointer_type(13, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(11, + node::max_id, + node::pointer_type(13, node::max_id - 1), + node::pointer_type(13, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (m) - AssertThat(out_nodes.pull(), Is().EqualTo(node(11, node::max_id-1, - node::pointer_type(13, node::max_id), - node::pointer_type(13, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(11, + node::max_id - 1, + node::pointer_type(13, node::max_id), + node::pointer_type(13, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // (14) - AssertThat(out_nodes.pull(), Is().EqualTo(node(11, node::max_id-2, - node::pointer_type(12, node::max_id-1), - node::pointer_type(12, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(11, + node::max_id - 2, + node::pointer_type(12, node::max_id - 1), + node::pointer_type(12, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (15) - AssertThat(out_nodes.pull(), Is().EqualTo(node(11, node::max_id-3, - node::pointer_type(12, node::max_id), - node::pointer_type(12, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(11, + node::max_id - 3, + node::pointer_type(12, node::max_id), + node::pointer_type(12, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // (TODO) - AssertThat(out_nodes.pull(), Is().EqualTo(node(11, node::max_id-4, - node::pointer_type(12, node::max_id-2), - node::pointer_type(12, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(11, + node::max_id - 4, + node::pointer_type(12, node::max_id - 2), + node::pointer_type(12, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (14,l) - AssertThat(out_nodes.pull(), Is().EqualTo(node(11, node::max_id-5, - node::pointer_type(12, node::max_id-3), - node::pointer_type(12, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(11, + node::max_id - 5, + node::pointer_type(12, node::max_id - 3), + node::pointer_type(12, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (15,m) - AssertThat(out_nodes.pull(), Is().EqualTo(node(11, node::max_id-6, - node::pointer_type(12, node::max_id-2), - node::pointer_type(12, node::max_id-3)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(11, + node::max_id - 6, + node::pointer_type(12, node::max_id - 2), + node::pointer_type(12, node::max_id - 3)))); AssertThat(out_nodes.can_pull(), Is().True()); // (k) - AssertThat(out_nodes.pull(), Is().EqualTo(node(10, node::max_id, - node::pointer_type(11, node::max_id-1), - node::pointer_type(11, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(10, + node::max_id, + node::pointer_type(11, node::max_id - 1), + node::pointer_type(11, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (j) - AssertThat(out_nodes.pull(), Is().EqualTo(node(10, node::max_id-1, - node::pointer_type(11, node::max_id), - node::pointer_type(11, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(10, + node::max_id - 1, + node::pointer_type(11, node::max_id), + node::pointer_type(11, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // (13) - AssertThat(out_nodes.pull(), Is().EqualTo(node(10, node::max_id-2, - node::pointer_type(11, node::max_id-3), - node::pointer_type(11, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(10, + node::max_id - 2, + node::pointer_type(11, node::max_id - 3), + node::pointer_type(11, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (12) - AssertThat(out_nodes.pull(), Is().EqualTo(node(10, node::max_id-3, - node::pointer_type(11, node::max_id-2), - node::pointer_type(11, node::max_id-3)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(10, + node::max_id - 3, + node::pointer_type(11, node::max_id - 2), + node::pointer_type(11, node::max_id - 3)))); AssertThat(out_nodes.can_pull(), Is().True()); // (TODO) - AssertThat(out_nodes.pull(), Is().EqualTo(node(10, node::max_id-4, - node::pointer_type(11, node::max_id-4), - node::pointer_type(11, node::max_id-4)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(10, + node::max_id - 4, + node::pointer_type(11, node::max_id - 4), + node::pointer_type(11, node::max_id - 4)))); AssertThat(out_nodes.can_pull(), Is().True()); // (13,k) - AssertThat(out_nodes.pull(), Is().EqualTo(node(10, node::max_id-5, - node::pointer_type(11, node::max_id-6), - node::pointer_type(11, node::max_id-5)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(10, + node::max_id - 5, + node::pointer_type(11, node::max_id - 6), + node::pointer_type(11, node::max_id - 5)))); AssertThat(out_nodes.can_pull(), Is().True()); // (12,j) - AssertThat(out_nodes.pull(), Is().EqualTo(node(10, node::max_id-6, - node::pointer_type(11, node::max_id-5), - node::pointer_type(11, node::max_id-6)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(10, + node::max_id - 6, + node::pointer_type(11, node::max_id - 5), + node::pointer_type(11, node::max_id - 6)))); AssertThat(out_nodes.can_pull(), Is().True()); // (h) - AssertThat(out_nodes.pull(), Is().EqualTo(node(9, node::max_id, - node::pointer_type(10, node::max_id-1), - node::pointer_type(10, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(9, + node::max_id, + node::pointer_type(10, node::max_id - 1), + node::pointer_type(10, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (i) - AssertThat(out_nodes.pull(), Is().EqualTo(node(9, node::max_id-1, - node::pointer_type(10, node::max_id), - node::pointer_type(10, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(9, + node::max_id - 1, + node::pointer_type(10, node::max_id), + node::pointer_type(10, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // (10) - AssertThat(out_nodes.pull(), Is().EqualTo(node(9, node::max_id-2, - node::pointer_type(10, node::max_id-3), - node::pointer_type(10, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(9, + node::max_id - 2, + node::pointer_type(10, node::max_id - 3), + node::pointer_type(10, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (11) - AssertThat(out_nodes.pull(), Is().EqualTo(node(9, node::max_id-3, - node::pointer_type(10, node::max_id-2), - node::pointer_type(10, node::max_id-3)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(9, + node::max_id - 3, + node::pointer_type(10, node::max_id - 2), + node::pointer_type(10, node::max_id - 3)))); AssertThat(out_nodes.can_pull(), Is().True()); // (TODO) - AssertThat(out_nodes.pull(), Is().EqualTo(node(9, node::max_id-4, - node::pointer_type(10, node::max_id-4), - node::pointer_type(10, node::max_id-4)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(9, + node::max_id - 4, + node::pointer_type(10, node::max_id - 4), + node::pointer_type(10, node::max_id - 4)))); AssertThat(out_nodes.can_pull(), Is().True()); // (10,h) - AssertThat(out_nodes.pull(), Is().EqualTo(node(9, node::max_id-5, - node::pointer_type(10, node::max_id-6), - node::pointer_type(10, node::max_id-5)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(9, + node::max_id - 5, + node::pointer_type(10, node::max_id - 6), + node::pointer_type(10, node::max_id - 5)))); AssertThat(out_nodes.can_pull(), Is().True()); // (11,i) - AssertThat(out_nodes.pull(), Is().EqualTo(node(9, node::max_id-6, - node::pointer_type(10, node::max_id-5), - node::pointer_type(10, node::max_id-6)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(9, + node::max_id - 6, + node::pointer_type(10, node::max_id - 5), + node::pointer_type(10, node::max_id - 6)))); AssertThat(out_nodes.can_pull(), Is().True()); // (g) - AssertThat(out_nodes.pull(), Is().EqualTo(node(8, node::max_id, - node::pointer_type(9, node::max_id-1), - node::pointer_type(9, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(8, + node::max_id, + node::pointer_type(9, node::max_id - 1), + node::pointer_type(9, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (f) - AssertThat(out_nodes.pull(), Is().EqualTo(node(8, node::max_id-1, - node::pointer_type(9, node::max_id), - node::pointer_type(9, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(8, + node::max_id - 1, + node::pointer_type(9, node::max_id), + node::pointer_type(9, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // (9) - AssertThat(out_nodes.pull(), Is().EqualTo(node(8, node::max_id-2, - node::pointer_type(9, node::max_id-3), - node::pointer_type(9, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(8, + node::max_id - 2, + node::pointer_type(9, node::max_id - 3), + node::pointer_type(9, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (8) - AssertThat(out_nodes.pull(), Is().EqualTo(node(8, node::max_id-3, - node::pointer_type(9, node::max_id-2), - node::pointer_type(9, node::max_id-3)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(8, + node::max_id - 3, + node::pointer_type(9, node::max_id - 2), + node::pointer_type(9, node::max_id - 3)))); AssertThat(out_nodes.can_pull(), Is().True()); // (8,g) - AssertThat(out_nodes.pull(), Is().EqualTo(node(8, node::max_id-4, - node::pointer_type(9, node::max_id-4), - node::pointer_type(9, node::max_id-4)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(8, + node::max_id - 4, + node::pointer_type(9, node::max_id - 4), + node::pointer_type(9, node::max_id - 4)))); AssertThat(out_nodes.can_pull(), Is().True()); // (8,f) - AssertThat(out_nodes.pull(), Is().EqualTo(node(8, node::max_id-5, - node::pointer_type(9, node::max_id-5), - node::pointer_type(9, node::max_id-6)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(8, + node::max_id - 5, + node::pointer_type(9, node::max_id - 5), + node::pointer_type(9, node::max_id - 6)))); AssertThat(out_nodes.can_pull(), Is().True()); // (7) - AssertThat(out_nodes.pull(), Is().EqualTo(node(7, node::max_id, - node::pointer_type(8, node::max_id-3), - node::pointer_type(8, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(7, + node::max_id, + node::pointer_type(8, node::max_id - 3), + node::pointer_type(8, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (7,g) - AssertThat(out_nodes.pull(), Is().EqualTo(node(7, node::max_id-1, - node::pointer_type(8, node::max_id-4), - node::pointer_type(8, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(7, + node::max_id - 1, + node::pointer_type(8, node::max_id - 4), + node::pointer_type(8, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (d) - AssertThat(out_nodes.pull(), Is().EqualTo(node(6, node::max_id, - node::pointer_type(8, node::max_id-1), - node::pointer_type(8, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(6, + node::max_id, + node::pointer_type(8, node::max_id - 1), + node::pointer_type(8, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (6) - AssertThat(out_nodes.pull(), Is().EqualTo(node(6, node::max_id-1, - node::pointer_type(7, node::max_id), - node::pointer_type(8, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(6, + node::max_id - 1, + node::pointer_type(7, node::max_id), + node::pointer_type(8, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (5) - AssertThat(out_nodes.pull(), Is().EqualTo(node(6, node::max_id-2, - node::pointer_type(8, node::max_id-3), - node::pointer_type(7, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(6, + node::max_id - 2, + node::pointer_type(8, node::max_id - 3), + node::pointer_type(7, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (5,d) - AssertThat(out_nodes.pull(), Is().EqualTo(node(6, node::max_id-3, - node::pointer_type(8, node::max_id-5), - node::pointer_type(7, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(6, + node::max_id - 3, + node::pointer_type(8, node::max_id - 5), + node::pointer_type(7, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // (c) - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, - node::pointer_type(6, node::max_id), - node::pointer_type(true)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node( + 5, node::max_id, node::pointer_type(6, node::max_id), node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); // (b,5,d) - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id-1, - node::pointer_type(6, node::max_id-3), - node::pointer_type(6, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(5, + node::max_id - 1, + node::pointer_type(6, node::max_id - 3), + node::pointer_type(6, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (4,b,5,d) - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id-2, - node::pointer_type(6, node::max_id-2), - node::pointer_type(6, node::max_id-1)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(5, + node::max_id - 2, + node::pointer_type(6, node::max_id - 2), + node::pointer_type(6, node::max_id - 1)))); AssertThat(out_nodes.can_pull(), Is().True()); // (3,b,5,d) - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - node::pointer_type(5, node::max_id-2), - node::pointer_type(true)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node( + 4, node::max_id, node::pointer_type(5, node::max_id - 2), node::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().True()); // (2,b,5,d) - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id-1, - node::pointer_type(5, node::max_id-1), - node::pointer_type(5, node::max_id-2)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(4, + node::max_id - 1, + node::pointer_type(5, node::max_id - 1), + node::pointer_type(5, node::max_id - 2)))); AssertThat(out_nodes.can_pull(), Is().True()); // (1,b,5,d) - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - node::pointer_type(4, node::max_id-1), - node::pointer_type(4, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(3, + node::max_id, + node::pointer_type(4, node::max_id - 1), + node::pointer_type(4, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); // (1,a,5,d) - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - node::pointer_type(3, node::max_id), - node::pointer_type(5, node::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id, + node::pointer_type(3, node::max_id), + node::pointer_type(5, node::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream out_meta(out); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(13u,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(13u, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(12u,4u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(12u, 4u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(11u,7u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(11u, 7u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(10u,7u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(10u, 7u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(9u,7u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(9u, 7u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(8u,6u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(8u, 6u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(7u,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(7u, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(6u,4u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(6u, 4u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(5u,3u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(5u, 3u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(4u,2u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(4u, 2u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(3u,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(3u, 1u))); AssertThat(out_meta.can_pull(), Is().True()); - AssertThat(out_meta.pull(), Is().EqualTo(level_info(2u,1u))); + AssertThat(out_meta.pull(), Is().EqualTo(level_info(2u, 1u))); AssertThat(out_meta.can_pull(), Is().False()); @@ -1520,16 +1682,16 @@ go_bandit([]() { AssertThat(call_history.size(), Is().EqualTo(41u)); // - First check for at least one variable satisfying the predicate. - AssertThat(call_history.at(0), Is().EqualTo(13u)); - AssertThat(call_history.at(1), Is().EqualTo(12u)); - AssertThat(call_history.at(2), Is().EqualTo(11u)); - AssertThat(call_history.at(3), Is().EqualTo(10u)); - AssertThat(call_history.at(4), Is().EqualTo(9u)); - AssertThat(call_history.at(5), Is().EqualTo(8u)); - AssertThat(call_history.at(6), Is().EqualTo(7u)); - AssertThat(call_history.at(7), Is().EqualTo(6u)); - AssertThat(call_history.at(8), Is().EqualTo(5u)); - AssertThat(call_history.at(9), Is().EqualTo(4u)); + AssertThat(call_history.at(0), Is().EqualTo(13u)); + AssertThat(call_history.at(1), Is().EqualTo(12u)); + AssertThat(call_history.at(2), Is().EqualTo(11u)); + AssertThat(call_history.at(3), Is().EqualTo(10u)); + AssertThat(call_history.at(4), Is().EqualTo(9u)); + AssertThat(call_history.at(5), Is().EqualTo(8u)); + AssertThat(call_history.at(6), Is().EqualTo(7u)); + AssertThat(call_history.at(7), Is().EqualTo(6u)); + AssertThat(call_history.at(8), Is().EqualTo(5u)); + AssertThat(call_history.at(9), Is().EqualTo(4u)); AssertThat(call_history.at(10), Is().EqualTo(3u)); AssertThat(call_history.at(11), Is().EqualTo(2u)); AssertThat(call_history.at(12), Is().EqualTo(1u)); @@ -1572,48 +1734,40 @@ go_bandit([]() { }); describe("zdd_project(const zdd&, const generator&)", [&]() { - it("returns same file for Ø with dom = {6,4,2,0} [const &]", [&](){ + it("returns same file for Ø with dom = {6,4,2,0} [const &]", [&]() { const zdd in = zdd_empty; - zdd out = zdd_project(in, [var = 6]() mutable -> optional { - if (var == 42) { - return {}; - } + zdd out = zdd_project(in, [var = 6]() mutable -> optional { + if (var == 42) { return {}; } const zdd::label_type ret = var; - var = ret == 1 ? 42 : var-2; - return {ret}; + var = ret == 1 ? 42 : var - 2; + return { ret }; }); AssertThat(out.file_ptr(), Is().EqualTo(in.file_ptr())); }); - it("returns same file for { Ø } with dom = {5,3,1} [&&]", [&](){ + it("returns same file for { Ø } with dom = {5,3,1} [&&]", [&]() { zdd out = zdd_project(zdd(zdd_null), [var = 5]() mutable -> optional { - if (var == 42) { - return {}; - } + if (var == 42) { return {}; } const zdd::label_type ret = var; - var = ret == 1 ? 42 : var-2; - return {ret}; + var = ret == 1 ? 42 : var - 2; + return { ret }; }); AssertThat(out.file_ptr(), Is().EqualTo(zdd_null)); }); - it("returns same file for Ø with dom = Ø [&&]", [&](){ - zdd out = zdd_project(zdd(zdd_empty), []() { - return make_optional(); - }); + it("returns same file for Ø with dom = Ø [&&]", [&]() { + zdd out = zdd_project(zdd(zdd_empty), []() { return make_optional(); }); AssertThat(out.file_ptr(), Is().EqualTo(zdd_empty)); }); - it("returns same file for { Ø } with dom = Ø [const &]", [&](){ + it("returns same file for { Ø } with dom = Ø [const &]", [&]() { const zdd in = zdd_null; - zdd out = zdd_project(in, []() -> optional { - return {}; - }); + zdd out = zdd_project(in, []() -> optional { return {}; }); AssertThat(out.file_ptr(), Is().EqualTo(in.file_ptr())); }); @@ -1621,11 +1775,9 @@ go_bandit([]() { describe("algorithm: Singleton", [&]() { const exec_policy ep = exec_policy::quantify::Singleton; - it("collapses zdd_1 with dom = Ø into { Ø } [const &]", [&](){ + it("collapses zdd_1 with dom = Ø into { Ø } [const &]", [&]() { const zdd in = zdd_1; - zdd out = zdd_project(in, []() -> optional { - return {}; - }); + zdd out = zdd_project(in, []() -> optional { return {}; }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); @@ -1642,13 +1794,11 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("collapses zdd_2 with dom = Ø into { Ø } [&&]", [&](){ - zdd out = zdd_project(ep, zdd(zdd_2), []() -> optional { - return {}; - }); + it("collapses zdd_2 with dom = Ø into { Ø } [&&]", [&]() { + zdd out = zdd_project(ep, zdd(zdd_2), []() -> optional { return {}; }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); @@ -1665,14 +1815,12 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("collapses zdd_3 with dom = Ø into { Ø } [const &]", [&](){ + it("collapses zdd_3 with dom = Ø into { Ø } [const &]", [&]() { const zdd in = zdd_3; - zdd out = zdd_project(ep, in, []() -> optional { - return {}; - }); + zdd out = zdd_project(ep, in, []() -> optional { return {}; }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); @@ -1689,20 +1837,18 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("collapses zdd_2 with disjoint domain into { Ø } [const &]", [&](){ + it("collapses zdd_2 with disjoint domain into { Ø } [const &]", [&]() { const zdd in = zdd_2; zdd out = zdd_project(ep, in, [var = 1]() mutable -> optional { - if (var == 0) { - return {}; - } + if (var == 0) { return {}; } const zdd::label_type ret = var; var--; - return {ret}; + return { ret }; }); node_test_stream out_nodes(out); @@ -1720,16 +1866,15 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("computes with disjoint dom to be { Ø } [zdd_3] [&&]", [&](){ + it("computes with disjoint dom to be { Ø } [zdd_3] [&&]", [&]() { zdd::label_type var = 5; - zdd out = zdd_project(ep, zdd(zdd_3), [&var]() { - return 3 <= var && var <= 5 - ? make_optional(var--) - : make_optional(); - }); + zdd out = zdd_project(ep, zdd(zdd_3), [&var]() { + return 3 <= var && var <= 5 ? make_optional(var--) + : make_optional(); + }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); @@ -1746,7 +1891,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); ////////////////////// @@ -1757,9 +1902,10 @@ go_bandit([]() { nw << node(1u, node::max_id, ptr_uint64(false), ptr_uint64(true)); } - it("returns { Ø } for {1} with dom = {0} [const &]", [&](){ + it("returns { Ø } for {1} with dom = {0} [const &]", [&]() { shared_file dom; - { label_writer lw(dom); + { + label_writer lw(dom); lw << 0; } @@ -1771,9 +1917,8 @@ go_bandit([]() { */ zdd out = zdd_project(ep, in, [var = 0]() mutable { - return var == 0 - ? make_optional(var--) - : make_optional(); + return var == 0 ? make_optional(var--) + : make_optional(); }); node_test_stream out_nodes(out); @@ -1791,10 +1936,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("returns { 1 } for {1} with dom = {1,0} [const &]", [&](){ + it("returns { 1 } for {1} with dom = {1,0} [const &]", [&]() { const zdd in = zdd_x1; /* Expected: { 1 } @@ -1804,22 +1949,21 @@ go_bandit([]() { * F T */ zdd out = zdd_project(ep, in, [var = 1]() mutable { - return 0 <= var - ? make_optional(var--) - : make_optional(); + return 0 <= var ? make_optional(var--) + : make_optional(); }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, - zdd::pointer_type(false), - zdd::pointer_type(true)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, zdd::pointer_type(false), zdd::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(out->max_1level_cut[cut::Internal], Is().GreaterThanOrEqualTo(0u)); @@ -1828,12 +1972,12 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); ////////////////////// // Non-terminal general case - it("computes zdd_1 with dom = {4,3,2} [const &]", [&](){ + it("computes zdd_1 with dom = {4,3,2} [const &]", [&]() { const zdd in = zdd_1; /* Expected: { Ø, {2}, {3}, {3,4} } @@ -1847,41 +1991,37 @@ go_bandit([]() { // T T */ zdd out = zdd_project(ep, in, [var = 4]() mutable { - return 2 <= var && var <= 4 - ? make_optional(var--) - : make_optional(); + return 2 <= var && var <= 4 ? make_optional(var--) + : make_optional(); }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(3, node::max_id, terminal_T, ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, node::max_id, ptr_uint64(3, ptr_uint64::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,1u))); - + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1891,10 +2031,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); }); - it("computes zdd_2 with dom = {4,3,2} [&&]", [&](){ + it("computes zdd_2 with dom = {4,3,2} [&&]", [&]() { /* Expected: { Ø, {2}, {3}, {2,4} } // // 1 ---- x2 @@ -1906,41 +2046,37 @@ go_bandit([]() { // T T */ zdd out = zdd_project(ep, zdd_2, [var = 4]() mutable { - return 2 <= var && var <= 4 - ? make_optional(var--) - : make_optional(); + return 2 <= var && var <= 4 ? make_optional(var--) + : make_optional(); }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,1u))); - + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -1950,10 +2086,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); }); - it("computes zdd_3 with dom = {4,2,0} [&&]", [&](){ + it("computes zdd_3 with dom = {4,2,0} [&&]", [&]() { /* Expected: { {0}, {2}, {0,2} } // // 1 ---- x0 @@ -1965,36 +2101,34 @@ go_bandit([]() { // T T */ zdd out = zdd_project(ep, zdd_3, [var = 4]() mutable -> optional { - if (var == 42) { - return {}; - } + if (var == 42) { return {}; } const zdd::label_type ret = var; - var = ret == 0 ? 42 : var-2; - return {ret}; + var = ret == 0 ? 42 : var - 2; + return { ret }; }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2004,10 +2138,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); - it("computes zdd_4 with dom = {4,0} [&&]", [&](){ + it("computes zdd_4 with dom = {4,0} [&&]", [&]() { /* Expected: { {0}, {4}, {0,4} } // // 1 ---- x0 @@ -2019,41 +2153,38 @@ go_bandit([]() { // F T T T */ zdd out = zdd_project(ep, zdd_4, [var = 4]() mutable -> optional { - if (var == 42) { - return {}; - } + if (var == 42) { return {}; } - const zdd::label_type ret = var; - var = ret == 0 ? 42 : var-4; - return {ret}; - }); + const zdd::label_type ret = var; + var = ret == 0 ? 42 : var - 4; + return { ret }; + }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id-1, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(4, node::max_id - 1, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(4, ptr_uint64::max_id-1), - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(4, ptr_uint64::max_id - 1), + ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,2u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 2u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2063,10 +2194,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); - it("computes zdd_4 with dom = {4,2} [&&]", [&](){ + it("computes zdd_4 with dom = {4,2} [&&]", [&]() { /* Expected: { {2}, {4}, {2,4} } // // 1 ---- x2 @@ -2076,42 +2207,42 @@ go_bandit([]() { // F T */ zdd out = zdd_project(ep, zdd_4, [var = 4]() mutable -> optional { - if (var == 42) { - return make_optional(); - } + if (var == 42) { return make_optional(); } const zdd::label_type res = var; - if (var == 4) { var -= 2; } - else { var = 42; } + if (var == 4) { + var -= 2; + } else { + var = 42; + } return res; }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id-1, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(4, node::max_id - 1, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(4, ptr_uint64::max_id-1), - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id, + ptr_uint64(4, ptr_uint64::max_id - 1), + ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,2u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 2u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2121,18 +2252,16 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); }); describe("algorithm: Nested, max: _", [&]() { const exec_policy ep = exec_policy::quantify::Nested; - it("collapses zdd_1 with dom = Ø into { Ø } [const &]", [&](){ + it("collapses zdd_1 with dom = Ø into { Ø } [const &]", [&]() { const zdd in = zdd_1; - zdd out = zdd_project(ep, in, []() -> optional { - return {}; - }); + zdd out = zdd_project(ep, in, []() -> optional { return {}; }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); @@ -2149,13 +2278,11 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("collapses zdd_2 with dom = Ø into { Ø } [&&]", [&](){ - zdd out = zdd_project(ep, zdd(zdd_2), []() -> optional { - return {}; - }); + it("collapses zdd_2 with dom = Ø into { Ø } [&&]", [&]() { + zdd out = zdd_project(ep, zdd(zdd_2), []() -> optional { return {}; }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); @@ -2172,14 +2299,12 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("collapses zdd_3 with dom = Ø into { Ø } [const &]", [&](){ + it("collapses zdd_3 with dom = Ø into { Ø } [const &]", [&]() { const zdd in = zdd_3; - zdd out = zdd_project(ep, in, []() -> optional { - return {}; - }); + zdd out = zdd_project(ep, in, []() -> optional { return {}; }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); @@ -2196,17 +2321,15 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("collapses zdd_2 with disjoint domain into { Ø } [const &]", [&](){ + it("collapses zdd_2 with disjoint domain into { Ø } [const &]", [&]() { const zdd in = zdd_2; - zdd out = zdd_project(ep, in, [var = 1]() mutable -> optional { - if (var != 1) { - return {}; - } - return {var--}; - }); + zdd out = zdd_project(ep, in, [var = 1]() mutable -> optional { + if (var != 1) { return {}; } + return { var-- }; + }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); @@ -2223,14 +2346,13 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("computes with disjoint dom to be { Ø } [zdd_3] [&&]", [&](){ + it("computes with disjoint dom to be { Ø } [zdd_3] [&&]", [&]() { zdd out = zdd_project(ep, zdd(zdd_3), [var = 5]() mutable { - return 3 <= var && var <= 5 - ? make_optional(var--) - : make_optional(); + return 3 <= var && var <= 5 ? make_optional(var--) + : make_optional(); }); node_test_stream out_nodes(out); @@ -2248,7 +2370,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); // TODO: Shortcut on nothing to do @@ -2261,9 +2383,10 @@ go_bandit([]() { nw << node(1u, node::max_id, ptr_uint64(false), ptr_uint64(true)); } - it("returns { Ø } for {1} with dom = {0} [const &]", [&](){ + it("returns { Ø } for {1} with dom = {0} [const &]", [&]() { shared_file dom; - { label_writer lw(dom); + { + label_writer lw(dom); lw << 0; } @@ -2274,9 +2397,8 @@ go_bandit([]() { * T */ zdd out = zdd_project(ep, in, [var = 0]() mutable { - return var == 0 - ? make_optional(var--) - : make_optional(); + return var == 0 ? make_optional(var--) + : make_optional(); }); node_test_stream out_nodes(out); @@ -2294,10 +2416,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); - it("returns { 1 } for {1} with dom = {1,0} [const &]", [&](){ + it("returns { 1 } for {1} with dom = {1,0} [const &]", [&]() { const zdd in = zdd_x1; /* Expected: { 1 } @@ -2307,20 +2429,21 @@ go_bandit([]() { * F T */ zdd out = zdd_project(ep, in, [var = 1]() mutable { - return 0 <= var - ? make_optional(var--) - : make_optional(); + return 0 <= var ? make_optional(var--) + : make_optional(); }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(1, node::max_id, zdd::pointer_type(false), zdd::pointer_type(true)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(1, node::max_id, zdd::pointer_type(false), zdd::pointer_type(true)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(ms.can_pull(), Is().False()); AssertThat(out->max_1level_cut[cut::Internal], Is().GreaterThanOrEqualTo(0u)); @@ -2329,12 +2452,12 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(1u)); }); ////////////////////// // Non-terminal general case - it("computes zdd_1 with dom = {4,3,2} [const &]", [&](){ + it("computes zdd_1 with dom = {4,3,2} [const &]", [&]() { const zdd in = zdd_1; /* Expected: { Ø, {2}, {3}, {3,4} } @@ -2348,41 +2471,37 @@ go_bandit([]() { // T T */ zdd out = zdd_project(ep, in, [var = 4]() mutable { - return 2 <= var && var <= 4 - ? make_optional(var--) - : make_optional(); + return 2 <= var && var <= 4 ? make_optional(var--) + : make_optional(); }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(3, node::max_id, terminal_T, ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, node::max_id, ptr_uint64(3, ptr_uint64::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,1u))); - + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2392,10 +2511,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); }); - it("computes zdd_2 with dom = {4,3,2} [&&]", [&](){ + it("computes zdd_2 with dom = {4,3,2} [&&]", [&]() { /* Expected: { Ø, {2}, {3}, {2,4} } // // 1 ---- x2 @@ -2407,41 +2526,37 @@ go_bandit([]() { // T T */ zdd out = zdd_project(ep, zdd_2, [var = 4]() mutable { - return 2 <= var && var <= 4 - ? make_optional(var--) - : make_optional(); + return 2 <= var && var <= 4 ? make_optional(var--) + : make_optional(); }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,1u))); - + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2451,10 +2566,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); }); - it("computes zdd_3 with dom = {4,2,0} [&&]", [&](){ + it("computes zdd_3 with dom = {4,2,0} [&&]", [&]() { /* Expected: { {0}, {2}, {0,2} } // // 1 ---- x0 @@ -2466,36 +2581,34 @@ go_bandit([]() { // T T */ zdd out = zdd_project(ep, zdd_3, [var = 4]() mutable -> optional { - if (var == 42) { - return make_optional(); - } + if (var == 42) { return make_optional(); } const zdd::label_type ret = var; - var = ret == 0 ? 42 : var-2; + var = ret == 0 ? 42 : var - 2; return ret; }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2505,10 +2618,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); - it("computes zdd_4 with dom = {4,0} [&&]", [&](){ + it("computes zdd_4 with dom = {4,0} [&&]", [&]() { /* Expected: { {0}, {4}, {0,4} } // // 1 ---- x0 @@ -2520,41 +2633,38 @@ go_bandit([]() { // F T T T */ zdd out = zdd_project(ep, zdd_4, [var = 4]() mutable -> optional { - if (var == 42) { - return {}; - } + if (var == 42) { return {}; } const zdd::label_type ret = var; - var = ret == 0 ? 42 : var-4; - return {ret}; + var = ret == 0 ? 42 : var - 4; + return { ret }; }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id-1, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(4, node::max_id - 1, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(4, ptr_uint64::max_id-1), - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(4, ptr_uint64::max_id - 1), + ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,2u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 2u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2564,10 +2674,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); - it("computes zdd_4 with dom = {4,2} [&&]", [&](){ + it("computes zdd_4 with dom = {4,2} [&&]", [&]() { /* Expected: { {2}, {4}, {2,4} } // // 1 ---- x2 @@ -2577,42 +2687,42 @@ go_bandit([]() { // F T */ zdd out = zdd_project(ep, zdd_4, [var = 4]() mutable -> optional { - if (var == 42) { - return make_optional(); - } + if (var == 42) { return make_optional(); } const zdd::label_type res = var; - if (var == 4) { var -= 2; } - else { var = 42; } + if (var == 4) { + var -= 2; + } else { + var = 42; + } return res; }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id-1, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(4, node::max_id - 1, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(4, ptr_uint64::max_id-1), - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id, + ptr_uint64(4, ptr_uint64::max_id - 1), + ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,2u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 2u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2622,10 +2732,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); - it("bails out of inner sweep for zdd_4 with dom = { x | x % 2 == 0 } [const &]", [&](){ + it("bails out of inner sweep for zdd_4 with dom = { x | x % 2 == 0 } [const &]", [&]() { const zdd in = zdd_1; /* Expected: { Ø, {0}, {2}, {4} } @@ -2639,44 +2749,40 @@ go_bandit([]() { // T T */ zdd out = zdd_project(ep, in, [var = 8]() mutable -> optional { - if (var == 42) { - return {}; - } + if (var == 42) { return {}; } const zdd::label_type res = var; - var = var == 0 ? 42 : var-2; - return {res}; + var = var == 0 ? 42 : var - 2; + return { res }; }); node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(4, ptr_uint64::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(2, node::max_id, ptr_uint64(4, ptr_uint64::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - terminal_T))); + AssertThat( + out_nodes.pull(), + Is().EqualTo(node(0, node::max_id, ptr_uint64(2, ptr_uint64::max_id), terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2686,10 +2792,10 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(4u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); }); - it("accounts for number of root arcs from Outer Sweep [const &]", [&](){ + it("accounts for number of root arcs from Outer Sweep [const &]", [&]() { const zdd in = zdd_6; /* Expected: { Ø, {5} } @@ -2703,16 +2809,14 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(5, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(5,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(5, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2722,7 +2826,7 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); }); }); @@ -2734,8 +2838,8 @@ go_bandit([]() { describe("algorithm: Singleton", [&]() { const exec_policy ep = exec_policy::quantify::Singleton; - it("computes zdd_2 with dom = {4,3,2} [&&]", [&](){ - const std::vector dom = {4,3,2}; + it("computes zdd_2 with dom = {4,3,2} [&&]", [&]() { + const std::vector dom = { 4, 3, 2 }; /* Expected: { Ø, {2}, {3}, {2,4} } // @@ -2752,33 +2856,30 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(3, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - ptr_uint64(3, ptr_uint64::max_id), - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(2, + node::max_id, + ptr_uint64(3, ptr_uint64::max_id), + ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,1u))); - + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2788,15 +2889,15 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(1u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(4u)); }); }); describe("algorithm: Nested, max: _", [&]() { const exec_policy ep = exec_policy::quantify::Nested; - it("computes zdd_3 with dom = {4,2,0} [&&]", [&](){ - const std::vector dom = {4,2,0}; + it("computes zdd_3 with dom = {4,2,0} [&&]", [&]() { + const std::vector dom = { 4, 2, 0 }; /* Expected: { {0}, {2}, {0,2} } // @@ -2813,24 +2914,24 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(2, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(2, ptr_uint64::max_id), - ptr_uint64(2, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(2, ptr_uint64::max_id), + ptr_uint64(2, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2840,12 +2941,12 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(2u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(2u)); }); - it("computes zdd_4 with dom = {4,0} [const &]", [&](){ - std::vector dom = {4,0}; - zdd in = zdd_4; + it("computes zdd_4 with dom = {4,0} [const &]", [&]() { + std::vector dom = { 4, 0 }; + zdd in = zdd_4; /* Expected: { {0}, {4}, {0,4} } // @@ -2862,29 +2963,28 @@ go_bandit([]() { node_test_stream out_nodes(out); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, - terminal_T, - terminal_T))); + AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id, terminal_T, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(4, node::max_id-1, - terminal_F, - terminal_T))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(4, node::max_id - 1, terminal_F, terminal_T))); AssertThat(out_nodes.can_pull(), Is().True()); - AssertThat(out_nodes.pull(), Is().EqualTo(node(0, node::max_id, - ptr_uint64(4, ptr_uint64::max_id-1), - ptr_uint64(4, ptr_uint64::max_id)))); + AssertThat(out_nodes.pull(), + Is().EqualTo(node(0, + node::max_id, + ptr_uint64(4, ptr_uint64::max_id - 1), + ptr_uint64(4, ptr_uint64::max_id)))); AssertThat(out_nodes.can_pull(), Is().False()); level_info_test_stream ms(out); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(4,2u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(4, 2u))); AssertThat(ms.can_pull(), Is().True()); - AssertThat(ms.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(ms.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(ms.can_pull(), Is().False()); @@ -2894,9 +2994,9 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::All], Is().GreaterThanOrEqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out->number_of_terminals[true], Is().EqualTo(3u)); }); }); }); }); - }); +}); diff --git a/test/adiar/zdd/test_subset.cpp b/test/adiar/zdd/test_subset.cpp index f6ff668ba..199c2c8dd 100644 --- a/test/adiar/zdd/test_subset.cpp +++ b/test/adiar/zdd/test_subset.cpp @@ -32,12 +32,12 @@ go_bandit([]() { */ shared_levelized_file zdd_1; - node n1_6 = node(4, node::max_id, terminal_T, terminal_T); - node n1_5 = node(3, node::max_id, n1_6.uid(), terminal_T); - node n1_4 = node(3, node::max_id-1, terminal_F, n1_6.uid()); - node n1_3 = node(2, node::max_id, n1_4.uid(), n1_5.uid()); - node n1_2 = node(1, node::max_id, n1_4.uid(), n1_3.uid()); - node n1_1 = node(0, node::max_id, n1_2.uid(), n1_2.uid()); + node n1_6 = node(4, node::max_id, terminal_T, terminal_T); + node n1_5 = node(3, node::max_id, n1_6.uid(), terminal_T); + node n1_4 = node(3, node::max_id - 1, terminal_F, n1_6.uid()); + node n1_3 = node(2, node::max_id, n1_4.uid(), n1_5.uid()); + node n1_2 = node(1, node::max_id, n1_4.uid(), n1_3.uid()); + node n1_1 = node(0, node::max_id, n1_2.uid(), n1_2.uid()); { // Garbage collect writer to free write-lock node_writer w(zdd_1); @@ -82,7 +82,7 @@ go_bandit([]() { */ shared_levelized_file zdd_2_mirror; - const node n2m_4 = node(3, node::max_id, terminal_F, terminal_T); + const node n2m_4 = node(3, node::max_id, terminal_F, terminal_T); const node n2m_3 = node(2, node::max_id, n2m_4.uid(), terminal_T); const node n2m_2 = node(1, node::max_id, n2m_3.uid(), terminal_T); const node n2m_1 = node(0, node::max_id, n2m_3.uid(), n2m_2.uid()); @@ -142,7 +142,8 @@ go_bandit([]() { shared_levelized_file zdd_5; const node n5_2(2, node::max_id, terminal_T, terminal_T); - const node n5_1(1, node::max_id, n5_2.uid(), n5_2.uid());; + const node n5_1(1, node::max_id, n5_2.uid(), n5_2.uid()); + ; { node_writer nw(zdd_5); @@ -204,7 +205,7 @@ go_bandit([]() { }); it("returns input unchanged when given empty set of labels", [&]() { - std::vector labels = { }; + std::vector labels = {}; __zdd out = zdd_offset(zdd_1, labels.begin(), labels.end()); AssertThat(out.get>(), Is().EqualTo(zdd_1)); @@ -231,17 +232,25 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("restricts to a terminal in [3] without (1,2)", [&]() { - std::vector labels = { 1,2 }; + std::vector labels = { 1, 2 }; __zdd out = zdd_offset(zdd_3, labels.begin(), labels.end()); @@ -254,17 +263,25 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("restricts to a (reduced) terminal in [6] without (1,2)", [&]() { - std::vector labels = { 0,2 }; + std::vector labels = { 0, 2 }; __zdd out = zdd_offset(zdd_6, labels.begin(), labels.end()); @@ -277,13 +294,21 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); }); @@ -310,24 +335,27 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n4_1.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n4_1.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n4_1.uid(), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n4_1.uid(), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("returns { Ø, { 1 } } for [5] without 2", [&]() { @@ -337,24 +365,27 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_1.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_1.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_1.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_1.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("returns { Ø, { 2 } } for [5] without 1", [&]() { @@ -364,24 +395,27 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_2.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_2.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_2.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_2.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("returns { Ø, { 2 } } for [5] without 1", [&]() { @@ -391,24 +425,27 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_2.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_2.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n5_2.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n5_2.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("skips 'dead' nodes in [1] without 1", [&]() { @@ -418,44 +455,47 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().True()); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_1.uid(), false, n1_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_1.uid(), false, n1_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_1.uid(), true, n1_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_1.uid(), true, n1_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_4.uid(), true, n1_6.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_4.uid(), true, n1_6.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_4.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_4.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_6.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_6.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_6.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_6.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("restricts to a (reduced) terminal in [6] without 1", [&]() { @@ -470,13 +510,21 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(0u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(1u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(0u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("bridges levels in [2] without 3", [&]() { @@ -486,44 +534,47 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().True()); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2_1.uid(), false, n2_2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2_1.uid(), false, n2_2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2_1.uid(), true, n2_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2_1.uid(), true, n2_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2_2.uid(), true, n2_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2_2.uid(), true, n2_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_2.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_2.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_3.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_3.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_3.uid(), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_3.uid(), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); }); @@ -535,59 +586,62 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().True()); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_2.uid(), true, n1_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_2.uid(), true, n1_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_2.uid(), false, n1_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_2.uid(), false, n1_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_3.uid(), false, n1_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_3.uid(), false, n1_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_3.uid(), true, n1_5.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_3.uid(), true, n1_5.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_4.uid(), true, n1_6.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_4.uid(), true, n1_6.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_5.uid(), false, n1_6.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_5.uid(), false, n1_6.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_4.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_4.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_5.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_5.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_6.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_6.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_6.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_6.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(3u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); }); it("skips 'dead' nodes of [2 mirrored]", [&]() { @@ -597,44 +651,45 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().True()); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2m_3.uid(), false, n2m_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2m_3.uid(), false, n2m_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2m_3.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2m_3.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2m_4.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2m_4.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2m_4.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2m_4.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); - it("throws an exception when given the F terminal", [&]() { - AssertThrows(invalid_argument, zdd_offset(zdd_F)); - }); + it("throws an exception when given the F terminal", + [&]() { AssertThrows(invalid_argument, zdd_offset(zdd_F)); }); - it("throws an throw exception when given the T terminal", [&]() { - AssertThrows(invalid_argument, zdd_offset(zdd_T)); - }); + it("throws an throw exception when given the T terminal", + [&]() { AssertThrows(invalid_argument, zdd_offset(zdd_T)); }); }); describe("zdd_onset(const zdd&, const generator<...>&)", [&]() { @@ -652,14 +707,14 @@ go_bandit([]() { }); it("returns input unchanged when given { Ø } for ()", [&]() { - std::vector labels = { }; + std::vector labels = {}; __zdd out = zdd_onset(zdd_T, labels.begin(), labels.end()); AssertThat(out.get>(), Is().EqualTo(zdd_T)); }); it("returns input unchanged when given [1] for ()", [&]() { - std::vector labels = { }; + std::vector labels = {}; __zdd out = zdd_onset(zdd_1, labels.begin(), labels.end()); AssertThat(out.get>(), Is().EqualTo(zdd_1)); @@ -679,13 +734,21 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("returns Ø when given disjoint labels", [&]() { @@ -702,13 +765,21 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("returns Ø when given { Ø, { 0 } } for (0,1)", [&]() { @@ -725,13 +796,21 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("returns { Ø } in [2] for (0,2,3)", [&]() { @@ -745,44 +824,47 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().True()); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2_1.uid(), true, n2_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2_1.uid(), true, n2_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2_3.uid(), true, n2_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2_3.uid(), true, n2_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_1.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_1.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_3.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_3.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_4.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_4.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_4.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_4.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("returns Ø in [2] for (0,2,3,4)", [&]() { @@ -801,35 +883,38 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().True()); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2_1.uid(), true, n2_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2_1.uid(), true, n2_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_1.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_1.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_3.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_3.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_3.uid(), true, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_3.uid(), true, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("skips 'dead' nodes of [1] for (1,2)", [&]() { @@ -841,62 +926,65 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().True()); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_1.uid(), false, n1_2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_1.uid(), false, n1_2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_1.uid(), true, n1_2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_1.uid(), true, n1_2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_2.uid(), true, n1_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_2.uid(), true, n1_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_3.uid(), true, n1_5.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_3.uid(), true, n1_5.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_5.uid(), false, n1_6.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_5.uid(), false, n1_6.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_2.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_2.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_3.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_3.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_5.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_5.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_6.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_6.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_6.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_6.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); }); it("skips root in [2] due to cut on high edge for (1,3)", [&]() { @@ -908,44 +996,47 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().True()); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2_2.uid(), true, n2_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2_2.uid(), true, n2_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2_3.uid(), true, n2_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2_3.uid(), true, n2_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_2.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_2.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_3.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_3.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_4.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_4.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_4.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_4.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); it("cuts high edge on restricted node, if it goes past the next label", [&]() { @@ -962,12 +1053,12 @@ go_bandit([]() { */ shared_levelized_file in; - node n6 = node(3, node::max_id, terminal_T, terminal_T); - node n5 = node(3, node::max_id-1, terminal_F, terminal_T); - node n4 = node(2, node::max_id, n5.uid(), n6.uid()); - node n3 = node(1, node::max_id, n5.uid(), n4.uid()); - node n2 = node(1, node::max_id-1, terminal_T, n5.uid()); - node n1 = node(0, node::max_id, n2.uid(), n3.uid()); + node n6 = node(3, node::max_id, terminal_T, terminal_T); + node n5 = node(3, node::max_id - 1, terminal_F, terminal_T); + node n4 = node(2, node::max_id, n5.uid(), n6.uid()); + node n3 = node(1, node::max_id, n5.uid(), n4.uid()); + node n2 = node(1, node::max_id - 1, terminal_T, n5.uid()); + node n1 = node(0, node::max_id, n2.uid(), n3.uid()); { // Garbage collect writer to free write-lock node_writer w(in); @@ -982,53 +1073,56 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().True()); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1.uid(), true, n3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1.uid(), true, n3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n3.uid(), true, n4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n3.uid(), true, n4.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n4.uid(), true, n6.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n4.uid(), true, n6.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n3.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n3.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n4.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n4.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n6.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n6.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n6.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n6.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); }); @@ -1050,13 +1144,21 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("returns Ø when given non-existent label (after)", [&]() { @@ -1071,13 +1173,21 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("returns Ø when given non-existent label (in-between)", [&]() { @@ -1092,13 +1202,21 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("returns { { 0 } } when given [7] with 0", [&]() { @@ -1108,24 +1226,27 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n7_1.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n7_1.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n7_1.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n7_1.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(0u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(0u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("returns Ø in { Ø, {0}, {0,2} } with 1", [&]() { @@ -1157,13 +1278,21 @@ go_bandit([]() { level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get>()->max_1level_cut[cut::Internal], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out.get>()->max_1level_cut[cut::Internal_True], Is().EqualTo(0u)); - AssertThat(out.get>()->max_1level_cut[cut::All], Is().EqualTo(1u)); - - AssertThat(out.get>()->number_of_terminals[false], Is().EqualTo(1u)); - AssertThat(out.get>()->number_of_terminals[true], Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::Internal], + Is().EqualTo(0u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_False], + Is().EqualTo(1u)); + AssertThat( + out.get>()->max_1level_cut[cut::Internal_True], + Is().EqualTo(0u)); + AssertThat(out.get>()->max_1level_cut[cut::All], + Is().EqualTo(1u)); + + AssertThat(out.get>()->number_of_terminals[false], + Is().EqualTo(1u)); + AssertThat(out.get>()->number_of_terminals[true], + Is().EqualTo(0u)); }); it("cuts edge going across onset label in { {2}, {0,1}, {0,2}, {0,1,2} } with 1", [&]() { @@ -1193,44 +1322,47 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().True()); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1.uid(), true, n2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1.uid(), true, n2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2.uid(), true, n3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2.uid(), true, n3.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n3.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n3.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n3.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n3.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("cuts edge and ignore 'dead' node in { {2}, {0,1}, {0,2} } with 1", [&]() { @@ -1259,35 +1391,38 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1.uid(), true, n2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1.uid(), true, n2.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("falsifies early terminals in [2] for (3)", [&]() { @@ -1299,53 +1434,56 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().True()); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2_1.uid(), false, n2_2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2_1.uid(), false, n2_2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2_1.uid(), true, n2_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2_1.uid(), true, n2_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2_2.uid(), true, n2_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2_2.uid(), true, n2_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2_3.uid(), true, n2_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2_3.uid(), true, n2_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_2.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_2.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_3.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_3.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_4.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_4.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_4.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_4.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(3u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); it("falsifies early terminal and bridge over removed node in [1] with 4", [&]() { @@ -1355,62 +1493,65 @@ go_bandit([]() { AssertThat(arcs.can_pull_internal(), Is().True()); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_1.uid(), false, n1_2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_1.uid(), false, n1_2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_1.uid(), true, n1_2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_1.uid(), true, n1_2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_2.uid(), true, n1_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_2.uid(), true, n1_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_2.uid(), false, n1_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_2.uid(), false, n1_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_3.uid(), false, n1_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_3.uid(), false, n1_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_3.uid(), true, n1_6.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_3.uid(), true, n1_6.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_4.uid(), true, n1_6.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_4.uid(), true, n1_6.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_4.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_4.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_6.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_6.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_6.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_6.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(3u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(1u)); }); }); @@ -1421,68 +1562,71 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_1.uid(), true, n1_2.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_1.uid(), true, n1_2.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_2.uid(), true, n1_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_2.uid(), true, n1_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_2.uid(), false, n1_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_2.uid(), false, n1_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_3.uid(), false, n1_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_3.uid(), false, n1_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_3.uid(), true, n1_5.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_3.uid(), true, n1_5.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_4.uid(), true, n1_6.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_4.uid(), true, n1_6.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n1_5.uid(), false, n1_6.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n1_5.uid(), false, n1_6.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_1.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_1.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_4.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_4.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_5.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_5.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_6.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_6.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n1_6.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n1_6.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(1, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,2u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 2u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(4,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(4, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(3u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(3u)); }); it("skips 'dead' nodes for [2]", [&]() { @@ -1491,53 +1635,54 @@ go_bandit([]() { arc_test_stream arcs(out); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2_1.uid(), true, n1_3.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2_1.uid(), true, n1_3.uid() })); AssertThat(arcs.can_pull_internal(), Is().True()); - AssertThat(arcs.pull_internal(), Is().EqualTo(arc { n2_3.uid(), true, n2_4.uid() })); + AssertThat(arcs.pull_internal(), Is().EqualTo(arc{ n2_3.uid(), true, n2_4.uid() })); AssertThat(arcs.can_pull_internal(), Is().False()); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_1.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_1.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_3.uid(), false, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_3.uid(), false, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_4.uid(), false, terminal_F })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_4.uid(), false, terminal_F })); AssertThat(arcs.can_pull_terminal(), Is().True()); - AssertThat(arcs.pull_terminal(), Is().EqualTo(arc { n2_4.uid(), true, terminal_T })); + AssertThat(arcs.pull_terminal(), Is().EqualTo(arc{ n2_4.uid(), true, terminal_T })); AssertThat(arcs.can_pull_terminal(), Is().False()); level_info_test_stream meta_arcs(out); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(0, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(2, 1u))); AssertThat(meta_arcs.can_pull(), Is().True()); - AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3,1u))); + AssertThat(meta_arcs.pull(), Is().EqualTo(level_info(3, 1u))); AssertThat(meta_arcs.can_pull(), Is().False()); - AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, Is().GreaterThanOrEqualTo(1u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->max_1level_cut, + Is().GreaterThanOrEqualTo(1u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], Is().EqualTo(2u)); - AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[false], + Is().EqualTo(2u)); + AssertThat(out.get<__zdd::shared_arc_file_type>()->number_of_terminals[true], + Is().EqualTo(2u)); }); - it("throws an exception when given the F terminal", [&]() { - AssertThrows(invalid_argument, zdd_onset(zdd_F)); - }); + it("throws an exception when given the F terminal", + [&]() { AssertThrows(invalid_argument, zdd_onset(zdd_F)); }); - it("throws an throw exception when given the T terminal", [&]() { - AssertThrows(invalid_argument, zdd_onset(zdd_T)); - }); + it("throws an throw exception when given the T terminal", + [&]() { AssertThrows(invalid_argument, zdd_onset(zdd_T)); }); }); }); - }); +}); diff --git a/test/adiar/zdd/test_zdd.cpp b/test/adiar/zdd/test_zdd.cpp index ad08c92f3..e48eb929b 100644 --- a/test/adiar/zdd/test_zdd.cpp +++ b/test/adiar/zdd/test_zdd.cpp @@ -5,9 +5,7 @@ go_bandit([]() { shared_levelized_file x0_nf; { node_writer nw_0(x0_nf); - nw_0 << node(0, node::max_id, - ptr_uint64(false), - ptr_uint64(true)); + nw_0 << node(0, node::max_id, ptr_uint64(false), ptr_uint64(true)); } zdd x0(x0_nf); @@ -15,9 +13,7 @@ go_bandit([]() { shared_levelized_file x1_nf; { node_writer nw_1(x1_nf); - nw_1 << node(1, node::max_id, - ptr_uint64(false), - ptr_uint64(true)); + nw_1 << node(1, node::max_id, ptr_uint64(false), ptr_uint64(true)); } zdd x1(x1_nf); @@ -26,13 +22,9 @@ go_bandit([]() { { node_writer nw_01(x0_or_x1_nf); - nw_01 << node(1, node::max_id, - ptr_uint64(false), - ptr_uint64(true)); + nw_01 << node(1, node::max_id, ptr_uint64(false), ptr_uint64(true)); - nw_01 << node(0, node::max_id, - ptr_uint64(1, ptr_uint64::max_id), - ptr_uint64(true)); + nw_01 << node(0, node::max_id, ptr_uint64(1, ptr_uint64::max_id), ptr_uint64(true)); } zdd x0_or_x1(x0_or_x1_nf); @@ -80,14 +72,14 @@ go_bandit([]() { { arc_writer aw(af); - aw.push_internal(arc {ptr_uint64(0,0), false, ptr_uint64(1,0)}); + aw.push_internal(arc{ ptr_uint64(0, 0), false, ptr_uint64(1, 0) }); - aw.push_terminal(arc {ptr_uint64(0,0), true, ptr_uint64(true)}); - aw.push_terminal(arc {ptr_uint64(1,0), false, ptr_uint64(false)}); - aw.push_terminal(arc {ptr_uint64(1,0), true, ptr_uint64(true)}); + aw.push_terminal(arc{ ptr_uint64(0, 0), true, ptr_uint64(true) }); + aw.push_terminal(arc{ ptr_uint64(1, 0), false, ptr_uint64(false) }); + aw.push_terminal(arc{ ptr_uint64(1, 0), true, ptr_uint64(true) }); - aw.push(level_info(0,1u)); - aw.push(level_info(1,1u)); + aw.push(level_info(0, 1u)); + aw.push(level_info(1, 1u)); } af->max_1level_cut = 1; @@ -107,17 +99,15 @@ go_bandit([]() { }); describe("operators", [&]() { - it("should reject Ø == {Ø}", [&]() { - AssertThat(terminal_F, Is().Not().EqualTo(terminal_T)); - }); + it("should reject Ø == {Ø}", + [&]() { AssertThat(terminal_F, Is().Not().EqualTo(terminal_T)); }); it("should accept {{0}} == {{0}} (different files)", [&]() { shared_levelized_file x0_nf_2; - { node_writer nw_0(x0_nf_2); - nw_0 << node(0, node::max_id, - ptr_uint64(false), - ptr_uint64(true)); + { + node_writer nw_0(x0_nf_2); + nw_0 << node(0, node::max_id, ptr_uint64(false), ptr_uint64(true)); } zdd x0_2(x0_nf); @@ -125,17 +115,14 @@ go_bandit([]() { AssertThat(x0, Is().EqualTo(x0_2)); }); - it("should compute {{0}} /\\ {{1}} == {{0}, {1}}", [&]() { - AssertThat((x0 | x1) == x0_or_x1, Is().True()); - }); + it("should compute {{0}} /\\ {{1}} == {{0}, {1}}", + [&]() { AssertThat((x0 | x1) == x0_or_x1, Is().True()); }); - it("should compute {{0}} \\/ {{0},{1}} == {{0}}", [&]() { - AssertThat((x0 & x0_or_x1) == x0, Is().True()); - }); + it("should compute {{0}} \\/ {{0},{1}} == {{0}}", + [&]() { AssertThat((x0 & x0_or_x1) == x0, Is().True()); }); - it("should compute {{0},{1}} \\ {{0} == {{0}}", [&]() { - AssertThat((x0_or_x1 - x0) == x1, Is().True()); - }); + it("should compute {{0},{1}} \\ {{0} == {{0}}", + [&]() { AssertThat((x0_or_x1 - x0) == x1, Is().True()); }); it("should compute {{0},{1}}' == {Ø,{0,1}} with dom {0,1}", [&]() { shared_file dom; @@ -162,18 +149,18 @@ go_bandit([]() { }); it("should compute with __zdd&& operators [|,~,-,]", [&]() { - shared_file dom; - { - label_writer lw(dom); - lw << 0 << 1; - } + shared_file dom; + { + label_writer lw(dom); + lw << 0 << 1; + } - domain_set(dom); + domain_set(dom); - zdd out = ~(~(x0 | x1) - terminal_T); - zdd expected = x0 | x1 | terminal_T; - AssertThat(expected, Is().EqualTo(out)); - }); + zdd out = ~(~(x0 | x1) - terminal_T); + zdd expected = x0 | x1 | terminal_T; + AssertThat(expected, Is().EqualTo(out)); + }); it("should ?= __zdd&&", [&]() { zdd out = x0_or_x1; @@ -198,10 +185,11 @@ go_bandit([]() { }); }); - it("should copy-construct shared_levelized_file and negation back to zdd", [&]() { - zdd t2 = zdd(__zdd(x0_or_x1)); - AssertThat(t2.file_ptr(), Is().EqualTo(x0_or_x1_nf)); - AssertThat(t2.is_negated(), Is().False()); - }); + it("should copy-construct shared_levelized_file and negation back to zdd", + [&]() { + zdd t2 = zdd(__zdd(x0_or_x1)); + AssertThat(t2.file_ptr(), Is().EqualTo(x0_or_x1_nf)); + AssertThat(t2.is_negated(), Is().False()); + }); }); - }); +}); diff --git a/test/test.cpp b/test/test.cpp index d5d876ec9..71e4a74f7 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -8,25 +8,17 @@ // Adiar Initialization unit tests go_bandit([]() { describe("adiar/adiar.h", []() { - it("is at first not initialized", [&]() { - AssertThat(adiar_initialized(), Is().False()); - }); + it("is at first not initialized", [&]() { AssertThat(adiar_initialized(), Is().False()); }); - it("throws exception when given '0' memory", [&]() { - AssertThrows(invalid_argument, adiar_init(0)); - }); + it("throws exception when given '0' memory", + [&]() { AssertThrows(invalid_argument, adiar_init(0)); }); - it("throws exception when given 'minimum_memory - 1' memory", [&]() { - AssertThrows(invalid_argument, adiar_init(minimum_memory - 1)); - }); + it("throws exception when given 'minimum_memory - 1' memory", + [&]() { AssertThrows(invalid_argument, adiar_init(minimum_memory - 1)); }); - it("can run 'adiar_init()'", [&]() { - adiar_init(1024 * 1024 * 1024); - }); + it("can run 'adiar_init()'", [&]() { adiar_init(1024 * 1024 * 1024); }); - it("is then initialized", [&]() { - AssertThat(adiar_initialized(), Is().True()); - }); + it("is then initialized", [&]() { AssertThat(adiar_initialized(), Is().True()); }); it("can rerun 'adiar_init()' without any new effect", [&]() { AssertThat(adiar_initialized(), Is().True()); @@ -39,72 +31,61 @@ go_bandit([]() { // Kill program immediately instead of trying to run crashing unit tests. if (!adiar_initialized()) exit(-1); - }); +}); go_bandit([]() { describe("adiar/domain.h", []() { - it("initially as no domain", [&]() { - AssertThat(domain_isset(), Is().False()); - }); + it("initially as no domain", [&]() { AssertThat(domain_isset(), Is().False()); }); }); - }); +}); //////////////////////////////////////////////////////////////////////////////// // Adiar Internal unit tests -#include "adiar/internal/data_types/test_ptr.cpp" -#include "adiar/internal/data_types/test_uid.cpp" +#include "adiar/internal/algorithms/test_convert.cpp" +#include "adiar/internal/algorithms/test_dot.cpp" +#include "adiar/internal/algorithms/test_isomorphism.cpp" +#include "adiar/internal/algorithms/test_nested_sweeping.cpp" +#include "adiar/internal/algorithms/test_reduce.cpp" +#include "adiar/internal/data_structures/test_level_merger.cpp" +#include "adiar/internal/data_structures/test_levelized_priority_queue.cpp" #include "adiar/internal/data_types/test_arc.cpp" +#include "adiar/internal/data_types/test_convert.cpp" #include "adiar/internal/data_types/test_node.cpp" -#include "adiar/internal/data_types/test_tuple.cpp" +#include "adiar/internal/data_types/test_ptr.cpp" #include "adiar/internal/data_types/test_request.cpp" -#include "adiar/internal/data_types/test_convert.cpp" - -#include "adiar/test_exec_policy.cpp" -#include "adiar/test_functional.cpp" - +#include "adiar/internal/data_types/test_tuple.cpp" +#include "adiar/internal/data_types/test_uid.cpp" +#include "adiar/internal/io/test_arc_file.cpp" #include "adiar/internal/io/test_file.cpp" #include "adiar/internal/io/test_levelized_file.cpp" -#include "adiar/internal/io/test_shared_file_ptr.cpp" #include "adiar/internal/io/test_node_file.cpp" -#include "adiar/internal/io/test_arc_file.cpp" - -#include "adiar/internal/data_structures/test_level_merger.cpp" -#include "adiar/internal/data_structures/test_levelized_priority_queue.cpp" - +#include "adiar/internal/io/test_shared_file_ptr.cpp" #include "adiar/internal/test_dd_func.cpp" #include "adiar/internal/test_util.cpp" - -#include "adiar/internal/algorithms/test_convert.cpp" -#include "adiar/internal/algorithms/test_dot.cpp" -#include "adiar/internal/algorithms/test_isomorphism.cpp" -#include "adiar/internal/algorithms/test_nested_sweeping.cpp" -#include "adiar/internal/algorithms/test_reduce.cpp" +#include "adiar/test_exec_policy.cpp" +#include "adiar/test_functional.cpp" //////////////////////////////////////////////////////////////////////////////// // Adiar Core unit tests #include "adiar/test_bool_op.cpp" - -#include "adiar/test_domain.cpp" #include "adiar/test_builder.cpp" +#include "adiar/test_domain.cpp" //////////////////////////////////////////////////////////////////////////////// // Adiar BDD unit tests -#include "adiar/bdd/test_bdd.cpp" - #include "adiar/bdd/test_apply.cpp" +#include "adiar/bdd/test_bdd.cpp" #include "adiar/bdd/test_build.cpp" #include "adiar/bdd/test_count.cpp" #include "adiar/bdd/test_evaluate.cpp" #include "adiar/bdd/test_if_then_else.cpp" -#include "adiar/bdd/test_pred.cpp" #include "adiar/bdd/test_negate.cpp" +#include "adiar/bdd/test_pred.cpp" #include "adiar/bdd/test_quantify.cpp" #include "adiar/bdd/test_restrict.cpp" //////////////////////////////////////////////////////////////////////////////// // Adiar ZDD unit tests -#include "adiar/zdd/test_zdd.cpp" - #include "adiar/zdd/test_binop.cpp" #include "adiar/zdd/test_build.cpp" #include "adiar/zdd/test_change.cpp" @@ -116,6 +97,7 @@ go_bandit([]() { #include "adiar/zdd/test_pred.cpp" #include "adiar/zdd/test_project.cpp" #include "adiar/zdd/test_subset.cpp" +#include "adiar/zdd/test_zdd.cpp" //////////////////////////////////////////////////////////////////////////////// // Adiar Deinitialization unit tests @@ -138,4 +120,4 @@ go_bandit([]() { AssertThrows(runtime_error, adiar_init(minimum_memory)); }); }); - }); +}); diff --git a/test/test.h b/test/test.h index a15035bc3..4a6ab6226 100644 --- a/test/test.h +++ b/test/test.h @@ -1,9 +1,10 @@ #ifndef ADIAR_TEST_H #define ADIAR_TEST_H -#include #include +#include + using namespace snowhouse; using namespace bandit; @@ -25,44 +26,44 @@ using namespace adiar::internal; using level_info_test_stream = level_info_stream; -class node_test_stream: public node_stream +class node_test_stream : public node_stream { public: - node_test_stream(const shared_levelized_file &f) + node_test_stream(const shared_levelized_file& f) : node_stream(f) - { } + {} - node_test_stream(const bdd &f) + node_test_stream(const bdd& f) : node_stream(f) - { } + {} - node_test_stream(const __bdd &f) + node_test_stream(const __bdd& f) : node_stream(f.get<__bdd::shared_node_file_type>(), f.negate) - { } + {} - node_test_stream(const zdd &f) + node_test_stream(const zdd& f) : node_stream(f) - { } + {} - node_test_stream(const __zdd &f) + node_test_stream(const __zdd& f) : node_stream(f.get<__zdd::shared_node_file_type>(), f.negate) - { } + {} }; -class arc_test_stream: public arc_stream +class arc_test_stream : public arc_stream { public: - arc_test_stream(const shared_levelized_file &f) + arc_test_stream(const shared_levelized_file& f) : arc_stream(f) - { } + {} - arc_test_stream(const __bdd &bdd) + arc_test_stream(const __bdd& bdd) : arc_stream(bdd.get<__bdd::shared_arc_file_type>()) - { } + {} - arc_test_stream(const __zdd &zdd) + arc_test_stream(const __zdd& zdd) : arc_stream(zdd.get<__zdd::shared_arc_file_type>()) - { } + {} }; //////////////////////////////////////////////////////////////////////////////// @@ -71,7 +72,8 @@ class arc_test_stream: public arc_stream // TODO: move into '<<'/'toString' methods in each respective data type. namespace snowhouse { - std::string string_of_adiar_ptr(adiar::internal::ptr_uint64 p) + std::string + string_of_adiar_ptr(adiar::internal::ptr_uint64 p) { std::stringstream stream; if (p.is_nil()) { @@ -82,72 +84,63 @@ namespace snowhouse stream << "(x" << p.label() << ", " << p.id() << ")"; } - if (p.is_flagged()) { - stream << "'"; - } + if (p.is_flagged()) { stream << "'"; } return stream.str(); } - std::string string_of_adiar_uid(adiar::internal::uid_uint64 u) + std::string + string_of_adiar_uid(adiar::internal::uid_uint64 u) { std::stringstream stream; if (u.is_terminal()) { stream << u.value(); } else { // u.is_node() - stream << "(x" << u.label() << ", " << u.id() << ")" ; + stream << "(x" << u.label() << ", " << u.id() << ")"; } return stream.str(); } - template<> + template <> struct Stringizer { - static std::string ToString(const adiar::internal::arc& a) + static std::string + ToString(const adiar::internal::arc& a) { std::stringstream stream; - stream << "arc: " - << string_of_adiar_ptr(a.source()) - << " " << (a.out_idx() ? "--->" : "- ->") << " " - << string_of_adiar_ptr(a.target()) - ; + stream << "arc: " << string_of_adiar_ptr(a.source()) << " " << (a.out_idx() ? "--->" : "- ->") + << " " << string_of_adiar_ptr(a.target()); return stream.str(); } }; - template<> + template <> struct Stringizer { - static std::string ToString(const adiar::internal::node& n) + static std::string + ToString(const adiar::internal::node& n) { std::stringstream stream; if (n.is_terminal()) { stream << "node: " << n.value(); } else { - stream << "node: (" - << string_of_adiar_uid(n.uid()) - << ", " - << string_of_adiar_ptr(n.low()) - << ", " - << string_of_adiar_ptr(n.high()) - << ")" - ; + stream << "node: (" << string_of_adiar_uid(n.uid()) << ", " << string_of_adiar_ptr(n.low()) + << ", " << string_of_adiar_ptr(n.high()) << ")"; } return stream.str(); } }; - template<> + template <> struct Stringizer { - static std::string ToString(const adiar::internal::level_info& m) + static std::string + ToString(const adiar::internal::level_info& m) { std::stringstream stream; stream << "level_info: (" - << "x" << m.label() - << " (" << m.level() << ")" - << ", #nodes = " << m.width() - << ")"; + << "x" << m.label() << " (" << m.level() << ")" + << ", #nodes = " << m.width() << ")"; return stream.str(); } }; @@ -172,9 +165,12 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////// // Main -int main(int argc, char* argv[]) { +int +main(int argc, char* argv[]) +{ #ifdef NDEBUG - std::cerr << "Warning: Internal assertions are not enabled!" << std::endl << std::endl;; + std::cerr << "Warning: Internal assertions are not enabled!" << std::endl << std::endl; + ; std::cerr << "Warning: Some tests may fail due to ties in ordering" << std::endl << std::endl; #endif