History

Add tests on Windows for strtoll and strtoull. Tests can probably be used on all systems.

Christian Jullien committed 4 years ago

Commit 6219b2d1 parent 40f01471 file · +39 −0Browse files

Unified · Split

tests/tests2/119_random_stuff.c+39−0
@@ -1,4 +1,15 @@
1+#if defined(_WIN32)
2+/*
3+ * strtoll and strtoull require the following define.
4+ * Not really needed in our case
5+ */
6+ #if !defined(_ISOC99_SOURCE)
7+ #define _ISOC99_SOURCE 1
8+ #endif
9+#endif
10+
111 #include <stdio.h>
12+#include <stdlib.h>
213
314 struct big_struct { char a[262144]; };
415
@@ -88,6 +99,33 @@ void tst_cast(void) · 83 unmodified lines
8899 printf ("schar to ushort cast: %x\n", r);
89100 }
90101
102+void tst_strtoll_strtoull(void)
103+{
104+ /*
105+ * It probably makes sense to run this test on all systems,
106+ * not just on Windows.
107+ */
108+#if defined(_WIN32)
109+ const unsigned int shift = 32;
110+
111+ {
112+ long long x = strtoll("0x100000000", NULL, 0);
113+ x = (x >> shift);
114+ if (x != 1LL) {
115+ printf("Windows: strtoll error\n");
116+ }
117+ }
118+
119+ {
120+ unsigned long long x = strtoll("0x100000000", NULL, 0);
121+ x = (x >> shift);
122+ if (x != 1) {
123+ printf ("Windows: strtoull error\n");
124+ }
125+ }
126+#endif
127+}
128+
91129 int
92130 main (void)
93131 {
@@ -105,4 +143,5 @@ main (void) · 11 unmodified lines
105143 tst_compare();
106144 tst_pack();
107145 tst_cast();
146+ tst_strtoll_strtoull();
108147 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t