[libcxx-commits] [libcxx] ab01833 - [libcxx][test][NFC] Tests for set comparisons
Ruslan Arutyunyan via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Dec 10 03:53:23 PST 2021
Author: Konstantin Boyarinov
Date: 2021-12-10T14:51:24+03:00
New Revision: ab018330f33c325b9d242401f3fffeb1645a292f
URL: https://github.com/llvm/llvm-project/commit/ab018330f33c325b9d242401f3fffeb1645a292f
DIFF: https://github.com/llvm/llvm-project/commit/ab018330f33c325b9d242401f3fffeb1645a292f.diff
LOG: [libcxx][test][NFC] Tests for set comparisons
Add tests for std::set and std::multiset comparisons that were missed by
D111738 and D112424.
Reviewed By: ldionne, rarutyun, #libc
Differential Revision: https://reviews.llvm.org/D115136
Added:
libcxx/test/std/containers/associative/multiset/multiset.nonmember/op_compare.pass.cpp
libcxx/test/std/containers/associative/set/set.nonmember/op_compare.pass.cpp
Modified:
Removed:
################################################################################
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.nonmember/op_compare.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.nonmember/op_compare.pass.cpp
new file mode 100644
index 0000000000000..da142d2b87769
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.nonmember/op_compare.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// template<class Key, class Compare, class Alloc>
+// bool operator==(const std::multiset<Key, Compare, Alloc>& lhs,
+// const std::multiset<Key, Compare, Alloc>& rhs);
+//
+// template<class Key, class Compare, class Alloc>
+// bool operator!=(const std::multiset<Key, Compare, Alloc>& lhs,
+// const std::multiset<Key, Compare, Alloc>& rhs);
+//
+// template<class Key, class Compare, class Alloc>
+// bool operator<(const std::multiset<Key, Compare, Alloc>& lhs,
+// const std::multiset<Key, Compare, Alloc>& rhs);
+//
+// template<class Key, class Compare, class Alloc>
+// bool operator>(const std::multiset<Key, Compare, Alloc>& lhs,
+// const std::multiset<Key, Compare, Alloc>& rhs);
+//
+// template<class Key, class Compare, class Alloc>
+// bool operator<=(const std::multiset<Key, Compare, Alloc>& lhs,
+// const std::multiset<Key, Compare, Alloc>& rhs);
+//
+// template<class Key, class Compare, class Alloc>
+// bool operator>=(const std::multiset<Key, Compare, Alloc>& lhs,
+// const std::multiset<Key, Compare, Alloc>& rhs);
+
+#include <set>
+#include <cassert>
+#include <string>
+
+#include "test_comparisons.h"
+
+int main(int, char**) {
+ {
+ std::multiset<int> s1, s2;
+ s1.insert(1);
+ s2.insert(2);
+ const std::multiset<int>& cs1 = s1, cs2 = s2;
+ assert(testComparisons6(cs1, cs2, false, true));
+ }
+ {
+ std::multiset<int> s1, s2;
+ s1.insert(1);
+ s2.insert(1);
+ const std::multiset<int>& cs1 = s1, cs2 = s2;
+ assert(testComparisons6(cs1, cs2, true, false));
+ }
+ {
+ std::multiset<int> s1, s2;
+ s1.insert(1);
+ s2.insert(1);
+ s2.insert(2);
+ const std::multiset<int>& cs1 = s1, cs2 = s2;
+ assert(testComparisons6(cs1, cs2, false, true));
+ }
+ {
+ std::multiset<int> s1, s2;
+ s1.insert(1);
+ s2.insert(1);
+ s2.insert(1);
+ s2.insert(1);
+ const std::multiset<int>& cs1 = s1, cs2 = s2;
+ assert(testComparisons6(cs1, cs2, false, true));
+ }
+ return 0;
+}
diff --git a/libcxx/test/std/containers/associative/set/set.nonmember/op_compare.pass.cpp b/libcxx/test/std/containers/associative/set/set.nonmember/op_compare.pass.cpp
new file mode 100644
index 0000000000000..9e45e97f1d7dd
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.nonmember/op_compare.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// template<class Key, class Compare, class Alloc>
+// bool operator==(const std::set<Key, Compare, Alloc>& lhs,
+// const std::set<Key, Compare, Alloc>& rhs);
+//
+// template<class Key, class Compare, class Alloc>
+// bool operator!=(const std::set<Key, Compare, Alloc>& lhs,
+// const std::set<Key, Compare, Alloc>& rhs);
+//
+// template<class Key, class Compare, class Alloc>
+// bool operator<(const std::set<Key, Compare, Alloc>& lhs,
+// const std::set<Key, Compare, Alloc>& rhs);
+//
+// template<class Key, class Compare, class Alloc>
+// bool operator>(const std::set<Key, Compare, Alloc>& lhs,
+// const std::set<Key, Compare, Alloc>& rhs);
+//
+// template<class Key, class Compare, class Alloc>
+// bool operator<=(const std::set<Key, Compare, Alloc>& lhs,
+// const std::set<Key, Compare, Alloc>& rhs);
+//
+// template<class Key, class Compare, class Alloc>
+// bool operator>=(const std::set<Key, Compare, Alloc>& lhs,
+// const std::set<Key, Compare, Alloc>& rhs);
+
+#include <set>
+#include <cassert>
+#include <string>
+
+#include "test_comparisons.h"
+
+int main(int, char**) {
+ {
+ std::set<int> s1, s2;
+ s1.insert(1);
+ s2.insert(2);
+ const std::set<int>& cs1 = s1, cs2 = s2;
+ assert(testComparisons6(cs1, cs2, false, true));
+ }
+ {
+ std::set<int> s1, s2;
+ s1.insert(1);
+ s2.insert(1);
+ const std::set<int>& cs1 = s1, cs2 = s2;
+ assert(testComparisons6(cs1, cs2, true, false));
+ }
+ {
+ std::set<int> s1, s2;
+ s1.insert(1);
+ s2.insert(1);
+ s2.insert(2);
+ const std::set<int>& cs1 = s1, cs2 = s2;
+ assert(testComparisons6(cs1, cs2, false, true));
+ }
+ return 0;
+}
More information about the libcxx-commits
mailing list