From: Patrick Pelletier Date: Mon, 20 Aug 2018 17:53:35 +0000 (-0700) Subject: seek test: Test some additional error cases. X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=357d94e834c33ff09d2e993b7a930ebb7819919c;p=cc65 seek test: Test some additional error cases. --- diff --git a/testcode/lib/seek.c b/testcode/lib/seek.c index 59603a795..200f344c2 100644 --- a/testcode/lib/seek.c +++ b/testcode/lib/seek.c @@ -173,6 +173,35 @@ int main(int argc, char **argv) } else { printf("NOT OK, no error\n"); + fclose(file); + return(1); + } + + /* ProDOS on the Apple II only supports 24-bit file offsets, + ** so anything beyond that should be an error. I don't know + ** about other platforms, but I'm guessing no 6502-based + ** operating systems support 32-bit offsets? + */ + printf("seeking to position 2^24:\n\t"); + pos = lseek(fd, 0x1000000L, SEEK_SET); + if (pos == -1) { + printf("Ok, error %s\n", strerror(errno)); + } + else { + printf("NOT OK, returned %ld but expected -1\n", pos); + fclose(file); + return(1); + } + + printf("trying invalid value for whence:\n\t"); + pos = lseek(fd, 0L, 3); + if (pos == -1) { + printf("Ok, error %s\n", strerror(errno)); + } + else { + printf("NOT OK, returned %ld but expected -1\n", pos); + fclose(file); + return(1); } fclose(file);