summaryrefslogtreecommitdiff
path: root/libcxx/test
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-12-21 04:09:01 +0000
committerEric Fiselier <eric@efcs.ca>2018-12-21 04:09:01 +0000
commit8cf803bd99b588b1baae20efca8e239adb4512d6 (patch)
treebf704770e18533e1f604db75463475395945f383 /libcxx/test
parent114384b825673d9c709431269afc5edde88930f0 (diff)
Implement LWG 3065: Make path operators friends.
This prevents things like: using namespace std::filesystem; auto x = L"a/b" == std::string("a/b");
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/std/input.output/filesystems/class.path/path.nonmember/append_op.fail.cpp27
-rw-r--r--libcxx/test/std/input.output/filesystems/class.path/path.nonmember/append_op.pass.cpp4
-rw-r--r--libcxx/test/std/input.output/filesystems/class.path/path.nonmember/comparison_ops.fail.cpp33
3 files changed, 63 insertions, 1 deletions
diff --git a/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/append_op.fail.cpp b/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/append_op.fail.cpp
new file mode 100644
index 00000000000..e0b3a959c29
--- /dev/null
+++ b/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/append_op.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <filesystem>
+
+#include "filesystem_include.hpp"
+
+using namespace fs;
+
+struct ConvToPath {
+ operator fs::path() const {
+ return "";
+ }
+};
+
+int main() {
+ ConvToPath LHS, RHS;
+ (void)(LHS / RHS); // expected-error {{invalid operands to binary expression}}
+} \ No newline at end of file
diff --git a/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/append_op.pass.cpp b/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/append_op.pass.cpp
index 09498bf2135..2a291d61da7 100644
--- a/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/append_op.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/append_op.pass.cpp
@@ -20,7 +20,6 @@
#include "test_macros.h"
#include "filesystem_test_helper.hpp"
-
// This is mainly tested via the member append functions.
int main()
{
@@ -29,4 +28,7 @@ int main()
path p2("def");
path p3 = p1 / p2;
assert(p3 == "abc/def");
+
+ path p4 = p1 / "def";
+ assert(p4 == "abc/def");
}
diff --git a/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/comparison_ops.fail.cpp b/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/comparison_ops.fail.cpp
new file mode 100644
index 00000000000..00eafe532d0
--- /dev/null
+++ b/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/comparison_ops.fail.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <filesystem>
+
+
+#include "filesystem_include.hpp"
+
+using namespace fs;
+
+struct ConvToPath {
+ operator fs::path() const {
+ return "";
+ }
+};
+
+int main() {
+ ConvToPath LHS, RHS;
+ (void)(LHS == RHS); // expected-error {{invalid operands to binary expression}}
+ (void)(LHS != RHS); // expected-error {{invalid operands to binary expression}}
+ (void)(LHS < RHS); // expected-error {{invalid operands to binary expression}}
+ (void)(LHS <= RHS); // expected-error {{invalid operands to binary expression}}
+ (void)(LHS > RHS); // expected-error {{invalid operands to binary expression}}
+ (void)(LHS >= RHS); // expected-error {{invalid operands to binary expression}}
+} \ No newline at end of file