@@ -117,6 +117,69 @@ FOSSIL_TEST_CASE(cpp_test_stream_get_type) {
117117 ASSUME_ITS_EQUAL_I32 (2 , fossil_fstream_get_type (filename)); // Regular file
118118}
119119
120+ FOSSIL_TEST_CASE (cpp_test_stream_is_readable) {
121+ const char *filename = " testfile_readable.txt" ;
122+
123+ // Create the file
124+ ASSUME_ITS_EQUAL_I32 (0 , fossil_fstream_open (&cpp_stream, filename, " w" ));
125+ fossil_fstream_close (&cpp_stream);
126+
127+ // Check if the file is readable
128+ ASSUME_ITS_EQUAL_I32 (1 , fossil_fstream_is_readable (filename));
129+ }
130+
131+ FOSSIL_TEST_CASE (cpp_test_stream_is_writable) {
132+ const char *filename = " testfile_writable.txt" ;
133+
134+ // Create the file
135+ ASSUME_ITS_EQUAL_I32 (0 , fossil_fstream_open (&cpp_stream, filename, " w" ));
136+ fossil_fstream_close (&cpp_stream);
137+
138+ // Check if the file is writable
139+ ASSUME_ITS_EQUAL_I32 (1 , fossil_fstream_is_writable (filename));
140+ }
141+
142+ FOSSIL_TEST_CASE (cpp_test_stream_is_executable) {
143+ const char *filename = " testfile_executable.txt" ;
144+
145+ // Create the file
146+ ASSUME_ITS_EQUAL_I32 (0 , fossil_fstream_open (&cpp_stream, filename, " w" ));
147+ fossil_fstream_close (&cpp_stream);
148+
149+ // Check if the file is executable
150+ ASSUME_ITS_EQUAL_I32 (0 , fossil_fstream_is_executable (filename));
151+ }
152+
153+ FOSSIL_TEST_CASE (cpp_test_stream_set_permissions) {
154+ const char *filename = " testfile_permissions.txt" ;
155+
156+ // Create the file
157+ ASSUME_ITS_EQUAL_I32 (0 , fossil_fstream_open (&cpp_stream, filename, " w" ));
158+ fossil_fstream_close (&cpp_stream);
159+
160+ // Set file permissions
161+ ASSUME_ITS_EQUAL_I32 (0 , fossil_fstream_set_permissions (filename, 0644 ));
162+
163+ // Check if the file is readable and writable
164+ ASSUME_ITS_EQUAL_I32 (1 , fossil_fstream_is_readable (filename));
165+ ASSUME_ITS_EQUAL_I32 (1 , fossil_fstream_is_writable (filename));
166+ }
167+
168+ FOSSIL_TEST_CASE (cpp_test_stream_get_permissions) {
169+ const char *filename = " testfile_get_permissions.txt" ;
170+ int32_t mode;
171+
172+ // // Create the file
173+ ASSUME_ITS_EQUAL_I32 (0 , fossil_fstream_open (&cpp_stream, filename, " w" ));
174+ fossil_fstream_close (&cpp_stream);
175+
176+ // Set file permissions
177+ ASSUME_ITS_EQUAL_I32 (0 , fossil_fstream_set_permissions (filename, 0644 ));
178+
179+ // Get file permissions
180+ ASSUME_ITS_EQUAL_I32 (0 , fossil_fstream_get_permissions (filename, &mode));
181+ }
182+
120183FOSSIL_TEST_CASE (cpp_test_stream_class_write_and_read_file) {
121184 const char *filename = " testfile.txt" ;
122185 const char *content = " This is a test." ;
@@ -189,6 +252,69 @@ FOSSIL_TEST_CASE(cpp_test_stream_class_get_type) {
189252 ASSUME_ITS_EQUAL_I32 (2 , fossil::io::Stream::get_type (filename)); // Regular file
190253}
191254
255+ FOSSIL_TEST_CASE (cpp_test_stream_class_is_readable) {
256+ const char *filename = " testfile_readable_class.txt" ;
257+
258+ // Create the file
259+ ASSUME_ITS_EQUAL_I32 (0 , fossil::io::Stream::open (&cpp_stream, filename, " w" ));
260+ fossil::io::Stream::close (&cpp_stream);
261+
262+ // Check if the file is readable
263+ ASSUME_ITS_EQUAL_I32 (1 , fossil::io::Stream::is_readable (filename));
264+ }
265+
266+ FOSSIL_TEST_CASE (cpp_test_stream_class_is_writable) {
267+ const char *filename = " testfile_writable_class.txt" ;
268+
269+ // Create the file
270+ ASSUME_ITS_EQUAL_I32 (0 , fossil::io::Stream::open (&cpp_stream, filename, " w" ));
271+ fossil::io::Stream::close (&cpp_stream);
272+
273+ // Check if the file is writable
274+ ASSUME_ITS_EQUAL_I32 (1 , fossil::io::Stream::is_writable (filename));
275+ }
276+
277+ FOSSIL_TEST_CASE (cpp_test_stream_class_is_executable) {
278+ const char *filename = " testfile_executable_class.txt" ;
279+
280+ // Create the file
281+ ASSUME_ITS_EQUAL_I32 (0 , fossil::io::Stream::open (&cpp_stream, filename, " w" ));
282+ fossil::io::Stream::close (&cpp_stream);
283+
284+ // Check if the file is executable
285+ ASSUME_ITS_EQUAL_I32 (0 , fossil::io::Stream::is_executable (filename));
286+ }
287+
288+ FOSSIL_TEST_CASE (cpp_test_stream_class_set_permissions) {
289+ const char *filename = " testfile_permissions_class.txt" ;
290+
291+ // Create the file
292+ ASSUME_ITS_EQUAL_I32 (0 , fossil::io::Stream::open (&cpp_stream, filename, " w" ));
293+ fossil::io::Stream::close (&cpp_stream);
294+
295+ // Set file permissions
296+ ASSUME_ITS_EQUAL_I32 (0 , fossil::io::Stream::set_permissions (filename, 0644 ));
297+
298+ // Check if the file is readable and writable
299+ ASSUME_ITS_EQUAL_I32 (1 , fossil::io::Stream::is_readable (filename));
300+ ASSUME_ITS_EQUAL_I32 (1 , fossil::io::Stream::is_writable (filename));
301+ }
302+
303+ FOSSIL_TEST_CASE (cpp_test_stream_class_get_permissions) {
304+ const char *filename = " testfile_get_permissions_class.txt" ;
305+ int32_t mode;
306+
307+ // Create the file
308+ ASSUME_ITS_EQUAL_I32 (0 , fossil::io::Stream::open (&cpp_stream, filename, " w" ));
309+ fossil::io::Stream::close (&cpp_stream);
310+
311+ // Set file permissions
312+ ASSUME_ITS_EQUAL_I32 (0 , fossil::io::Stream::set_permissions (filename, 0644 ));
313+
314+ // Get file permissions
315+ ASSUME_ITS_EQUAL_I32 (0 , fossil::io::Stream::get_permissions (filename, &mode));
316+ }
317+
192318// * * * * * * * * * * * * * * * * * * * * * * * *
193319// * Fossil Logic Test Pool
194320// * * * * * * * * * * * * * * * * * * * * * * * *
@@ -200,11 +326,22 @@ FOSSIL_TEST_GROUP(cpp_file_tests) {
200326 FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_seek_and_tell);
201327 FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_get_type);
202328
329+ FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_is_readable);
330+ FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_is_writable);
331+ FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_is_executable);
332+ FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_set_permissions);
333+ FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_get_permissions);
334+
203335 FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_class_write_and_read_file);
204336 FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_class_open_and_close_file);
205337 FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_class_multiple_files);
206338 FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_class_seek_and_tell);
207339 FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_class_get_type);
340+ FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_class_is_readable);
341+ FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_class_is_writable);
342+ FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_class_is_executable);
343+ FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_class_set_permissions);
344+ FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_class_get_permissions);
208345
209346 FOSSIL_TEST_REGISTER (cpp_stream_suite);
210347}
0 commit comments