@@ -130,6 +130,14 @@ TEST(file, read_text) {
130130 EXPECT_EQ (tmpfile.read (), " Hello,\n world!\n " );
131131}
132132
133+ // / Tests file reading error reporting
134+ TEST (file, read_error) {
135+ file tmpfile = file ();
136+ fs::remove (tmpfile);
137+
138+ EXPECT_THROW (tmpfile.read (), fs::filesystem_error);
139+ }
140+
133141// / Tests binary file writing
134142TEST (file, write_binary) {
135143 file tmpfile = file ();
@@ -178,6 +186,15 @@ TEST(file, write_text) {
178186 }
179187}
180188
189+ // / Tests file writing error reporting
190+ TEST (file, write_error) {
191+ file tmpfile = file ();
192+ fs::permissions (tmpfile.path (), fs::perms::none);
193+
194+ EXPECT_THROW (tmpfile.write (" Hello!" ), fs::filesystem_error);
195+ fs::permissions (tmpfile.path (), fs::perms::all);
196+ }
197+
181198// / Tests binary file appending
182199TEST (file, append_binary) {
183200 file tmpfile = file ();
@@ -230,6 +247,15 @@ TEST(file, append_text) {
230247 }
231248}
232249
250+ // / Tests file appending error reporting
251+ TEST (file, append_error) {
252+ file tmpfile = file ();
253+ fs::permissions (tmpfile.path (), fs::perms::none);
254+
255+ EXPECT_THROW (tmpfile.append (" world!" ), fs::filesystem_error);
256+ fs::permissions (tmpfile.path (), fs::perms::all);
257+ }
258+
233259// / Tests binary file reading from input_stream
234260TEST (file, input_stream_binary) {
235261 file tmpfile = file ();
0 commit comments