[libcxx-commits] [PATCH] D121523: [libc++][ranges] Implement ranges::count{, _if}

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 21 08:21:06 PDT 2022


philnik added inline comments.


================
Comment at: libcxx/test/std/algorithms/alg.nonmodifying/alg.count/ranges.count.pass.cpp:59-69
+  {
+    int a[] = {1, 2, 3, 4};
+    std::same_as<std::ptrdiff_t> auto ret = std::ranges::count(It(a), Sent(It(a + 4)), 4);
+    assert(ret == 1);
+  }
+  {
+    int a[] = {1, 2, 3, 4};
----------------
ldionne wrote:
> Here, you should test with a 0-sized range and 1-sized range too. And for each range size (when that makes sense), you can vary the position of the element you're finding. Right now, you're always finding the last element in the range -- that's not exhaustive enough. You can also check for an element which is not in the range.
> 
> Then, you can remove a couple of tests below that are only run on `int[]`, like the one that says `// check that 0 is returned with no match`.
> 
> This comment applies to the other algorithms patches I haven't looked at yet -- we need to be more exhaustive when checking algorithms, especially since it's so easy to do.
I'm not sure what you are asking for. Do you want that the result changes for every iterator type? Or just have more invocations for each of them?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121523



More information about the libcxx-commits mailing list