diff --git a/private/rdf4cpp/parser/IStreamQuadIteratorSerdImpl.cpp b/private/rdf4cpp/parser/IStreamQuadIteratorSerdImpl.cpp index b6d830151..3a3e56ada 100644 --- a/private/rdf4cpp/parser/IStreamQuadIteratorSerdImpl.cpp +++ b/private/rdf4cpp/parser/IStreamQuadIteratorSerdImpl.cpp @@ -3,6 +3,8 @@ #include #include +#include + namespace rdf4cpp::parser { std::string_view IStreamQuadIterator::Impl::node_into_string_view(SerdNode const *node) noexcept { @@ -132,8 +134,7 @@ nonstd::expected IStreamQuadIterator::Impl::get_literal(Ser case SerdType::SERD_URI: return this->get_iri(datatype); default: - assert(false); - __builtin_unreachable(); + RDF4CPP_UNREACHABLE; } } else { return std::nullopt; diff --git a/private/rdf4cpp/regex/RegexReplacerImpl.cpp b/private/rdf4cpp/regex/RegexReplacerImpl.cpp index 68e775104..fe79ed307 100644 --- a/private/rdf4cpp/regex/RegexReplacerImpl.cpp +++ b/private/rdf4cpp/regex/RegexReplacerImpl.cpp @@ -4,6 +4,8 @@ #include #include +#include + namespace rdf4cpp::regex { namespace detail { @@ -16,7 +18,7 @@ namespace detail { * @throws RegexError if the substring s.substr(pos, 2) is an invalid group reference */ static void replace(std::string &s, size_t pos) { - assert(s[pos] == '$'); + RDF4CPP_ASSERT(s[pos] == '$'); s[pos] = '\\'; if (pos == s.size() - 1 || !std::isdigit(s[pos + 1])) { diff --git a/private/rdf4cpp/writer/Prefixes.hpp b/private/rdf4cpp/writer/Prefixes.hpp index 35f44852a..17738f7ea 100644 --- a/private/rdf4cpp/writer/Prefixes.hpp +++ b/private/rdf4cpp/writer/Prefixes.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace rdf4cpp::writer { @@ -52,7 +53,7 @@ static constexpr auto type_iri_buffer = make_type_iri_buf<1 << storage::identifi // will only get called with fixed ids inline bool write_fixed_type_iri(datatypes::registry::LiteralType t, BufWriterParts const writer, bool use_prefixes) noexcept { - assert(t.is_fixed()); + RDF4CPP_ASSERT(t.is_fixed()); if (use_prefixes) { auto const &p = detail::type_iri_buffer[t.to_underlying()]; diff --git a/src/rdf4cpp/Assert.hpp b/src/rdf4cpp/Assert.hpp new file mode 100644 index 000000000..3d95938b5 --- /dev/null +++ b/src/rdf4cpp/Assert.hpp @@ -0,0 +1,30 @@ +#ifndef RDF4CPP_ASSERT_HPP +#define RDF4CPP_ASSERT_HPP + +#include +#include + +#ifdef NDEBUG + +#define RDF4CPP_ASSERT(expr) \ + if (!(expr)) [[unlikely]] { \ + std::cerr << std::format("Assertion failed: {} ({}:{})", #expr, __FILE__, __LINE__); \ + std::abort(); \ + } + +#define RDF4CPP_UNREACHABLE \ + std::cerr << std::format("Unreachable statement reached ({}:{})", __FILE__, __LINE__); \ + std::abort(); + +#define RDF4CPP_DEBUG_UNREACHABLE(...) return __VA_ARGS__ + +#else + +#define RDF4CPP_ASSERT(expr) assert(expr) +#define RDF4CPP_UNREACHABLE assert(false) +#define RDF4CPP_DEBUG_UNREACHABLE(...) assert(false) + +#endif +#define RDF4CPP_DEBUG_ASSERT(expr) assert(expr) + +#endif //RDF4CPP_ASSERT_HPP diff --git a/src/rdf4cpp/BigDecimal.hpp b/src/rdf4cpp/BigDecimal.hpp index fc826e002..f4dacada6 100644 --- a/src/rdf4cpp/BigDecimal.hpp +++ b/src/rdf4cpp/BigDecimal.hpp @@ -11,6 +11,7 @@ #include #include +#include namespace rdf4cpp { enum struct RoundingMode { @@ -363,8 +364,7 @@ struct BigDecimal { return BigDecimal{v, e}; } default: - assert(false); - __builtin_unreachable(); + RDF4CPP_UNREACHABLE; } } diff --git a/src/rdf4cpp/BlankNode.cpp b/src/rdf4cpp/BlankNode.cpp index 254632645..59bd274ca 100644 --- a/src/rdf4cpp/BlankNode.cpp +++ b/src/rdf4cpp/BlankNode.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -39,7 +40,7 @@ namespace detail_bnode_inlining { } [[nodiscard]] constexpr InlinedRepr from_inlined(storage::identifier::NodeBackendID id) noexcept { - assert(id.is_inlined() && id.is_blank_node()); + RDF4CPP_ASSERT(id.is_inlined() && id.is_blank_node()); return std::bit_cast(id.node_id()); } diff --git a/src/rdf4cpp/Literal.cpp b/src/rdf4cpp/Literal.cpp index 24052db71..1a2ee88a0 100644 --- a/src/rdf4cpp/Literal.cpp +++ b/src/rdf4cpp/Literal.cpp @@ -103,7 +103,7 @@ Literal Literal::make_lang_tagged_unchecked_from_node_id(std::string_view lang, Literal Literal::make_inlined_typed_unchecked(storage::identifier::LiteralID inlined_value, storage::identifier::LiteralType fixed_id, storage::DynNodeStoragePtr node_storage) noexcept { using namespace storage::identifier; - assert(fixed_id != LiteralType::other()); + RDF4CPP_ASSERT(fixed_id != LiteralType::other()); return Literal{NodeBackendHandle{NodeID{inlined_value, fixed_id}, RDFNodeType::Literal, @@ -139,7 +139,7 @@ Literal Literal::make_string_like_copy_lang_tag(std::string_view str, Literal co return Literal::make_lang_tagged_unchecked(str, needs_escape, lang_tag_src.language_tag(), node_storage); } - assert(lang_tag_src.datatype_eq()); + RDF4CPP_ASSERT(lang_tag_src.datatype_eq()); return Literal::make_simple_unchecked(str, needs_escape, node_storage); } @@ -153,7 +153,7 @@ Literal Literal::lang_tagged_get_de_inlined() const noexcept { } bool Literal::dynamic_datatype_eq_impl(std::string_view datatype) const noexcept { - assert(!this->is_fixed()); + RDF4CPP_ASSERT(!this->is_fixed()); return this->datatype().identifier() == datatype; } @@ -269,7 +269,7 @@ Literal Literal::to_node_storage(storage::DynNodeStoragePtr node_storage) const // This node storage doesn't have specialized storage for the given type but the target node storage does. // Need to send value over. // This doesn't work for rdf:langString, but it shouldn't have a specialized storage anyway. - assert(!this->datatype_eq()); + RDF4CPP_ASSERT(!this->datatype_eq()); auto const from_string = DatatypeRegistry::get_factory(dt_id); auto value = from_string(lexical_backend.lexical_form); @@ -292,7 +292,7 @@ Literal Literal::to_node_storage(storage::DynNodeStoragePtr node_storage) const if (!node_storage.has_specialized_storage_for(value_backend.datatype)) { // target node storage is not specialized for this datatype, need to convert to lexical form auto const serialize = DatatypeRegistry::get_serialize_canonical_string(datatypes::registry::DatatypeIDView{value_backend.datatype}); - assert(serialize != nullptr); + RDF4CPP_ASSERT(serialize != nullptr); auto const lex = run_serialize(serialize, value_backend.value); @@ -360,7 +360,7 @@ Literal Literal::try_get_in_node_storage(storage::DynNodeStoragePtr node_storage // This node storage doesn't have specialized storage for the given type but the target node storage does. // Need to send value over. // This doesn't work for rdf:langString, but it shouldn't have a specialized storage anyway. - assert(!this->datatype_eq()); + RDF4CPP_ASSERT(!this->datatype_eq()); auto const from_string = DatatypeRegistry::get_factory(dt_id); auto value = from_string(lexical_backend.lexical_form); @@ -389,7 +389,7 @@ Literal Literal::try_get_in_node_storage(storage::DynNodeStoragePtr node_storage if (!node_storage.has_specialized_storage_for(value_backend.datatype)) { // target node storage is not specialized for this datatype, need to convert to lexical form auto const serialize_canonical = DatatypeRegistry::get_serialize_canonical_string(datatypes::registry::DatatypeIDView{value_backend.datatype}); - assert(serialize_canonical != nullptr); + RDF4CPP_ASSERT(serialize_canonical != nullptr); auto const lex = run_serialize(serialize_canonical, value_backend.value); @@ -494,8 +494,8 @@ auto Literal::serialize_lexical_form_impl(C &&consume) const noexcept { } auto const *entry = datatypes::registry::DatatypeRegistry::get_entry(this->datatype_id()); - assert(entry != nullptr); - assert(entry->inlining_ops.has_value()); + RDF4CPP_ASSERT(entry != nullptr); + RDF4CPP_ASSERT(entry->inlining_ops.has_value()); auto const inlined_value = this->handle_.node_id().literal_id(); auto const value = entry->inlining_ops->from_inlined_fptr(inlined_value); @@ -735,14 +735,14 @@ bool Literal::serialize(writer::BufWriterParts const writer, NodeSerializationOp return this->serialize_lexical_form(writer); } else if (this->is_inlined()) { - assert(!this->datatype_eq()); + RDF4CPP_ASSERT(!this->datatype_eq()); // Notes: // 1. inlined values are assumed to not require escaping // 2. This is a known datatype because it is inlined => the registry contains the datatype IRI auto const *entry = datatypes::registry::DatatypeRegistry::get_entry(this->datatype_id()); - assert(entry != nullptr); - assert(entry->inlining_ops.has_value()); + RDF4CPP_ASSERT(entry != nullptr); + RDF4CPP_ASSERT(entry->inlining_ops.has_value()); RDF4CPP_DETAIL_TRY_WRITE_STR("\""); @@ -780,7 +780,7 @@ bool Literal::serialize(writer::BufWriterParts const writer, NodeSerializationOp // 2. This is a known datatype because it is stored in a value backend => the registry contains the datatype IRI auto const *entry = datatypes::registry::DatatypeRegistry::get_entry(this->datatype_id()); - assert(entry != nullptr); + RDF4CPP_ASSERT(entry != nullptr); RDF4CPP_DETAIL_TRY_WRITE_STR("\""); @@ -853,7 +853,7 @@ std::any Literal::value() const noexcept { } auto const ops = registry::DatatypeRegistry::get_inlining_ops(datatype); - assert(ops != nullptr); + RDF4CPP_ASSERT(ops != nullptr); auto const inlined_value = this->handle_.node_id().literal_id(); return ops->from_inlined_fptr(inlined_value); @@ -883,7 +883,7 @@ std::any Literal::value() const noexcept { return std::any{}; }, [&datatype](storage::view::ValueLiteralBackendView const &value_backend) noexcept { - assert(value_backend.datatype == datatype); + RDF4CPP_ASSERT(value_backend.datatype == datatype); (void)datatype; return value_backend.value; @@ -943,7 +943,7 @@ Literal Literal::cast(IRI const &target, storage::DynNodeStoragePtr node_storage } else { auto const &impl_converter = DatatypeRegistry::get_numeric_op_impl_conversion(*target_e); auto const *target_num_impl = DatatypeRegistry::get_numerical_ops(impl_converter.target_type_id); - assert(target_num_impl != nullptr); + RDF4CPP_ASSERT(target_num_impl != nullptr); // perform conversion as impl numeric type auto const value = this->template value() ? target_num_impl->get_impl().one_value_fptr() @@ -989,7 +989,7 @@ template Literal Literal::numeric_binop_impl(OpSelect op_select, Literal const &other, storage::DynNodeStoragePtr node_storage) const { using namespace datatypes::registry; - assert(!this->null() && !other.null()); + RDF4CPP_ASSERT(!this->null() && !other.null()); if (this->is_fixed_not_numeric() || other.is_fixed_not_numeric()) { return Literal{}; @@ -1019,7 +1019,7 @@ Literal Literal::numeric_binop_impl(OpSelect op_select, Literal const &other, st } }(); - assert(result_entry != nullptr); + RDF4CPP_ASSERT(result_entry != nullptr); return Literal::make_typed_unchecked(std::move(*op_res.result_value), op_res.result_type_id, *result_entry, node_storage); } else { auto const *other_entry = DatatypeRegistry::get_entry(other_datatype); @@ -1044,9 +1044,9 @@ Literal Literal::numeric_binop_impl(OpSelect op_select, Literal const &other, st } }(); - assert(equalized_entry != nullptr); - assert(equalized_entry->numeric_ops.has_value()); - assert(equalized_entry->numeric_ops->is_impl()); + RDF4CPP_ASSERT(equalized_entry != nullptr); + RDF4CPP_ASSERT(equalized_entry->numeric_ops.has_value()); + RDF4CPP_ASSERT(equalized_entry->numeric_ops->is_impl()); DatatypeRegistry::OpResult op_res = op_select(equalized_entry->numeric_ops->get_impl())(equalizer->convert_lhs(this->value()), equalizer->convert_rhs(other.value())); @@ -1063,7 +1063,7 @@ Literal Literal::numeric_binop_impl(OpSelect op_select, Literal const &other, st } }(); - assert(result_entry != nullptr); + RDF4CPP_ASSERT(result_entry != nullptr); return Literal::make_typed_unchecked(std::move(*op_res.result_value), op_res.result_type_id, *result_entry, node_storage); } } @@ -1096,9 +1096,9 @@ Literal Literal::numeric_unop_impl(OpSelect op_select, storage::DynNodeStoragePt } }(); - assert(operand_entry != nullptr); - assert(operand_entry->numeric_ops.has_value()); - assert(operand_entry->numeric_ops->is_impl()); + RDF4CPP_ASSERT(operand_entry != nullptr); + RDF4CPP_ASSERT(operand_entry->numeric_ops.has_value()); + RDF4CPP_ASSERT(operand_entry->numeric_ops->is_impl()); DatatypeRegistry::OpResult op_res = op_select(operand_entry->numeric_ops->get_impl())(value); @@ -1110,7 +1110,7 @@ Literal Literal::numeric_unop_impl(OpSelect op_select, storage::DynNodeStoragePt } }(); - assert(result_entry != nullptr); + RDF4CPP_ASSERT(result_entry != nullptr); return Literal::make_typed_unchecked(std::move(*op_res.result_value), op_res.result_type_id, *result_entry, node_storage); } @@ -1197,7 +1197,7 @@ std::partial_ordering Literal::compare_impl(Literal const &other, std::strong_or } }(); - assert(equalized_compare_fptr != nullptr); + RDF4CPP_ASSERT(equalized_compare_fptr != nullptr); return equalized_compare_fptr(equalizer->convert_lhs(this->value()), equalizer->convert_rhs(other.value())); @@ -1329,7 +1329,7 @@ bool Literal::operator==(Literal const &other) const noexcept { } datatypes::registry::DatatypeIDView Literal::datatype_id() const noexcept { - assert(!this->null()); + RDF4CPP_ASSERT(!this->null()); auto const lit_type = this->handle_.node_id().literal_type(); if (lit_type.is_fixed()) { @@ -1340,7 +1340,7 @@ datatypes::registry::DatatypeIDView Literal::datatype_id() const noexcept { } bool Literal::is_fixed() const noexcept { - assert(!this->null()); + RDF4CPP_ASSERT(!this->null()); return this->handle_.node_id().literal_type().is_fixed(); } @@ -1393,7 +1393,7 @@ std::optional Literal::run_binop(Literal const &other, } }(); - assert(result_entry != nullptr); + RDF4CPP_ASSERT(result_entry != nullptr); return Literal::make_typed_unchecked(std::move(*op_res.result_value), op_res.result_type_id, *result_entry, node_storage); } else { // slow path, needs conversion @@ -1412,7 +1412,7 @@ std::optional Literal::run_binop(Literal const &other, } }(); - assert(equalized_entry != nullptr); + RDF4CPP_ASSERT(equalized_entry != nullptr); DatatypeRegistry::OpResult op_res = std::invoke(std::forward(op), *equalized_entry, @@ -1431,7 +1431,7 @@ std::optional Literal::run_binop(Literal const &other, } }(); - assert(result_entry != nullptr); + RDF4CPP_ASSERT(result_entry != nullptr); return Literal::make_typed_unchecked(std::move(*op_res.result_value), op_res.result_type_id, *result_entry, node_storage); } } @@ -1444,10 +1444,10 @@ std::optional Literal::run_binop_cast_rhs(Literal const &other, Op &&op) const { using namespace datatypes::registry; - assert(!this->null() && !other.null()); + RDF4CPP_ASSERT(!this->null() && !other.null()); auto const *target_entry = DatatypeRegistry::get_entry(other_target); - assert(target_entry != nullptr); + RDF4CPP_ASSERT(target_entry != nullptr); auto const other_converter = DatatypeRegistry::get_common_type_conversion(other_entry.conversion_table, target_entry->conversion_table); if (!other_converter.has_value()) { @@ -1507,7 +1507,7 @@ std::optional Literal::chrono_add_impl(Literal const &other, storage::D if (this_entry->duration_ops.has_value()) { return run_binop(other, this_datatype, *this_entry, other_datatype, *other_entry, node_storage, [](DatatypeRegistry::DatatypeEntry const &entry, std::any const &lhs, std::any const &rhs) noexcept { - assert(entry.duration_ops.has_value()); + RDF4CPP_ASSERT(entry.duration_ops.has_value()); return entry.duration_ops->duration_add(lhs, rhs); }); } @@ -1550,7 +1550,7 @@ Literal &Literal::operator+=(const Literal &other) { std::optional Literal::chrono_sub_impl(Literal const &other, storage::DynNodeStoragePtr node_storage) const { using namespace datatypes::registry; - assert(!this->null() && !other.null()); + RDF4CPP_ASSERT(!this->null() && !other.null()); if ((this->is_fixed_not_timepoint() && this->is_fixed_not_duration()) || (other.is_fixed_not_timepoint() && other.is_fixed_not_duration())) { // is not any of @@ -1578,7 +1578,7 @@ std::optional Literal::chrono_sub_impl(Literal const &other, storage::D // timepoint - timepoint return run_binop(other, this_datatype, *this_entry, other_datatype, *other_entry, node_storage, [](DatatypeRegistry::DatatypeEntry const &entry, std::any const &lhs, std::any const &rhs) noexcept { - assert(entry.timepoint_ops.has_value()); + RDF4CPP_ASSERT(entry.timepoint_ops.has_value()); return entry.timepoint_ops->timepoint_sub(lhs, rhs); }); } @@ -1596,7 +1596,7 @@ std::optional Literal::chrono_sub_impl(Literal const &other, storage::D // duration - duration return run_binop(other, this_datatype, *this_entry, other_datatype, *other_entry, node_storage, [](DatatypeRegistry::DatatypeEntry const &entry, std::any const &lhs, std::any const &rhs) noexcept { - assert(entry.duration_ops.has_value()); + RDF4CPP_ASSERT(entry.duration_ops.has_value()); return entry.duration_ops->duration_sub(lhs, rhs); }); } @@ -1639,7 +1639,7 @@ Literal &Literal::operator-=(const Literal &other) { std::optional Literal::chrono_mul_impl(Literal const &other, storage::DynNodeStoragePtr node_storage) const { using namespace datatypes::registry; - assert(!this->null() && !other.null()); + RDF4CPP_ASSERT(!this->null() && !other.null()); if (this->is_fixed_not_duration() && other.is_fixed_not_numeric()) { // is not @@ -1703,7 +1703,7 @@ Literal &Literal::operator*=(const Literal &other) { std::optional Literal::chrono_div_impl(Literal const &other, storage::DynNodeStoragePtr node_storage) const { using namespace datatypes::registry; - assert(!this->null() && !other.null()); + RDF4CPP_ASSERT(!this->null() && !other.null()); if (this->is_fixed_not_duration() || (other.is_fixed_not_duration() && other.is_fixed_not_numeric())) { // is not any of @@ -1731,7 +1731,7 @@ std::optional Literal::chrono_div_impl(Literal const &other, storage::D auto const binop_res = run_binop(other, this_datatype, *this_entry, other_datatype, *other_entry, node_storage, [](DatatypeRegistry::DatatypeEntry const &entry, std::any const &lhs, std::any const &rhs) noexcept { - assert(entry.duration_ops.has_value()); + RDF4CPP_ASSERT(entry.duration_ops.has_value()); return entry.duration_ops->duration_div(lhs, rhs); }); if (binop_res.has_value()) { diff --git a/src/rdf4cpp/Literal.hpp b/src/rdf4cpp/Literal.hpp index 67aceb9aa..5c57a969c 100644 --- a/src/rdf4cpp/Literal.hpp +++ b/src/rdf4cpp/Literal.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include namespace rdf4cpp { @@ -775,7 +776,7 @@ struct Literal : Node { } else { auto const &impl_converter = DatatypeRegistry::get_numeric_op_impl_conversion(*target_e); auto const *target_num_impl = DatatypeRegistry::get_numerical_ops(impl_converter.target_type_id); - assert(target_num_impl != nullptr); + RDF4CPP_ASSERT(target_num_impl != nullptr); // perform conversion as impl numeric type auto const value = this->template value() ? target_num_impl->get_impl().one_value_fptr() @@ -985,7 +986,7 @@ struct Literal : Node { return T::from_string(lexical.lexical_form); }, [](storage::view::ValueLiteralBackendView const &any) noexcept { - assert(any.datatype == T::datatype_id); + RDF4CPP_ASSERT(any.datatype == T::datatype_id); return std::any_cast(any.value); }); } diff --git a/src/rdf4cpp/Node.cpp b/src/rdf4cpp/Node.cpp index 8d729299a..890094520 100644 --- a/src/rdf4cpp/Node.cpp +++ b/src/rdf4cpp/Node.cpp @@ -5,7 +5,7 @@ #include #include #include - +#include namespace rdf4cpp { @@ -30,8 +30,7 @@ Node Node::to_node_storage(storage::DynNodeStoragePtr node_storage) const { return Literal{handle_}.to_node_storage(node_storage); } default: { - assert(false); - __builtin_unreachable(); + RDF4CPP_UNREACHABLE; } } } @@ -51,8 +50,7 @@ Node Node::try_get_in_node_storage(storage::DynNodeStoragePtr node_storage) cons return Literal{handle_}.try_get_in_node_storage(node_storage); } default: { - assert(false); - __builtin_unreachable(); + RDF4CPP_UNREACHABLE; } } } @@ -76,8 +74,7 @@ bool Node::serialize(writer::BufWriterParts const writer, NodeSerializationOpts return Literal{handle_}.serialize(writer, opts); } default: { - assert(false); - __builtin_unreachable(); + RDF4CPP_UNREACHABLE; } } } @@ -97,8 +94,7 @@ Node::operator std::string() const noexcept { return std::string{Literal{handle_}}; } default: { - assert(false); - __builtin_unreachable(); + RDF4CPP_UNREACHABLE; } } } @@ -150,8 +146,7 @@ TriBool Node::eq_impl(Node const &other) const noexcept { return query::Variable{handle_}.eq(query::Variable{other.handle_}); } default: { - assert(false); // unreachable - return TriBool::Err; + RDF4CPP_UNREACHABLE; } } } @@ -208,8 +203,8 @@ std::strong_ordering Node::order(Node const &other) const noexcept { case storage::identifier::RDFNodeType::Variable: return query::Variable{this->handle_}.order(query::Variable{other.handle_}); default:{ - assert(false); // this will never be reached because RDFNodeType has only 4 values. - return std::strong_ordering::less; + // this will never be reached because RDFNodeType has only 4 values. + RDF4CPP_UNREACHABLE; } } } diff --git a/src/rdf4cpp/Timezone.hpp b/src/rdf4cpp/Timezone.hpp index befdb60b2..e59c45f37 100644 --- a/src/rdf4cpp/Timezone.hpp +++ b/src/rdf4cpp/Timezone.hpp @@ -9,6 +9,7 @@ #include #include +#include #include @@ -303,7 +304,7 @@ struct YearMonthDay { Day day_ = Day{1}; static constexpr std::chrono::day last_day_in_month(Year year, Month month) noexcept { - assert(month.ok()); + RDF4CPP_ASSERT(month.ok()); constexpr unsigned char common[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; auto m = static_cast(month); return std::chrono::day{m != 2 || !year.is_leap() ? common[m - 1] : 29u}; diff --git a/src/rdf4cpp/bnode_mngt/reference_backends/generator/IncreasingIdGenerator.cpp b/src/rdf4cpp/bnode_mngt/reference_backends/generator/IncreasingIdGenerator.cpp index 7aa90a36f..a785b01fb 100644 --- a/src/rdf4cpp/bnode_mngt/reference_backends/generator/IncreasingIdGenerator.cpp +++ b/src/rdf4cpp/bnode_mngt/reference_backends/generator/IncreasingIdGenerator.cpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace rdf4cpp::bnode_mngt { @@ -24,7 +25,7 @@ BlankNode IncreasingIdGenerator::generate(storage::DynNodeStoragePtr node_storag auto write_it = std::copy(prefix_.begin(), prefix_.end(), buf.data()); std::to_chars_result const res = std::to_chars(write_it, write_it + generator_detail::max_generated_id_size, counter_.fetch_add(1, std::memory_order_relaxed)); - assert(res.ec == std::errc{}); + RDF4CPP_ASSERT(res.ec == std::errc{}); // checked in constructor, can use make_unchecked return BlankNode::make_unchecked(std::string_view{buf.data(), static_cast(res.ptr - buf.data())}, node_storage); diff --git a/src/rdf4cpp/bnode_mngt/reference_backends/scope_manager/MergeNodeScopeManager.hpp b/src/rdf4cpp/bnode_mngt/reference_backends/scope_manager/MergeNodeScopeManager.hpp index 04edc024c..7e2a19d2d 100644 --- a/src/rdf4cpp/bnode_mngt/reference_backends/scope_manager/MergeNodeScopeManager.hpp +++ b/src/rdf4cpp/bnode_mngt/reference_backends/scope_manager/MergeNodeScopeManager.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -25,7 +26,7 @@ struct MergeNodeScopeManager { } auto [it, inserted] = scopes.emplace(name, std::make_unique()); - assert(inserted); + RDF4CPP_ASSERT(inserted); return *it->second; } }; diff --git a/src/rdf4cpp/datatypes/rdf/LangString.hpp b/src/rdf4cpp/datatypes/rdf/LangString.hpp index aecc8cc6a..e9b7c53cd 100644 --- a/src/rdf4cpp/datatypes/rdf/LangString.hpp +++ b/src/rdf4cpp/datatypes/rdf/LangString.hpp @@ -10,6 +10,7 @@ #include #include +#include namespace rdf4cpp::datatypes::registry { struct LangStringRepr { @@ -28,29 +29,25 @@ struct DatatypeMapping { template<> inline capabilities::Default::cpp_type capabilities::Default::from_string(std::string_view) { // dummy implementation, actual implementation in Literal - assert(false); - __builtin_unreachable(); + RDF4CPP_UNREACHABLE; } template<> inline bool capabilities::Default::serialize_canonical_string(cpp_type const &, writer::BufWriterParts) noexcept { // dummy implementation, actual implementation in Literal - assert(false); - __builtin_unreachable(); + RDF4CPP_UNREACHABLE; } template<> inline std::optional capabilities::Inlineable::try_into_inlined(cpp_type const &) noexcept { // dummy implementation, actual implementation in Literal - assert(false); - __builtin_unreachable(); + RDF4CPP_UNREACHABLE; } template<> inline capabilities::Inlineable::cpp_type capabilities::Inlineable::from_inlined(storage::identifier::LiteralID) noexcept { // dummy implementation, actual implementation in Literal - assert(false); - __builtin_unreachable(); + RDF4CPP_UNREACHABLE; } #endif diff --git a/src/rdf4cpp/datatypes/registry/DatatypeConversionTyping.hpp b/src/rdf4cpp/datatypes/registry/DatatypeConversionTyping.hpp index 63157e914..6b4e93236 100644 --- a/src/rdf4cpp/datatypes/registry/DatatypeConversionTyping.hpp +++ b/src/rdf4cpp/datatypes/registry/DatatypeConversionTyping.hpp @@ -9,6 +9,7 @@ #include #include #include +#include namespace rdf4cpp::datatypes::registry { @@ -138,8 +139,8 @@ struct RuntimeConversionTable { * for more details see: const version of conversion_at_index */ inline RuntimeConversionEntry &conversion_at_index(size_t s_off, size_t p_off) noexcept { - assert(s_off < s_rank); - assert(p_off < promotion_rank_at_level(s_off)); + RDF4CPP_ASSERT(s_off < s_rank); + RDF4CPP_ASSERT(p_off < promotion_rank_at_level(s_off)); return table[s_off * max_p_rank + p_off]; } @@ -199,8 +200,8 @@ struct RuntimeConversionTable { * @return the found conversion */ [[nodiscard]] inline RuntimeConversionEntry const &conversion_at_index(size_t s_off, size_t p_off) const noexcept { - assert(s_off < s_rank); - assert(p_off < promotion_rank_at_level(s_off)); + RDF4CPP_ASSERT(s_off < s_rank); + RDF4CPP_ASSERT(p_off < promotion_rank_at_level(s_off)); return table[s_off * max_p_rank + p_off]; } diff --git a/src/rdf4cpp/datatypes/registry/DatatypeID.hpp b/src/rdf4cpp/datatypes/registry/DatatypeID.hpp index 01a44dfca..a4d708837 100644 --- a/src/rdf4cpp/datatypes/registry/DatatypeID.hpp +++ b/src/rdf4cpp/datatypes/registry/DatatypeID.hpp @@ -14,6 +14,7 @@ #include #include +#include namespace rdf4cpp::datatypes::registry { @@ -75,7 +76,7 @@ struct DatatypeIDView { public: constexpr DatatypeIDView(storage::identifier::LiteralType fixed) noexcept : inner{fixed} { - assert(fixed.is_fixed()); + RDF4CPP_ASSERT(fixed.is_fixed()); } explicit constexpr DatatypeIDView(std::string_view const other) noexcept diff --git a/src/rdf4cpp/datatypes/registry/DatatypeRegistry.cpp b/src/rdf4cpp/datatypes/registry/DatatypeRegistry.cpp index 105436197..c63e68fa0 100644 --- a/src/rdf4cpp/datatypes/registry/DatatypeRegistry.cpp +++ b/src/rdf4cpp/datatypes/registry/DatatypeRegistry.cpp @@ -17,10 +17,10 @@ DatatypeRegistry::registered_datatypes_t &DatatypeRegistry::get_mutable() noexce void DatatypeRegistry::add_fixed(DatatypeEntry entry_to_add, LiteralType type_id) noexcept { auto const id_as_index = static_cast(type_id.to_underlying()) - 1; // ids from 1 to n stored in places 0 to n-1 - assert(id_as_index < dynamic_datatype_offset); + RDF4CPP_ASSERT(id_as_index < dynamic_datatype_offset); auto &slot = DatatypeRegistry::get_mutable()[id_as_index]; - assert(slot.datatype_iri.empty()); // is placeholder + RDF4CPP_ASSERT(slot.datatype_iri.empty()); // is placeholder slot = std::move(entry_to_add); } @@ -170,8 +170,8 @@ DatatypeRegistry::InliningOps const *DatatypeRegistry::get_inlining_ops(Datatype } std::optional DatatypeRegistry::get_common_numeric_op_type_conversion(DatatypeEntry const &lhs_entry, DatatypeEntry const &rhs_entry) noexcept { - assert(lhs_entry.numeric_ops.has_value()); - assert(rhs_entry.numeric_ops.has_value()); + RDF4CPP_ASSERT(lhs_entry.numeric_ops.has_value()); + RDF4CPP_ASSERT(rhs_entry.numeric_ops.has_value()); size_t const lhs_init_soff = lhs_entry.numeric_ops->is_stub() ? lhs_entry.numeric_ops->get_stub().start_s_off : 0; size_t const rhs_init_soff = rhs_entry.numeric_ops->is_stub() ? rhs_entry.numeric_ops->get_stub().start_s_off : 0; @@ -180,8 +180,8 @@ std::optional DatatypeRegistry::get_common_ } RuntimeConversionEntry const &DatatypeRegistry::get_numeric_op_impl_conversion(DatatypeEntry const &entry) noexcept { - assert(entry.numeric_ops.has_value()); - assert(entry.numeric_ops->is_stub()); + RDF4CPP_ASSERT(entry.numeric_ops.has_value()); + RDF4CPP_ASSERT(entry.numeric_ops->is_stub()); return entry.conversion_table.conversion_at_index(entry.numeric_ops->get_stub().start_s_off, 0); } @@ -213,7 +213,7 @@ std::optional DatatypeRegistry::get_common_ auto const greater_s_rank = greater.subtype_rank() - greater_init_soff; // lesser should be the conversion table of the type with lower subtype rank - assert(lesser_s_rank <= greater_s_rank); + RDF4CPP_ASSERT(lesser_s_rank <= greater_s_rank); // calculate initial subtype offsets to equalize subtype rank size_t lesser_s_off = lesser_init_soff; diff --git a/src/rdf4cpp/datatypes/registry/DatatypeRegistry.hpp b/src/rdf4cpp/datatypes/registry/DatatypeRegistry.hpp index 5f9f7900a..683ebcadf 100644 --- a/src/rdf4cpp/datatypes/registry/DatatypeRegistry.hpp +++ b/src/rdf4cpp/datatypes/registry/DatatypeRegistry.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -182,7 +183,7 @@ struct DatatypeRegistry { RuntimeConversionEntry::inverted_convert_fptr_t inverted_convert_rhs; inline static DatatypeConverter from_individuals(RuntimeConversionEntry const &l, RuntimeConversionEntry const &r) noexcept { - assert(l.target_type_id == r.target_type_id); + RDF4CPP_ASSERT(l.target_type_id == r.target_type_id); return DatatypeConverter{ .target_type_id = l.target_type_id, @@ -539,7 +540,7 @@ std::optional return visit(DatatypeIDVisitor{ [®istry, f](LiteralType const fixed_id) -> ret_type { auto const id_as_index = static_cast(fixed_id.to_underlying()) - 1; // ids from 1 to n stored in places 0 to n-1 - assert(id_as_index < dynamic_datatype_offset); + RDF4CPP_ASSERT(id_as_index < dynamic_datatype_offset); return f(registry[id_as_index]); }, diff --git a/src/rdf4cpp/datatypes/registry/util/CharConvExt.hpp b/src/rdf4cpp/datatypes/registry/util/CharConvExt.hpp index 5202bc9ac..3869d74a5 100644 --- a/src/rdf4cpp/datatypes/registry/util/CharConvExt.hpp +++ b/src/rdf4cpp/datatypes/registry/util/CharConvExt.hpp @@ -10,6 +10,7 @@ #include #include +#include namespace rdf4cpp::datatypes::registry::util { /** @@ -30,7 +31,7 @@ bool to_chars_canonical(I const value, writer::BufWriterParts const writer) noex std::array buf; std::to_chars_result const res = std::to_chars(buf.data(), buf.data() + buf.size(), value); - assert(res.ec == std::errc{}); + RDF4CPP_ASSERT(res.ec == std::errc{}); std::string_view const s{buf.data(), static_cast(res.ptr - buf.data())}; return writer::write_str(s, writer); @@ -134,10 +135,10 @@ bool to_chars_canonical(F const value, writer::BufWriterParts const writer) noex std::array buf; std::to_chars_result res = std::to_chars(buf.data(), buf.data() + buf.size(), value, std::chars_format::scientific); - assert(res.ec == std::errc{}); + RDF4CPP_ASSERT(res.ec == std::errc{}); auto *e_ptr = std::find(buf.data(), res.ptr, 'e'); - assert(e_ptr != res.ptr); // serializing in scientific notation, there must be an 'e' + RDF4CPP_ASSERT(e_ptr != res.ptr); // serializing in scientific notation, there must be an 'e' *e_ptr = 'E'; // convert 'e' to 'E' as required by the SPARQL standard if (auto *dot_ptr = buf.data() + 1; dot_ptr == e_ptr) { @@ -196,7 +197,7 @@ bool to_chars_simplified(F const value, writer::BufWriterParts const writer) noe std::array buf; auto const res = std::to_chars(buf.data(), buf.data() + buf.size(), value, std::chars_format::fixed); - assert(res.ec == std::errc{}); + RDF4CPP_ASSERT(res.ec == std::errc{}); std::string_view const s{buf.data(), static_cast(res.ptr - buf.data())}; return writer::write_str(s, writer); diff --git a/src/rdf4cpp/datatypes/registry/util/DateTimeUtils.hpp b/src/rdf4cpp/datatypes/registry/util/DateTimeUtils.hpp index 06426d150..2ce7a4539 100644 --- a/src/rdf4cpp/datatypes/registry/util/DateTimeUtils.hpp +++ b/src/rdf4cpp/datatypes/registry/util/DateTimeUtils.hpp @@ -10,6 +10,7 @@ #include #include #include +#include /** * @file @@ -44,7 +45,7 @@ std::chrono::duration, R> to_checked(std */ template std::chrono::duration from_checked(std::chrono::duration, R> v) noexcept { - assert(!v.count().is_invalid()); + RDF4CPP_ASSERT(!v.count().is_invalid()); return std::chrono::duration{v.count().get_value()}; } /** @@ -169,7 +170,7 @@ inline char *canonical_seconds_remove_empty_millis(char *it) { return it; --it; } - assert(*(it - 1) == '.'); + RDF4CPP_ASSERT(*(it - 1) == '.'); --it; return it; } diff --git a/src/rdf4cpp/datatypes/registry/util/Inlining.hpp b/src/rdf4cpp/datatypes/registry/util/Inlining.hpp index 5f3bc30e4..e978c34b1 100644 --- a/src/rdf4cpp/datatypes/registry/util/Inlining.hpp +++ b/src/rdf4cpp/datatypes/registry/util/Inlining.hpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace rdf4cpp::datatypes::registry::util { @@ -107,7 +108,7 @@ constexpr T unpack(P packed_value) noexcept { template constexpr P pack_signed(T value) noexcept { // bit at position bits - 1 must have the same value as every bit to the left of it - assert(packing_detail::no_information_in_bits_after(value)); + RDF4CPP_ASSERT(packing_detail::no_information_in_bits_after(value)); if constexpr (sizeof(T) * 8 > bits) { using UT = std::make_unsigned_t; diff --git a/src/rdf4cpp/datatypes/xsd/Base64Binary.cpp b/src/rdf4cpp/datatypes/xsd/Base64Binary.cpp index ed09bb2f6..15c698b72 100644 --- a/src/rdf4cpp/datatypes/xsd/Base64Binary.cpp +++ b/src/rdf4cpp/datatypes/xsd/Base64Binary.cpp @@ -5,6 +5,7 @@ #include #include +#include namespace rdf4cpp::datatypes::registry { @@ -116,7 +117,7 @@ Base64BinaryRepr Base64BinaryRepr::from_encoded(std::string_view const base64enc auto const old_pos = pos; while (ch == ' ') { - assert(pos < base64encoded.size()); + RDF4CPP_ASSERT(pos < base64encoded.size()); ch = base64encoded[pos++]; } diff --git a/src/rdf4cpp/datatypes/xsd/Decimal.cpp b/src/rdf4cpp/datatypes/xsd/Decimal.cpp index 3ec34eb43..9a6f0ca96 100644 --- a/src/rdf4cpp/datatypes/xsd/Decimal.cpp +++ b/src/rdf4cpp/datatypes/xsd/Decimal.cpp @@ -6,6 +6,7 @@ #include #include +#include namespace rdf4cpp::datatypes::registry { @@ -166,14 +167,14 @@ std::optional capabilities::Inlineable(inlined); } template<> capabilities::Inlineable::cpp_type capabilities::Inlineable::from_inlined(storage::identifier::LiteralID inlined) noexcept { auto const data = util::unpack(inlined); - assert(data.padding == 0); + RDF4CPP_ASSERT(data.padding == 0); auto const unscaled_value = util::unpack_integral(data.unscaled_value); auto const exponent = util::unpack_integral(data.exponent); diff --git a/src/rdf4cpp/datatypes/xsd/HexBinary.cpp b/src/rdf4cpp/datatypes/xsd/HexBinary.cpp index a57372a77..17d773cff 100644 --- a/src/rdf4cpp/datatypes/xsd/HexBinary.cpp +++ b/src/rdf4cpp/datatypes/xsd/HexBinary.cpp @@ -3,6 +3,7 @@ #include #include +#include namespace rdf4cpp::datatypes::registry { @@ -46,7 +47,7 @@ static uint8_t hex_decode(char const ch) { template static char hex_encode(uint8_t const half_octet) noexcept { - assert(half_octet <= 15); + RDF4CPP_ASSERT(half_octet <= 15); if constexpr (mode == Mode::Number) { return encode_lut[half_octet]; diff --git a/src/rdf4cpp/datatypes/xsd/String.hpp b/src/rdf4cpp/datatypes/xsd/String.hpp index b84db823a..16ea90730 100644 --- a/src/rdf4cpp/datatypes/xsd/String.hpp +++ b/src/rdf4cpp/datatypes/xsd/String.hpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace rdf4cpp::datatypes::registry { @@ -16,15 +17,13 @@ struct DatatypeMapping { template<> inline capabilities::Default::cpp_type capabilities::Default::from_string(std::string_view) { // dummy implementation, actual implementation in Literal - assert(false); - __builtin_unreachable(); + RDF4CPP_UNREACHABLE; } template<> inline bool capabilities::Default::serialize_canonical_string(cpp_type const &, writer::BufWriterParts) noexcept { // dummy implementation, actual implementation in Literal - assert(false); - __builtin_unreachable(); + RDF4CPP_UNREACHABLE; } template<> diff --git a/src/rdf4cpp/datatypes/xsd/time/Date.cpp b/src/rdf4cpp/datatypes/xsd/time/Date.cpp index 8d928c0e3..cd899f93d 100644 --- a/src/rdf4cpp/datatypes/xsd/time/Date.cpp +++ b/src/rdf4cpp/datatypes/xsd/time/Date.cpp @@ -1,6 +1,7 @@ #include "Date.hpp" #include +#include namespace rdf4cpp::datatypes::registry { @@ -35,7 +36,7 @@ bool capabilities::Default::serialize_canonical_string(cpp_type const it = value.second->to_canonical_string(it); } size_t const len = it - buff.data(); - assert(len <= buff.size()); + RDF4CPP_ASSERT(len <= buff.size()); return writer::write_str(std::string_view(buff.data(), len), writer); } diff --git a/src/rdf4cpp/datatypes/xsd/time/DateTime.cpp b/src/rdf4cpp/datatypes/xsd/time/DateTime.cpp index 063dc3b8c..c3a614df0 100644 --- a/src/rdf4cpp/datatypes/xsd/time/DateTime.cpp +++ b/src/rdf4cpp/datatypes/xsd/time/DateTime.cpp @@ -66,7 +66,7 @@ bool capabilities::Default::serialize_canonical_string(cpp_type co it = value.second->to_canonical_string(it); } size_t const len = it - buff.data(); - assert(len <= buff.size()); + RDF4CPP_ASSERT(len <= buff.size()); return writer::write_str(std::string_view(buff.data(), len), writer); } diff --git a/src/rdf4cpp/datatypes/xsd/time/DateTimeStamp.cpp b/src/rdf4cpp/datatypes/xsd/time/DateTimeStamp.cpp index bd5cc7d79..a7ee098d7 100644 --- a/src/rdf4cpp/datatypes/xsd/time/DateTimeStamp.cpp +++ b/src/rdf4cpp/datatypes/xsd/time/DateTimeStamp.cpp @@ -71,7 +71,7 @@ bool capabilities::Default::serialize_canonical_string(cpp_ty it = util::canonical_seconds_remove_empty_millis(it); it = value.get_time_zone().to_canonical_string(it); size_t const len = it - buff.data(); - assert(len <= buff.size()); + RDF4CPP_ASSERT(len <= buff.size()); return writer::write_str(std::string_view(buff.data(), len), writer); } diff --git a/src/rdf4cpp/datatypes/xsd/time/Day.cpp b/src/rdf4cpp/datatypes/xsd/time/Day.cpp index 819d9dd53..d0815137c 100644 --- a/src/rdf4cpp/datatypes/xsd/time/Day.cpp +++ b/src/rdf4cpp/datatypes/xsd/time/Day.cpp @@ -32,7 +32,7 @@ bool capabilities::Default::serialize_canonical_string(cpp_type const it = value.second->to_canonical_string(it); } size_t const len = it - buff.data(); - assert(len <= buff.size()); + RDF4CPP_ASSERT(len <= buff.size()); return writer::write_str(std::string_view(buff.data(), len), writer); } diff --git a/src/rdf4cpp/datatypes/xsd/time/DayTimeDuration.cpp b/src/rdf4cpp/datatypes/xsd/time/DayTimeDuration.cpp index 2e03233d3..4d1cefe33 100644 --- a/src/rdf4cpp/datatypes/xsd/time/DayTimeDuration.cpp +++ b/src/rdf4cpp/datatypes/xsd/time/DayTimeDuration.cpp @@ -105,7 +105,7 @@ bool capabilities::Default::serialize_canonical_string(cpp_ } } size_t const len = it - buff.data(); - assert(len <= buff.size()); + RDF4CPP_ASSERT(len <= buff.size()); return writer::write_str(std::string_view(buff.data(), len), writer); } diff --git a/src/rdf4cpp/datatypes/xsd/time/Duration.cpp b/src/rdf4cpp/datatypes/xsd/time/Duration.cpp index d04098c53..4488565f3 100644 --- a/src/rdf4cpp/datatypes/xsd/time/Duration.cpp +++ b/src/rdf4cpp/datatypes/xsd/time/Duration.cpp @@ -128,7 +128,7 @@ bool capabilities::Default::serialize_canonical_string(cpp_type co } } size_t const len = it - buff.data(); - assert(len <= buff.size()); + RDF4CPP_ASSERT(len <= buff.size()); return writer::write_str(std::string_view(buff.data(), len), writer); } diff --git a/src/rdf4cpp/datatypes/xsd/time/Month.cpp b/src/rdf4cpp/datatypes/xsd/time/Month.cpp index 95c7eeef3..3888bb7c9 100644 --- a/src/rdf4cpp/datatypes/xsd/time/Month.cpp +++ b/src/rdf4cpp/datatypes/xsd/time/Month.cpp @@ -32,7 +32,7 @@ bool capabilities::Default::serialize_canonical_string(cpp_type cons it = value.second->to_canonical_string(it); } size_t const len = it - buff.data(); - assert(len <= buff.size()); + RDF4CPP_ASSERT(len <= buff.size()); return writer::write_str(std::string_view(buff.data(), len), writer); } diff --git a/src/rdf4cpp/datatypes/xsd/time/MonthDay.cpp b/src/rdf4cpp/datatypes/xsd/time/MonthDay.cpp index c938853cf..f36476c94 100644 --- a/src/rdf4cpp/datatypes/xsd/time/MonthDay.cpp +++ b/src/rdf4cpp/datatypes/xsd/time/MonthDay.cpp @@ -36,7 +36,7 @@ bool capabilities::Default::serialize_canonical_string(cpp_type c it = value.second->to_canonical_string(it); } size_t const len = it - buff.data(); - assert(len <= buff.size()); + RDF4CPP_ASSERT(len <= buff.size()); return writer::write_str(std::string_view(buff.data(), len), writer); } diff --git a/src/rdf4cpp/datatypes/xsd/time/Time.cpp b/src/rdf4cpp/datatypes/xsd/time/Time.cpp index f489023be..d9516a735 100644 --- a/src/rdf4cpp/datatypes/xsd/time/Time.cpp +++ b/src/rdf4cpp/datatypes/xsd/time/Time.cpp @@ -44,7 +44,7 @@ bool capabilities::Default::serialize_canonical_string(cpp_type const it = value.second->to_canonical_string(it); } size_t const len = it - buff.data(); - assert(len <= buff.size()); + RDF4CPP_ASSERT(len <= buff.size()); return writer::write_str(std::string_view(buff.data(), len), writer); } diff --git a/src/rdf4cpp/datatypes/xsd/time/Year.cpp b/src/rdf4cpp/datatypes/xsd/time/Year.cpp index fddba2a64..7958de751 100644 --- a/src/rdf4cpp/datatypes/xsd/time/Year.cpp +++ b/src/rdf4cpp/datatypes/xsd/time/Year.cpp @@ -20,7 +20,7 @@ bool capabilities::Default::serialize_canonical_string(cpp_type const it = value.second->to_canonical_string(it); } size_t const len = it - buff.data(); - assert(len <= buff.size()); + RDF4CPP_ASSERT(len <= buff.size()); return writer::write_str(std::string_view(buff.data(), len), writer); } diff --git a/src/rdf4cpp/datatypes/xsd/time/YearMonth.cpp b/src/rdf4cpp/datatypes/xsd/time/YearMonth.cpp index c2c2f17ab..f12200bc2 100644 --- a/src/rdf4cpp/datatypes/xsd/time/YearMonth.cpp +++ b/src/rdf4cpp/datatypes/xsd/time/YearMonth.cpp @@ -30,7 +30,7 @@ bool capabilities::Default::serialize_canonical_string(cpp_type it = value.second->to_canonical_string(it); } size_t const len = it - buff.data(); - assert(len <= buff.size()); + RDF4CPP_ASSERT(len <= buff.size()); return writer::write_str(std::string_view(buff.data(), len), writer); } diff --git a/src/rdf4cpp/datatypes/xsd/time/YearMonthDuration.cpp b/src/rdf4cpp/datatypes/xsd/time/YearMonthDuration.cpp index ddb23feb5..1f97c3478 100644 --- a/src/rdf4cpp/datatypes/xsd/time/YearMonthDuration.cpp +++ b/src/rdf4cpp/datatypes/xsd/time/YearMonthDuration.cpp @@ -69,7 +69,7 @@ bool capabilities::Default::serialize_canonical_string(cp *(it++) = 'M'; } size_t const len = it - buff.data(); - assert(len <= buff.size()); + RDF4CPP_ASSERT(len <= buff.size()); return writer::write_str(std::string_view(buff.data(), len), writer); } diff --git a/src/rdf4cpp/parser/IStreamQuadIterator.cpp b/src/rdf4cpp/parser/IStreamQuadIterator.cpp index 51a8ff91c..677a8522c 100644 --- a/src/rdf4cpp/parser/IStreamQuadIterator.cpp +++ b/src/rdf4cpp/parser/IStreamQuadIterator.cpp @@ -19,7 +19,7 @@ namespace rdf4cpp::parser { * @param voided_self pointer to std::istream cast to void * */ static size_t istream_read(void *buf, [[maybe_unused]] size_t elem_size, size_t count, void *voided_self) noexcept { - assert(elem_size == 1); + RDF4CPP_ASSERT(elem_size == 1); auto *self = static_cast(voided_self); self->read(static_cast(buf), static_cast(count)); diff --git a/src/rdf4cpp/query/Solution.cpp b/src/rdf4cpp/query/Solution.cpp index f6cd061bc..1d6ad5162 100644 --- a/src/rdf4cpp/query/Solution.cpp +++ b/src/rdf4cpp/query/Solution.cpp @@ -34,17 +34,17 @@ Node Solution::operator[](Variable const &variable) const noexcept { } Node const &Solution::operator[](size_t pos) const noexcept { - assert(pos < partial_mapping.size()); + RDF4CPP_ASSERT(pos < partial_mapping.size()); return partial_mapping[pos].second; } Node &Solution::operator[](size_t pos) noexcept { - assert(pos < partial_mapping.size()); + RDF4CPP_ASSERT(pos < partial_mapping.size()); return partial_mapping[pos].second; } Variable const &Solution::variable(size_t pos) const noexcept { - assert(pos < partial_mapping.size()); + RDF4CPP_ASSERT(pos < partial_mapping.size()); return partial_mapping[pos].first; } diff --git a/src/rdf4cpp/query/Variable.cpp b/src/rdf4cpp/query/Variable.cpp index e11da5800..7b0a301bb 100644 --- a/src/rdf4cpp/query/Variable.cpp +++ b/src/rdf4cpp/query/Variable.cpp @@ -44,7 +44,7 @@ namespace detail_variable_inlining { } [[nodiscard]] constexpr InlinedRepr from_inlined(storage::identifier::NodeBackendID id) noexcept { - assert(id.is_inlined() && id.is_variable()); + RDF4CPP_ASSERT(id.is_inlined() && id.is_variable()); return std::bit_cast(id.node_id()); } diff --git a/src/rdf4cpp/storage/identifier/LiteralID.hpp b/src/rdf4cpp/storage/identifier/LiteralID.hpp index 50a64564b..82927423e 100644 --- a/src/rdf4cpp/storage/identifier/LiteralID.hpp +++ b/src/rdf4cpp/storage/identifier/LiteralID.hpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace rdf4cpp::storage::identifier { /** @@ -27,7 +28,7 @@ struct __attribute__((__packed__)) LiteralID { * @param underlying literal ID. MUST be smaller than 2^42. Bounds are not checked. */ explicit constexpr LiteralID(underlying_type const underlying) noexcept : underlying{underlying} { - assert(underlying < (1UL << 42)); + RDF4CPP_ASSERT(underlying < (1UL << 42)); } constexpr LiteralID &operator++() noexcept { diff --git a/src/rdf4cpp/storage/identifier/LiteralType.hpp b/src/rdf4cpp/storage/identifier/LiteralType.hpp index 6e6e236e1..701dc8357 100644 --- a/src/rdf4cpp/storage/identifier/LiteralType.hpp +++ b/src/rdf4cpp/storage/identifier/LiteralType.hpp @@ -7,6 +7,7 @@ #include #include #include +#include namespace rdf4cpp::storage::identifier { @@ -49,7 +50,7 @@ struct __attribute__((__packed__)) LiteralType { constexpr LiteralType() noexcept = default; explicit constexpr LiteralType(underlying_type const underlying) noexcept : underlying_{underlying} { - assert((underlying & 0b1100'0000) == 0); + RDF4CPP_ASSERT((underlying & 0b1100'0000) == 0); } static constexpr LiteralType other() noexcept { @@ -57,8 +58,8 @@ struct __attribute__((__packed__)) LiteralType { } static constexpr LiteralType from_parts(LiteralTypeTag tag, underlying_type const type_id) noexcept { - assert(tag != LiteralTypeTag::Default || type_id != 0); - assert((type_id & 0b1111'0000) == 0); + RDF4CPP_ASSERT(tag != LiteralTypeTag::Default || type_id != 0); + RDF4CPP_ASSERT((type_id & 0b1111'0000) == 0); return LiteralType{static_cast(type_id | (static_cast(tag) << numeric_tagging_bit_shift))}; } diff --git a/src/rdf4cpp/storage/identifier/NodeBackendHandle.hpp b/src/rdf4cpp/storage/identifier/NodeBackendHandle.hpp index 88ee2c1e1..3f99448c6 100644 --- a/src/rdf4cpp/storage/identifier/NodeBackendHandle.hpp +++ b/src/rdf4cpp/storage/identifier/NodeBackendHandle.hpp @@ -43,7 +43,7 @@ struct NodeBackendHandle { bool const inlined = false, uint16_t const tagging_bits = 0) noexcept : id_{node_id, node_type, inlined, tagging_bits}, storage_{storage} { - assert(tagging_bits < (1 << 13)); + RDF4CPP_ASSERT(tagging_bits < (1 << 13)); } /** @@ -159,7 +159,7 @@ struct NodeBackendHandle { * @return */ [[nodiscard]] view::IRIBackendView iri_backend() const noexcept { - assert(id_.is_iri()); + RDF4CPP_ASSERT(id_.is_iri()); return storage_.find_iri_backend(id_); } @@ -169,7 +169,7 @@ struct NodeBackendHandle { * @return */ [[nodiscard]] view::LiteralBackendView literal_backend() const noexcept { - assert(id_.is_literal()); + RDF4CPP_ASSERT(id_.is_literal()); return storage_.find_literal_backend(id_); } @@ -179,7 +179,7 @@ struct NodeBackendHandle { * @return */ [[nodiscard]] view::BNodeBackendView bnode_backend() const noexcept { - assert(id_.is_blank_node()); + RDF4CPP_ASSERT(id_.is_blank_node()); return storage_.find_bnode_backend(id_); } @@ -189,7 +189,7 @@ struct NodeBackendHandle { * @return */ [[nodiscard]] view::VariableBackendView variable_backend() const noexcept { - assert(id_.is_variable()); + RDF4CPP_ASSERT(id_.is_variable()); return storage_.find_variable_backend(id_); } }; @@ -207,8 +207,8 @@ inline std::ostream &operator<<(std::ostream &os, NodeBackendHandle handle) { * @return handle to the datatype of the literal */ [[nodiscard]] inline NodeBackendHandle datatype_iri_handle_for_fixed_lit_handle(NodeBackendHandle lit_handle) noexcept { - assert(lit_handle.is_literal()); - assert(lit_handle.node_id().literal_type().is_fixed()); + RDF4CPP_ASSERT(lit_handle.is_literal()); + RDF4CPP_ASSERT(lit_handle.node_id().literal_type().is_fixed()); return NodeBackendHandle{literal_type_to_iri_node_id(lit_handle.node_id().literal_type()), lit_handle.storage()}; } diff --git a/src/rdf4cpp/storage/identifier/NodeBackendID.hpp b/src/rdf4cpp/storage/identifier/NodeBackendID.hpp index 2a23b8018..105b87d34 100644 --- a/src/rdf4cpp/storage/identifier/NodeBackendID.hpp +++ b/src/rdf4cpp/storage/identifier/NodeBackendID.hpp @@ -47,7 +47,7 @@ struct alignas(uint64_t) NodeBackendID { RDFNodeType const node_type, bool const inlined = false, uint16_t const tagging_bits = 0) noexcept : parts_{node_id, node_type, inlined, tagging_bits} { - assert(tagging_bits < (1 << tagging_bits_width)); + RDF4CPP_ASSERT(tagging_bits < (1 << tagging_bits_width)); } /** @@ -126,7 +126,7 @@ struct alignas(uint64_t) NodeBackendID { * @param new_value */ constexpr void set_free_tagging_bits(uint16_t new_value) noexcept { - assert(new_value < (1 << tagging_bits_width)); + RDF4CPP_ASSERT(new_value < (1 << tagging_bits_width)); parts_.free_tagging_bits_ = new_value; } @@ -179,7 +179,7 @@ inline std::ostream &operator<<(std::ostream &os, NodeBackendID id) { * @return the LiteralType associated with that IRI */ constexpr LiteralType iri_node_id_to_literal_type(NodeBackendID const id) noexcept { - assert(id.is_iri()); + RDF4CPP_ASSERT(id.is_iri()); auto const value = id.node_id().to_underlying(); // all ids values below min_dynamic_datatype_id (except for the null id) are reserved for fixed datatype IRIs @@ -195,7 +195,7 @@ constexpr LiteralType iri_node_id_to_literal_type(NodeBackendID const id) noexce * @return NodeID of the IRI associated with the given datatype */ constexpr NodeBackendID literal_type_to_iri_node_id(LiteralType const datatype) { - assert(datatype.is_fixed()); + RDF4CPP_ASSERT(datatype.is_fixed()); return NodeBackendID{NodeID{datatype.to_underlying()}, RDFNodeType::IRI}; } diff --git a/src/rdf4cpp/storage/identifier/NodeID.hpp b/src/rdf4cpp/storage/identifier/NodeID.hpp index c996307fe..afdb28949 100644 --- a/src/rdf4cpp/storage/identifier/NodeID.hpp +++ b/src/rdf4cpp/storage/identifier/NodeID.hpp @@ -45,7 +45,7 @@ struct __attribute__((__packed__)) NodeID { * @param value literal ID. MUST be smaller than 2^48. Bounds are not checked. */ explicit constexpr NodeID(underlying_type const underlying) noexcept : underlying_{underlying} { - assert(underlying < (1UL << 48)); + RDF4CPP_ASSERT(underlying < (1UL << 48)); } constexpr NodeID(LiteralID const literal_id, LiteralType const literal_type) noexcept diff --git a/src/rdf4cpp/storage/reference_node_storage/SpecializedLiteralBackend.hpp b/src/rdf4cpp/storage/reference_node_storage/SpecializedLiteralBackend.hpp index 47f1e58e4..812bdf2b2 100644 --- a/src/rdf4cpp/storage/reference_node_storage/SpecializedLiteralBackend.hpp +++ b/src/rdf4cpp/storage/reference_node_storage/SpecializedLiteralBackend.hpp @@ -18,7 +18,7 @@ struct SpecializedLiteralBackend { explicit SpecializedLiteralBackend(view_type const &view) noexcept : hash{view.hash()}, value{std::any_cast(view.value)} { - assert(view.datatype == SpecializedLiteralBackend::datatype); + RDF4CPP_ASSERT(view.datatype == SpecializedLiteralBackend::datatype); } explicit operator view_type() const noexcept { @@ -49,12 +49,12 @@ struct SpecializedLiteralBackend { } bool operator()(view_type const &lhs, SpecializedLiteralBackend const &rhs) const noexcept { - assert(lhs.datatype == SpecializedLiteralBackend::datatype); + RDF4CPP_ASSERT(lhs.datatype == SpecializedLiteralBackend::datatype); return lhs.eq(rhs.value); } bool operator()(SpecializedLiteralBackend const &lhs, view_type const &rhs) const noexcept { - assert(SpecializedLiteralBackend::datatype == rhs.datatype); + RDF4CPP_ASSERT(SpecializedLiteralBackend::datatype == rhs.datatype); return rhs.eq(lhs.value); } }; @@ -63,7 +63,7 @@ struct SpecializedLiteralBackend { using is_transparent = void; [[nodiscard]] size_t operator()(view_type const &x) const noexcept { - assert(x.datatype == SpecializedLiteralBackend::datatype); + RDF4CPP_ASSERT(x.datatype == SpecializedLiteralBackend::datatype); return x.hash(); } }; diff --git a/src/rdf4cpp/storage/reference_node_storage/SyncReferenceNodeStorage.cpp b/src/rdf4cpp/storage/reference_node_storage/SyncReferenceNodeStorage.cpp index 1380927eb..ffe625a05 100644 --- a/src/rdf4cpp/storage/reference_node_storage/SyncReferenceNodeStorage.cpp +++ b/src/rdf4cpp/storage/reference_node_storage/SyncReferenceNodeStorage.cpp @@ -96,11 +96,11 @@ static identifier::NodeBackendID lookup_or_insert_impl(typename Storage::backend identifier::NodeBackendID SyncReferenceNodeStorage::find_or_make_id(view::LiteralBackendView const &view) { return view.visit( [this](view::LexicalFormLiteralBackendView const &lexical) { - assert(!has_specialized_storage_for(identifier::iri_node_id_to_literal_type(lexical.datatype_id))); + RDF4CPP_ASSERT(!has_specialized_storage_for(identifier::iri_node_id_to_literal_type(lexical.datatype_id))); return lookup_or_insert_impl(lexical, this->fallback_literal_storage_); }, [this](view::ValueLiteralBackendView const &any) { - assert(has_specialized_storage_for(any.datatype)); + RDF4CPP_ASSERT(has_specialized_storage_for(any.datatype)); return specialization_detail::visit_specialized(this->specialized_literal_storage_, any.datatype, [&any](auto &storage) { return lookup_or_insert_impl(any, storage); }); @@ -130,12 +130,12 @@ identifier::NodeBackendID SyncReferenceNodeStorage::find_id(view::IRIBackendView identifier::NodeBackendID SyncReferenceNodeStorage::find_id(view::LiteralBackendView const &view) const noexcept { return view.visit( [this](view::LexicalFormLiteralBackendView const &lexical) noexcept { - assert(!has_specialized_storage_for(identifier::iri_node_id_to_literal_type(lexical.datatype_id))); + RDF4CPP_ASSERT(!has_specialized_storage_for(identifier::iri_node_id_to_literal_type(lexical.datatype_id))); return lookup_or_insert_impl(lexical, this->fallback_literal_storage_); }, [this](view::ValueLiteralBackendView const &any) noexcept { return specialization_detail::visit_specialized(this->specialized_literal_storage_, any.datatype, [&any](auto const &storage) noexcept { - assert(has_specialized_storage_for(any.datatype)); + RDF4CPP_ASSERT(has_specialized_storage_for(any.datatype)); return lookup_or_insert_impl(any, storage); }); }); @@ -152,8 +152,7 @@ static typename Storage::backend_view_type find_backend_view(Storage &storage, i if (auto const *value = storage.mapping.lookup_value(Storage::to_storage_id(id)); value != nullptr) { return static_cast(*value); } else { - assert(false); // assert in debug build; not critical error but should not happen - return Storage::get_default_view(); + RDF4CPP_DEBUG_UNREACHABLE(Storage::get_default_view()); } } diff --git a/src/rdf4cpp/storage/reference_node_storage/UnsyncReferenceNodeStorage.cpp b/src/rdf4cpp/storage/reference_node_storage/UnsyncReferenceNodeStorage.cpp index fad547435..16dd0577c 100644 --- a/src/rdf4cpp/storage/reference_node_storage/UnsyncReferenceNodeStorage.cpp +++ b/src/rdf4cpp/storage/reference_node_storage/UnsyncReferenceNodeStorage.cpp @@ -78,11 +78,11 @@ static identifier::NodeBackendID lookup_or_insert_impl(typename Storage::backend identifier::NodeBackendID UnsyncReferenceNodeStorage::find_or_make_id(view::LiteralBackendView const &view) { return view.visit( [this](view::LexicalFormLiteralBackendView const &lexical) { - assert(!has_specialized_storage_for(identifier::iri_node_id_to_literal_type(lexical.datatype_id))); + RDF4CPP_ASSERT(!has_specialized_storage_for(identifier::iri_node_id_to_literal_type(lexical.datatype_id))); return lookup_or_insert_impl(lexical, this->fallback_literal_storage_); }, [this](view::ValueLiteralBackendView const &any) { - assert(has_specialized_storage_for(any.datatype)); + RDF4CPP_ASSERT(has_specialized_storage_for(any.datatype)); return specialization_detail::visit_specialized(this->specialized_literal_storage_, any.datatype, [&any](auto &storage) { return lookup_or_insert_impl(any, storage); }); @@ -112,12 +112,12 @@ identifier::NodeBackendID UnsyncReferenceNodeStorage::find_id(view::IRIBackendVi identifier::NodeBackendID UnsyncReferenceNodeStorage::find_id(view::LiteralBackendView const &view) const noexcept { return view.visit( [this](view::LexicalFormLiteralBackendView const &lexical) noexcept { - assert(!has_specialized_storage_for(identifier::iri_node_id_to_literal_type(lexical.datatype_id))); + RDF4CPP_ASSERT(!has_specialized_storage_for(identifier::iri_node_id_to_literal_type(lexical.datatype_id))); return lookup_or_insert_impl(lexical, this->fallback_literal_storage_); }, [this](view::ValueLiteralBackendView const &any) noexcept { return specialization_detail::visit_specialized(this->specialized_literal_storage_, any.datatype, [&any](auto const &storage) noexcept { - assert(has_specialized_storage_for(any.datatype)); + RDF4CPP_ASSERT(has_specialized_storage_for(any.datatype)); return lookup_or_insert_impl(any, storage); }); }); @@ -132,8 +132,7 @@ static typename Storage::backend_view_type find_backend_view(Storage &storage, i if (auto const *value = storage.mapping.lookup_value(Storage::to_storage_id(id)); value != nullptr) { return static_cast(*value); } else { - assert(false); // assert in debug build; not critical error but should not happen - return Storage::get_default_view(); + RDF4CPP_DEBUG_UNREACHABLE(Storage::get_default_view()); } } diff --git a/src/rdf4cpp/storage/reference_node_storage/detail/BiDirFlatMap.hpp b/src/rdf4cpp/storage/reference_node_storage/detail/BiDirFlatMap.hpp index 4951e562d..c3be58662 100644 --- a/src/rdf4cpp/storage/reference_node_storage/detail/BiDirFlatMap.hpp +++ b/src/rdf4cpp/storage/reference_node_storage/detail/BiDirFlatMap.hpp @@ -150,8 +150,8 @@ struct BiDirFlatMap { template [[nodiscard]] static dice::template_library::copy_const_t, backend_type> &lookup_value_unchecked_impl(Self &&self, id_type const id) noexcept { auto const ix = to_index(id); - assert(ix < self.forward_.size()); - assert(self.forward_[ix].has_value()); + RDF4CPP_ASSERT(ix < self.forward_.size()); + RDF4CPP_ASSERT(self.forward_[ix].has_value()); return *self.forward_[ix]; } @@ -303,7 +303,7 @@ struct BiDirFlatMap { [[nodiscard]] id_type insert_assume_not_present(view_type const &view, Args &&...additional_args) { auto const assigned_ix = freelist_.occupy_next_available(); if (assigned_ix >= forward_.size()) { - assert(assigned_ix == forward_.size()); + RDF4CPP_ASSERT(assigned_ix == forward_.size()); forward_.emplace_back(); } @@ -331,8 +331,8 @@ struct BiDirFlatMap { template void insert_assume_not_present_at(view_type const &view, id_type const requested_id, Args &&...additional_args) { auto const lookup_ix = to_index(requested_id); - assert(lookup_ix < forward_.size()); - assert(!forward_[lookup_ix].has_value()); + RDF4CPP_ASSERT(lookup_ix < forward_.size()); + RDF4CPP_ASSERT(!forward_[lookup_ix].has_value()); forward_[lookup_ix] = std::make_obj_using_allocator(alloc_, view, std::forward(additional_args)...); @@ -347,7 +347,7 @@ struct BiDirFlatMap { * @param id id of the value to be erased */ void erase_assume_present(id_type const id) { - assert(lookup_value(id) != nullptr); + RDF4CPP_ASSERT(lookup_value(id) != nullptr); auto const ix = to_index(id); auto &value = forward_[ix]; @@ -357,7 +357,7 @@ struct BiDirFlatMap { auto it = std::find_if(beg, end, [id](backward_key_type const &k) noexcept { return k.id == id; }); - assert(it != backward_.end()); + RDF4CPP_ASSERT(it != backward_.end()); backward_.erase(it); value.reset(); diff --git a/src/rdf4cpp/storage/reference_node_storage/detail/SpecializationDetail.hpp b/src/rdf4cpp/storage/reference_node_storage/detail/SpecializationDetail.hpp index 0c8855457..95ecdb789 100644 --- a/src/rdf4cpp/storage/reference_node_storage/detail/SpecializationDetail.hpp +++ b/src/rdf4cpp/storage/reference_node_storage/detail/SpecializationDetail.hpp @@ -81,8 +81,7 @@ decltype(auto) visit_specialized(S &&container, identifier::LiteralType const da case xsd::YearMonthDuration::fixed_id.to_underlying(): return f(std::get<17>(std::forward(container))); default: - assert(false); - __builtin_unreachable(); + RDF4CPP_UNREACHABLE; } } diff --git a/src/rdf4cpp/util/CharMatcher.cpp b/src/rdf4cpp/util/CharMatcher.cpp index adbfc3658..3a46ccfda 100644 --- a/src/rdf4cpp/util/CharMatcher.cpp +++ b/src/rdf4cpp/util/CharMatcher.cpp @@ -7,6 +7,7 @@ #include #include #include +#include HWY_BEFORE_NAMESPACE(); // at file scope @@ -85,8 +86,8 @@ namespace rdf4cpp::util::char_matcher_detail::HWY_NAMESPACE { // set up ranges std::array, rn> range_vectors; for (size_t i = 0; i < rn; ++i) { - assert(ranges[i].first != '\0'); - assert(ranges[i].first < ranges[i].last); + RDF4CPP_ASSERT(ranges[i].first != '\0'); + RDF4CPP_ASSERT(ranges[i].first < ranges[i].last); range_vectors[i].first = LOAD_SINGLE(static_cast(ranges[i].first - 1)); range_vectors[i].second = LOAD_SINGLE(static_cast(ranges[i].last + 1)); } @@ -192,7 +193,7 @@ namespace rdf4cpp::util::char_matcher_detail::HWY_NAMESPACE { std::array match_vectors; auto view = static_cast(match); for (size_t i = 0; i < n-1; ++i) { - assert(view[i] != '\0'); + RDF4CPP_ASSERT(view[i] != '\0'); match_vectors[i] = LOAD_SINGLE(static_cast(view[i])); } diff --git a/src/rdf4cpp/writer/BufWriter.hpp b/src/rdf4cpp/writer/BufWriter.hpp index 36d014df2..47cf98cb4 100644 --- a/src/rdf4cpp/writer/BufWriter.hpp +++ b/src/rdf4cpp/writer/BufWriter.hpp @@ -315,7 +315,7 @@ struct OutputIteratorBuffer { void write_out(char const *end) { char const *b = buffer_.data(); - assert(b <= end && end <= buffer_.end()); + RDF4CPP_ASSERT(b <= end && end <= buffer_.end()); while (b != end) { *iter = *b; ++iter; diff --git a/tests/nodes/tests_Literal.cpp b/tests/nodes/tests_Literal.cpp index 271ff583a..bac2a25b5 100644 --- a/tests/nodes/tests_Literal.cpp +++ b/tests/nodes/tests_Literal.cpp @@ -838,7 +838,7 @@ TEST_CASE("to_node_storage") { SUBCASE("no non-inline storage available") { auto lit = Literal::make_typed_from_value(5); - assert(lit.is_inlined()); + CHECK(lit.is_inlined()); auto lit2 = lit.to_node_storage(ns2); CHECK(lit2.is_inlined()); @@ -851,7 +851,7 @@ TEST_CASE("to_node_storage") { SUBCASE("specialized storage") { SUBCASE("inlined") { auto lit = Literal::make_typed_from_value(10); - assert(lit.is_inlined()); + CHECK(lit.is_inlined()); auto lit2 = lit.to_node_storage(ns2); CHECK(lit2.is_inlined()); @@ -863,7 +863,7 @@ TEST_CASE("to_node_storage") { SUBCASE("not inlined") { auto lit = Literal::make_typed_from_value(std::numeric_limits::max()); - assert(!lit.is_inlined()); + CHECK(!lit.is_inlined()); auto lit2 = lit.to_node_storage(ns2); CHECK(!lit2.is_inlined()); @@ -877,7 +877,7 @@ TEST_CASE("to_node_storage") { SUBCASE("rdf:langString") { SUBCASE("tag inlined") { auto lit = Literal::make_lang_tagged("test", "en"); - assert(lit.is_inlined()); + CHECK(lit.is_inlined()); auto lit2 = lit.to_node_storage(ns2); CHECK(lit2.is_inlined()); @@ -888,7 +888,7 @@ TEST_CASE("to_node_storage") { SUBCASE("tag not inlined") { auto lit = Literal::make_lang_tagged("test", "spherical"); - assert(!lit.is_inlined()); + CHECK(!lit.is_inlined()); auto lit2 = lit.to_node_storage(ns2); CHECK(!lit2.is_inlined()); @@ -900,7 +900,7 @@ TEST_CASE("to_node_storage") { SUBCASE("xsd:string") { auto lit = Literal::make_simple("test"); - assert(!lit.is_inlined()); + CHECK(!lit.is_inlined()); auto lit2 = lit.to_node_storage(ns2); CHECK(!lit2.is_inlined()); @@ -916,7 +916,7 @@ TEST_CASE("try_get_in_node_storage") { SUBCASE("no non-inline storage available") { auto lit = Literal::make_typed_from_value(5); - assert(lit.is_inlined()); + CHECK(lit.is_inlined()); auto lit2 = lit.try_get_in_node_storage(ns2); CHECK(!lit2.null()); @@ -930,7 +930,7 @@ TEST_CASE("try_get_in_node_storage") { SUBCASE("specialized storage") { SUBCASE("inlined") { auto lit = Literal::make_typed_from_value(10); - assert(lit.is_inlined()); + CHECK(lit.is_inlined()); auto lit2 = lit.try_get_in_node_storage(ns2); CHECK(!lit2.null()); @@ -943,7 +943,7 @@ TEST_CASE("try_get_in_node_storage") { SUBCASE("not inlined") { auto lit = Literal::make_typed_from_value(std::numeric_limits::max()); - assert(!lit.is_inlined()); + CHECK(!lit.is_inlined()); auto lit2 = lit.try_get_in_node_storage(ns2); CHECK(lit2.null()); @@ -962,7 +962,7 @@ TEST_CASE("try_get_in_node_storage") { SUBCASE("rdf:langString") { SUBCASE("tag inlined") { auto lit = Literal::make_lang_tagged("test", "en"); - assert(lit.is_inlined()); + CHECK(lit.is_inlined()); auto lit2 = lit.try_get_in_node_storage(ns2); CHECK(lit2.null()); @@ -978,7 +978,7 @@ TEST_CASE("try_get_in_node_storage") { SUBCASE("tag not inlined") { auto lit = Literal::make_lang_tagged("test", "spherical"); - assert(!lit.is_inlined()); + CHECK(!lit.is_inlined()); auto lit2 = lit.try_get_in_node_storage(ns2); CHECK(lit2.null()); @@ -995,7 +995,7 @@ TEST_CASE("try_get_in_node_storage") { SUBCASE("xsd:string") { auto lit = Literal::make_simple("test"); - assert(!lit.is_inlined()); + CHECK(!lit.is_inlined()); auto lit2 = lit.try_get_in_node_storage(ns2); CHECK(lit2.null()); @@ -1111,7 +1111,7 @@ TEST_CASE("Literal::fetch_or_serialize_lexical_form") { SUBCASE("no non-inline storage available") { auto lit = Literal::make_typed_from_value(5); - assert(lit.is_inlined()); + CHECK(lit.is_inlined()); std::string_view s; auto r = lit.fetch_or_serialize_lexical_form(s, w); @@ -1122,7 +1122,7 @@ TEST_CASE("Literal::fetch_or_serialize_lexical_form") { SUBCASE("specialized storage") { SUBCASE("inlined") { auto lit = Literal::make_typed_from_value(10); - assert(lit.is_inlined()); + CHECK(lit.is_inlined()); std::string_view s; auto r = lit.fetch_or_serialize_lexical_form(s, w); @@ -1132,7 +1132,7 @@ TEST_CASE("Literal::fetch_or_serialize_lexical_form") { SUBCASE("not inlined") { auto lit = Literal::make_typed_from_value(std::numeric_limits::max()); - assert(!lit.is_inlined()); + CHECK(!lit.is_inlined()); std::string_view s; auto r = lit.fetch_or_serialize_lexical_form(s, w); @@ -1145,7 +1145,7 @@ TEST_CASE("Literal::fetch_or_serialize_lexical_form") { SUBCASE("rdf:langString") { SUBCASE("tag inlined") { auto lit = Literal::make_lang_tagged("test", "en"); - assert(lit.is_inlined()); + CHECK(lit.is_inlined()); std::string_view s; auto r = lit.fetch_or_serialize_lexical_form(s, w); @@ -1155,7 +1155,7 @@ TEST_CASE("Literal::fetch_or_serialize_lexical_form") { SUBCASE("tag not inlined") { auto lit = Literal::make_lang_tagged("test", "spherical"); - assert(!lit.is_inlined()); + CHECK(!lit.is_inlined()); std::string_view s; auto r = lit.fetch_or_serialize_lexical_form(s, w); @@ -1166,7 +1166,7 @@ TEST_CASE("Literal::fetch_or_serialize_lexical_form") { SUBCASE("xsd:string") { auto lit = Literal::make_simple("test"); - assert(!lit.is_inlined()); + CHECK(!lit.is_inlined()); std::string_view s; auto r = lit.fetch_or_serialize_lexical_form(s, w); diff --git a/tests/parser/tests_IStreamQuadIterator.cpp b/tests/parser/tests_IStreamQuadIterator.cpp index 85d20f15a..7c705cd4c 100644 --- a/tests/parser/tests_IStreamQuadIterator.cpp +++ b/tests/parser/tests_IStreamQuadIterator.cpp @@ -622,7 +622,7 @@ TEST_SUITE("IStreamQuadIterator") { s.push_back('o'); } s.append("> ."); - assert(s.size() == buffer_len); + CHECK(s.size() == buffer_len); std::istringstream iss{s};