diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-06-23 17:54:23 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-06-23 17:54:23 -0700 |
commit | 866f54c895f16de3c439efda9e15956019c7771b (patch) | |
tree | 58386abd902a60238c071236a0e8e468832138c1 | |
parent | 67edb0096dd6f4d07c604834679dbfd1337e4c50 (diff) |
libc seek tests
-rw-r--r-- | tests/files.cpp | 21 | ||||
-rw-r--r-- | tests/runner.py | 2 |
2 files changed, 21 insertions, 2 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; } diff --git a/tests/runner.py b/tests/runner.py index 80503de6..8a1fd974 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -1781,7 +1781,7 @@ if 'benchmark' not in sys.argv: other.close() src = open(path_from_root('tests', 'files.cpp'), 'r').read() - self.do_test(src, 'size: 7\ndata: 100,-56,50,25,10,77,123\ninput:hi there!\ntexto\ntexte\n5 : 10,30,20,11,88\nother=some data.\n', post_build=post) + self.do_test(src, 'size: 7\ndata: 100,-56,50,25,10,77,123\ninput:hi there!\ntexto\ntexte\n5 : 10,30,20,11,88\nother=some data.\nseeked=me da.\nseeked=ata.\nseeked=ta.', post_build=post) ### 'Big' tests |