summaryrefslogtreecommitdiff
path: root/test/testfile.c
diff options
context:
space:
mode:
authortrawick <trawick@13f79535-47bb-0310-9956-ffa450edef68>2004-05-04 00:07:32 +0000
committertrawick <trawick@13f79535-47bb-0310-9956-ffa450edef68>2004-05-04 00:07:32 +0000
commit31f7634e559261ecd9ec8c4549c0beca60251cdc (patch)
tree2dcd64e65861c5f6c89cf33fac8afe7978d9a26a /test/testfile.c
parent5e0a20225ecaa9c99a0da3de492ca1c83e13b4cd (diff)
downloadlibapr-31f7634e559261ecd9ec8c4549c0beca60251cdc.tar.gz
Fix sign error in apr_file_seek().
Submitted by: Greg Hudson <ghudson MIT.EDU> Reviewed by: Jeff Trawick git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@65086 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testfile.c')
-rw-r--r--test/testfile.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/testfile.c b/test/testfile.c
index 1305efc10..ce02faf7b 100644
--- a/test/testfile.c
+++ b/test/testfile.c
@@ -228,6 +228,27 @@ static void test_seek(CuTest *tc)
CuAssertStrEquals(tc, TESTSTR + 5, str);
apr_file_close(filetest);
+
+ /* Test for regression of sign error bug with SEEK_END and
+ buffered files. */
+ rv = apr_file_open(&filetest, FILENAME,
+ APR_READ | APR_BUFFERED,
+ APR_UREAD | APR_UWRITE | APR_GREAD, p);
+ apr_assert_success(tc, "Open test file " FILENAME, rv);
+
+ offset = -5;
+ rv = apr_file_seek(filetest, SEEK_END, &offset);
+ CuAssertIntEquals(tc, APR_SUCCESS, rv);
+ CuAssertIntEquals(tc, strlen(TESTSTR) - 5, nbytes);
+
+ memset(str, 0, nbytes + 1);
+ nbytes = 256;
+ rv = apr_file_read(filetest, str, &nbytes);
+ CuAssertIntEquals(tc, APR_SUCCESS, rv);
+ CuAssertIntEquals(tc, 5, nbytes);
+ CuAssertStrEquals(tc, TESTSTR + strlen(TESTSTR) - 5, str);
+
+ apr_file_close(filetest);
}
static void test_userdata_set(CuTest *tc)