diff --git a/Cartesian_kernel/include/CGAL/Cartesian_converter.h b/Cartesian_kernel/include/CGAL/Cartesian_converter.h index 096e0b4831b..d87dcac6610 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian_converter.h +++ b/Cartesian_kernel/include/CGAL/Cartesian_converter.h @@ -126,7 +126,7 @@ public: return c(a); } - // This intentionally does not check that K1::FT is constructible from T, because otherwise + // This intentionally does not require that K1::FT is constructible from T, because otherwise // the function `bool Enum_converter::operator()(bool)` might be called instead, with an implicit // conversion from the fundamental type to bool, which is usually unintended. template diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous_converter.h b/Homogeneous_kernel/include/CGAL/Homogeneous_converter.h index 25391d6097a..9d844278427 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous_converter.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous_converter.h @@ -86,7 +86,7 @@ public: return fc(a); } - // This intentionally does not check that K1::RT is constructible from T, because otherwise + // This intentionally does not require that K1::RT is constructible from T, because otherwise // the function `bool Enum_converter::operator()(bool)` might be called instead, with an implicit // conversion from the fundamental type to bool, which is usually unintended. template diff --git a/Kernel_23/test/Kernel_23/test_converter.cpp b/Kernel_23/test/Kernel_23/test_converter.cpp new file mode 100644 index 00000000000..0acf4647406 --- /dev/null +++ b/Kernel_23/test/Kernel_23/test_converter.cpp @@ -0,0 +1,69 @@ +#include +#include +#include +#include +#include + +#include +#include + +#ifdef CGAL_USE_CORE +#include +#endif + +#include + +int main() +{ + using EPICK = CGAL::Exact_predicates_inexact_constructions_kernel; + using EPECK = CGAL::Exact_predicates_exact_constructions_kernel; + using SCI = CGAL::Simple_cartesian >; + using SHI = CGAL::Simple_homogeneous >; + using NT_exact = CGAL::internal::Exact_field_selector::Type; + using SHD = CGAL::Simple_homogeneous; + using SHE = CGAL::Simple_homogeneous; + + CGAL::Cartesian_converter sci_to_epick; +// CGAL::Cartesian_converter sci_to_epeck; + CGAL::Cartesian_converter epeck_to_epick; + CGAL::Homogeneous_converter shi_to_shd; + CGAL::Homogeneous_converter she_to_shd; + + assert(sci_to_epick(SCI::FT(2)) == EPICK::FT(2)); + assert(sci_to_epick((long int)(2)) == EPICK::FT(2)); // long int --> SCI::FT --> EPICK::FT + assert(sci_to_epick(2.) == EPICK::FT(2)); // double --> SCI::FT --> EPICK::FT + assert(sci_to_epick(bool(2.)) == true); + +#ifdef CGAL_USE_CORE + using SSCE = CGAL::Simple_cartesian; + CGAL::Cartesian_converter scce_to_epick; + + // double is a fundamental type, but CORE::Expr has no implicit double --> CORE::Expr conversion + assert(scce_to_epick(2) == EPICK::FT(2)); + + // This does not compile because 'signed long long int' is a fundamental type, + // but there is no CORE::Expr(signed long long int) constructor +// assert(scce_to_epick((signed long long int)(1)) == true); +#endif + + // int* is not a fundamental type, so this goes through Enum_converter(bool) + int a = 123; + auto a_ptr = &a; + assert(sci_to_epick(a_ptr) == true); + + // this does not compile because there is no conversion between Interval_nt and EPECK::FT +// assert(sci_to_epeck(2.) == EPECK::FT(2)); + + assert(epeck_to_epick(EPECK::FT(2)) == EPICK::FT(2)); + assert(epeck_to_epick(2.) == EPICK::FT(2)); // double --> EPECK::FT --> EPICK::FT + + assert(shi_to_shd(2.) == SHD::FT(2)); // double --> SHI::FT --> SHD::FT + + assert(she_to_shd(SHE::RT(2)) == SHD::RT(2)); + assert(she_to_shd(SHE::FT(2.)) == SHD::FT(2.)); + assert(she_to_shd(2.) == SHD::FT(2)); // double --> SHE::RT --> SHD::FT + + std::cout << "Done" << std::endl; + + return EXIT_SUCCESS; +}