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
1#include <stdio.h>11#include <stdio.h>
12#include <stdlib.h>
2 13
3struct big_struct { char a[262144]; };14struct big_struct { char a[262144]; };
4 15
@@ -88,6 +99,33 @@ void tst_cast(void) · 83 unmodified lines
88 printf ("schar to ushort cast: %x\n", r);99 printf ("schar to ushort cast: %x\n", r);
89}100}
90 101
102void 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
91int129int
92main (void)130main (void)
93{131{
@@ -105,4 +143,5 @@ main (void) · 11 unmodified lines
105 tst_compare();143 tst_compare();
106 tst_pack();144 tst_pack();
107 tst_cast();145 tst_cast();
146 tst_strtoll_strtoull();
108}147}

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