@@ -45,6 +45,31 @@ FOSSIL_TEARDOWN(cpp_stream_suite) {
45
45
// as samples for library usage.
46
46
// * * * * * * * * * * * * * * * * * * * * * * * *
47
47
48
+ FOSSIL_TEST_CASE (cpp_test_stream_tempfile_creation) {
49
+ // Create a temporary file
50
+ fossil_fstream_t temp_stream = fossil_fstream_tempfile ();
51
+
52
+ // Check if the temporary file is open
53
+ ASSUME_ITS_TRUE (fossil_fstream_is_open (&temp_stream));
54
+
55
+ // Close the temporary file
56
+ fossil_fstream_close (&temp_stream);
57
+ }
58
+
59
+ FOSSIL_TEST_CASE (cpp_test_stream_tempfile_cleanup) {
60
+ // Create a temporary file
61
+ fossil_fstream_t temp_stream = fossil_fstream_tempfile ();
62
+
63
+ // Get the temporary file name
64
+ const char *temp_filename = temp_stream.filename ;
65
+
66
+ // Close the temporary file
67
+ fossil_fstream_close (&temp_stream);
68
+
69
+ // Verify the temporary file is deleted
70
+ ASSUME_NOT_EQUAL_I32 (0 , fossil_fstream_file_exists (temp_filename));
71
+ }
72
+
48
73
FOSSIL_TEST_CASE (cpp_test_stream_let_write_and_read_file) {
49
74
const char *filename = " testfile.txt" ;
50
75
const char *content = " This is a test." ;
@@ -233,6 +258,31 @@ FOSSIL_TEST_CASE(cpp_test_stream_setpos_and_getpos) {
233
258
fossil_fstream_close (&cpp_stream);
234
259
}
235
260
261
+ FOSSIL_TEST_CASE (cpp_test_stream_class_tempfile_creation) {
262
+ // Create a temporary file using the class method
263
+ fossil_fstream_t temp_stream = fossil::io::Stream::tempfile ();
264
+
265
+ // Check if the temporary file is open
266
+ ASSUME_ITS_TRUE (fossil::io::Stream::is_open (&temp_stream));
267
+
268
+ // Close the temporary file
269
+ fossil::io::Stream::close (&temp_stream);
270
+ }
271
+
272
+ FOSSIL_TEST_CASE (cpp_test_stream_class_tempfile_cleanup) {
273
+ // Create a temporary file using the class method
274
+ fossil_fstream_t temp_stream = fossil::io::Stream::tempfile ();
275
+
276
+ // Get the temporary file name
277
+ const char *temp_filename = temp_stream.filename ;
278
+
279
+ // Close the temporary file
280
+ fossil::io::Stream::close (&temp_stream);
281
+
282
+ // Verify the temporary file is deleted
283
+ ASSUME_NOT_EQUAL_I32 (0 , fossil::io::Stream::file_exists (temp_filename));
284
+ }
285
+
236
286
FOSSIL_TEST_CASE (cpp_test_stream_class_write_and_read_file) {
237
287
const char *filename = " testfile.txt" ;
238
288
const char *content = " This is a test." ;
@@ -373,6 +423,8 @@ FOSSIL_TEST_CASE(cpp_test_stream_class_get_permissions) {
373
423
// * * * * * * * * * * * * * * * * * * * * * * * *
374
424
375
425
FOSSIL_TEST_GROUP (cpp_file_tests) {
426
+ FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_tempfile_creation);
427
+ FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_tempfile_cleanup);
376
428
FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_let_write_and_read_file);
377
429
FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_let_open_and_close_file);
378
430
FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_multiple_files);
@@ -387,6 +439,8 @@ FOSSIL_TEST_GROUP(cpp_file_tests) {
387
439
FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_flush_file);
388
440
FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_setpos_and_getpos);
389
441
442
+ FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_class_tempfile_creation);
443
+ FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_class_tempfile_cleanup);
390
444
FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_class_write_and_read_file);
391
445
FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_class_open_and_close_file);
392
446
FOSSIL_TEST_ADD (cpp_stream_suite, cpp_test_stream_class_multiple_files);
0 commit comments