Implements part of P1614R2 "The Mothership has Landed"
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
One thing I have thought about in our march towards finishing the lexically ordered containers is that we should be able to write a test utils header with one or more templated test functions that will work for most or all of these containers. We can possibly even add (in another header?) some helpful types like weakly ordered ints, types that compare with user orderings, etc. so we don't have to keep writing them over and over. This feels fairly sane to me but I don't know what the general vibe is on how DRY is too DRY for our test suite, and maybe it's better to just copy-paste those parts of the code each time.
libcxx/test/std/containers/sequences/list/compare.pass.cpp | ||
---|---|---|
47 | I recommend simply adding another file, such as compare.three_way.pass.cpp, that marks standard versions before 20 as unsupported, then simply does the test. Adding the parts of the test you want to conditionally execute with dozens of conditional directives is honestly too much noise with no real benefit. Don't forget the SFINAE tests! They should be pretty easy to do here as well. We should be able to test ordering behavior and SFINAE for all of the following:
All of these should be trivially reusable or easily copyable to the other container types. |
I'm very +1 for that direction of having a reusable header with common types and functions for this.
libcxx/include/list | ||
---|---|---|
2341 | the complete <compare> header is a standard-mandated include. See line 226 |
libcxx/test/std/containers/sequences/list/compare.pass.cpp | ||
---|---|---|
47 | I like the general idea! How about instead add a generic header file and make it possible to use the functions in there for the tests? Like we do in the test_comparisons.h header. That way the tests are at the expected location. WDYT? |
Introduce reusable test function
libcxx/test/std/containers/sequences/list/compare.pass.cpp | ||
---|---|---|
47 | Good idea. I introduced test_container_comparisons.h to contain those test helpers. In the future, we should also add a similar utility to test containers like std::map, std::set. The test functions are already written with std::vector in mind, i.e. they are constexpr and return true, so they can be used to test the constexpr-ness of std::vector.
How do I write such a user-ordering? |