Date: Thu, 9 Jun 2022 16:45:23 +0200
Gabriel Dos Reis <gdr_at_[hidden]> writes:
> [Boris]
> > For example, the implementation partition may include a unit test
> > (because that's the only way to access the private parts) which
> > is registered with the test harness.
>
> How would that work in practice (concrete example)?
The following example works with GCC 12.
// file: tester.hxx
//
struct test_registrar
{
static void (*test) ();
explicit test_registrar (void (*t) ()) {test = t;}
};
// file: tester.cxx
//
#include "tester.hxx"
void (*test_registrar::test) ();
int main ()
{
test_registrar::test ();
}
// file: hello-printer.mxx
//
module;
#include <cassert>
#include "tester.hxx"
module hello:print;
static void
unit_test ()
{
assert (false);
}
test_registrar init (&unit_test);
// buidfile
//
exe{tester}: cxx{tester} mxx{hello-printer}
> [Boris]
> > For example, the implementation partition may include a unit test
> > (because that's the only way to access the private parts) which
> > is registered with the test harness.
>
> How would that work in practice (concrete example)?
The following example works with GCC 12.
// file: tester.hxx
//
struct test_registrar
{
static void (*test) ();
explicit test_registrar (void (*t) ()) {test = t;}
};
// file: tester.cxx
//
#include "tester.hxx"
void (*test_registrar::test) ();
int main ()
{
test_registrar::test ();
}
// file: hello-printer.mxx
//
module;
#include <cassert>
#include "tester.hxx"
module hello:print;
static void
unit_test ()
{
assert (false);
}
test_registrar init (&unit_test);
// buidfile
//
exe{tester}: cxx{tester} mxx{hello-printer}
Received on 2022-06-09 14:45:30