123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- #include "ceres/internal/integer_sequence_algorithm.h"
- #include <type_traits>
- #include <utility>
- #include "ceres/internal/jet_traits.h"
- namespace ceres::internal {
- static_assert(std::is_same<ExclusiveScan<std::integer_sequence<int>>,
- std::integer_sequence<int>>::value,
- "Unit test of calculating the exclusive scan of an integer "
- "sequence failed.");
- static_assert(std::is_same<ExclusiveScan<std::integer_sequence<int, 2>>,
- std::integer_sequence<int, 0>>::value,
- "Unit test of calculating the exclusive scan of an integer "
- "sequence failed.");
- static_assert(std::is_same<ExclusiveScan<std::integer_sequence<int, 2, 1>>,
- std::integer_sequence<int, 0, 2>>::value,
- "Unit test of calculating the exclusive scan of an integer "
- "sequence failed.");
- static_assert(std::is_same<ExclusiveScan<std::integer_sequence<int, 2, 1, 10>>,
- std::integer_sequence<int, 0, 2, 3>>::value,
- "Unit test of calculating the exclusive scan of an integer "
- "sequence failed.");
- using Ranks001 = Ranks_t<Jet<double, 0>, double, Jet<double, 1>>;
- using Ranks1 = Ranks_t<Jet<double, 1>>;
- using Ranks110 = Ranks_t<Jet<double, 1>, Jet<double, 1>, double>;
- using Ranks023 = Ranks_t<double, Jet<double, 2>, Jet<double, 3>>;
- using EmptyRanks = Ranks_t<>;
- using NonZeroRanks001 = RemoveValue_t<Ranks001, 0>;
- using NonZeroRanks1 = RemoveValue_t<Ranks1, 0>;
- using NonZeroRanks110 = RemoveValue_t<Ranks110, 0>;
- using NonZeroRanks023 = RemoveValue_t<Ranks023, 0>;
- static_assert(std::is_same<RemoveValue_t<EmptyRanks, 0>,
- std::integer_sequence<int>>::value,
- "filtered sequence does not match an empty one");
- static_assert(std::is_same<RemoveValue_t<std::integer_sequence<int, 2, 2>, 2>,
- std::integer_sequence<int>>::value,
- "filtered sequence does not match an empty one");
- static_assert(
- std::is_same<RemoveValue_t<std::integer_sequence<int, 0, 0, 2>, 2>,
- std::integer_sequence<int, 0, 0>>::value,
- "filtered sequence does not match the expected one");
- static_assert(
- std::is_same<RemoveValue_t<std::make_integer_sequence<int, 6>, 7>,
- std::make_integer_sequence<int, 6>>::value,
- "sequence not containing the element to remove must not be transformed");
- static_assert(
- std::is_same<NonZeroRanks001, std::integer_sequence<int, 1>>::value,
- "sequences do not match");
- static_assert(std::is_same<NonZeroRanks1, std::integer_sequence<int, 1>>::value,
- "sequences do not match");
- static_assert(
- std::is_same<NonZeroRanks110, std::integer_sequence<int, 1, 1>>::value,
- "sequences do not match");
- static_assert(
- std::is_same<NonZeroRanks023, std::integer_sequence<int, 2, 3>>::value,
- "sequences do not match");
- static_assert(std::is_same<RemoveValue_t<std::integer_sequence<long>, -1>,
- std::integer_sequence<long>>::value,
- "sequences do not match");
- static_assert(
- std::is_same<RemoveValue_t<std::integer_sequence<short, -2, -3, -1>, -1>,
- std::integer_sequence<short, -2, -3>>::value,
- "sequences do not match");
- using J = Jet<double, 2>;
- template <typename T>
- using J0 = Jet<T, 0>;
- using J0d = J0<double>;
- static_assert(AreAllSame_v<int, int>, "types must be the same");
- static_assert(AreAllSame_v<long, long, long>, "types must be the same");
- static_assert(AreAllSame_v<J0d, J0d, J0d>, "types must be the same");
- static_assert(!AreAllSame_v<double, int>, "types must not be the same");
- static_assert(!AreAllSame_v<int, short, char>, "types must not be the same");
- static_assert(AreAllEqual_v<int, 1, 1>,
- "integer sequence must contain same values");
- static_assert(AreAllEqual_v<long, 2>,
- "integer sequence must contain one value");
- static_assert(!AreAllEqual_v<short, 3, 4>,
- "integer sequence must not contain the same values");
- static_assert(!AreAllEqual_v<unsigned, 3, 4, 3>,
- "integer sequence must not contain the same values");
- static_assert(!AreAllEqual_v<int, 4, 4, 3>,
- "integer sequence must not contain the same values");
- static_assert(IsEmptyOrAreAllEqual_v<std::integer_sequence<short>>,
- "expected empty sequence is not");
- static_assert(IsEmptyOrAreAllEqual_v<std::integer_sequence<unsigned, 7, 7, 7>>,
- "expected all equal sequence is not");
- static_assert(IsEmptyOrAreAllEqual_v<std::integer_sequence<int, 1>>,
- "expected all equal sequence is not");
- static_assert(
- IsEmptyOrAreAllEqual_v<std::integer_sequence<long, 111, 111, 111, 111>>,
- "expected all equal sequence is not");
- }
|