---
 mingw-w64-crt/testcases/Makefile.am  |  1 +
 mingw-w64-crt/testcases/t_lseeki64.c | 40 ++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 mingw-w64-crt/testcases/t_lseeki64.c

diff --git a/mingw-w64-crt/testcases/Makefile.am 
b/mingw-w64-crt/testcases/Makefile.am
index 889439141918..7263b124fe00 100644
--- a/mingw-w64-crt/testcases/Makefile.am
+++ b/mingw-w64-crt/testcases/Makefile.am
@@ -28,6 +28,7 @@ testcase_progs = \
   t_intrinc \
   t_imagebase \
   t_lfs \
+  t_lseeki64 \
   t_matherr \
   t_mbrlen \
   t_mbrtowc \
diff --git a/mingw-w64-crt/testcases/t_lseeki64.c 
b/mingw-w64-crt/testcases/t_lseeki64.c
new file mode 100644
index 000000000000..682e1add205f
--- /dev/null
+++ b/mingw-w64-crt/testcases/t_lseeki64.c
@@ -0,0 +1,40 @@
+#include <stdio.h>
+#include <assert.h>
+#include <io.h>
+
+int main() {
+    FILE *file;
+    int fd;
+
+    /* create temporary file which is automatically deleted when process 
terminates */
+    file = tmpfile();
+    assert(file);
+    fd = fileno(file);
+    assert(fd >= 0);
+
+    /* absolute offset which fits into 32-bit signed type */
+    assert(_lseeki64(fd, 0x10, SEEK_SET) == 0x10);
+    assert(_lseeki64(fd, 0, SEEK_CUR) == 0x10);
+
+    /* relative offset which fits into 32-bit signed type, but absolute does 
not */
+    assert(_lseeki64(fd, 0x7FFFFFFF, SEEK_CUR) == 0x7FFFFFFFLL + 0x10);
+    assert(_lseeki64(fd, 0, SEEK_CUR) == 0x7FFFFFFFLL + 0x10);
+
+    /* absolute offset which fits into 32-bit unsigned type but does not into 
32-bit signed type */
+    assert(_lseeki64(fd, 0x90000000, SEEK_SET) == 0x90000000);
+    assert(_lseeki64(fd, 0, SEEK_CUR) == 0x90000000);
+
+    /* relative offset which fits into 32-bit unsigned type but absolute does 
not */
+    assert(_lseeki64(fd, 0xFFFFFFFF, SEEK_CUR) == 0xFFFFFFFFLL + 0x90000000);
+    assert(_lseeki64(fd, 0, SEEK_CUR) == 0xFFFFFFFFLL + 0x90000000);
+
+    /* absolute offset which does not fit into 32-bit unsigned type */
+    assert(_lseeki64(fd, 0x100000000, SEEK_SET) == 0x100000000);
+    assert(_lseeki64(fd, 0, SEEK_CUR) == 0x100000000);
+
+    /* relative offset which does not fit into 32-bit unsigned type */
+    assert(_lseeki64(fd, 0x100000000, SEEK_CUR) == 0x200000000);
+    assert(_lseeki64(fd, 0, SEEK_CUR) == 0x200000000);
+
+    return 0;
+}
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to