Debian Codegraph @

tests/string_test.cpp

raw
1 #include "fast_float/fast_float.h"
2
3 #include <cctype>
4 #include <cstdio>
5 #include <iostream>
6 #include <limits>
7 #include <stdexcept>
8 #include <string>
9 #include <system_error>
10 #include <vector>
11
12 #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) || \
13 defined(sun) || defined(__sun)
14 // Anything at all that is related to cygwin, msys and so forth will
15 // always use this fallback because we cannot rely on it behaving as normal
16 // gcc.
17 #include <locale>
18 #include <sstream>
19
20 // workaround for CYGWIN
21 double cygwin_strtod_l(char const *start, char **end) {
22 double d;
23 std::stringstream ss;
24 ss.imbue(std::locale::classic());
25 ss << start;
26 ss >> d;
27 if (ss.fail()) {
28 *end = nullptr;
29 }
30 if (ss.eof()) {
31 ss.clear();
32 }
33 auto nread = ss.tellg();
34 *end = const_cast<char *>(start) + nread;
35 return d;
36 }
37
38 float cygwin_strtof_l(char const *start, char **end) {
39 float d;
40 std::stringstream ss;
41 ss.imbue(std::locale::classic());
42 ss << start;
43 ss >> d;
44 if (ss.fail()) {
45 *end = nullptr;
46 }
47 if (ss.eof()) {
48 ss.clear();
49 }
50 auto nread = ss.tellg();
51 *end = const_cast<char *>(start) + nread;
52 return d;
53 }
54 #endif
55
56 inline void Assert(bool Assertion) {
57 #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) || \
58 defined(sun) || defined(__sun)
59 if (!Assertion) {
60 std::cerr << "Omitting hard failure on msys/cygwin/sun systems.";
61 }
62 #else
63 if (!Assertion) {
64 throw std::runtime_error("bug");
65 }
66 #endif
67 }
68
69 template <typename T> std::string to_string(T d) {
70 std::string s(64, '\0');
71 auto written = std::snprintf(&s[0], s.size(), "%.*e",
72 std::numeric_limits<T>::max_digits10 - 1, d);
73 s.resize(size_t(written));
74 return s;
75 }
76
77 template <typename T> bool test() {
78 std::string input =
79 "0.1 1e1000 100000 3.14159265359 -1e-500 001 1e01 1e0000001 -inf";
80 std::vector<T> answers = {T(0.1),
81 std::numeric_limits<T>::infinity(),
82 100000,
83 T(3.14159265359),
84 -0.0,
85 1,
86 10,
87 10,
88 -std::numeric_limits<T>::infinity()};
89 std::vector<std::errc> expected_ec = {std::errc(),
90 std::errc::result_out_of_range,
91 std::errc(),
92 std::errc(),
93 std::errc::result_out_of_range,
94 std::errc(),
95 std::errc(),
96 std::errc(),
97 std::errc()};
98 char const *begin = input.data();
99 char const *end = input.data() + input.size();
100 for (size_t i = 0; i < answers.size(); i++) {
101 T result_value;
102 while ((begin < end) && (std::isspace(*begin))) {
103 begin++;
104 }
105 auto result = fast_float::from_chars(begin, end, result_value);
106 if (result.ec != expected_ec[i]) {
107 printf("parsing %.*s\n", int(end - begin), begin);
108 std::cerr << " I could not parse " << std::endl;
109 return false;
110 }
111 if (result_value != answers[i]) {
112 printf("parsing %.*s\n", int(end - begin), begin);
113 std::cerr << " Mismatch " << std::endl;
114 return false;
115 }
116 begin = result.ptr;
117 }
118 if (begin != end) {
119 std::cerr << " bad ending " << std::endl;
120 return false;
121 }
122 return true;
123 }
124
125 template <typename T> void strtod_from_string(std::string const &st, T &d);
126
127 template <> void strtod_from_string(std::string const &st, double &d) {
128 char *pr = (char *)st.c_str();
129 #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) || \
130 defined(sun) || defined(__sun)
131 d = cygwin_strtod_l(pr, &pr);
132 #elif defined(_WIN32)
133 static _locale_t c_locale = _create_locale(LC_ALL, "C");
134 d = _strtod_l(st.c_str(), &pr, c_locale);
135 #else
136 static locale_t c_locale = newlocale(LC_ALL_MASK, "C", NULL);
137 d = strtod_l(st.c_str(), &pr, c_locale);
138 #endif
139 if (pr == st.c_str()) {
140 throw std::runtime_error("bug in strtod_from_string");
141 }
142 }
143
144 template <> void strtod_from_string(std::string const &st, float &d) {
145 char *pr = (char *)st.c_str();
146 #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) || \
147 defined(sun) || defined(__sun)
148 d = cygwin_strtof_l(st.c_str(), &pr);
149 #elif defined(_WIN32)
150 static _locale_t c_locale = _create_locale(LC_ALL, "C");
151 d = _strtof_l(st.c_str(), &pr, c_locale);
152 #else
153 static locale_t c_locale = newlocale(LC_ALL_MASK, "C", NULL);
154 d = strtof_l(st.c_str(), &pr, c_locale);
155 #endif
156 if (pr == st.c_str()) {
157 throw std::runtime_error("bug in strtod_from_string");
158 }
159 }
160
161 template <typename T> bool partow_test() {
162 // credit:
163 // https://github.com/ArashPartow/strtk/blob/master/strtk_tokenizer_cmp.cpp#L568
164 // MIT license
165 std::string const strint_list[] = {
166 "9007199254740993",
167 "9007199254740994",
168 "9007199254740995",
169 "0",
170 "1",
171 "2",
172 "3",
173 "4",
174 "5",
175 "6",
176 "7",
177 "8",
178 "9",
179 "917049",
180 "4931205",
181 "6768064",
182 "6884243",
183 "5647132",
184 "7371203",
185 "-8629878",
186 "4941840",
187 "4543268",
188 "1075600",
189 "290",
190 "823",
191 "111",
192 "715",
193 "-866",
194 "367",
195 "666",
196 "-706",
197 "850",
198 "-161",
199 "9922547",
200 "6960207",
201 "1883152",
202 "2300759",
203 "-279294",
204 "4187292",
205 "3699841",
206 "8386395",
207 "-1441129",
208 "-887892",
209 "-635422",
210 "9742573",
211 "2326186",
212 "-5903851",
213 "5648486",
214 "3057647",
215 "2980079",
216 "2957468",
217 "7929158",
218 "1925615",
219 "879",
220 "130",
221 "292",
222 "705",
223 "817",
224 "446",
225 "576",
226 "750",
227 "523",
228 "-527",
229 "4365041",
230 "5624958",
231 "8990205",
232 "2652177",
233 "3993588",
234 "-298316",
235 "2901599",
236 "3887387",
237 "-5202979",
238 "1196268",
239 "5968501",
240 "7619928",
241 "3565643",
242 "1885272",
243 "-749485",
244 "2961381",
245 "2982579",
246 "2387454",
247 "4250081",
248 "5958205",
249 "00000",
250 "00001",
251 "00002",
252 "00003",
253 "00004",
254 "00005",
255 "00006",
256 "00007",
257 "00008",
258 "00009",
259 "4907034",
260 "2592882",
261 "3269234",
262 "549815",
263 "6256292",
264 "9721039",
265 "-595225",
266 "5587491",
267 "4596297",
268 "-3885009",
269 "673",
270 "-899",
271 "174",
272 "354",
273 "870",
274 "147",
275 "898",
276 "-510",
277 "369",
278 "859",
279 "6518423",
280 "5149762",
281 "8834164",
282 "-8085586",
283 "3233120",
284 "8166948",
285 "4172345",
286 "6735549",
287 "-934295",
288 "9481935",
289 "-430406",
290 "6932717",
291 "4087292",
292 "4047263",
293 "3236400",
294 "-3863050",
295 "4312079",
296 "6956261",
297 "5689446",
298 "3871332",
299 "535",
300 "691",
301 "326",
302 "-409",
303 "704",
304 "-568",
305 "301",
306 "951",
307 "121",
308 "384",
309 "4969414",
310 "9378599",
311 "7971781",
312 "5380630",
313 "5001363",
314 "1715827",
315 "6044615",
316 "9118925",
317 "9956168",
318 "-8865496",
319 "5962464",
320 "7408980",
321 "6646513",
322 "-634564",
323 "4188330",
324 "9805948",
325 "5625691",
326 "7641113",
327 "-4212929",
328 "7802447",
329 "0",
330 "1",
331 "2",
332 "3",
333 "4",
334 "5",
335 "6",
336 "7",
337 "8",
338 "9",
339 "2174248",
340 "7449361",
341 "9896659",
342 "-25961",
343 "1706598",
344 "2412368",
345 "-4617035",
346 "6314554",
347 "2225957",
348 "7521434",
349 "-9530566",
350 "3914164",
351 "2394759",
352 "7157744",
353 "9919392",
354 "6406949",
355 "-744004",
356 "9899789",
357 "8380325",
358 "-1416284",
359 "3402833",
360 "2150043",
361 "5191009",
362 "8979538",
363 "9565778",
364 "3750211",
365 "7304823",
366 "2829359",
367 "6544236",
368 "-615740",
369 "363",
370 "-627",
371 "129",
372 "656",
373 "135",
374 "113",
375 "381",
376 "646",
377 "198",
378 "38",
379 "8060564",
380 "-176752",
381 "1184717",
382 "-666343",
383 "-1273292",
384 "-485827",
385 "6241066",
386 "6579411",
387 "8093119",
388 "7481306",
389 "-4924485",
390 "7467889",
391 "9813178",
392 "7927100",
393 "3614859",
394 "7293354",
395 "9232973",
396 "4323115",
397 "1133911",
398 "9511638",
399 "4443188",
400 "2289448",
401 "5639726",
402 "9073898",
403 "8540394",
404 "5389992",
405 "1397726",
406 "-589230",
407 "1017086",
408 "1852330",
409 "-840",
410 "267",
411 "201",
412 "533",
413 "-675",
414 "494",
415 "315",
416 "706",
417 "-920",
418 "784",
419 "9097353",
420 "6002251",
421 "-308780",
422 "-3830169",
423 "4340467",
424 "2235284",
425 "3314444",
426 "1085967",
427 "4152107",
428 "5431117",
429 "-0000",
430 "-0001",
431 "-0002",
432 "-0003",
433 "-0004",
434 "-0005",
435 "-0006",
436 "-0007",
437 "-0008",
438 "-0009",
439 "-444999",
440 "2136400",
441 "6925907",
442 "6990614",
443 "3588271",
444 "8422028",
445 "-4034772",
446 "5804039",
447 "-6740545",
448 "9381873",
449 "-924923",
450 "1652367",
451 "2302616",
452 "6776663",
453 "2567821",
454 "-248935",
455 "2587688",
456 "7076742",
457 "-6461467",
458 "1562896",
459 "-768116",
460 "2338768",
461 "9887307",
462 "9992184",
463 "2045182",
464 "2797589",
465 "9784597",
466 "9696554",
467 "5113329",
468 "1067216",
469 "-76247763",
470 "58169007",
471 "29408062",
472 "85342511",
473 "42092201",
474 "-95817703",
475 "-1912517",
476 "-26275135",
477 "54656606",
478 "-58188878",
479 "473",
480 "74",
481 "374",
482 "-64",
483 "266",
484 "715",
485 "937",
486 "-249",
487 "249",
488 "780",
489 "3907360",
490 "-23063423",
491 "59062754",
492 "83711047",
493 "-95221044",
494 "34894840",
495 "-38562139",
496 "-82018330",
497 "14226223",
498 "-10799717",
499 "8529722",
500 "88961903",
501 "25608618",
502 "-39988247",
503 "33228241",
504 "38598533",
505 "21161480",
506 "-33723784",
507 "8873948",
508 "96505557",
509 "-47385048",
510 "-79413272",
511 "-85904404",
512 "87791158",
513 "49194195",
514 "13051222",
515 "57773302",
516 "31904423",
517 "3142966",
518 "27846156",
519 "7420011",
520 "-72376922",
521 "-68873971",
522 "23765361",
523 "4040725",
524 "-22359806",
525 "85777219",
526 "10099223",
527 "-90364256",
528 "-40158172",
529 "-7948696",
530 "-64344821",
531 "34404238",
532 "84037448",
533 "-85084788",
534 "-42078409",
535 "-56550310",
536 "96898389",
537 "-595829",
538 "-73166703",
539 "-0",
540 "-1",
541 "-2",
542 "-3",
543 "-4",
544 "-5",
545 "-6",
546 "-7",
547 "-8",
548 "-9",
549 "2147483647",
550 "31",
551 "2147483610",
552 "33",
553 "2147483573",
554 "37",
555 "2147483536",
556 "-82838342",
557 "64441808",
558 "43641062",
559 "-64419642",
560 "-44421934",
561 "75232413",
562 "-75773725",
563 "-89139509",
564 "12812089",
565 "-97633526",
566 "36090916",
567 "-57706234",
568 "17804655",
569 "4189936",
570 "-4100124",
571 "38803710",
572 "-39735126",
573 "-62397437",
574 "75801648",
575 "51302332",
576 "73433906",
577 "13015224",
578 "-12624818",
579 "91360377",
580 "11576319",
581 "-54467535",
582 "8892431",
583 "36319780",
584 "38832042",
585 "50172572",
586 "-317",
587 "109",
588 "-888",
589 "302",
590 "-463",
591 "716",
592 "916",
593 "665",
594 "826",
595 "513",
596 "42423473",
597 "41078812",
598 "40445652",
599 "-76722281",
600 "95092224",
601 "12075234",
602 "-4045888",
603 "-74396490",
604 "-57304222",
605 "-21726885",
606 "92038121",
607 "-31899682",
608 "21589254",
609 "-30260046",
610 "56000244",
611 "69686659",
612 "93327838",
613 "96882881",
614 "-91419389",
615 "77529147",
616 "43288506",
617 "1192435",
618 "-74095920",
619 "76756590",
620 "-31184683",
621 "-35716724",
622 "9451980",
623 "-63168350",
624 "62864002",
625 "26283194",
626 "37188395",
627 "29151634",
628 "99343471",
629 "-69450330",
630 "-55680090",
631 "-64957599",
632 "47577948",
633 "47107924",
634 "2490477",
635 "48633003",
636 "-82740809",
637 "-24122215",
638 "67301713",
639 "-63649610",
640 "75499016",
641 "82746620",
642 "17052193",
643 "4602244",
644 "-32721165",
645 "20837836",
646 "674",
647 "467",
648 "706",
649 "889",
650 "172",
651 "282",
652 "-795",
653 "188",
654 "87",
655 "153",
656 "64501793",
657 "53146328",
658 "5152287",
659 "-9674493",
660 "68105580",
661 "57245637",
662 "39740229",
663 "-74071854",
664 "86777268",
665 "86484437",
666 "-86962508",
667 "12644427",
668 "-62944073",
669 "59539680",
670 "43340539",
671 "30661534",
672 "20143968",
673 "-68183731",
674 "-48250926",
675 "42669063",
676 "000",
677 "001",
678 "002",
679 "003",
680 "004",
681 "005",
682 "006",
683 "007",
684 "008",
685 "009",
686 "2147483499",
687 "71",
688 "2147483462",
689 "73",
690 "2147483425",
691 "77",
692 "2147483388",
693 "87736852",
694 "-4444906",
695 "-48094147",
696 "54774735",
697 "54571890",
698 "-22473078",
699 "95053418",
700 "393654",
701 "-33229960",
702 "32276798",
703 "-48361110",
704 "44295939",
705 "-79813406",
706 "11630865",
707 "38544571",
708 "70972830",
709 "-9821748",
710 "-60965384",
711 "-13096675",
712 "-24569041",
713 "708",
714 "-467",
715 "-794",
716 "610",
717 "929",
718 "766",
719 "152",
720 "482",
721 "397",
722 "-191",
723 "97233152",
724 "51028396",
725 "-13796948",
726 "95437272",
727 "71352512",
728 "-83233730",
729 "-68517318",
730 "61832742",
731 "-42667174",
732 "-18002395",
733 "-92239407",
734 "12701336",
735 "-63830875",
736 "41514172",
737 "-5726049",
738 "18668677",
739 "69555144",
740 "-13737009",
741 "-22626233",
742 "-55078143",
743 "00",
744 "11",
745 "22",
746 "33",
747 "44",
748 "-00",
749 "-11",
750 "-22",
751 "-33",
752 "-44",
753 "000",
754 "111",
755 "222",
756 "333",
757 "444",
758 "-000",
759 "-111",
760 "-222",
761 "-333",
762 "-444",
763 "0000",
764 "1111",
765 "2222",
766 "3333",
767 "4444",
768 "-0000",
769 "-1111",
770 "-2222",
771 "-3333",
772 "-4444",
773 "00000",
774 "11111",
775 "22222",
776 "33333",
777 "44444",
778 "-00000",
779 "-11111",
780 "-22222",
781 "-33333",
782 "-44444",
783 "000000",
784 "111111",
785 "222222",
786 "333333",
787 "444444",
788 "-000000",
789 "-111111",
790 "-222222",
791 "-333333",
792 "-444444",
793 "0000000",
794 "1111111",
795 "2222222",
796 "3333333",
797 "4444444",
798 "-0000000",
799 "-1111111",
800 "-2222222",
801 "-3333333",
802 "-4444444",
803 "00000000",
804 "11111111",
805 "22222222",
806 "33333333",
807 "44444444",
808 "-00000000",
809 "-11111111",
810 "-22222222",
811 "-33333333",
812 "-44444444",
813 "000000000",
814 "111111111",
815 "222222222",
816 "333333333",
817 "444444444",
818 "-000000000",
819 "-111111111",
820 "-222222222",
821 "-333333333",
822 "-444444444",
823 "2147483351",
824 "51",
825 "2147483314",
826 "53",
827 "-2147483648",
828 "57",
829 "-2147483611",
830 "55",
831 "66",
832 "77",
833 "88",
834 "99",
835 "-55",
836 "-66",
837 "-77",
838 "-88",
839 "-99",
840 "555",
841 "666",
842 "777",
843 "888",
844 "999",
845 "-555",
846 "-666",
847 "-777",
848 "-888",
849 "-999",
850 "5555",
851 "6666",
852 "7777",
853 "8888",
854 "9999",
855 "-5555",
856 "-6666",
857 "-7777",
858 "-8888",
859 "-9999",
860 "55555",
861 "66666",
862 "77777",
863 "88888",
864 "99999",
865 "-55555",
866 "-66666",
867 "-77777",
868 "-88888",
869 "-99999",
870 "555555",
871 "666666",
872 "777777",
873 "888888",
874 "999999",
875 "-555555",
876 "-666666",
877 "-777777",
878 "-888888",
879 "-999999",
880 "5555555",
881 "6666666",
882 "7777777",
883 "8888888",
884 "9999999",
885 "-5555555",
886 "-6666666",
887 "-7777777",
888 "-8888888",
889 "-9999999",
890 "55555555",
891 "66666666",
892 "77777777",
893 "88888888",
894 "99999999",
895 "-55555555",
896 "-66666666",
897 "-77777777",
898 "-88888888",
899 "-99999999",
900 "555555555",
901 "666666666",
902 "777777777",
903 "888888888",
904 "999999999",
905 "-555555555",
906 "-666666666",
907 "-777777777",
908 "-888888888",
909 "-999999999",
910 "-2147483574",
911 "91",
912 "-2147483537",
913 "93",
914 "-2147483500",
915 "97",
916 "-2147483463",
917 "0000000011",
918 "0000000022",
919 "0000000033",
920 "0000000044",
921 "-000000011",
922 "-000000022",
923 "-000000033",
924 "-000000044",
925 "-000000088",
926 "0000000111",
927 "0000000222",
928 "0000000333",
929 "0000000444",
930 "-000000111",
931 "-000000222",
932 "-000000333",
933 "-000000444",
934 "-000000888",
935 "0000001111",
936 "0000002222",
937 "0000003333",
938 "0000004444",
939 "-000001111",
940 "-000002222",
941 "-000003333",
942 "-000004444",
943 "-000008888",
944 "0000011111",
945 "0000022222",
946 "0000033333",
947 "0000044444",
948 "-000011111",
949 "-000022222",
950 "-000033333",
951 "-000044444",
952 "-000088888",
953 "0000111111",
954 "0000222222",
955 "0000333333",
956 "0000444444",
957 "-000111111",
958 "-000222222",
959 "-000333333",
960 "-000444444",
961 "-000888888",
962 "0001111111",
963 "0002222222",
964 "0003333333",
965 "0004444444",
966 "-001111111",
967 "-002222222",
968 "-003333333",
969 "-004444444",
970 "-008888888",
971 "0011111111",
972 "0022222222",
973 "0033333333",
974 "0044444444",
975 "-011111111",
976 "-022222222",
977 "-033333333",
978 "-044444444",
979 "-088888888",
980 "0111111111",
981 "0222222222",
982 "0333333333",
983 "0444444444",
984 "-111111111",
985 "-222222222",
986 "-333333333",
987 "-444444444",
988 "-888888888",
989 "0000000055",
990 "0000000066",
991 "0000000077",
992 "0000000088",
993 "0000000099",
994 "-000000055",
995 "-000000066",
996 "-000000077",
997 "-000000099",
998 "0000000555",
999 "0000000666",
1000 "0000000777",
1001 "0000000888",
1002 "0000000999",
1003 "-000000555",
1004 "-000000666",
1005 "-000000777",
1006 "-000000999",
1007 "0000005555",
1008 "0000006666",
1009 "0000007777",
1010 "0000008888",
1011 "0000009999",
1012 "-000005555",
1013 "-000006666",
1014 "-000007777",
1015 "-000009999",
1016 "0000055555",
1017 "0000066666",
1018 "0000077777",
1019 "0000088888",
1020 "0000099999",
1021 "-000055555",
1022 "-000066666",
1023 "-000077777",
1024 "-000099999",
1025 "0000555555",
1026 "0000666666",
1027 "0000777777",
1028 "0000888888",
1029 "0000999999",
1030 "-000555555",
1031 "-000666666",
1032 "-000777777",
1033 "-000999999",
1034 "0005555555",
1035 "0006666666",
1036 "0007777777",
1037 "0008888888",
1038 "0009999999",
1039 "-005555555",
1040 "-006666666",
1041 "-007777777",
1042 "-009999999",
1043 "0055555555",
1044 "0066666666",
1045 "0077777777",
1046 "0088888888",
1047 "0099999999",
1048 "-055555555",
1049 "-066666666",
1050 "-077777777",
1051 "-099999999",
1052 "0555555555",
1053 "0666666666",
1054 "0777777777",
1055 "0888888888",
1056 "0999999999",
1057 "-555555555",
1058 "-666666666",
1059 "-777777777",
1060 "-999999999",
1061 "-2147483426",
1062 "101",
1063 "-2147483389",
1064 "103",
1065 "-2147483352",
1066 "105",
1067 "-2147483315",
1068 "0000001234567890",
1069 "0000001234567890",
1070 "-0000001234567890",
1071 "000001234567890",
1072 "000001234567890",
1073 "-000001234567890",
1074 "00001234567890",
1075 "00001234567890",
1076 "-00001234567890",
1077 "0001234567890",
1078 "0001234567890",
1079 "-0001234567890",
1080 "001234567890",
1081 "001234567890",
1082 "-001234567890",
1083 "01234567890",
1084 "01234567890",
1085 "-01234567890",
1086 "1234567890",
1087 "1234567890",
1088 "-1234567890",
1089 };
1090 for (std::string const &st : strint_list) {
1091 T expected_value;
1092 strtod_from_string(st, expected_value);
1093 T result_value;
1094 auto result =
1095 fast_float::from_chars(st.data(), st.data() + st.size(), result_value);
1096 if (result.ec != std::errc() &&
1097 result.ec != std::errc::result_out_of_range) {
1098 printf("parsing %.*s\n", int(st.size()), st.data());
1099 std::cerr << " I could not parse " << std::endl;
1100 return false;
1101 }
1102 if (result.ptr != st.data() + st.size()) {
1103 printf("parsing %.*s\n", int(st.size()), st.data());
1104 std::cerr << " Did not get to the end " << std::endl;
1105 return false;
1106 }
1107 if (result_value != expected_value) {
1108 printf("parsing %.*s\n", int(st.size()), st.data());
1109 std::cerr << "expected value : " << to_string(expected_value)
1110 << std::endl;
1111 std::cerr << "result value : " << to_string(result_value) << std::endl;
1112 std::cerr << " Mismatch " << std::endl;
1113 return false;
1114 }
1115 }
1116 return true;
1117 }
1118
1119 int main() {
1120 #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) || \
1121 defined(sun) || defined(__sun)
1122 std::cout << "Warning: msys/cygwin or solaris detected." << std::endl;
1123 #endif
1124 std::cout << "32 bits checks" << std::endl;
1125 Assert(partow_test<float>());
1126 Assert(test<float>());
1127
1128 std::cout << "64 bits checks" << std::endl;
1129 Assert(partow_test<double>());
1130 Assert(test<double>());
1131
1132 std::cout << "All ok" << std::endl;
1133 return EXIT_SUCCESS;
1134 }