diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-01-11 16:17:16 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-01-11 16:17:16 -0800 |
commit | c47f7eba9be951c8e308e66c2541091c6b057af8 (patch) | |
tree | 59aed1cd174e91921e867955507c13f63303f40e /tests/files.cpp | |
parent | ada59f0a9d23d8ec19ee6a1326977ddf6e93f5f9 (diff) | |
parent | 2113958017b5def518bd4bcf0bf77e8be233a93f (diff) |
Merge branch 'incoming'
Diffstat (limited to 'tests/files.cpp')
-rw-r--r-- | tests/files.cpp | 18 |
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; } |