aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael J. Bishop <mbtyke@gmail.com>2013-09-18 10:59:04 -0400
committerMichael J. Bishop <mbtyke@gmail.com>2013-09-18 10:59:04 -0400
commit2ed2fb5df392251a0957543b920272b9b2ae7908 (patch)
treef8d91c4753f810e667296b1468e4d704445675c0 /tests
parent8c867e3a4646dadf6922907543103ccf9a11fd75 (diff)
Added to the test_files test to ensure the pread() functionality.
Diffstat (limited to 'tests')
-rw-r--r--tests/files.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/files.cpp b/tests/files.cpp
index 176cdb62..5d158ba9 100644
--- a/tests/files.cpp
+++ b/tests/files.cpp
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
int main()
{
@@ -61,7 +62,14 @@ int main()
char data2[10];
FILE *inf = fopen("go.out", "rb");
- int num = fread(data2, 1, 10, inf);
+
+ // make sure pread returns 0 if we read starting at the end (or past the end) of the file
+ int num = pread(fileno(inf), data2, 10, 5);
+ assert(num == 0);
+ num = pread(fileno(inf), data2, 10, sizeof(data)*8);
+ assert(num == 0);
+
+ num = fread(data2, 1, 10, inf);
fclose(inf);
printf("%d : %d,%d,%d,%d,%d\n", num, data2[0], data2[1], data2[2], data2[3], data2[4]);