[libcxx-commits] [PATCH] D132312: [libc++][spaceship] Implement `operator<=>` for `list`

Kent Ross via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Aug 20 20:21:59 PDT 2022


mumbleskates added a comment.

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.



================
Comment at: libcxx/test/std/containers/sequences/list/compare.pass.cpp:47
+  AssertComparisonsReturnBool<std::vector<ElemT> >();
+#if TEST_STD_VER >= 20
+  AssertOrderReturn<Order, std::vector<ElemT>>();
----------------
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:

1. strongly ordered types
2. partially ordered types
3. weakly ordered types
4. synth-ordered types (weak_ordering)
5. custom user-ordering types (also causes synthesized weak_ordering)
6. unordered types (SFINAE should cause the operator to not participate)

All of these should be trivially reusable or easily copyable to the other container types.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132312/new/

https://reviews.llvm.org/D132312



More information about the libcxx-commits mailing list