1 /* Test for file I/O bug */
3 #include <libchimara/glk.h>
7 #define MAGIC_STRING "Zapp\xF6licious.\n"
13 char buffer[BUFLEN + 1];
15 /* Open a temporary file */
16 frefid_t ref = glk_fileref_create_temp(fileusage_Data | fileusage_BinaryMode, 0);
17 strid_t file = glk_stream_open_file_uni(ref, filemode_Write, 0);
19 /* Write the string to the file */
20 glk_put_string_stream(file, MAGIC_STRING);
22 /* Close and check result counts */
23 stream_result_t counts;
24 glk_stream_close(file, &counts);
25 g_assert_cmpint(counts.readcount, ==, 0);
26 g_assert_cmpint(counts.writecount, ==, 14);
28 file = glk_stream_open_file_uni(ref, filemode_Read, 0);
29 glui32 readcount = glk_get_line_stream(file, buffer, BUFLEN);
30 g_printerr("String: %s\n", buffer);
31 g_assert_cmpint(readcount, ==, strlen(buffer));
33 glk_stream_close(file, &counts);
34 glk_fileref_destroy(ref);