aboutsummaryrefslogtreecommitdiff
path: root/tests/files.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/files.cpp')
-rw-r--r--tests/files.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/files.cpp b/tests/files.cpp
index e1a38421..04baa151 100644
--- a/tests/files.cpp
+++ b/tests/files.cpp
@@ -1,6 +1,7 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
int main()
{
@@ -103,6 +104,23 @@ int main()
fclose(inf);
printf("fscanfed: %d - %s\n", number, text);
+ // temp files
+ const char *tname = "file_XXXXXX.txt";
+ char tname1[100];
+ char tname2[100];
+ strcpy(tname1, tname);
+ strcpy(tname2, tname);
+ assert(!strcmp(tname1, tname2)); // equal
+ int f1 = mkstemp(tname1);
+ int f2 = mkstemp(tname2);
+ assert(f1 != f2);
+ //printf("%d,%d,%s,%s\n", f1, f2, tname1, tname2);
+ assert(strcmp(tname1, tname2)); // not equal
+ assert(fopen(tname1, "r"));
+ assert(fopen(tname2, "r"));
+ assert(!fopen(tname2+1, "r")); // sanity check that we can't open just anything
+ printf("ok.\n");
+
return 0;
}