Boost logo

Boost Users :

From: Krzysztof Jusiak (krzysztof_at_[hidden])
Date: 2019-11-23 03:31:05


Thank you for your feedback. I appreciate it.

Well, IMHO, there are pros and cons to any solution; I'm not going to start
a flame war here about whether macros are evil or not.
However, with [Boost].UT there is nothing stopping anyone from using simple
macros (one-lines) to achieve other frameworks syntax
The good bit about it is that it's an opt-in 'feature' as opposed to being
the only available option (see example below [1]).
This way more users can be satisfied and other benefits such as faster
execution, quicker compilation times and other features are still available.

```
#define EXPECT(...) ::boost::ut::expect(::boost::ut::that % __VA_ARGS__)
#define SUITE ::boost::ut::suite _ = []
#define TEST(name) ::boost::ut::detail::test{"test", name} = [=]() mutable

SUITE {
  TEST("suite") {
    EXPECT(42 == 42);
  };
};

int main() {
  TEST("macro") {
    EXPECT(1 != 2);
  };

  TEST("vector") {
    std::vector<int> v(5);

    EXPECT(5u == std::size(v)) << "fatal";

    TEST("resize bigger") {
      v.resize(10);
      EXPECT(10u == std::size(v));
    };
  };
}
```

[1]: https://godbolt.org/z/tvy-nP

-Kris

On Fri, Nov 22, 2019 at 2:27 PM Mateusz Loskot via Boost-users <
boost-users_at_[hidden]> wrote:

> (CC'ed to boost-users)
>
> On Fri, 22 Nov 2019 at 21:53, Vinnie Falco via Boost
> <boost_at_[hidden]> wrote:
> > On Thu, Nov 21, 2019 at 7:24 AM Krzysztof Jusiak via Boost-users <
> boost-users_at_[hidden]>>
> > > I was wondering whether there is any interest in exploring
> > > a C++20 single header/single module, macro-free Unit
> > > Testing Framework with no dependencies?
> >
> > I have no interest in a library that requires C++20, especially
> > considering that C++20 is not even official yet but also because once
> > C++20 is released, there will be hardly any users for many years. This
> > project seems very much like it was written "just because", to use the
> > latest language features, rather than for pragmatic reasons. I don't
> > see anything compelling to use it over Boost.LightweightTest for
> > example.
>
> I had a look at the current documentation and examples,
> and I'm glad to see I'm not the only sceptical about it.
> My opinion is very similar to what Hans, Raffi and Vinnie explained.
>
> Macros in testing and benchmarking frameworks are kosher,
> in fact, they can be very helpul to organize and structure large
> amount of tests that in turn makes it easier to search and browse
> through the code. I can't imagine how any of the modern IDE's will
> support the string-driven syntax.
>
> As a long time maintainer of SOCI library, I'm no stranger to
> the syntax-first library development [1], still, I find the UT's
> string-based test cases approach as an interesting curiosity
> with very little practical value. (It falls into similar drawer
> as the (over)use of emoji in commit messages on GitHub :)).
>
> Boost is known as a C++ guinea pigs playground, so any library can
> make it in. If it does, I just hope Boost will not allow to adopt the UT
> as a test framework of choice of any/too many of its libraries.
>
> [1]
> https://www.drdobbs.com/database/a-simple-oracle-call-interface/184405930?pgno=2
>
> Best regards,
> --
> Mateusz Loskot, http://mateusz.loskot.net
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net