aboutsummaryrefslogtreecommitdiff
path: root/tests/files.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-06-23 17:54:23 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-06-23 17:54:23 -0700
commit866f54c895f16de3c439efda9e15956019c7771b (patch)
tree58386abd902a60238c071236a0e8e468832138c1 /tests/files.cpp
parent67edb0096dd6f4d07c604834679dbfd1337e4c50 (diff)
libc seek tests
Diffstat (limited to 'tests/files.cpp')
-rw-r--r--tests/files.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/files.cpp b/tests/files.cpp
index 39f9e61a..1167bbdf 100644
--- a/tests/files.cpp
+++ b/tests/files.cpp
@@ -51,12 +51,31 @@ int main()
FILE *other = fopen("test.file", "r");
assert(other);
+
char otherData[1000];
num = fread(otherData, 1, 9, other);
otherData[num] = 0;
- fclose(other);
printf("other=%s.\n", otherData);
+ // Seeking
+
+ fseek(other, 2, SEEK_SET);
+ num = fread(otherData, 1, 5, other);
+ otherData[num] = 0;
+ printf("seeked=%s.\n", otherData);
+
+ fseek(other, -1, SEEK_CUR);
+ num = fread(otherData, 1, 3, other);
+ otherData[num] = 0;
+ printf("seeked=%s.\n", otherData);
+
+ fseek(other, -2, SEEK_END);
+ num = fread(otherData, 1, 2, other);
+ otherData[num] = 0;
+ printf("seeked=%s.\n", otherData);
+
+ fclose(other);
+
return 0;
}