@@ -52,14 +52,14 @@ TEST(file, type_traits) {
5252 static_assert (std::is_same_v<file::off_type, traits::off_type>);
5353}
5454
55- // / Tests file creation with label
56- TEST (file, create_with_label ) {
57- file tmpfile = file (LABEL );
55+ // / Tests file creation
56+ TEST (file, create ) {
57+ file tmpfile = file ();
5858 fs::path parent = tmpfile.path ().parent_path ();
5959
6060 EXPECT_TRUE (fs::exists (tmpfile));
6161 EXPECT_TRUE (fs::is_regular_file (tmpfile));
62- EXPECT_TRUE (fs::equivalent (parent, fs::temp_directory_path () / LABEL ));
62+ EXPECT_TRUE (fs::equivalent (parent, fs::temp_directory_path ()));
6363 EXPECT_TRUE (is_open (tmpfile));
6464
6565#if __cpp_lib_fstream_native_handle >= 202306L
@@ -76,49 +76,23 @@ TEST(file, create_with_label) {
7676#endif
7777}
7878
79- // / Tests file creation without label
80- TEST (file, create_without_label) {
81- file tmpfile = file ();
82- fs::path parent = tmpfile.path ().parent_path ();
83-
84- EXPECT_TRUE (fs::exists (tmpfile));
85- EXPECT_TRUE (fs::is_regular_file (tmpfile));
86- EXPECT_TRUE (fs::equivalent (parent, fs::temp_directory_path ()));
87- EXPECT_TRUE (is_open (tmpfile));
88- }
89-
90- // / Tests multiple file creation with the same label
79+ // / Tests multiple file creation
9180TEST (file, create_multiple) {
92- file fst = file (LABEL );
93- file snd = file (LABEL );
81+ file fst = file ();
82+ file snd = file ();
9483
9584 EXPECT_FALSE (fs::equivalent (fst, snd));
9685}
9786
98- // / Tests error handling with invalid labels
99- TEST (file, create_invalid_label) {
100- EXPECT_THROW (file (" multi/segment" ), std::invalid_argument);
101- EXPECT_THROW (file (" /root" ), std::invalid_argument);
102- EXPECT_THROW (file (" .." ), std::invalid_argument);
103- EXPECT_THROW (file (" ." ), std::invalid_argument);
104-
105- fs::path root = fs::temp_directory_path ().root_name ();
106- if (!root.empty ()) {
107- EXPECT_THROW (file (root.string () + " relative" ), std::invalid_argument);
108- EXPECT_THROW (file (root.string () + " /root" ), std::invalid_argument);
109- }
110- }
111-
11287// / Tests error handling with invalid open mode
11388TEST (file, create_invalid_openmode) {
11489 // C++ standard forbids opening a filebuf with `trunc | app`
115- std::ios::openmode openmode = std::ios::trunc | std::ios::app;
116- EXPECT_THROW (file (" " , openmode), fs::filesystem_error);
90+ EXPECT_THROW (file (std::ios::trunc | std::ios::app), fs::filesystem_error);
11791}
11892
11993// / Tests that file adds std::ios::in and std::ios::out flags
12094TEST (file, ios_flags) {
121- file tmpfile = file (" " , std::ios::binary);
95+ file tmpfile = file (std::ios::binary);
12296 tmpfile << " Hello, world!" << std::flush;
12397
12498 std::ifstream stream = std::ifstream (tmpfile.path ());
0 commit comments