Skip to content

Commit

Permalink
Merge branch 'master' into explicit-args-passing
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-jusiak authored Dec 16, 2023
2 parents 7c21339 + 20f2c3f commit 5e6975b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 27 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
cmake_minimum_required(VERSION 3.21...3.25)
project(
ut
VERSION 1.1.9
VERSION 2.0.0
LANGUAGES CXX
)

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ target_link_libraries(my_test PRIVATE Boost::ut)
> [Optional] [Conan](https://conan.io) integration
The [boost-ext-ut](https://conan.io/center/boost-ext-ut) package is available from [Conan Center](https://conan.io/center/).
Just include it in your project's Conanfile with `boost-ext-ut/1.1.9`.
Just include it in your project's Conanfile with `boost-ext-ut/2.0.0`.

</p>
</details>
Expand Down Expand Up @@ -1243,7 +1243,7 @@ int main() {
```cpp
export module boost.ut; /// __cpp_modules
namespace boost::inline ext::ut::inline v1_1_9 {
namespace boost::inline ext::ut::inline v2_0_0 {
/**
* Represents test suite object
*/
Expand Down Expand Up @@ -1604,7 +1604,7 @@ namespace boost::inline ext::ut::inline v1_1_9 {

| Option | Description | Example |
|-|-|-|
| `BOOST_UT_VERSION` | Current version | `1'1'9` |
| `BOOST_UT_VERSION` | Current version | `2'0'0` |

</p>
</details>
Expand Down
6 changes: 6 additions & 0 deletions example/parameterized.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/ut.hpp>
#include <ranges>
#include <string>
#include <tuple>
#include <type_traits>
Expand All @@ -26,6 +27,11 @@ int main() {
expect(arg > 0_i) << "all values greater than 0";
} | std::vector{1, 2, 3};

/// Alternative syntax
"views"_test = [](auto arg) {
expect(arg > 0_i) << "all values greater than 0";
} | std::views::iota(1, 4);

/// Alternative syntax
"types"_test = []<class T>() {
expect(std::is_integral_v<T>) << "all types are integrals";
Expand Down
31 changes: 16 additions & 15 deletions include/boost/ut.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export import std;
#elif not defined(__cpp_static_assert)
#error "[Boost::ext].UT requires support for static assert";
#else
#define BOOST_UT_VERSION 1'1'9
#define BOOST_UT_VERSION 2'0'0

#if defined(__has_builtin) and defined(__GNUC__) and (__GNUC__ < 10) and \
not defined(__clang__)
Expand Down Expand Up @@ -103,7 +103,7 @@ struct _unique_name_for_auto_detect_prefix_and_suffix_lenght_0123456789_struct {
};

BOOST_UT_EXPORT
namespace boost::inline ext::ut::inline v1_1_9 {
namespace boost::inline ext::ut::inline v2_0_0 {
namespace utility {
template <class>
class function;
Expand Down Expand Up @@ -467,7 +467,7 @@ constexpr auto is_valid(...) -> bool {
}

template <class T>
inline constexpr auto is_container_v =
inline constexpr auto is_range_v =
is_valid<T>([](auto t) -> decltype(t.begin(), t.end(), void()) {});

template <class T>
Expand Down Expand Up @@ -1355,7 +1355,7 @@ class printer {

template <class T,
type_traits::requires_t<not type_traits::has_user_print<T> and
type_traits::is_container_v<T>> = 0>
type_traits::is_range_v<T>> = 0>
auto& operator<<(T&& t) {
*this << '{';
auto first = true;
Expand Down Expand Up @@ -2623,12 +2623,12 @@ namespace operators {
return detail::neq_{lhs, rhs};
}

template <class T, type_traits::requires_t<type_traits::is_container_v<T>> = 0>
template <class T, type_traits::requires_t<type_traits::is_range_v<T>> = 0>
[[nodiscard]] constexpr auto operator==(T&& lhs, T&& rhs) {
return detail::eq_{static_cast<T&&>(lhs), static_cast<T&&>(rhs)};
}

template <class T, type_traits::requires_t<type_traits::is_container_v<T>> = 0>
template <class T, type_traits::requires_t<type_traits::is_range_v<T>> = 0>
[[nodiscard]] constexpr auto operator!=(T&& lhs, T&& rhs) {
return detail::neq_{static_cast<T&&>(lhs), static_cast<T&&>(rhs)};
}
Expand Down Expand Up @@ -2721,23 +2721,24 @@ template <class Test>
}

template <class F, class T,
type_traits::requires_t<type_traits::is_container_v<T>> = 0>
type_traits::requires_t<type_traits::is_range_v<T>> = 0>
[[nodiscard]] constexpr auto operator|(const F& f, const T& t) {
return [f, t](const auto name) {
for (const auto& arg : t) {
detail::on<F>(events::test<F, typename T::value_type>{.type = "test",
.name = name,
.tag = {},
.location = {},
.arg = arg,
.run = f});
detail::on<F>(events::test<F, decltype(arg)>{
.type = "test",
.name = name,
.tag = {},
.location = {},
.arg = arg,
.run = f});
}
};
}

template <
class F, template <class...> class T, class... Ts,
type_traits::requires_t<not type_traits::is_container_v<T<Ts...>>> = 0>
type_traits::requires_t<not type_traits::is_range_v<T<Ts...>>> = 0>
[[nodiscard]] constexpr auto operator|(const F& f, const T<Ts...>& t) {
return [f, t](const auto name) {
apply(
Expand Down Expand Up @@ -3286,7 +3287,7 @@ using operators::operator not;
using operators::operator|;
using operators::operator/;
using operators::operator>>;
} // namespace boost::inline ext::ut::inline v1_1_9
} // namespace boost::inline ext::ut::inline v2_0_0

#if (defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER)) && \
!defined(__EMSCRIPTEN__)
Expand Down
16 changes: 8 additions & 8 deletions test/ut/ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,14 +423,14 @@ int main() {

{
struct foo {};
static_assert(type_traits::is_container_v<std::vector<int>>);
static_assert(type_traits::is_container_v<std::array<bool, 0>>);
static_assert(type_traits::is_container_v<std::string>);
static_assert(type_traits::is_container_v<std::string_view>);
static_assert(type_traits::is_container_v<std::map<int, int>>);
static_assert(not type_traits::is_container_v<int>);
static_assert(not type_traits::is_container_v<foo>);
static_assert(not type_traits::is_container_v<void>);
static_assert(type_traits::is_range_v<std::vector<int>>);
static_assert(type_traits::is_range_v<std::array<bool, 0>>);
static_assert(type_traits::is_range_v<std::string>);
static_assert(type_traits::is_range_v<std::string_view>);
static_assert(type_traits::is_range_v<std::map<int, int>>);
static_assert(not type_traits::is_range_v<int>);
static_assert(not type_traits::is_range_v<foo>);
static_assert(not type_traits::is_range_v<void>);
}

{
Expand Down

0 comments on commit 5e6975b

Please sign in to comment.