[libcxx-commits] [libcxx] dd2cfab - [libc++] add test for latch ctor

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 12 12:33:24 PDT 2023


Author: Edoardo Sanguineti
Date: 2023-07-12T12:33:19-07:00
New Revision: dd2cfabddb6d3e7e7d55130349f3022deefca896

URL: https://github.com/llvm/llvm-project/commit/dd2cfabddb6d3e7e7d55130349f3022deefca896
DIFF: https://github.com/llvm/llvm-project/commit/dd2cfabddb6d3e7e7d55130349f3022deefca896.diff

LOG: [libc++] add test for latch ctor

Currently, there are no tests to confirm without a doubt the constructor of latch is really constexpr and explicit.
I think this would be an addition that it would not harm to have. In another revision, I was asked to add tests for an almost identical case which made me consider adding this test for the latch class too.

Reviewed By: #libc, philnik

Spies: philnik, libcxx-commits, kristof.beyls

Differential Revision: https://reviews.llvm.org/D154957

Added: 
    libcxx/test/std/thread/thread.latch/ctor.pass.cpp

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/thread/thread.latch/ctor.pass.cpp b/libcxx/test/std/thread/thread.latch/ctor.pass.cpp
new file mode 100644
index 00000000000000..1983f6409cb5a5
--- /dev/null
+++ b/libcxx/test/std/thread/thread.latch/ctor.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: no-threads
+// UNSUPPORTED: c++03, c++11
+
+// <latch>
+
+// inline constexpr explicit latch(ptr
diff _t __expected);
+
+// Make sure that the ctor of latch is constexpr and explicit.
+
+#include <latch>
+
+#include "test_convertible.h"
+
+static_assert(!test_convertible<std::latch, std::ptr
diff _t>(), "This constructor must be explicit");
+
+constexpr bool test() {
+  std::latch l(5);
+  (void)l;
+  return true;
+}
+
+int main(int, char**) {
+  test();
+  static_assert(test(), "");
+
+  return 0;
+}


        


More information about the libcxx-commits mailing list