tests/ansi: fix fopen test
#include <assert.h>
#include <string.h>
+#define TEST_FILE "fopen.tmp"
+
int main() {
FILE *file;
char str[] = "mlibc fopen test";
@@ -15,7 +17,7 @@ int main() {
memset(buffer2, 0, sizeof(buffer2));
// Open the file for writing.
- file = fopen("mlibc-test.txt", "w");
+ file = fopen(TEST_FILE, "w");
assert(file);
// Write string minus null terminator, flush and close.
@@ -24,7 +26,7 @@ int main() {
fclose(file);
// Open the file for reading.
- file = fopen("mlibc-test.txt", "r");
+ file = fopen(TEST_FILE, "r");
assert(file);
// Verify that we read back the written string and close the file.
@@ -33,15 +35,14 @@ int main() {
fclose(file);
// Open the file in appending mode, append string 2 (minus the null terminator) to the file, flush and close.
- file = fopen("mlibc-test.txt", "a");
+ file = fopen(TEST_FILE, "a");
fwrite(str2, 1, sizeof(str2) - 1, file);
fflush(file);
fclose(file);
// Open the file for reading again, verify the contents, close the file and return.
- file = fopen("mlibc-test.txt", "r");
+ file = fopen(TEST_FILE, "r");
fread(buffer2, strlen(completestr) + 1, 1, file);
- printf("buffer2: %s\nstr: %s\n", buffer2, completestr);
assert(!strcmp(buffer2, completestr));
fclose(file);
