aboutsummaryrefslogtreecommitdiff
path: root/test/source/TestEABase.cpp
blob: 1e7bee90f3f28a33908c39f84a842fb310ed3d8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
///////////////////////////////////////////////////////////////////////////////
// TestEABase.cpp
//
// Copyright (c) 2003 Electronic Arts, Inc. -- All Rights Reserved.
// Created by Paul Pedriana.
///////////////////////////////////////////////////////////////////////////////

#include "TestEABase.h"
#include "TestEABase.h" // Intentionally double-include the same header file, to test it.
#include <EABase/eabase.h>
#include <EABase/earesult.h>
#include <EABase/eahave.h>
#include <EABase/nullptr.h>
#include <EABase/eaunits.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <cmath>
#include <new>
#include <assert.h>
#include <stdarg.h>
#include <EAMain/EAEntryPointMain.inl>
#include <EATest/EASTLVsnprintf.inl>
#include <EATest/EASTLNewOperatorGuard.inl>
#include <EATest/EATest.h>
#include <EASTL/vector.h>
#include <EASTL/fixed_vector.h>
#include <EASTL/string.h>
#include <EASTL/sort.h>
#include <EASTL/numeric_limits.h>
#include <EAStdC/EAString.h>
#if !defined(EA_COMPILER_NO_STANDARD_CPP_LIBRARY)
EA_DISABLE_ALL_VC_WARNINGS()
	#include <iterator>
EA_RESTORE_ALL_VC_WARNINGS()
#endif

#if defined(EA_COMPILER_MSVC) && defined(EA_PLATFORM_MICROSOFT)
	EA_DISABLE_ALL_VC_WARNINGS()
		#define NOMINMAX
		#include <Windows.h>
	EA_RESTORE_ALL_VC_WARNINGS()
#elif defined(EA_PLATFORM_ANDROID)
	#include <android/log.h>
#endif

#if EA_FP16C
	// Include emmintrin.h so that the test code can try to call one of the intrinsics.
	#include "emmintrin.h"
	#if EA_COMPILER_CLANG
		// On some versions of clang immintrin.h needs to be included to pull in f16c operations.
		#include "immintrin.h"
	#endif
#endif

EA_DISABLE_SN_WARNING(1229) // function is deprecated.
EA_DISABLE_VC_WARNING(4265 4296 4310 4350 4481 4530 4625 4626 4996)


// ------------------------------------------------------------------------
// EA_STATIC_WARNING
//
// ** Temporarily here instead of eabase.h **
//
// Unilaterally prints a message during the compilation pre-processing phase.
// No string quotes are required, and no trailing semicolon should be used.
// As of this writing, clang reports this usage like a warning, but using
// -Wno-#pragma-messages causes both the warning and message to go away.
//
// Example usage:
//     EA_STATIC_WARNING(This function is deprecated.)
//
#if defined(_MSC_VER)
	#define EA_PRAGMA_MESSAGE(x) __pragma(message(#x))
	#define EA_STATIC_WARNING(msg) EA_PRAGMA_MESSAGE(msg)
#elif defined(__clang__) || (defined(__GNUC__) && (EA_COMPILER_VERSION >= 4005)) || defined(__SN_VER__)
	#define EA_PRAGMA(x) _Pragma(#x)
	#define EA_STATIC_WARNING(msg) EA_PRAGMA(message(#msg))
#else
	#define EA_STATIC_WARNING(msg)
#endif




///////////////////////////////////////////////////////////////////////////////
// Exercise EA_HAS_INCLUDE
///////////////////////////////////////////////////////////////////////////////
#if EA_HAS_INCLUDE_AVAILABLE
	#if EA_HAS_INCLUDE(<EASTL/map.h>)
		#include <EASTL/map.h>

		eastl::map<int, int> gTestHasIncludeMap;
	#endif
#endif

#if EA_HAS_INCLUDE_AVAILABLE
	#if EA_HAS_INCLUDE(<DefinitelyDoesNotExist.h>)
		#error "Include Does Not EXIST!"
	#endif
#endif


///////////////////////////////////////////////////////////////////////////////
// Exercise EAHave
///////////////////////////////////////////////////////////////////////////////

// EA_HAVE_EXTENSIONS_FEATURE
// We don't yet have a test for this.

// EA_HAVE_DINKUMWARE_CPP_LIBRARY
// EA_HAVE_LIBSTDCPP_LIBRARY
// EA_HAVE_LIBCPP_LIBRARY

#if defined(EA_HAVE_DINKUMWARE_CPP_LIBRARY)
	#if !defined(_YVALS)
		#error 
	#endif
#elif defined(EA_HAVE_LIBSTDCPP_LIBRARY)
	#if !defined(__GLIBCXX__) && !defined(__GLIBCPP__)
		#error
	#endif
#elif defined(EA_HAVE_LIBCPP_LIBRARY)
	#if !defined(_LIBCPP_VERSION)
		#error
	#endif
#endif

// EA_HAVE_XXX_H
#if defined(EA_HAVE_SYS_TYPES_H)
	#include <sys/types.h>
#endif
#if defined(EA_HAVE_IO_H)
	#include <io.h>
#endif
#if defined(EA_HAVE_INTTYPES_H)
	#include <inttypes.h>
#endif
#if defined(EA_HAVE_UNISTD_H)
	#include <unistd.h>
#endif
#if defined(EA_HAVE_SYS_TIME_H)
	#include <sys/time.h>
#endif
#if defined(EA_HAVE_SYS_PTRACE_H)
	#include <sys/ptrace.h>
#endif
#if defined(EA_HAVE_SYS_STAT_H)
	#include <sys/stat.h>
#endif
#if defined(EA_HAVE_LOCALE_H)
	#include <locale.h>
#endif
#if defined(EA_HAVE_DIRENT_H)
	#include <dirent.h>
#endif
#if defined(EA_HAVE_SIGNAL_H)
	#include <signal.h>
#endif
#if defined(EA_HAVE_SYS_SIGNAL_H)
	#include <sys/signal.h>
#endif
#if defined(EA_HAVE_PTHREAD_H)
	#include <pthread.h>
#endif
#if defined(EA_HAVE_WCHAR_H)
	#include <wchar.h>
#endif
#if defined(EA_HAVE_MALLOC_H)
	#include <malloc.h>
#endif
#if defined(EA_HAVE_ALLOCA_H)
	#include <alloca.h>
#endif
#if defined(EA_HAVE_EXECINFO_H)
	#include <execinfo.h>
#endif
#if defined(EA_HAVE_SEMAPHORE_H)
	#include <semaphore.h>
#endif

#if defined(EA_HAVE_CPP11_CONTAINERS)
	#include <array>
	#include <forward_list>
	#include <unordered_set>
	#include <unordered_map>
#endif
#if defined(EA_HAVE_CPP11_ATOMIC)
	#include <atomic>
#endif
#if defined(EA_HAVE_CPP11_CONDITION_VARIABLE)
	#include <condition_variable>
#endif
#if defined(EA_HAVE_CPP11_MUTEX) 
	#include <mutex>
#endif
#if defined(EA_HAVE_CPP11_THREAD)
	#if defined(_MSC_VER) && defined(EA_COMPILER_NO_EXCEPTIONS) || defined(EA_COMPILER_NO_UNWIND)
		// Skip this #include, as VC++ has a bug: <concrt.h> (included by <future>) fails to compile when exceptions are disabled.
	#else
		#include <thread>
	#endif
#endif
#if defined(EA_HAVE_CPP11_FUTURE)
	#if defined(_MSC_VER) && defined(EA_COMPILER_NO_EXCEPTIONS) || defined(EA_COMPILER_NO_UNWIND)
		// Skip this #include, as VC++ has a bug: <concrt.h> (included by <future>) fails to compile when exceptions are disabled.
	#else
		#include <future>
	#endif
#endif
#if defined(EA_HAVE_CPP11_TYPE_TRAITS)
	#include <type_traits>
#endif
#if defined(EA_HAVE_CPP11_TUPLES)
	#include <tuple>
#endif
#if defined(EA_HAVE_CPP11_REGEX)
	#include <regex>
#endif
#if defined(EA_HAVE_CPP11_RANDOM)
	#include <random>
#endif
#if defined(EA_HAVE_CPP11_CHRONO)
	#include <chrono> 
#endif
#if defined(EA_HAVE_CPP11_SCOPED_ALLOCATOR)
	#include <scoped_allocator> 
#endif
#if defined(EA_HAVE_CPP11_INITIALIZER_LIST)
	#include <initializer_list>
#else
	// If there is no initializer_list support the the following should succeed.
	// The following is disabled because EASTL defines initializer_list itself and that can collide with this:
	// namespace std{ template<class E> class initializer_list{ }; }
#endif
#if defined(EA_HAVE_CPP11_SYSTEM_ERROR)
	#include <system_error> 
#endif
#if defined(EA_HAVE_CPP11_CODECVT)
	#include <codecvt> 
#endif
#if defined(EA_HAVE_CPP11_TYPEINDEX)
	#include <typeindex> 
#endif



// EA_HAVE_XXX_IMPL
#if defined(EA_HAVE_inet_ntop_IMPL)
	#include <arpa/inet.h>
#endif

#if defined(EA_HAVE_time_IMPL)
	#include <time.h>
#endif

#if defined(EA_HAVE_clock_gettime_IMPL)
	#include <time.h>
#endif

#if defined(EA_HAVE_getcwd_IMPL)
	#if defined(EA_PLATFORM_MICROSOFT)
		#include <direct.h>
	#else
		#include <unistd.h>
	#endif
#endif

#if defined(EA_HAVE_std_terminate_IMPL)
	#include <exception>
#endif

#if defined(EA_HAVE_CPP11_ITERATOR_IMPL)
	#include <iterator>
#endif

#if defined(EA_HAVE_CPP11_SMART_POINTER_IMPL)
	 #include <memory>
#endif

#if defined(EA_HAVE_CPP11_FUNCTIONAL_IMPL)
	#include <functional>
	void BindTestFunction(int /*n1*/, int /*n2*/, int /*n3*/, const int& /*n4*/, int /*n5*/)
	{
	}
	 
	struct BindTestStruct
	{
		void Test(int /*n1*/, int /*n2*/) const
		{
		}
	};
#endif

#if defined(EA_HAVE_CPP11_EXCEPTION_IMPL)
	#include <exception>
#endif


EA_DISABLE_SN_WARNING(1229) // function is deprecated.


// Some CPU/Compiler combinations don't support arbitrary alignment declarations.
// In particular some ARM compilers often don't. You can use EAStdC's EAAlignment to 
// achieve arbitrary alignment if EA_ALIGN doesn't work.
#if (EA_ALIGN_MAX_AUTOMATIC < 64)
	#define ALIGNMENT_AMOUNT_64 EA_ALIGN_MAX_AUTOMATIC
#else
	#define ALIGNMENT_AMOUNT_64 64
#endif

#if (EA_ALIGN_MAX_AUTOMATIC < 32)
	#define ALIGNMENT_AMOUNT_32 EA_ALIGN_MAX_AUTOMATIC
#else
	#define ALIGNMENT_AMOUNT_32 32
#endif

#if (EA_ALIGN_MAX_AUTOMATIC < 16)
	#define ALIGNMENT_AMOUNT_16 EA_ALIGN_MAX_AUTOMATIC
#else
	#define ALIGNMENT_AMOUNT_16 16
#endif


// EA_OVERRIDE
struct OverrideBase { virtual ~OverrideBase(){} virtual void f(int){} };
struct OverrideDerived : public OverrideBase { void f(int) EA_OVERRIDE {} };


// EA_INHERITANCE_FINAL
struct FinalBase EA_INHERITANCE_FINAL { virtual ~FinalBase(){} virtual void f() EA_INHERITANCE_FINAL; };


// EA_SEALED
struct SealedBase EA_SEALED { virtual ~SealedBase(){} virtual void f() EA_SEALED; };


// EA_ABSTRACT
struct AbstractBase EA_ABSTRACT {virtual ~AbstractBase(){} virtual void f(){} };


// EA_CONSTEXPR / EA_COMPILER_NO_CONSTEXPR
EA_CONSTEXPR int GetValue(){ return 37; }


// EA_EXTERN_TEMPLATE / EA_COMPILER_NO_EXTERN_TEMPLATE
template struct eabase_template<char>;


// Forward declarations
template<class T>
bool VerifyValue(T v1, T v2);
void DoError(int& nErrorCount, const char* pMessage = NULL);
int  Stricmp(const char* pString1, const char* pString2);
int  TestEABase();
int  TestEAResult();
int  TestEAPlatform();
bool TestNU();
int  TestEACompiler();
int  TestEACompilerTraits();


template<class T>
bool VerifyValue(T v1, T v2)
{
	return (v1 == v2);
}


// Test EA_PLATFORM_XXX support
// We don't do anything with the defined values below. We are just doing basic testing
// of the usage of #if EA_PLATFORM_XXX
#if EA_PLATFORM_WIN64
	#define EA_PLATFORM_WIN64_OK
#elif EA_PLATFORM_WIN32
	#define EA_PLATFORM_WIN64_OK
#elif EA_PLATFORM_WINDOWS
	#define EA_PLATFORM_WINDOWS_OK
#elif EA_PLATFORM_POSIX
	#define EA_PLATFORM_POSIX_OK
#elif EA_PLATFORM_UNIX
	#define EA_PLATFORM_UNIX_OK
#elif EA_PLATFORM_APPLE
	#define EA_PLATFORM_APPLE_OK
#elif EA_PLATFORM_CONSOLE
	#define EA_PLATFORM_CONSOLE_OK
#elif EA_PLATFORM_DESKTOP
	#define EA_PLATFORM_DESKTOP_OK
#else
	#define EA_PLATFORM_OK
#endif



/* Test EA_DISABLE_WARNING */
EA_DISABLE_VC_WARNING(4548 4127)
EA_DISABLE_ALL_VC_WARNINGS()
EA_RESTORE_ALL_VC_WARNINGS()

EA_DISABLE_GCC_WARNING(-Wuninitialized)

EA_DISABLE_SN_WARNING(1787)
EA_DISABLE_ALL_SN_WARNINGS()
EA_RESTORE_ALL_SN_WARNINGS()

EA_DISABLE_GHS_WARNING(123)

EA_DISABLE_EDG_WARNING(193)

EA_DISABLE_CW_WARNING(10317)
EA_DISABLE_ALL_CW_WARNINGS()
EA_RESTORE_ALL_CW_WARNINGS()

/* Test EA_DISABLE_WARNING */
EA_RESTORE_VC_WARNING()
EA_RESTORE_GCC_WARNING()
EA_RESTORE_SN_WARNING()
EA_RESTORE_GHS_WARNING()
EA_RESTORE_EDG_WARNING()
EA_RESTORE_CW_WARNING(10317)


void DoError(int& nErrorCount, const char* pMessage)
{
	++nErrorCount;
	if(pMessage)
		EA::EAMain::Report("Test error: %s\n", pMessage);
}


int Stricmp(const char* pString1, const char* pString2)
{
	char c1, c2;

	while((c1 = (char)tolower(*pString1++)) == (c2 = (char)tolower(*pString2++)))
	{
		if(c1 == 0)
			return 0;
	}
	
	return (c1 - c2);
}


// EA_PURE
static EA_PURE bool PureFunction()
{
	return (strlen("abc") == 3);
}

// EA_WEAK
EA_WEAK int gWeakVariable = 1;


// EA_NO_VTABLE
struct EA_NO_VTABLE NoVTable1
{
	virtual ~NoVTable1(){}
	virtual void InterfaceFunction()
	{
	}
};

EA_STRUCT_NO_VTABLE(NoVTable2)
{
	virtual ~NoVTable2(){}
	virtual void InterfaceFunction()
	{
	}
};

class NoVTable1Subclass : public NoVTable1
{
	virtual void InterfaceFunction()
	{
	}
};

class NoVTable2Subclass : public NoVTable2
{
	virtual void InterfaceFunction()
	{
	}
};



struct ClassWithDefaultCtor
{
	ClassWithDefaultCtor(int x = 0)
		{ char buffer[16]; sprintf(buffer, "%d", x); }
};


struct ClassWithoutDefaultCtor
{
	ClassWithoutDefaultCtor(int x)
		{ char buffer[16]; sprintf(buffer, "%d", x); }
};


struct InitPriorityTestClass
{
	int mX;
	InitPriorityTestClass(int x = 0) { mX = x; }
};


struct OffsetofTestClass // Intentionally a non-pod.
{
	int32_t mX;
	int32_t mY;
	OffsetofTestClass(int32_t x = 0) : mX(x), mY(0) { }
};

struct SizeofMemberTestClass // Intentionally a non-pod.
{
	int32_t mX;
	int32_t mY;
	SizeofMemberTestClass(int32_t x = 0) : mX(x), mY(0) { }
};

// EA_INIT_PRIORITY
InitPriorityTestClass gInitPriorityTestClass0 EA_INIT_PRIORITY(2000);
InitPriorityTestClass gInitPriorityTestClass1 EA_INIT_PRIORITY(2000) (1);

// EA_INIT_SEG
EA_INIT_SEG(compiler) InitPriorityTestClass gInitSegTestSection(2300);


// EA_MAY_ALIAS
void* EA_MAY_ALIAS gPtr0 = NULL;

typedef void* EA_MAY_ALIAS pvoid_may_alias;
pvoid_may_alias gPtr1 = NULL;


// EA_NO_INLINE
static EA_NO_INLINE void DoNothingInline()
{
}


// EA_PREFIX_NO_INLINE / EA_POSTFIX_NO_INLINE
static void EA_PREFIX_NO_INLINE DoNothingPrefixInline() EA_POSTFIX_NO_INLINE;

static void DoNothingPrefixInline()
{
}


// EA_FORCE_INLINE
static EA_FORCE_INLINE void DoNothingForceInline()
{
}


// EA_PREFIX_FORCE_INLINE / EA_POSTFIX_FORCE_INLINE
static void EA_PREFIX_FORCE_INLINE DoNothingPrefixForceInline() EA_POSTFIX_FORCE_INLINE;

static void DoNothingPrefixForceInline()
{
}


// static_asset at global scope
// Should succeed.
static_assert(sizeof(int32_t) == 4, "static_assert failure");
// Should fail.
//static_assert(sizeof(int32_t) == 8, "static_assert failure");


// EA_STATIC_WARNING
EA_DISABLE_CLANG_WARNING(-W#pragma-messages) // Clang treats messages as warnings.
EA_STATIC_WARNING(EA_STATIC_WARNING test)
EA_RESTORE_CLANG_WARNING()


// EA_OPTIMIZE_OFF / EA_OPTIMIZE_ON
EA_OPTIMIZE_OFF()
static EA_NO_INLINE int DisabledOptimizations(int x)
{
	return x * 37;
}
EA_OPTIMIZE_ON()


// EA_UNUSED
static void FunctionWithUnusedVariables(int x)
{
	int y = 0;
	EA_UNUSED(x);
	EA_UNUSED(y);
}


// EA_NON_COPYABLE / EANonCopyable
struct NonCopyableA
{
	NonCopyableA(){}
	int x;

	EA_NON_COPYABLE(NonCopyableA)
};

EA_DISABLE_VC_WARNING(4625 4626) // C4625: A copy constructor was not accessible in a base class and was therefore not generated for a derived class. C4626: An assignment operator was not accessible in a base class and was therefore not generated for a derived class.
struct NonCopyableB : public EANonCopyable
{
	#if !EA_COMPILER_NO_DELETED_FUNCTIONS
		NonCopyableB& operator=(NonCopyableB&& other) = delete;
	#endif
	int x;
};
EA_RESTORE_VC_WARNING()



// Exercize the case of using EA_NON_COPYABLE when 
struct NonDefaultConstructibleBase
{
	int mX;
	NonDefaultConstructibleBase(int x) : mX(x){}
};

struct NonCopyableSubclass : public NonDefaultConstructibleBase
{
	NonCopyableSubclass(int x) : NonDefaultConstructibleBase(x){}
	EA_NON_COPYABLE(NonCopyableSubclass)
};




// EA_COMPILER_NO_DEFAULTED_FUNCTIONS
// EA_COMPILER_NO_DELETED_FUNCTIONS
//
// We currently test only the ability of the compiler to build the code, 
// and don't test if the compiler built it correctly.
struct DefaultedDeletedTest
{
	#if defined(EA_COMPILER_NO_DEFAULTED_FUNCTIONS)
	   DefaultedDeletedTest(){}
	#else
	   DefaultedDeletedTest() = default;
	#endif

	#if defined(EA_COMPILER_NO_DEFAULTED_FUNCTIONS)
	  ~DefaultedDeletedTest(){}
	#else
	  ~DefaultedDeletedTest() = delete;
	#endif
};


struct EA_FUNCTION_DELETE_Test
{
	int x;
	EA_FUNCTION_DELETE_Test(int xValue) : x(xValue){}

private: // For portability with pre-C++11 compilers, make the function private.
	void foo() EA_FUNCTION_DELETE;
};


#if !defined(EA_COMPILER_NO_USER_DEFINED_LITERALS)
	// Conversion example
	inline long double operator"" _deg(long double degrees)
		{ return (degrees * 3.141592) / 180; }

	// Custom type example
	struct UDLTest
	{
		UDLTest() : mX(0){}
		UDLTest(uint64_t x) : mX(x){}

		uint64_t mX;
	};

	UDLTest operator"" _udl(unsigned long long x) // The type must be unsigned long long and can't be uint64_t, as uint64_t might be unsigned long int.
		{ return UDLTest(x); }
#endif


#if !defined(EA_COMPILER_NO_INLINE_NAMESPACES)
	namespace INSNamespace
	{
		inline namespace INSNamespace_1
		{
			template <typename T>
			class A; 
		}

		template <typename T>
		int g(T){ return 37; }
	}

	struct INSClass{ };

	namespace INSNamespace
	{
		template<>
		class A<INSClass>{ };
	}

#endif


#if !defined(EA_COMPILER_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS)
	struct FunctionTemplateTest
	{
		template<typename T = int>
		static T AddOne(T value)
			{ return value + 1; }
	};
#endif


#if !defined(EA_COMPILER_NO_NOEXCEPT)
	int NoExceptTestFunction() EA_NOEXCEPT
		{ return 37; }
	
	struct NoExceptTestStruct
	{
		int mX;
		NoExceptTestStruct() : mX(37) {}
	};

	template <class T>
	int NoExceptTestTemplate() EA_NOEXCEPT_IF(EA_NOEXCEPT_EXPR(T()))
		{ T t; return t.mX; }
#endif


// The following function defintions are intended to generate compilation errors if EA_CHAR16_NATIVE or EA_CHAR32_NATIVE is set to 1 when it should be 0.
// i.e. if the types are not actually native then their will be a function redefinition error generated.
void NoopTakingString(const wchar_t *)
{
}
#if EA_WCHAR_UNIQUE
    #if EA_WCHAR_SIZE == 2
        // This definition should not conflict with the wchar_t defintion because char16_t should be unique.
        void NoopTakingString(const char16_t *)
        {
            #if !EA_CHAR16_NATIVE
                #error Expected EA_CHAR16_NATIVE to be 1.
            #endif
        }
    #else
        // This definition should not conflict with the wchar_t defintion because char32_t should be unique.
        void NoopTakingString(const char32_t *)
        {
            #if !EA_CHAR32_NATIVE
                #error Expected EA_CHAR32_NATIVE to be 1.
            #endif
        }

    #endif
#endif


int TestEABase()
{
	int nErrorCount(0);

	DoNothingInline();

	// Test NULL
	{
		if(!VerifyValue<void*>(NULL, (void*)0))
			DoError(nErrorCount, "unspecified test");
	}

	// Verify sized type sizes
	{
		if(!VerifyValue<size_t>(sizeof(int8_t), 1))
			DoError(nErrorCount, "int8_t size test");
		if(!VerifyValue<size_t>(sizeof(uint8_t), 1))
			DoError(nErrorCount, "uint8_t size test");
		if(!VerifyValue<size_t>(sizeof(int16_t), 2))
			DoError(nErrorCount, "int16_t size test");
		if(!VerifyValue<size_t>(sizeof(uint16_t), 2))
			DoError(nErrorCount, "uint16_t size test");
		if(!VerifyValue<size_t>(sizeof(int32_t), 4))
			DoError(nErrorCount, "int32_t size test");
		if(!VerifyValue<size_t>(sizeof(uint32_t), 4))
			DoError(nErrorCount, "uint32_t size test");
		if(!VerifyValue<size_t>(sizeof(int64_t), 8))
			DoError(nErrorCount, "int64_t size test");
		if(!VerifyValue<size_t>(sizeof(uint64_t), 8))
			DoError(nErrorCount, "uint64_t size test");

		#if !defined(FLT_EVAL_METHOD)
			#error  EABase should always define FLT_EVAL_METHOD
			DoError(nErrorCount, "FLT_EVAL_METHOD test: not defined.");
		#else
			#if (FLT_EVAL_METHOD == -1)
				// In this case the C99 standard states that the 
				// precision of float_t and double_t is indeterminable.
			#elif (FLT_EVAL_METHOD == 0)
				if(!VerifyValue<size_t>(sizeof(float_t), sizeof(float)))
					DoError(nErrorCount, "float_t size test");
				if(!VerifyValue<size_t>(sizeof(double_t), sizeof(double)))
					DoError(nErrorCount, "double_t size test");
			#elif (FLT_EVAL_METHOD == 1)
				if(!VerifyValue<size_t>(sizeof(float_t), sizeof(double)))
					DoError(nErrorCount, "float_t size test");
				if(!VerifyValue<size_t>(sizeof(double_t), sizeof(double)))
					DoError(nErrorCount, "double_t size test");
			#elif (FLT_EVAL_METHOD == 2)
				if(!VerifyValue<size_t>(sizeof(float_t), sizeof(long double)))
					DoError(nErrorCount, "float_t size test");
				if(!VerifyValue<size_t>(sizeof(double_t), sizeof(long double)))
					DoError(nErrorCount, "double_t size test");
			#else
				DoError(nErrorCount, "FLT_EVAL_METHOD test: invalid value.");
			#endif
		#endif

		if(sizeof(bool8_t) != 1)
			DoError(nErrorCount, "bool8_t size test");

		if(!VerifyValue<size_t>(sizeof(intptr_t), sizeof(void*)))
			DoError(nErrorCount, "intptr_t size test");
		if(!VerifyValue<size_t>(sizeof(uintptr_t), sizeof(void*)))
			DoError(nErrorCount, "uintptr_t size test");

		if(!VerifyValue<size_t>(sizeof(ssize_t), sizeof(size_t)))
			DoError(nErrorCount, "ssize_t size test");

		EA_DISABLE_VC_WARNING(6326)
		const ssize_t ss(1); // Verify that ssize_t is a signed type.
		if(ssize_t((ss ^ ss) - 1) >= 0)
			DoError(nErrorCount, "ssize_t sign test");
		EA_RESTORE_VC_WARNING()

		if(!VerifyValue<size_t>(sizeof(char8_t), 1))
			DoError(nErrorCount, "char8_t size test");
		if(!VerifyValue<size_t>(sizeof(char16_t), 2))
			DoError(nErrorCount, "char16_t size test");
		if(!VerifyValue<size_t>(sizeof(char32_t), 4))
			DoError(nErrorCount, "char32_t size test");

		#if (EA_WCHAR_SIZE == 2) || (EA_WCHAR_SIZE == 4)
			if(!VerifyValue<size_t>(sizeof(wchar_t), EA_WCHAR_SIZE))
				DoError(nErrorCount, "EA_WCHAR_SIZE test");
		#else
			DoError(nErrorCount, "EA_WCHAR_SIZE test");
		#endif
	}

	// Test CHAR8_MIN, etc.
	{
		// The C standard allows compilers/platforms to use -127 as the min 8 bit value, but we've never seen it in modern systems.
		static_assert(((((CHAR8_MIN  ==                -128)  && (CHAR8_MAX  ==                127)))  || ((CHAR8_MIN  == 0) && (CHAR8_MAX  ==                255))),  "CHAR8_MAX failure");
		static_assert(((((CHAR16_MIN ==              -32768)  && (CHAR16_MAX ==              32767)))  || ((CHAR16_MIN == 0) && (CHAR16_MAX ==              65535))),  "CHAR16_MAX failure");
		static_assert(((((CHAR32_MIN == -INT64_C(2147483648)) && (CHAR32_MAX == INT64_C(2147483647)))) || ((CHAR32_MIN == 0) && (CHAR32_MAX == INT64_C(4294967295)))), "CHAR32_MAX failure");
	}

	// Test char8_t, char16_t, char32_t string literals.
	{
		const char8_t*  p8  = EA_CHAR8("abc");
		const char8_t   c8  = EA_CHAR8('a');

		#ifdef EA_CHAR16
			const char16_t* p16 = EA_CHAR16("abc"); // Under GCC, this assumes compiling with -fshort-wchar
			const char16_t  c16 = EA_CHAR16('\x3001');
		#else
			const char16_t* p16 = NULL;
			const char16_t  c16 = static_cast<char16_t>('X');
		#endif

		#ifdef EA_CHAR32
			const char32_t* p32 = EA_CHAR32("abc");
			const char32_t  c32 = EA_CHAR32('\x3001');
		#else
			const char32_t p32[] = { 'a', 'b', 'c', '\0' }; // Microsoft doesn't support 32 bit strings here, and GCC doesn't use them when we compile with -fshort-wchar (which we do).
			#ifdef EA_CHAR16
				const char32_t c32   = EA_CHAR16('\x3001');         // 16 bit should silently convert to 32 bit.
			#else
				const char32_t c32   = static_cast<char16_t>('X');         // 16 bit should silently convert to 32 bit.
			#endif
		#endif

		const wchar_t* pW = EA_WCHAR("abc");
		const wchar_t  cW = EA_WCHAR('\x3001');

		EA_UNUSED(p8);
		EA_UNUSED(c8);
		EA_UNUSED(p16);
		EA_UNUSED(c16);
		EA_UNUSED(p32);
		EA_UNUSED(c32);
		EA_UNUSED(pW);
		EA_UNUSED(cW);
	}

	// Verify sized type signs
	{
		int8_t i8(1);
		if(int8_t((i8 ^ i8) - 1) >= 0)
			DoError(nErrorCount, "int8_t sign test");

		uint8_t u8(1);
		if(uint8_t((u8 ^ u8) - 1) <= 0)
			DoError(nErrorCount, "uint8_t sign test");

		int16_t i16(1);
		if(int16_t((i16 ^ i16) - 1) >= 0)
			DoError(nErrorCount, "int16_t sign test");

		uint16_t u16(1);
		if(uint16_t((u16 ^ u16) - 1) <= 0)
			DoError(nErrorCount, "uint16_t sign test");

		int32_t i32(1);
		if(int32_t((i32 ^ i32) - 1) >= 0)
			DoError(nErrorCount, "int32_t sign test");

		uint32_t u32(1);
		if(uint32_t((u32 ^ u32) - 1) <= 0)
			DoError(nErrorCount, "uint32_t sign test");

		int64_t i64(1);
		if(int64_t((i64 ^ i64) - 1) >= 0)
			DoError(nErrorCount, "int64_t sign test");

		uint64_t u64(1);
		if(uint64_t((u64 ^ u64) - 1) <= 0)
			DoError(nErrorCount, "uint64_t sign test");



		intptr_t ip(1);
		if(intptr_t((ip ^ ip) - 1) >= 0)
			DoError(nErrorCount, "intptr_t sign test");

		uintptr_t up(1);
		if(uintptr_t((up ^ up) - 1) <= 0)
			DoError(nErrorCount, "uintptr_t sign test");


		// The following sign tests have been disabled, as the determination of 
		// the sign of type char and wchar_t are in the hands of the compiler and
		// the user's configuration of that compiler.

		//char8_t c8(1); // We expect it to be signed, though the need for such a requirement is debateable.
		//if(char8_t((c8 ^ c8) - 1) >= 0)
		//    DoError(nErrorCount, "char8_t sign test");

		//char16_t c16(1); // We expect it to be unsigned
		//if(char16_t((c16 ^ c16) - 1) <= 0)
		//    DoError(nErrorCount, "char16_t sign test");

		//char32_t c32(1); // We expect it to be unsigned
		//if(char32_t((c32 ^ c32) - 1) <= 0)
		//    DoError(nErrorCount, "char32_t sign test");
	}



	//Test Constant macros
	{
		char buffer[256];

		const int8_t i8Min = INT8_C(-128); // Strictly speaking, the C language standard allows this to be -127 as well.
		const int8_t i8Max = INT8_C(127);

		const uint8_t u8Min = UINT8_C(0);
		const uint8_t u8Max = UINT8_C(255);

		const int16_t i16Min = INT16_C(-32767) - 1;
		const int16_t i16Max = INT16_C( 32767);

		const uint16_t u16Min = UINT16_C(0);
		const uint16_t u16Max = UINT16_C(65535);

		const int32_t i32Min = INT32_C(-2147483647) - 1;
		const int32_t i32Max = INT32_C( 2147483647);

		const uint32_t u32Min = UINT32_C(0);
		const uint32_t u32Max = UINT32_C(4294967295);

		#if defined(__GNUC__) && (__GNUC__ < 4) // If using a broken version of UINT64_C/INT64_C macros...
			const int64_t i64Min = -9223372036854775807LL - 1;
			const int64_t i64Max =  9223372036854775807LL;

			const uint64_t u64Min = UINT64_C(0);
			const uint64_t u64Max = 18446744073709551615ULL;
		#else
			const int64_t i64Min = INT64_C(-9223372036854775807) - 1;
			const int64_t i64Max = INT64_C( 9223372036854775807);

			const uint64_t u64Min = UINT64_C(0);
			const uint64_t u64Max = UINT64_C(18446744073709551615);
		#endif

		sprintf(buffer, "%d %d %u %u %d %d %u %u %d %d %u %u %" SCNd64" %" SCNd64" %" SCNu64" %" SCNu64,
				  (int)i8Min,  (int)i8Max,  (unsigned)u8Min,  (unsigned)u8Max, 
				  (int)i16Min, (int)i16Max, (unsigned)u16Min, (unsigned)u16Max, 
				  (int)i32Min, (int)i32Max, (unsigned)u32Min, (unsigned)u32Max, 
				  i64Min, i64Max, u64Min, u64Max);
		if(strcmp(buffer, "-128 127 0 255 -32768 32767 0 65535 -2147483648 2147483647 0 4294967295 -9223372036854775808 9223372036854775807 0 18446744073709551615"))
			DoError(nErrorCount, "INT_C test");

		EA_DISABLE_VC_WARNING(6326)
		// Verify the use of hex numbers with INT64_C
		const int64_t i64Hex = INT64_C(0x1111111122222222);
		if(i64Hex != INT64_C(1229782938533634594))
			DoError(nErrorCount, "INT64_C hex error");
		EA_RESTORE_VC_WARNING()

		// Verify the use of hex numbers with UINT64_C
		const uint64_t u64Hex = UINT64_C(0xaaaaaaaabbbbbbbb);

		#if defined(__GNUC__) && (__GNUC__ < 4) // If using a broken version of UINT64_C/INT64_C macros...
			const uint64_t temp = 12297829382759365563ULL; 
		#else
			const uint64_t temp = UINT64_C(12297829382759365563);
		#endif

		EA_DISABLE_VC_WARNING(6326)
		if(u64Hex != temp)
			DoError(nErrorCount, "UINT64_C hex error");
		EA_RESTORE_VC_WARNING()

		// Verify that the compiler both allows division with uint64_t but 
		// also that it allows it via UINT64_MAX. A bad implementation of 
		// UINT64_MAX would cause the code below to mis-execute or not compile.
		EA_DISABLE_VC_WARNING(6326)
		const uint64_t resultUint64 = UINT64_MAX / 2;
		if(resultUint64 != UINT64_C(9223372036854775807))
			DoError(nErrorCount, "UINT64_MAX error");
		EA_RESTORE_VC_WARNING()
	}

	{
		static_assert(INTPTR_MIN  == eastl::numeric_limits<intptr_t>::min(),  "INTPTR_MIN failure");
		static_assert(INTPTR_MAX  == eastl::numeric_limits<intptr_t>::max(),  "INTPTR_MAX failure");
	  //static_assert(UINTPTR_MIN == eastl::numeric_limits<uintptr_t>::min(), "UINTPTR_MIN failure"); // not specified by the standard
		static_assert(UINTPTR_MAX == eastl::numeric_limits<uintptr_t>::max(), "UINTPTR_MAX failure");
		static_assert(INTMAX_MIN  == eastl::numeric_limits<intmax_t>::min(),  "INTMAX_MIN failure");
		static_assert(INTMAX_MAX  == eastl::numeric_limits<intmax_t>::max(),  "INTMAX_MAX failure");
	  //static_assert(UINTMAX_MIN == eastl::numeric_limits<uintmax_t>::MIN(), "UINTMAX_MIN failure"); // not specified by the standard
		static_assert(UINTMAX_MAX == eastl::numeric_limits<uintmax_t>::max(), "UINTMAX_MAX failure");
	}

	//Test sized printf format specifiers
	{
		char buffer[256];

		int8_t  d8(INT8_MAX), i8(INT8_MIN), o8(INT8_MAX);
		uint8_t u8(UINT8_MAX), x8(UINT8_MAX), X8(UINT8_MAX);        
		sprintf(buffer, "%" PRId8 " %" PRIi8 " %" PRIo8 " %" PRIu8 " %" PRIx8 " %" PRIX8, d8, i8, o8, u8, x8, X8);
		
		#ifdef EA_COMPILER_GNUC
			if(Stricmp(buffer, "127 -128 177 255 ff FF"))
				DoError(nErrorCount, "PRI8 test"); // This is known to fail with compilers such as VC++ which don't support %hh.
		#endif

		int16_t  d16(INT16_MAX), i16(INT16_MIN), o16(INT16_MAX);
		uint16_t u16(UINT16_MAX), x16(UINT16_MAX), X16(UINT16_MAX);        
		sprintf(buffer, "%" PRId16 " %" PRIi16 " %" PRIo16 " %" PRIu16 " %" PRIx16 " %" PRIX16, d16, i16, o16, u16, x16, X16);
		if(Stricmp(buffer, "32767 -32768 77777 65535 ffff FFFF"))
			DoError(nErrorCount, "PRI16 test");

		int32_t  d32(INT32_MAX), i32(INT32_MIN), o32(INT32_MAX);
		uint32_t u32(UINT32_MAX), x32(UINT32_MAX), X32(UINT32_MAX);        
		sprintf(buffer, "%" PRId32 " %" PRIi32 " %" PRIo32 " %" PRIu32 " %" PRIx32 " %" PRIX32, d32, i32, o32, u32, x32, X32);
		if(Stricmp(buffer, "2147483647 -2147483648 17777777777 4294967295 ffffffff FFFFFFFF"))
			DoError(nErrorCount, "PRI32 test");

		int64_t  d64(INT64_MAX), i64(INT64_MIN), o64(INT64_MAX);
		uint64_t u64(UINT64_MAX), x64(UINT64_MAX), X64(UINT64_MAX);        
		sprintf(buffer, "%" PRId64 " %" PRIi64 " %" PRIo64 " %" PRIu64 " %" PRIx64 " %" PRIX64, d64, i64, o64, u64, x64, X64);
		if(Stricmp(buffer, "9223372036854775807 -9223372036854775808 777777777777777777777 18446744073709551615 ffffffffffffffff FFFFFFFFFFFFFFFF"))
			DoError(nErrorCount, "PRI64 test");

		// Many compilers give warnings for the following code because they 
		// recognize that a pointer is being formatted as an integer.  
		// This is what we want to do and what the C99 standard intends here.
		#if defined(_MSC_VER) && (_MSC_VER >= 1300)
			#pragma warning(disable: 4313) // Warning C4313: 'sprintf'  : '%d' in format string conflicts with argument 1 of type 'void *'
			#pragma warning(disable: 4777) // Warning C4777: 'sprintf' : format string '%lld' requires an argument of type '__int64', but variadic argument 1 has type 'intptr_t'
		#endif

		#if !defined(__GNUC__) // GCC generates warnings here which we can't work around.
			void *dPtr = (void*)INT32_MAX, *iPtr = (void*)INT32_MIN, *oPtr = (void*)INT32_MAX, *uPtr = (void*)(uintptr_t)UINT64_MAX, *xPtr = (void*)(uintptr_t)UINT64_MAX, *XPtr = (void*)(uintptr_t)UINT64_MAX;
			sprintf(buffer, "%" PRIdPTR " %" PRIiPTR " %" PRIoPTR " %" PRIuPTR " %" PRIxPTR " %" PRIXPTR, (intptr_t)dPtr, (intptr_t)iPtr, (uintptr_t)oPtr, (uintptr_t)uPtr, (uintptr_t)xPtr, (uintptr_t)XPtr);

			#if (EA_PLATFORM_PTR_SIZE == 4)
				if(Stricmp(buffer, "2147483647 -2147483648 17777777777 4294967295 ffffffff FFFFFFFF"))
					DoError(nErrorCount, "PRIPTR test");
			#else // EA_PLATFORM_PTR_SIZE == 8
				if(Stricmp(buffer, "2147483647 -2147483648 17777777777 18446744073709551615 ffffffffffffffff FFFFFFFFFFFFFFFF"))
					DoError(nErrorCount, "PRIPTR test");
			#endif
		#endif

		#if defined(_MSC_VER) && (_MSC_VER >= 1300)
			#pragma warning(default: 4313)
			#pragma warning(default: 4777)
		#endif
	}

	//Test sized scanf format specifiers
	{
		int numMatched = 0;
		#ifdef EA_COMPILER_IS_C99 // Enabled for C99 only because this code will simply crash on many platforms if the format specifiers aren't supported.
			int8_t  d8, i8, o8;
			uint8_t u8, x8;
			numMatched = sscanf("127 -127 177 255 ff", "%" SCNd8 " %" SCNi8 " %" SCNo8 " %" SCNu8 " %" SCNx8, &d8, &i8, &o8, &u8, &x8);
			if((numMatched != 5) || (d8 != 127) || (i8 != -127) || (o8 != 127) || (u8 != 255) || (x8 != 255))
				DoError(nErrorCount, "SCN8 test"); // This is known to fail with compilers such as VC++ which don't support %hh.
		#endif

		int16_t  d16, i16, o16;
		uint16_t u16, x16;
		numMatched = sscanf("32767 -32768 77777 65535 ffff", "%" SCNd16 " %" SCNi16 " %" SCNo16 " %" SCNu16 " %" SCNx16, &d16, &i16, &o16, &u16, &x16);
		if((numMatched != 5) || (d16 != 32767) || (i16 != -32768) || (o16 != 32767) || (u16 != 65535) || (x16 != 65535))
			DoError(nErrorCount, "SCN16 test");

		int32_t  d32, i32, o32;
		uint32_t u32, x32;
		numMatched = sscanf("2147483647 -2147483648 17777777777 4294967295 ffffffff", "%" SCNd32 " %" SCNi32 " %" SCNo32 " %" SCNu32 " %" SCNx32, &d32, &i32, &o32, &u32, &x32);
		if((numMatched != 5) || (d32 != INT32_MAX) || (i32 != INT32_MIN) || (o32 != INT32_MAX) || (u32 != UINT32_MAX) || (x32 != UINT32_MAX))
			DoError(nErrorCount, "SCN32 test");

		int64_t  d64, i64, o64;
		uint64_t u64, x64;
		numMatched = sscanf("9223372036854775807 -9223372036854775808 777777777777777777777 18446744073709551615 ffffffffffffffff", "%" SCNd64 " %" SCNi64 " %" SCNo64 " %" SCNu64 " %" SCNx64, &d64, &i64, &o64, &u64, &x64);
		if((numMatched != 5) || (d64 != INT64_MAX) || (i64 != INT64_MIN) || (o64 != INT64_MAX) || (u64 != UINT64_MAX) || (x64 != UINT64_MAX))
			DoError(nErrorCount, "SCN64 test");

		// Many compilers give warnings for the following code because they 
		// recognize that a pointer is being formatted as an integer.  
		// This is what we want to do and what the C99 standard intends here.
		#if !defined(__GNUC__) // GCC generates warnings here which we can't work around.
			void *dPtr, *iPtr, *oPtr, *uPtr, *xPtr;
			intptr_t dip, iip;
			uintptr_t ouip, uuip, xuip;

			EA_DISABLE_VC_WARNING(4777) // format string '%lld' requires an argument of type '__int64 *', but variadic argument 1 has type 'intptr_t *'
			#if (EA_PLATFORM_PTR_SIZE == 4)
				numMatched = sscanf("2147483647 -2147483648 17777777777 4294967295 ffffffff", "%" SCNdPTR " %" SCNiPTR " %" SCNoPTR " %" SCNuPTR " %" SCNxPTR, &dip, &iip, &ouip, &uuip, &xuip);
			#else // EA_PLATFORM_PTR_SIZE == 8
				numMatched = sscanf("2147483647 -2147483648 17777777777 18446744073709551615 ffffffffffffffff", "%" SCNdPTR " %" SCNiPTR " %" SCNoPTR " %" SCNuPTR " %" SCNxPTR, &dip, &iip, &ouip, &uuip, &xuip);
			#endif
			EA_RESTORE_VC_WARNING()

			dPtr = (void*)dip;
			iPtr = (void*)iip;
			oPtr = (void*)ouip;
			uPtr = (void*)uuip;
			xPtr = (void*)xuip;

			if((numMatched != 5) || (dPtr != (void*)INT32_MAX) || (iPtr != (void*)INT32_MIN) || (oPtr != (void*)INT32_MAX) || (uPtr != (void*)(uintptr_t)UINT64_MAX) || (xPtr != (void*)(uintptr_t)UINT64_MAX))
				DoError(nErrorCount, "SCNPTR test");
		#endif
	}


	// Test min/max
	{
		// The C standard allows INT8_MIN to be either -127 or -128. So in order to be able
		// to test for this in a portable way, we do the logic below whereby we test for 
		// -127 (which all compiles should support) or -127 - 1 which all compilers should
		// support if INT8_MIN isn't -127.
		if(!VerifyValue<int8_t>(INT8_MIN, INT8_C(-127)) && !VerifyValue<int8_t>(INT8_MIN, INT8_C(-127) - 1))
			DoError(nErrorCount, "INT8_MIN test");
		if(!VerifyValue<int8_t>(INT8_MAX, INT8_C(127)))
			DoError(nErrorCount, "INT8_MAX test");
		if(!VerifyValue<uint8_t>(UINT8_MAX, UINT8_C(255)))
			DoError(nErrorCount, "UINT8_MAX test");

		if(!VerifyValue<int16_t>(INT16_MIN, INT16_C(-32767)) && !VerifyValue<int16_t>(INT16_MIN, INT16_C(-32767) - 1))
			DoError(nErrorCount, "INT16_MIN test");
		if(!VerifyValue<int16_t>(INT16_MAX, INT16_C(32767)))
			DoError(nErrorCount, "INT16_MAX test");
		if(!VerifyValue<uint16_t>(UINT16_MAX, UINT16_C(65535)))
			DoError(nErrorCount, "UINT16_MAX test");

		if(!VerifyValue<int32_t>(INT32_MIN, INT32_C(-2147483647)) && !VerifyValue<int32_t>(INT32_MIN, INT32_C(-2147483647) - 1))
			DoError(nErrorCount, "INT32_MIN test");
		if(!VerifyValue<int32_t>(INT32_MAX, INT32_C(2147483647)))
			DoError(nErrorCount, "INT32_MAX test");
		if(!VerifyValue<uint32_t>(UINT32_MAX, UINT32_C(4294967295)))
			DoError(nErrorCount, "UINT32_MAX test");

		if(!VerifyValue<int64_t>(INT64_MIN, INT64_C(-9223372036854775807)) && !VerifyValue<int64_t>(INT64_MIN, INT64_C(-9223372036854775807) - 1))
			DoError(nErrorCount, "INT64_MIN test");
		if(!VerifyValue<uint64_t>(INT64_MAX, INT64_C(9223372036854775807)))
			DoError(nErrorCount, "INT64_MAX test");

		#if defined(__GNUC__) && (__GNUC__ < 4) // If using a broken version of UINT64_C/INT64_C macros...
			const uint64_t temp = 18446744073709551615ULL;
		#else
			const uint64_t temp = UINT64_C(18446744073709551615);
		#endif

		if(!VerifyValue<uint64_t>(UINT64_MAX, temp))
			DoError(nErrorCount, "UINT64_MAX test");
	}

    {
        NoopTakingString(L"");
        // Compilation errors below indicate that the EA_CHAR16/EA_CHAR32 may be incorrectly defined, or EA_CHAR16_NATIVE/EA_CHAR32_NATIVE is incorrect set to 0.
        #if EA_WCHAR_SIZE == 2 && defined(EA_CHAR16)
            const char16_t *str = EA_CHAR16("");
            NoopTakingString(str);
        #elif EA_WCHAR_SIZE == 4 && defined(EA_CHAR32)
            const char32_t *str = EA_CHAR32("");
            NoopTakingString(str);
        #endif
    }

	return nErrorCount;
}



int TestEAResult()
{
	int nErrorCount(0);

	EA::result_type resultSuccess(EA::SUCCESS);
	EA::result_type resultFailure(EA::FAILURE);
	EA::result_type resultZero(0); // success
	EA::result_type resultNeg(-1); // failure
	EA::result_type resultPos(+1); // success


	if(!EA_SUCCEEDED(resultSuccess))
		DoError(nErrorCount, "EA::SUCCESS test");
	if(EA_FAILED(resultSuccess))
		DoError(nErrorCount, "EA::SUCCESS test");

	if(EA_SUCCEEDED(resultFailure))
		DoError(nErrorCount, "EA::FAILURE test");
	if(!EA_FAILED(resultFailure))
		DoError(nErrorCount, "EA::FAILURE test");

	if(!EA_SUCCEEDED(resultZero))
		DoError(nErrorCount, "EA::SUCCESS test");
	if(EA_FAILED(resultZero))
		DoError(nErrorCount, "EA::SUCCESS test");

	if(EA_SUCCEEDED(resultNeg))
		DoError(nErrorCount, "EA::FAILURE test");
	if(!EA_FAILED(resultNeg))
		DoError(nErrorCount, "EA::FAILURE test");

	if(!EA_SUCCEEDED(resultPos))
		DoError(nErrorCount, "EA::SUCCESS test");
	if(EA_FAILED(resultPos))
		DoError(nErrorCount, "EA::SUCCESS test");

	return nErrorCount;
}



int TestEAPlatform()
{
	int nErrorCount(0);

	// Test EA_PLATFORM_PTR_SIZE
	{
		#ifdef EA_PLATFORM_PTR_SIZE
			if(!VerifyValue<size_t>(EA_PLATFORM_PTR_SIZE, sizeof(void*)))
				DoError(nErrorCount, "EA_PLATFORM_PTR_SIZE test");
		#else
			DoError(nErrorCount, "EA_PLATFORM_PTR_SIZE test");
		#endif
	}


	// Test EA_PLATFORM_NAME
	{
		#ifdef EA_PLATFORM_NAME
			char buffer[256];
			sprintf(buffer, "TestEAPlatform: EA_PLATFORM_NAME: %s\n", EA_PLATFORM_NAME);
		#else
			DoError(nErrorCount, "EA_PLATFORM_NAME test");
		#endif
	}


	// Test EA_PLATFORM_DESCRIPTION
	{
		#ifdef EA_PLATFORM_DESCRIPTION
			char buffer[256];
			sprintf(buffer, "TestEAPlatform: EA_PLATFORM_DESCRIPTION: %s\n", EA_PLATFORM_DESCRIPTION);
		#else
			DoError(nErrorCount, "EA_PLATFORM_DESCRIPTION test");
		#endif
	}


	// Test EA_SYSTEM_LITTLE_ENDIAN / EA_SYSTEM_BIG_ENDIAN
	{
		uint32_t kValue = 0x12345678;
		uint8_t* pValue = (uint8_t*)&kValue;

		#ifdef EA_SYSTEM_LITTLE_ENDIAN
			if(pValue[0] != 0x78)
				DoError(nErrorCount, "EA_SYSTEM_ENDIAN test");
		#elif defined(EA_SYSTEM_BIG_ENDIAN)
			if(pValue[0] != 0x12)
				DoError(nErrorCount, "EA_SYSTEM_ENDIAN test");
		#else
			DoError(nErrorCount, "EA_SYSTEM_ENDIAN test");
		#endif
	}


	// Test EA_ASM_STYLE
	{
		#if defined(EA_PROCESSOR_X86)
			#if defined(EA_ASM_STYLE_ATT)
				asm volatile ("nop");
			#elif defined(EA_ASM_STYLE_INTEL)
				__asm nop
			#endif
		#else
			// Add other processors here.
		#endif
	}


	return nErrorCount;
}



// Test compiler limitations
// Easiest way to come up with tests for some of the more complicated versions 
// of these is to look at the Boost /libs/config/test/*.cxx files. Many of the 
// Boost compiler limitation defines are similar or match exactly to those 
// defined by EABase. See http://www.boost.org if you want to check this out.

#ifndef EA_COMPILER_NO_STATIC_CONSTANTS // If class member static constants are allowed...
	struct NSC
	{
		static const int x = 10;
	};
#endif

#ifndef EA_COMPILER_NO_TEMPLATE_SPECIALIZATION
	// Todo
#endif

#ifndef EA_COMPILER_NO_TEMPLATE_PARTIAL_SPECIALIZATION
	// Todo
#endif

#ifndef EA_COMPILER_NO_MEMBER_TEMPLATES
	// Todo
#endif

#ifndef EA_COMPILER_NO_MEMBER_TEMPLATE_SPECIALIZATION
	// Todo
#endif

#ifndef EA_COMPILER_NO_TEMPLATE_TEMPLATES
	// Todo
#endif

#ifndef EA_COMPILER_NO_MEMBER_TEMPLATE_FRIENDS
	// Todo
#endif

#ifndef EA_COMPILER_NO_VOID_RETURNS
	void TestNVR1();
	void TestNVR();

	void TestNVR1()
	{
		char buffer[8];
		sprintf(buffer, " ");
	}
	void TestNVR()
	{
		return TestNVR1();
	}
#endif

#ifndef EA_COMPILER_NO_COVARIANT_RETURN_TYPE
	// Todo
#endif

#ifndef EA_COMPILER_NO_DEDUCED_TYPENAME
	// Todo
#endif

#ifndef EA_COMPILER_NO_ARGUMENT_DEPENDENT_LOOKUP
	// Todo
#endif

#if !defined(EA_COMPILER_NO_EXCEPTION_STD_NAMESPACE) && !defined(EA_COMPILER_NO_STANDARD_CPP_LIBRARY)
	#include <exception>

	static void TestNESN()
	{
	  // iPhone gives us this error: Undefined symbols for architecture armv6: std::terminate()
	  // Android gives: undefined reference to std::terminate()
	  // We could possibly define our own std::terminate, but that might collide in the future unexpectedly.
	  #if defined(EA_PLATFORM_IPHONE) || defined(EA_PLATFORM_ANDROID) 
		void (*pTerminate)() = NULL;
	  #else
		void (*pTerminate)() = std::terminate;
	  #endif
		char buffer[32];
		sprintf(buffer, "%p", pTerminate);
	}
#endif

#ifndef EA_COMPILER_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS
	// Todo
#endif

#ifndef EA_COMPILER_NO_EXCEPTIONS
	static bool TestNE()
	{
		EA_DISABLE_VC_WARNING(4571)
		try{
			char buffer1[8];
			sprintf(buffer1, " ");
			throw int(0);
		}
		catch(...){
			char buffer2[8];
			sprintf(buffer2, " "); // If you are tracing this in a debugger and the debugger stops here, then you need to let the app continue.
		}
		return true;
		EA_RESTORE_VC_WARNING()
	}
#endif


struct UnwindTest
{
	static int x;
	enum State{
		kStateNone,
		kStateConstructed,
		kStateDestructed
	};
	UnwindTest()
		{ x = kStateConstructed; };
   ~UnwindTest()
		{ x = kStateDestructed;  };
};
int UnwindTest::x = kStateNone;

#ifndef EA_COMPILER_NO_EXCEPTIONS
	static void TestNU1()
	{
		UnwindTest ut;
		#ifndef EA_COMPILER_NO_EXCEPTIONS
			throw(int(0)); // If you are tracing this in a debugger and the debugger stops here, then you need to let the app continue.
		#endif
	}
#endif

bool TestNU()
{
	bool bReturnValue(false);

	#ifdef EA_COMPILER_NO_EXCEPTIONS
		bReturnValue = true; //Nothing to test, so we just return true.
	#else
		EA_DISABLE_VC_WARNING(4571)
		try
		{
			TestNU1();
		}
		catch(...)
		{
			#ifdef EA_COMPILER_NO_UNWIND
				if(UnwindTest::x == UnwindTest::kStateConstructed)
					bReturnValue = true;
			#else
				if(UnwindTest::x == UnwindTest::kStateDestructed)
					bReturnValue = true;
			#endif
		}
		EA_RESTORE_VC_WARNING()
	#endif

	return bReturnValue;
}

#ifndef EA_COMPILER_NO_STANDARD_CPP_LIBRARY
	#include <vector> // We need do nothing more than #include this.
#endif

#ifndef EA_COMPILER_NO_COVARIANT_RETURN_TYPE
	// Todo
#endif

#ifndef EA_COMPILER_NO_COVARIANT_RETURN_TYPE
	// Todo
#endif


#if !defined(EA_COMPILER_NO_TRAILING_RETURN_TYPES)
	// This usage assumes that C++11 auto is supported, which in practice is always the case because
	// the case because otherwise trailing return types wouldn't be as useful.
	static auto AddOne(int i)->int
	{ 
		return i + 1;
	}

	template <typename T>
	struct AddTwoClass
	{
		typedef float Local_type;
		Local_type AddTwo(T t);
	};

	template <typename T>
	auto AddTwoClass<T>::AddTwo(T t)->Local_type
	{
		return (t + 2.f); // Assumes that t is a numerical type in this case.
	}
#endif


#if !defined(EA_COMPILER_NO_VARIADIC_TEMPLATES)
	template<typename...>
	struct VariadicTemplateTuple{};

	template<typename T1, typename T2>
	struct VariadicTemplatePair
	{
		T1 x;
		T1 y;
	};

	template<class ... Args1>
	struct VariadicTemplateZip
	{
		template<class ... Args2> struct with
		{
			typedef VariadicTemplateTuple<VariadicTemplatePair<Args1, Args2> ... > type;
		};
	};

	// VariadicTemplateType is Tuple<Pair<short, unsigned short>, Pair<int, unsigned> >
	typedef VariadicTemplateZip<short, int>::with<unsigned short, unsigned>::type VariadicTemplateType;
#endif


#if !defined(EA_COMPILER_NO_TEMPLATE_ALIASES)
	template<typename T> 
	using VectorAlias = eastl::vector<T, EASTLAllocatorType>;
#endif

#if !defined(EA_COMPILER_NO_VARIABLE_TEMPLATES)
	template<class T>
	constexpr T pi = T(3.1415926535897932385);
#endif


int TestEACompiler()
{
	int nErrorCount(0);

	// As of this writing, eacompiler.h defines at least the following compilers:
	// EA_COMPILER_GNUC
	// EA_COMPILER_INTEL
	// EA_COMPILER_METROWERKS
	// EA_COMPILER_MSVC, EA_COMPILER_MSVC6, EA_COMPILER_MSVC7, EA_COMPILER_MSVC7_1
	

	// Test EA_COMPILER_NAME
	{
		#ifdef EA_COMPILER_NAME
			char buffer[256];
			sprintf(buffer, "TestEACompiler: EA_COMPILER_NAME: %s\n", EA_COMPILER_NAME);
		#else
			DoError(nErrorCount, "EA_COMPILER_NAME test");
		#endif
	}


	// Test EA_COMPILER_VERSION
	{
		#ifdef EA_COMPILER_VERSION
			char buffer[256];
			sprintf(buffer, "TestEACompiler: EA_COMPILER_VERSION: %d\n", EA_COMPILER_VERSION);
		#else
			DoError(nErrorCount, "EA_COMPILER_VERSION test");
		#endif
	}


	// Test EA_COMPILER_STRING
	{
		#ifdef EA_COMPILER_STRING
			char buffer[256];
			sprintf(buffer, "TestEACompiler: EA_COMPILER_STRING: %s\n", EA_COMPILER_STRING);
		#else
			DoError(nErrorCount, "EA_COMPILER_STRING test");
		#endif
	}


	// Test EA_COMPILER_NO_STATIC_CONSTANTS
	{
		char buffer[256];
		sprintf(buffer, "%d", (int)NSC::x);
		if(buffer[0] != '1')
			DoError(nErrorCount, "EA_COMPILER_NO_STATIC_CONSTANTS test");
	}


	// Test EA_COMPILER_NO_VOID_RETURNS
	#ifndef EA_COMPILER_NO_VOID_RETURNS
		TestNVR1(); // Nothing to test for except successful compilation.
	#endif


	// Test EA_COMPILER_NO_EXCEPTION_STD_NAMESPACE
	#if !defined(EA_COMPILER_NO_EXCEPTION_STD_NAMESPACE) && !defined(EA_COMPILER_NO_STANDARD_CPP_LIBRARY)
		TestNESN();
	#endif

	#if !(defined(EA_PLATFORM_IPHONE) && defined(EA_COMPILER_CLANG)) || defined(__IPHONE_7_0)
	{
		// There was a bug in Apple's exception code in iOS SDK versions
		// prior to 7.0, which is why this test is disabled for versions
		// of the SDK before 7.0.
		// Note that __IPHONE_7_0 will be defined for all future SDKs as
		// well, because Apple simply adds another define with each release
		// and does not remove the old ones.

	// Test EA_COMPILER_NO_EXCEPTIONS
	#ifndef EA_COMPILER_NO_EXCEPTIONS
		if(!TestNE())
			DoError(nErrorCount, "EA_COMPILER_NO_EXCEPTIONS test");
	#endif


	// Test EA_COMPILER_NO_UNWIND
	if(!TestNU())
		DoError(nErrorCount, "EA_COMPILER_NO_UNWIND test");
	}
	#endif


	// Test EA_COMPILER_NO_RVALUE_REFERENCES
	#ifndef EA_COMPILER_NO_RVALUE_REFERENCES
	{
		// Trivial test 
		int&& i = 2;
		FunctionWithUnusedVariables(i);
	}
	#endif


	// Test EA_COMPILER_NO_RANGE_BASED_FOR_LOOP
	#if !defined(EA_COMPILER_NO_RANGE_BASED_FOR_LOOP)
	{
		float floatArray[2] = { 0.0f, 1.0f };

		for(float& f : floatArray)
			f += 1.0;

		EATEST_VERIFY(floatArray[1] == 2.0f);
	}
	#endif


	// Test EA_COMPILER_NO_AUTO
	#if !defined(EA_COMPILER_NO_AUTO)
	{
		auto length = strlen("test");
		EATEST_VERIFY(length == 4);
	}
	#endif


	// Test EA_COMPILER_NO_DECLTYPE
	#if !defined(EA_COMPILER_NO_DECLTYPE)
	{
		struct A { double x; };
		int b = 9;
		A   a; a.x = 7;
		decltype(b)   x2 = 2;
		decltype(a.x) x3 = 3.5;
		EATEST_VERIFY((b + a.x) == 16);
		EATEST_VERIFY((x3 + x2) == 5.5);
	}
	#endif


	// Test EA_COMPILER_NO_LAMBDA_EXPRESSIONS
	#if !defined(EA_COMPILER_NO_LAMBDA_EXPRESSIONS)
	{
		struct LambaTest
		{
			static void SortViaAbs(float* x, size_t n)
			{
				eastl::insertion_sort(x, x + n,
					[](float a, float b)
					  { return (a < b); }
				);
			}
		};

		float floatArray[3] = { 0.f, 1.f, 3.f };
		LambaTest::SortViaAbs(floatArray, EAArrayCount(floatArray));
		EATEST_VERIFY(floatArray[1] == 1.f);
	}
	#endif


	// Test EA_COMPILER_NO_TRAILING_RETURN_TYPES
	#if !defined(EA_COMPILER_NO_TRAILING_RETURN_TYPES)
	{
		int x = AddOne(2);          // AddOne declared above.
		EATEST_VERIFY(x == 3);

		AddTwoClass<float> a;             
		float y = a.AddTwo(2.f);
		EATEST_VERIFY(y == 4.f);
	}
	#endif


	// Test EA_COMPILER_NO_FORWARD_DECLARED_ENUMS
	// Forward declared enum support requires strongly typed enum support.
	#if !defined(EA_COMPILER_NO_FORWARD_DECLARED_ENUMS) && !defined(EA_COMPILER_NO_STRONGLY_TYPED_ENUMS)
	{
		// This happen to be used below in the EA_COMPILER_NO_STRONGLY_TYPED_ENUMS section.
		enum class Color;
		enum class Size    : uint8_t;
		enum       Distance: uint8_t;
	}
	#endif


	// Test EA_COMPILER_NO_STRONGLY_TYPED_ENUMS
	#if !defined(EA_COMPILER_NO_STRONGLY_TYPED_ENUMS)
	{
		enum class Color              { red, blue, green };
		enum class Size     : uint8_t { little = 1, med = 1, large = 2 };
		enum       Distance : uint8_t { close = 1, faraway = 2 };

		Color c = Color::red;
		EATEST_VERIFY(c != Color::blue);

		Size s = Size::med;
		EATEST_VERIFY(s != Size::large);
		static_assert(sizeof(s) == 1, "EA_COMPILER_NO_STRONGLY_TYPED_ENUMS failure");

		Distance d = close;
		EATEST_VERIFY(d != faraway);
		static_assert(sizeof(d) == 1, "EA_COMPILER_NO_STRONGLY_TYPED_ENUMS failure");
	}
	#endif


	// Test EA_COMPILER_NO_VARIADIC_TEMPLATES
	#if !defined(EA_COMPILER_NO_VARIADIC_TEMPLATES)
	{
		// This uses types defined above.
		VariadicTemplateType x;

		static_assert(sizeof(x) > 0, "EA_COMPILER_NO_VARIADIC_TEMPLATES failure");

		char buffer[32];
		sprintf(buffer, "%p", &x);
		// Ignore the result, as we're just verifying that it compiles.
	}
	#endif


	// Test EA_COMPILER_NO_TEMPLATE_ALIASES
	#if !defined(EA_COMPILER_NO_TEMPLATE_ALIASES)
	{
		// This uses types defined above.
		// Same as vector<int, EASTLAllocatorType> v;
		VectorAlias<int> v;
		EATEST_VERIFY(v.empty());
	}
	#endif


	// Test EA_COMPILER_NO_VARIABLE_TEMPLATES
	#if !defined(EA_COMPILER_NO_VARIABLE_TEMPLATES)
		static_assert(pi<int>      == 3, "variable template failure");
		static_assert(pi<intmax_t> == 3, "variable template failure");
		static_assert(pi<double>   == 3.1415926535897932385, "variable template failure");
	#endif


	// Test EA_COMPILER_NO_INITIALIZER_LISTS
	#if !defined(EA_COMPILER_NO_INITIALIZER_LISTS)
	{
		int a = { 1 };
		EATEST_VERIFY(a == 1);

		int* e{};
		EATEST_VERIFY(!e);

		double x = double{1};
		EATEST_VERIFY(x == 1.0);

		//Disabled until we have a compiler and standard library that can exercise this.
		//#include <initializer_list>
		//eastl::vector<eastl::string, int> anim = { {"bear", 4}, {"cassowary", 2}, {"tiger", 7} };
		//EATEST_VERIFY(!anim.empty());

		// Other tests to do.
		//std::complex<double> z{1,2};
		//eastl::vector<int>{1, 2, 3, 4}; 
		//f({"Nicholas","Annemarie"});
		//return { "Norah" };
	}
	#endif


	// Test EA_COMPILER_NO_NORETURN / EA_NORETURN
	#if !defined(EA_COMPILER_NO_NORETURN) && !defined(EA_PLATFORM_PS4) // Kettle SDK up to at least v.915 has a broken definition of the exit() function and fails to compile the valid code below.
	{
		struct NoReturnTest
		{
			EA_NORETURN void DoesNotReturn()
				{ exit(0); }

			int DoesReturn()
				{ return 17; }
		};

		NoReturnTest nrt;
		if(nrt.DoesReturn() == 18)
			nrt.DoesNotReturn();
	}
	#endif


	// Test EA_COMPILER_NO_CARRIES_DEPENDENCY / EA_CARRIES_DEPENDENCY
	#if !defined(EA_COMPILER_NO_CARRIES_DEPENDENCY)
	{
		struct CarriesDependencyTest
		{
			CarriesDependencyTest() : mX(0){}

			EA_CARRIES_DEPENDENCY int* Test1(){ return &mX; }
			void Test2(int* f EA_CARRIES_DEPENDENCY) { char buffer[32]; sprintf(buffer, "%p", f); }

			int mX;
		};

		CarriesDependencyTest cdt;
		cdt.Test2(cdt.Test1());
	}
	#endif


	// Test EA_COMPILER_NO_FALLTHROUGH / EA_FALLTHROUGH
	#if !defined(EA_COMPILER_NO_FALLTHROUGH)
	{
		int i = 1;
		switch (i)
		{
			case 1:
				i++;

			EA_FALLTHROUGH; 
			case 2: { i = 42; }
				break;
		}

		EATEST_VERIFY(i == 42);
	}
	#endif


	// Test EA_COMPILER_NO_NODISCARD / EA_NODISCARD
	#if !defined(EA_COMPILER_NO_NODISCARD)
	{
		struct EA_NODISCARD DoNotDiscardMe {};
		auto result = [](void) -> DoNotDiscardMe { return {}; }();
		(void)result;  // use the result to avoid [[nodiscard]] compiler warnings
	}
	#endif


	// Test EA_COMPILER_NO_MAYBE_UNUSED / EA_MAYBE_UNUSED
	#if !defined(EA_COMPILER_NO_MAYBE_UNUSED)
	{
		{
			EA_MAYBE_UNUSED int notAlwaysUsed = 42;

			// Do not use expressions below. It defeats the purpose of the test.
			// (void)notAlwaysUsed;
			// EA_UNUSED(notAlwaysUsed);
		}

		{
			[](EA_MAYBE_UNUSED bool b1, EA_MAYBE_UNUSED bool b2) { EA_ASSERT(b1 && b2); }(true, true);
		}
	}
	#endif

	#if !defined(EA_COMPILER_NO_NONSTATIC_MEMBER_INITIALIZERS)
	{
		struct NonstaticInitializerTest
		{
			int a = 7;
			int b = a;
		};

		NonstaticInitializerTest nit;
		EATEST_VERIFY((nit.a == 7) && (nit.b == 7));
	}
	#endif

	#if !defined(EA_COMPILER_NO_RIGHT_ANGLE_BRACKETS)
	{
		eastl::vector<eastl::vector<int>> listList;
		EA_UNUSED(listList);
	}
	#endif


	#if !defined(EA_COMPILER_NO_ALIGNOF)
	{
		char buffer[32];
		sprintf(buffer, "%u", (unsigned)alignof(uint64_t));
	}
	#endif


	#if !defined(EA_COMPILER_NO_ALIGNAS)
	{
		struct alignas(32) AlignAsTest1
			{ float mData[4]; };

		struct alignas(uint64_t) AlignAsTest2
			{ float mData[4]; };

		char buffer[32];
		sprintf(buffer, "%u %u", (unsigned)EA_ALIGN_OF(AlignAsTest1), (unsigned)EA_ALIGN_OF(AlignAsTest2));
	}
	#endif


	#if !defined(EA_COMPILER_NO_DELEGATING_CONSTRUCTORS)
	{
		struct DCTest
		{  
			char   mChar;  
			double mDouble;  

			DCTest() : mChar('\0'), mDouble(1.23){ };  
			DCTest(double d, char c): mChar(c), mDouble(d) { }  
			DCTest(char c) : DCTest(1.23, c) { }  
			DCTest(double d): DCTest(d, 'a') { }
			DCTest(char*): DCTest() { }
		};

		DCTest dcTest(1.5);
		EATEST_VERIFY(dcTest.mDouble == 1.5);
	}
	#endif


	#if !defined(EA_COMPILER_NO_INHERITING_CONSTRUCTORS)
	{
		struct B1{
			B1(int x) : mX(x){}
			int mX;
		};

		struct B2{
			B2(int x = 13, int y = 42) : mX(x), mY(y){}
			int mX, mY;
		};

		struct D1 : B1 {
			using B1::B1;
		};

		struct D2 : B2 {
			using B2::B2;
		};

		D1 d1(3);
		D2 d2a(17, 22);
		D2 d2b;

		EATEST_VERIFY((d1.mX == 3) && 
					  (d2a.mX == 17) && (d2a.mY == 22) && 
					  (d2b.mX == 13) && (d2b.mY == 42));
	}
	#endif


	#if !defined(EA_COMPILER_NO_USER_DEFINED_LITERALS)
	{
		// The operators are defined above.

		// Conversion example
		double x = 90.0_deg; // x = 1.570796
		EATEST_VERIFY((x > 1.57) && (x < 1.58));

		// Custom type example
		UDLTest y(123_udl);
		EATEST_VERIFY(y.mX == 123);
	}
	#endif


	#if !defined(EA_COMPILER_NO_STANDARD_LAYOUT_TYPES)
	{
		// We don't currently have a good way of testing this without bringing in <type_traits>.
	}
	#endif


	#if !defined(EA_COMPILER_NO_EXTENDED_SIZEOF)
	{
		struct SizeofTest{
			int32_t mMember;
		};

		const size_t testSize = sizeof(SizeofTest::mMember);
		EATEST_VERIFY(testSize == sizeof(int32_t));
		char buffer[32];
		sprintf(buffer, "%u", (unsigned)testSize);
	}
	#endif


	#if !defined(EA_COMPILER_NO_INLINE_NAMESPACES)
	{
		// The namespaces are defined above.

		INSNamespace::A<INSClass> a;
		int result = g(a);
		EATEST_VERIFY(result == 37);
	}
	#endif


	#if !defined(EA_COMPILER_NO_UNRESTRICTED_UNIONS)
	{
		struct Point {
			int mX, mY;

			Point(int x = 0, int y = 0) : mX(x), mY(y) {}
		};
		 
		union U {
			int    z;
			double w;
			Point  p; // Illegal in C++03; legal in C++11.

			U() { new(&p) Point(); } // Due to the Point member, a constructor definition is now required.
		};
	}
	#endif


	#if !defined(EA_COMPILER_NO_EXPLICIT_CONVERSION_OPERATORS)
	{
		// bool cast test
		struct Testable
		{
			explicit operator bool() const
				{ return false; }

			Testable() : mX(37) { }
			int mX;
		};
		 
		Testable a;

		if(a)
			EATEST_VERIFY(a.mX == 37);

		// Class cast test
		struct Y { 
			int mY;
			Y(int y = 0) : mY(y) { }
		};

		struct Z { 
			int mZ;
			Z(int z = 0) : mZ(z) { }
			explicit operator Y() const { return Y(mZ); }
		};

		Z z(3);
		Y y1(z);     // Direct initialization
		Y y2 = (Y)z; // Cast notation

		EATEST_VERIFY((z.mZ == 3) && (y1.mY == 3) && (y2.mY == 3));
	}
	#endif


	#if !defined(EA_COMPILER_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS)
	{
		// FunctionTemplateTest is declared above.
		int result = FunctionTemplateTest::AddOne((int)3);
		EATEST_VERIFY(result == 4);
	}
	#endif


	#if !defined(EA_COMPILER_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS)
	{
		struct LocalStruct{};  
		eastl::fixed_vector<LocalStruct, 2, false> localStructArray;
		EATEST_VERIFY(localStructArray.empty());
	}
	#endif


	#if !defined(EA_COMPILER_NO_NOEXCEPT)
	{
		EATEST_VERIFY(NoExceptTestFunction() == 37);
		EATEST_VERIFY(NoExceptTestTemplate<NoExceptTestStruct>() == 37);
	}
	#endif


	#if !defined(EA_COMPILER_NO_RAW_LITERALS)
	{
		// Older versions of GCC are preventing us from using " below in str1. Due to the way the preprocessor
		// works, it encounters what it sees as a string problem before it handles the #if above. No #ifdefs 
		// can make this problem go away.
		const char str1[] = R"(This slash is just a slash: \ This quote is just a quote: ' )";
		const char str2[] = R"delimiter(This slash is just a slash: \ This paren is just a paren: ) )delimiter";
		EA_UNUSED(str1);
		EA_UNUSED(str2);
		
		static_assert(EAArrayCount(str1) == 61, "EA_COMPILER_NO_RAW_LITERALS failure.");
		static_assert(EAArrayCount(str2) == 61, "EA_COMPILER_NO_RAW_LITERALS failure.");
	}
	#endif


	#if !defined(EA_COMPILER_NO_UNICODE_STRING_LITERALS)
	{
		const char8_t  str1[] = u8"Unicode: \u2018.";       // This assumes that \u and \U are supported by the compiler.
		const char16_t str2[] = u"Unicode: \U00002018.";
		const char32_t str3[] = U"Unicode: \U00022018.";

		static_assert(EAArrayCount(str1) == 14, "EA_COMPILER_NO_UNICODE_STRING_LITERALS failure.");
		static_assert(EAArrayCount(str2) == 12, "EA_COMPILER_NO_UNICODE_STRING_LITERALS failure.");
		static_assert(EAArrayCount(str3) == 12, "EA_COMPILER_NO_UNICODE_STRING_LITERALS failure.");
	}
	#endif


	#if !defined(EA_COMPILER_NO_UNICODE_CHAR_NAME_LITERALS)
	{
		const char8_t str1[] = "\u2018\u2019";
		static_assert(EAArrayCount(str1) == 7, "EA_COMPILER_NO_UNICODE_CHAR_NAME_LITERALS failure.");

		#if (EA_WCHAR_SIZE >= 2)
			const wchar_t str2[] = L"\U00002018\U00002019";
			static_assert(EAArrayCount(str2) == 3, "EA_COMPILER_NO_UNICODE_CHAR_NAME_LITERALS failure."); // This test assumes that wchar_t is a 16bit or greater value.
		#endif

		#if defined(EA_CHAR16_NATIVE) && EA_CHAR16_NATIVE
			const char16_t str3[] = u"\U00002018\U00002019";
			static_assert(EAArrayCount(str3) == 3, "EA_COMPILER_NO_UNICODE_CHAR_NAME_LITERALS failure.");
		#endif
	}
	#endif

	#ifndef EA_COMPILER_NO_RVALUE_REFERENCES
	{
		const int MAX_ARR_SIZE = 4096;
		struct StructWithArray { int arr[MAX_ARR_SIZE]; }; 
		static_assert(EAArrayCount(StructWithArray().arr) == MAX_ARR_SIZE, "");
	}
	#endif

	#if !defined(EA_COMPILER_NO_UNIFIED_INITIALIZATION_SYNTAX)
	{
		struct InitTest1
		{
			int    mX;
			double mY;
		};
		 
		struct InitTest2
		{
			InitTest2(int x, double y) : mX{x}, mY{y} {}

			int    mX;
			double mY;
		};
		 
		InitTest1 var1{5, 3.2};
		InitTest2 var2{2, 4.3};

		EATEST_VERIFY(var1.mY == 3.2);
		EATEST_VERIFY(var2.mY == 4.3);
	}
	#endif

	#if !defined(EA_COMPILER_NO_EXTENDED_FRIEND_DECLARATIONS)
	{
		class G;

		class X1 {
			friend G;
		};
	}
	#endif    


	#if !defined(EA_COMPILER_NO_THREAD_LOCAL)
	{
		// We don't yet test this because we don't have a sufficient compiler to test it with.
	}
	#endif

	return nErrorCount;
}


#if defined(EA_COMPILER_MSVC) && EA_COMPILER_VERSION >= 1900	// VS2015+
	EA_DISABLE_VC_WARNING(5029);  // nonstandard extension used: alignment attributes in C++ apply to variables, data members and tag types only
#endif
int TestEACompilerTraits()
{
	int nErrorCount(0);

	// EA_COMPILER_IS_ANSIC
	// EA_COMPILER_IS_C99
	// EA_COMPILER_IS_CPLUSPLUS
	// EA_COMPILER_MANAGED_CPP

	{
		// EA_COMPILER_INTMAX_SIZE

		#if (EA_COMPILER_INTMAX_SIZE == 16)
			/* To do: Test this when we get a machine that supports it (e.g. Linux64)/
			#if defined(__GNUC__)
				#define int128_t  __int128_t
				#define uint128_t __uint128_t
			#endif

			int128_t  x = UINT128_C(0x12345678123456781234567812345678);
			uint128_t y = (x * 2);

			if(x == (int128_t)y)
				DoError(nErrorCount, "EA_COMPILER_INTMAX_SIZE test");
			*/

		#elif (EA_COMPILER_INTMAX_SIZE == 8)
			int64_t  x = UINT64_C(0x1234567812345678);
			uint64_t y = (x * 2);

			if(x == (int64_t)y)
				DoError(nErrorCount, "EA_COMPILER_INTMAX_SIZE test");

		#elif (EA_COMPILER_INTMAX_SIZE == 32)
			int32_t  x = UINT64_C(0x12345678);
			uint32_t y = (x * 2);

			if(x == (int32_t)y)
				DoError(nErrorCount, "EA_COMPILER_INTMAX_SIZE test");

		#else
			int16_t  x = UINT16_C(0x1234);
			uint16_t y = (x * 2);

			if(x == (int16_t)y)
				DoError(nErrorCount, "EA_COMPILER_INTMAX_SIZE test");
		#endif
	}

	{
		// EA_OFFSETOF
		const size_t o = EA_OFFSETOF(OffsetofTestClass, mY);
		EA_DISABLE_VC_WARNING(6326)
		if(o != 4)
			DoError(nErrorCount, "EA_OFFSETOF test");
		EA_RESTORE_VC_WARNING()
	}

	{
		// EA_SIZEOF_MEMBER
		const size_t s = EA_SIZEOF_MEMBER(SizeofMemberTestClass, mY);
		EA_DISABLE_VC_WARNING(6326)
		if(s != 4)
			DoError(nErrorCount, "EA_SIZEOF_MEMBER test");
		EA_RESTORE_VC_WARNING()

		// There have been problems on some platforms (SNC version < 405) where extended sizeof was not properly
		// supported when used within a member function, so we test for that here.

		class TestClass
		{
		public:
			void TestExtendedSizeof(int& nErrorCount)
			{
				EA_DISABLE_VC_WARNING(6326)
				const size_t sizeOfmY = EA_SIZEOF_MEMBER(SizeofMemberTestClass, mY);
				if(sizeOfmY != 4)
					DoError(nErrorCount, "EA_SIZEOF_MEMBER test: within member function");
				EA_RESTORE_VC_WARNING()
			}
		}tc;

		tc.TestExtendedSizeof(nErrorCount);
	}
	
	{   // EA_ALIGN_OF, EA_PREFIX_ALIGN, etc.
		size_t a = EA_ALIGN_OF(int);
		EA_PREFIX_ALIGN(4) int b = 5;
		EA_ALIGN(8) int c;
		int d EA_POSTFIX_ALIGN(8);
		int e EA_POSTFIX_ALIGN(8) = 5;
		int f EA_POSTFIX_ALIGN(8)(5);
		struct EA_ALIGN(8) G { int x; }; 
		struct EA_PREFIX_ALIGN(8) GG { int x; } EA_POSTFIX_ALIGN(8);
		EA_ALIGNED(int, h, 8) = 5;
		EA_ALIGNED(int, i, ALIGNMENT_AMOUNT_16)(5);
		EA_ALIGNED(int, j[3], ALIGNMENT_AMOUNT_16);
		EA_ALIGNED(int, k[3], ALIGNMENT_AMOUNT_16) = { 1, 2, 3 };
		struct EA_ALIGN(8) L { int x; int y; };

		EA_DISABLE_VC_WARNING(4359)  // ARM64: C4359: 'TestEACompilerTraits::X': Alignment specifier is less than actual alignment (4), and will be ignored.
		EA_ALIGN(ALIGNMENT_AMOUNT_32) struct X { int x; int y; } m;
		EA_RESTORE_VC_WARNING()

	  //int N[3] EA_PACKED; // Some compilers (e.g. GCC) don't support this or ignore this and generate a warning.
		struct P { int x EA_PACKED; int y EA_PACKED; };
		struct Q { int x; int y; } EA_PACKED;
		typedef EA_ALIGNED(int, r, ALIGNMENT_AMOUNT_16);
		r rInstance;
		typedef EA_ALIGNED(Q, X16, ALIGNMENT_AMOUNT_16);
		X16 x16Instance;

		char buffer[256];
		sprintf(buffer, "%p %p %p %p %p %p %p %p %p %p %p %p %p", &a, &b, &c, &d, &e, &f, &h, &i, &j, &k, &m, &rInstance, &x16Instance);
	}

	{ // Test EA_ALIGN_OF
		if(EA_ALIGN_OF(int8_t) != sizeof(int8_t))   // This may not be a kosher test.
			DoError(nErrorCount, "EA_ALIGN_OF test (int16_t)");

		if(EA_ALIGN_OF(int16_t) != sizeof(int16_t)) // This may not be a kosher test.
			DoError(nErrorCount, "EA_ALIGN_OF test (int16_t)");

		if(EA_ALIGN_OF(int32_t) != sizeof(int32_t)) // This may not be a kosher test.
			DoError(nErrorCount, "EA_ALIGN_OF test (int32_t)");

		#if !defined(EA_ABI_ARM_APPLE)
		if(EA_ALIGN_OF(int64_t) != sizeof(int64_t)) // This may not be a kosher test.
			DoError(nErrorCount, "EA_ALIGN_OF test (int64_t)");
		#endif

		typedef void (*AlignTestFunctionType)();
		if(EA_ALIGN_OF(AlignTestFunctionType) != sizeof(void*)) // This may not be a kosher test.
			DoError(nErrorCount, "EA_ALIGN_OF test (AlignTestFunctionType)");
	}

	{ // Test EA_ALIGN
		#ifdef EA_ALIGN
			char buffer[32];
			
			EA_ALIGN(ALIGNMENT_AMOUNT_64) int x(0);
			sprintf(buffer, "%d", x);
			if(buffer[0] != '0')
				DoError(nErrorCount, "EA_ALIGN test 1");
			if((intptr_t)&x & (ALIGNMENT_AMOUNT_64 -1))
				DoError(nErrorCount, "EA_ALIGN test 2");

			EA_ALIGN(ALIGNMENT_AMOUNT_64) ClassWithDefaultCtor    cdcA;
		  //EA_ALIGN(64) ClassWithoutDefaultCtor cwdcA;
			if((intptr_t)&cdcA & (ALIGNMENT_AMOUNT_64 -1))
				DoError(nErrorCount, "EA_ALIGN test 3");

			EA_ALIGN(ALIGNMENT_AMOUNT_64) ClassWithDefaultCtor    cdcB(3);
			if((intptr_t)&cdcB & (ALIGNMENT_AMOUNT_64 -1))
				DoError(nErrorCount, "EA_ALIGN test 4");

			EA_ALIGN(ALIGNMENT_AMOUNT_64) ClassWithoutDefaultCtor cwdcB(3);
			if((intptr_t)&cwdcB & (ALIGNMENT_AMOUNT_64 -1))
				DoError(nErrorCount, "EA_ALIGN test 5");
		#else
			DoError(nErrorCount, "EA_ALIGN test 6");
		#endif
	}

	{ // Test EA_PREFIX_ALIGN
		#ifdef EA_PREFIX_ALIGN
			char buffer[32];
			EA_PREFIX_ALIGN(ALIGNMENT_AMOUNT_64) int x(0);
			sprintf(buffer, "%d", x);
			if(buffer[0] != '0')
				DoError(nErrorCount, "EA_PREFIX_ALIGN test 1");

			EA_PREFIX_ALIGN(64) ClassWithDefaultCtor    cdcA;
		  //EA_PREFIX_ALIGN(64) ClassWithoutDefaultCtor cwdcA;

			EA_PREFIX_ALIGN(64) ClassWithDefaultCtor    cdcB(3);
			EA_PREFIX_ALIGN(64) ClassWithoutDefaultCtor cwdcB(3);
		#else
			DoError(nErrorCount, "EA_PREFIX_ALIGN test 2");
		#endif
	}


	{ // Test EA_POSTFIX_ALIGN
		#ifdef EA_POSTFIX_ALIGN
			char buffer[32];
			int x EA_POSTFIX_ALIGN(ALIGNMENT_AMOUNT_64) = 0;
			sprintf(buffer, "%d", x);
			if(buffer[0] != '0')
				DoError(nErrorCount, "EA_POSTFIX_ALIGN test 1");

			ClassWithDefaultCtor    cdcA  EA_POSTFIX_ALIGN(ALIGNMENT_AMOUNT_64);
		  //ClassWithoutDefaultCtor cwdcA EA_POSTFIX_ALIGN(64);

			ClassWithDefaultCtor    cdcB  EA_POSTFIX_ALIGN(ALIGNMENT_AMOUNT_64)(3);
			ClassWithoutDefaultCtor cwdcB EA_POSTFIX_ALIGN(ALIGNMENT_AMOUNT_64)(3);
		#else
			DoError(nErrorCount, "EA_POSTFIX_ALIGN test 2");
		#endif
	}


	{ // Test EA_ALIGNED
		#ifdef EA_ALIGNED
			char buffer[64];

			// Verify that a simple declaration works.
			EA_ALIGNED(int, xA, ALIGNMENT_AMOUNT_64); xA = 0;
			sprintf(buffer, "%d", xA);
			if((intptr_t)&xA &  (ALIGNMENT_AMOUNT_64 -1))
				DoError(nErrorCount, "EA_ALIGNED test 1");

			// Verify that a declaration with assignment works.
			EA_ALIGNED(int, xB, ALIGNMENT_AMOUNT_64) = 0;
			sprintf(buffer, "%d", xB);
			if((intptr_t)&xB &  (ALIGNMENT_AMOUNT_64 -1))
				DoError(nErrorCount, "EA_ALIGNED test 2");

			// Verify that a declaration with construction works.
			EA_ALIGNED(int, xC, ALIGNMENT_AMOUNT_64)(0);
			sprintf(buffer, "%d", xC);
			if((intptr_t)&xC &  (ALIGNMENT_AMOUNT_64 -1))
				DoError(nErrorCount, "EA_ALIGNED test 3");

			// Verify that a typedefd declaration works.
			typedef EA_ALIGNED(int, int16, ALIGNMENT_AMOUNT_16);
			int16 n16 = 0;
			sprintf(buffer, "%p", &n16);
			if((intptr_t)&n16 & (ALIGNMENT_AMOUNT_16 - 1))
				DoError(nErrorCount, "EA_ALIGNED test 4");

			// Verify that the following tests compile. These tests are here
			// because the SN compiler (EDG front-end) has some problems with
			// GCC compatibility related to the 'aligned' __attribute__.
			ClassWithDefaultCtor    cdc;
			ClassWithoutDefaultCtor cwdc(3);
			sprintf(buffer, "%p%p", &cdc, &cwdc);

			// Verify that regular usage of EA_ALIGNED works.
			EA_ALIGNED(ClassWithDefaultCtor, cdc16A, ALIGNMENT_AMOUNT_16);
			//EA_ALIGNED(ClassWithoutDefaultCtor, cwdcA, 16);   // Doesn't have a default ctor, so this can't be done.
			sprintf(buffer, "%p%p", &cdc16A, (void*)NULL);

			// Verify that argument usage of EA_ALIGNED works.
			EA_ALIGNED(ClassWithDefaultCtor, cdcB, ALIGNMENT_AMOUNT_16)(3);
			EA_ALIGNED(ClassWithoutDefaultCtor, cwdcB, ALIGNMENT_AMOUNT_16)(3);
			sprintf(buffer, "%p%p", &cdcB, &cwdcB);

			// Verify that usage of EA_ALIGNED works within a typedef.
			typedef EA_ALIGNED(ClassWithDefaultCtor, ClassWithDefaultCtor16, ALIGNMENT_AMOUNT_16);
			ClassWithDefaultCtor16 cdcC(3);
			typedef EA_ALIGNED(ClassWithoutDefaultCtor, ClassWithoutDefaultCtor16, ALIGNMENT_AMOUNT_16);
			ClassWithoutDefaultCtor16 cwdcC(3);
			sprintf(buffer, "%p%p", &cdcC, &cwdcC);
		#else
			DoError(nErrorCount, "EA_ALIGNED test");
		#endif
	}


	{ // Test EA_NO_INLINE / EA_PREFIX_NO_INLINE / EA_POSTFIX_NO_INLINE
		DoNothingInline();
		DoNothingPrefixInline();
	}


	{ // Test EA_FORCE_INLINE / EA_PREFIX_FORCE_INLINE / EA_POSTFIX_FORCE_INLINE
		DoNothingForceInline();
		DoNothingPrefixForceInline();
	}

	{ // Test EA_FORCE_INLINE_LAMBDA
		auto testLambda = []() EA_FORCE_INLINE_LAMBDA
		{
		};
		testLambda();
	}


	{ // Test EA_PACKED
		#ifdef EA_PACKED
			char buffer[32];
			struct X { int x; } EA_PACKED;
			X x = { 0 };
			sprintf(buffer, "%d", x.x);
			if(buffer[0] != '0')
				DoError(nErrorCount, "EA_PACKED test");
		#else
			DoError(nErrorCount, "EA_PACKED test");
		#endif
	}


	{ // Test EA_LIKELY

		if(EA_UNLIKELY(nErrorCount > 0))
		{
			if(EA_LIKELY(nErrorCount == 999999)) // Actually this isn't likely, but that's beside the point.
				DoError(nErrorCount, "EA_LIKELY test");
		}
	}


	{ // Test EA_INIT_PRIORITY

		// We don't test that the init priority succeeded in modifying the init priority.
		// We merely test that this compiles on all platforms and assume the compiler's 
		// support of this is not broken.
		if(gInitPriorityTestClass0.mX != 0)
			DoError(nErrorCount, "EA_INIT_PRIORITY test.");

		if(gInitPriorityTestClass1.mX != 1)
			DoError(nErrorCount, "EA_INIT_PRIORITY test.");
	}


	{ // Test EA_INIT_SEG
		// We don't test that the init_seg succeeded in modifying the init priority.
		// We merely test that this compiles on all platforms and assume the compiler's 
		// support of this is not broken.
		if(gInitSegTestSection.mX != 2300)
			DoError(nErrorCount, "EA_INIT_SEG test.");
	}


	{ // Test EA_MAY_ALIAS
		// We don't test that the init priority succeeded in modifying the init priority.
		// We merely test that this compiles on all platforms and assume the compiler's 
		// support of this is not broken.
		if(gPtr0 != NULL)
			DoError(nErrorCount, "EA_MAY_ALIAS test.");

		if(gPtr1 != NULL)
			DoError(nErrorCount, "EA_MAY_ALIAS test.");
	}


	{ // Test EA_ASSUME
		switch (nErrorCount / (nErrorCount + 1))
		{
			case 0:
				Stricmp("nop0", "nop0");
				break;
			case 1:
				Stricmp("nop1", "nop1");
				break;
			default:
				EA_ASSUME(0);
		}
	}


	{ // Test EA_PURE
		if(!PureFunction())
			DoError(nErrorCount, "EA_PURE test");
	}


	{ // EA_WEAK
		if(gWeakVariable != 1)
			DoError(nErrorCount, "EA_WEAK test");
	}


	{ // Test EA_NO_VTABLE
		NoVTable1 nvt1;
		NoVTable2 nvt2;
		nvt1.InterfaceFunction();
		nvt2.InterfaceFunction();
	}

	{ // Test EA_WCHAR_SIZE
		EA_DISABLE_VC_WARNING(6326)
		#ifdef EA_WCHAR_SIZE
			if((EA_WCHAR_SIZE != 1) && (EA_WCHAR_SIZE != 2) && (EA_WCHAR_SIZE != 4))
				DoError(nErrorCount, "EA_WCHAR_SIZE test");
		#else
			DoError(nErrorCount, "EA_WCHAR_SIZE test");
		#endif
		EA_RESTORE_VC_WARNING()
	}


	{ // Test EA_RESTRICT
		struct TestRestrict{
			static size_t Test(char* EA_RESTRICT p){ return sizeof(p); }
		};
		char* p = NULL;
		if(TestRestrict::Test(p) == 0) // This isn't a real test. If there is a failure, it will happen at compile time.
			DoError(nErrorCount, "EA_RESTRICT test");
	}


	{ // Test EA_DEPRECATED
		/* This causes warnings on compilers, so just disable it.
		#if defined(EA_DEPRECATED) && (!defined(__GNUC__) || ((__GNUC__ * 100 + __GNUC_MINOR__) < 402)) // GCC 4.2+ is converting deprecated into an error instead of a warning.
			char buffer[32];
			EA_DEPRECATED int x(0);
			sprintf(buffer, "%d", x); (void)x;
			if(buffer[0] != '0')
				DoError(nErrorCount, "EA_DEPRECATED test");
		#elif !defined (EA_DEPRECATED)
			DoError(nErrorCount, "EA_DEPRECATED test");
		#endif
		*/
	}


	{ // Test EA_PASCAL
		#ifdef EA_PASCAL
			struct X{ void EA_PASCAL DoNothing(){} };
			X x;
			x.DoNothing();
		#else
			DoError(nErrorCount, "EA_PASCAL test");
		#endif
	}


	{ // Test EA_PASCAL_FUNC
		#ifdef EA_PASCAL_FUNC
			struct X{ void EA_PASCAL_FUNC(DoNothing()){} };
			X x;
			x.DoNothing();
		#else
			DoError(nErrorCount, "EA_PASCAL_FUNC test");
		#endif
	}


	// EA_SSE
	// Not sure how to properly test at this time.

	{ // EA_FP16C
		#if EA_FP16C
			// For this test just try to call an intrinsic that is only
			// available when FP16C is available.  The test can make sure the
			// platform actually supports FP16C when it claims to support it,
			// but it can't verify a platform doesn't support FP16C.
			_mm_cvtph_ps(_mm_set1_epi32(42));
		#endif
	}

	{ // EA_IMPORT
		// Not possible to do this because import means it will come from outside.
		//struct X{ EA_IMPORT void DoNothing(){} };
		//X x;
		//x.DoNothing();
	}


	{ // EA_EXPORT
		struct X{ EA_EXPORT void DoNothing(){} };
		X x;
		x.DoNothing();
	}


	// EA_PREPROCESSOR_JOIN
	// EA_STRINGIFY
	{
		char      buffer[32];
		char      bufferExpected[32];
		const int line = (__LINE__ + 2);

		sprintf(buffer, "%s %s", EA_STRINGIFY(EA_PREPROCESSOR_JOIN(test_, __LINE__)), EA_STRINGIFY(__LINE__));
		sprintf(bufferExpected, "test_%d %d", line, line);

		if(strcmp(buffer, bufferExpected) != 0)
			DoError(nErrorCount, "EA_PREPROCESSOR_JOIN/EA_STRINGIFY test");
	}


	{ // EAArrayCount
		const int    testArray[13] = { 0 };
		const size_t arrayCount = EAArrayCount(testArray);

		EA_DISABLE_VC_WARNING(6326)
		if((arrayCount != 13) || (testArray[0] != 0))
			DoError(nErrorCount, "EAArrayCount test");
		EA_RESTORE_VC_WARNING()

		const float testArray2[EAArrayCount(testArray)] = {};
		static_assert(EAArrayCount(testArray2) == EAArrayCount(testArray), "Array counts should be equivalent.");
		static_assert(EAArrayCount(testArray2) == 13, "Float array should have 13 elements.");

		EA_DISABLE_VC_WARNING(6326)
		if (EAArrayCount(testArray2) != EAArrayCount(testArray))
			DoError(nErrorCount, "EAArrayCount - Array counts should be equivalent.");
		EA_RESTORE_VC_WARNING()

		EA_DISABLE_VC_WARNING(6326)
		if (EAArrayCount(testArray2) != 13)
			DoError(nErrorCount, "EAArrayCount - Float array should have 13 elements.");
		EA_UNUSED(testArray2);
		EA_RESTORE_VC_WARNING()

		// Regresssion of user bug report that static_assert<member array> fails with some C++11 compilers.
		// We revised the templated definition of EAArrayCount to deal with the failure.
		struct Example
		{
			int32_t mItems[7];
			Example()
				{ static_assert(EAArrayCount(mItems) == 7, "invalid size"); memset(mItems, 0x77, sizeof(mItems)); } // This was failing with the original templated version of EAArrayCount.
		};

		Example example;
		EATEST_VERIFY(example.mItems[0] == 0x77777777);
	}

	{ // static_assert

		// Should succeed.
		static_assert(sizeof(int32_t) == 4, "static_assert failure");

		// Should fail.
		//static_assert(sizeof(int32_t) == 8, "static_assert failure");
	}

	{ // EA_OPTIMIZE_OFF / EA_OPTIMIZE_ON
		int result = DisabledOptimizations(2);

		if(result != 2*37)
			DoError(nErrorCount, "EA_OPTIMIZE_OFF test");
	}

	{ // EA_UNUSED
		FunctionWithUnusedVariables(3);
	}

	{ // EA_EXTERN_TEMPLATE

		eabase_template<char> x;
		x.value = 0;
		if(x.GetValue() != 0)
			DoError(nErrorCount, "EA_EXTERN_TEMPLATE test");
	}

	{ // EA_FUNCTION_DELETE
		EA_FUNCTION_DELETE_Test test(17);
		EATEST_VERIFY(test.x == 17);
	}

	{ // EA_NON_COPYABLE / EANonCopyable
		NonCopyableA ncA1;
		ncA1.x = 1;
		//NonCopyableA ncA2(ncA1);      // Both of these lines should result in 
		//ncA1 = ncA1;                  // compiler errors if enabled.
		EA_UNUSED(ncA1);

		NonCopyableB ncB1;
		ncB1.x = 1;
		//NonCopyableB ncB2(ncB1);      // Both of these lines should result in 
		//ncB1 = ncB1;                  // compiler errors if enabled.
		EA_UNUSED(ncB1);

		NonCopyableSubclass ncs1(3); 
		//NonCopyableSubclass ncs2(ncs1); // Both of these lines should result in 
		//ncs2 = ncs2;                    // compiler errors if enabled.
		EATEST_VERIFY(ncs1.mX == 3);

		struct NonCopyableLocal
		{
			NonCopyableLocal(){}
			int x;

			EA_NON_COPYABLE(NonCopyableLocal)
		};
		NonCopyableLocal ncLocal1;
		ncLocal1.x = 1;
		//NonCopyableLocal ncLocal2(ncLocal1);  // Both of these lines should result in 
		//ncLocal1 = ncLocal1;                  // compiler errors if enabled.
		EA_UNUSED(ncLocal1);
	}

	return nErrorCount;
}
#if defined(EA_COMPILER_MSVC) && EA_COMPILER_VERSION >= 1900	// VS2015+
	EA_RESTORE_VC_WARNING();
#endif


/////////////////////////////////////////////////
// nullptr test
/////////////////////////////////////////////////

#if !defined(EA_HAVE_nullptr_IMPL)
	#define EA_RTTI_ENABLED 0 // This is something that ideally would be defined in EABase.


	int mfCCount = 0;
	struct C
	{
		void mf()
		{
			mfCCount++;
		}
	};


	int fDoubleCount = 0;
	static void f(double*)
	{
		fDoubleCount++;
	}


	int fIntCount = 0;
	static void f(int)
	{
		fIntCount++;
	}


	int gTCount = 0;
	template<typename T>
	void g(T*)
	{
		gTCount++;
	}

	int hTCount = 0;
	template<typename T>
	void h(T)
	{
		hTCount++;
	}
#endif


static int TestNullPtr()
{
	int nErrorCount(0);

	#if defined(EA_HAVE_nullptr_IMPL) // If the compiler provides a native version... 
		// Don't question it. VC++ nullptr -seems- to be not entirely conforming anyway.
	#else
		using namespace std;

		// DoError("TestNullptr\n");
		void* pv = nullptr;                         // OK
		EATEST_VERIFY(pv == 0);
		EATEST_VERIFY(pv == nullptr);
		#ifndef __MWERKS__                          // Currently the Metrowerks compiler crashes on this code.
			EATEST_VERIFY(nullptr == pv);
		#endif

		pv = &pv;                                   // OK
		EATEST_VERIFY(pv != 0);
		#if !defined(__GNUC__) || (__GNUC__ > 3)
			EATEST_VERIFY(pv != nullptr);
		#endif

		const char* pc = nullptr;                   // OK
		EATEST_VERIFY(pc == 0);
		EATEST_VERIFY(pc == nullptr);
		#ifndef __MWERKS__
			EATEST_VERIFY(nullptr == pc);
		#endif

		C* pC = nullptr;                            // OK
		EATEST_VERIFY(pC == 0);
		EATEST_VERIFY(pC == nullptr);
		#ifndef __MWERKS__
			EATEST_VERIFY(nullptr == pC);
		#endif

		f(nullptr);                                 // OK. Calls f(double*).
		EATEST_VERIFY(fDoubleCount == 1);

		f(0);                                       // OK. Calls f(int)
		EATEST_VERIFY(fIntCount == 1);

		//g(nullptr);                               // Not OK. Can't deduce T

		h(0);                                       // OK. Deduces T = int
		EATEST_VERIFY(hTCount == 1);

		h(nullptr);                                 // OK. Deduces T = nullptr_t
		EATEST_VERIFY(hTCount == 2);

		h((float*)nullptr);                         // OK. Deduces T = float*
		EATEST_VERIFY(hTCount == 3);

		void (C::*pmf)() = 0;                       // OK
		EATEST_VERIFY(pmf == 0);

		#if !defined(__GNUC__) || (__GNUC__ > 3)
			void (C::*pmf2)() = nullptr;            // OK
			EA_UNUSED(pmf2);
			#ifndef __MWERKS__                      // CodeWarrior is not following the C++ Standard properly.
				EATEST_VERIFY(pmf2 == 0);
				EATEST_VERIFY(pmf2 == nullptr);
				EATEST_VERIFY(nullptr == pmf2);
			#endif
		#endif

		#if !defined(__GNUC__) || (__GNUC__ > 3)
			void (C::*pmf3)() = &C::mf;
			#ifndef __MWERKS__
				EATEST_VERIFY(pmf3 != nullptr);
			#endif
		#endif

		nullptr_t n1 = nullptr, n2 = nullptr;       // OK
		n1 = n2;                                    // OK
		h(n1);

		//const int const0 = 0;
		//if(const0 == nullptr) {}                  // Not OK.

		//int n = 0;
		//if(n == nullptr) {}                       // Not OK. 

		//nullptr_t* pN = &n1;                      // Not OK. Address can't be taken.

		EATEST_VERIFY(!nullptr);                    // Supposedly OK, but VC++ doesn't accept it.
		if(nullptr)                                 // Supposedly OK, but VC++ doesn't accept it.
			EATEST_VERIFY(false);

		int   val = 0;
		char* ch3 = val ? nullptr : nullptr;        // OK.
		EATEST_VERIFY(ch3 == 0);

		//char* ch4 = val ? 0       : nullptr;      // Not OK. Types are not compatible.
		//int   n3  = val ? nullptr : nullptr;      // Not OK. nullptr can't be converted to int.
		//int   n4  = val ? 0       : nullptr;      // Not OK. Types are not compatible.

		// void* p = 0;
		// reinterpret_cast<nullptr>(p);            // Not OK. But all compilers allow this. A reinterpret_cast cannot be used to convert a value of any type to the type std::nullptr_t.

		//This is supposed to succeed, but we can't make it so, given the conflicting requirements of the C++ and nullptr standards.
		//EATEST_VERIFY(sizeof(nullptr) == sizeof(void*));    // I don't currently have a means to make this work. See the class for why.

		#ifndef __MWERKS__
			nullptr_t n3 = nullptr, n4 = nullptr;
			EATEST_VERIFY(n3 == n4);
			EATEST_VERIFY(!(n3 != n4));
			EATEST_VERIFY(n3 <= n4);
			EATEST_VERIFY(n3 >= n4);
			EATEST_VERIFY(!(n3 < n4));
			EATEST_VERIFY(!(n3 > n4));
		#endif


		#if EA_RTTI_ENABLED
			typeid(nullptr);                        // OK
		#endif

		#ifndef EA_COMPILER_NO_EXCEPTIONS
			try{
				pv = 0;
				throw nullptr;                      // OK
			}
			catch(nullptr_t n)
			{
				EATEST_VERIFY(n == pv);             // OK
				h(n);
			}
		#endif
	#endif // EA_HAVE_nullptr_IMPL

	return nErrorCount;
}


static int TestEAHave()
{
	int nErrorCount(0);

	// EA_HAVE_XXX_DECL
	//
	// We don't have a simple way to test these, as they indicate the presence of 
	// declarations and not necessarily the presence of implementations.
	//
	// EA_HAVE_mkstemps_DECL
	// EA_HAVE_gettimeofday_DECL
	// EA_HAVE_strcasecmp_DECL
	// EA_HAVE_strncasecmp_DECL
	// EA_HAVE_mmap_DECL
	// EA_HAVE_fopen_DECL
	// EA_HAVE_ISNAN(x)
	// EA_HAVE_ISINF(x)
	// EA_HAVE_itoa_DECL
	// EA_HAVE_nanosleep_DECL
	// EA_HAVE_utime_DECL
	// EA_HAVE_ftruncate_DECL
	// EA_HAVE_localtime_DECL
	// EA_HAVE_pthread_getattr_np_DECL

	#if defined(EA_HAVE_ISNAN)
		EATEST_VERIFY(EA_HAVE_ISNAN(1.f) == 0);
	#endif
	#if defined(EA_HAVE_ISINF)
		EATEST_VERIFY(EA_HAVE_ISINF(1.f) == 0);
	#endif


	// EA_HAVE_XXX_IMPL

	#if defined(EA_HAVE_WCHAR_IMPL)
		size_t wlen = wcslen(L"test");
		EATEST_VERIFY(wlen == 4); // Expect success.
	#endif

	#if defined(EA_HAVE_getenv_IMPL)
		char* p = getenv("nonexistent_asdf");
		EATEST_VERIFY(!p); // Expect failure.
	#endif

	#if defined(EA_HAVE_setenv_IMPL)
		// http://pubs.opengroup.org/onlinepubs/009695399/functions/setenv.html
		// int setenv(const char *envname, const char *envval, int overwrite);
		setenv("test_asdf", "value", 0); // We ignore the return value, as we can't tell if the platform allows it.
	#endif

	#if defined(EA_HAVE_unsetenv_IMPL)
		unsetenv("test_asdf"); // Ignore the return value.
	#endif

	#if defined(EA_HAVE_putenv_IMPL)
		// int putenv(char* string);
		char str[] = "a=b";
		#if defined(EA_PLATFORM_MICROSOFT) && defined(EA_COMPILER_MICROSOFT)
			// Microsoft uses _putenv, while others use putenv.
			int putenvSuccess = _putenv(str);
		#else
			int putenvSuccess = putenv(str);
		#endif
		EATEST_VERIFY(putenvSuccess == 0);
	#endif

	#if defined(EA_HAVE_time_IMPL)
		time_t timeResult = time(NULL);
		EATEST_VERIFY(timeResult != 0); // Expect success.
	#endif

	#if defined(EA_HAVE_clock_IMPL)
		// http://www.cplusplus.com/reference/ctime/clock/ 
		clock_t clockResult = clock();
		EATEST_VERIFY(clockResult != (clock_t) -1); // Expect success.
	#endif

	#if defined(EA_HAVE_fopen_IMPL)
		// We don't have a portable way of testing the success of this, as different platforms have different file systems and requirements.
		// since we want this to fail, we will use a normal Windows path as some platforms /require/ a windows-like mount path else they call abort()
		FILE* pFile = fopen("Q:\\nonexistent_pleasedontexist", "r");
		EATEST_VERIFY(pFile == NULL); // Expect failure.
		if(pFile)
			fclose(pFile);
	#endif

	#if defined(EA_HAVE_inet_ntop_IMPL)
		char inetResult[32];
		const char* pInetNtopResult = inet_ntop(0, "", inetResult, (uint16_t)EAArrayCount(inetResult)); // Cast to uint16_t because different libraries declare this arg differently, and this is a lowest common denominator.
		EATEST_VERIFY(pInetNtopResult == NULL); // Expect failure.
	#endif

	#if defined(EA_HAVE_inet_pton_IMPL)
		char inetPtonResult[32];
		int inetResultVal = inet_pton(0, "", inetPtonResult);
		EATEST_VERIFY(inetResultVal <= 0); // Expect failure.
	#endif

	#if defined(EA_HAVE_clock_gettime_IMPL)
		struct timespec tp;
		int clockGettimeResult = clock_gettime(CLOCK_MONOTONIC, &tp);
		EATEST_VERIFY(clockGettimeResult <= 0); // Expect success or error.
	#endif

	#if defined(EA_HAVE_getcwd_IMPL)
		{
			char cwdBuffer[1];
			char *result = getcwd(cwdBuffer, EAArrayCount(cwdBuffer));
			EA_UNUSED(result);
		}
	#endif

	#if defined(EA_HAVE_tmpnam_IMPL)
		{
			char tmpnamBuffer[L_tmpnam];
			char *result = tmpnam(tmpnamBuffer);
			EA_UNUSED(result);
		}
	#endif

	#if defined(EA_HAVE_nullptr_IMPL)
		// This is exercised elsewhere in this test.
	#endif

	#if defined(EA_HAVE_std_terminate_IMPL)
		if(nErrorCount == INT_MIN) // This is impossible.
			std::terminate();
	#endif

	#if defined(EA_HAVE_CPP11_ITERATOR_IMPL)
		// <iterator>: std::begin, std::end, std::prev, std::next, std::move_iterator.
		#if defined(EA_HAVE_CPP11_INITIALIZER_LIST)
			eastl::vector<int> intArray;
			EATEST_VERIFY(std::begin(intArray) == std::end(intArray));
		#endif

		char charArray[16] = { 0 };
		EATEST_VERIFY(std::begin(charArray) != std::end(charArray));
	#endif

	#if defined(EA_HAVE_CPP11_SMART_POINTER_IMPL)
		// std::weak_ptr, std::shared_ptr, std::unique_ptr, std::bad_weak_ptr
		std::shared_ptr<int>   spInt;
		std::weak_ptr<int>     wpInt;
		std::unique_ptr<int>   upInt;
	  //std::bad_weak_ptr<int> bwpInt;
	#endif

	#if defined(EA_HAVE_CPP11_FUNCTIONAL_IMPL) && !defined(EA_PLATFORM_ANDROID) // Our Android build system is failing to link _1, _2, etc.
		// function, mem_fn, bad_function_call, is_bind_expression, is_placeholder, reference_wrapper, hash, bind, ref, cref.
		// It turns out that all compiler/library combinations that support this also support C++11 auto, so we can use it.

		#if !defined(EA_PLATFORM_ANDROID) // Our Android build system is failing to link _1, _2, etc.
			using namespace std::placeholders; //for _1, _2, _3...

			int  n = 7;
			auto f = std::bind(BindTestFunction, _2, _1, 42, std::cref(n), n);
			f(1, 2, 1001); // 1 is bound by _2, 2 is bound by _1, 1001 is unused

			BindTestStruct bts;
			auto f2 = std::bind(&BindTestStruct::Test, bts, 95, _1);
			f2(5);
		#endif

		std::hash<uint32_t> hash32;
		EATEST_VERIFY(hash32(37) == hash32(37));
	#endif

	#if defined(EA_HAVE_CPP11_EXCEPTION_IMPL)
		// current_exception, rethrow_exception, exception_ptr, make_exception_ptr
		#if !defined(EA_COMPILER_NO_EXCEPTIONS)
			EA_DISABLE_VC_WARNING(4571)

			if(nErrorCount == 9999999) // This will never be true.
			{
				std::exception_ptr ep = std::make_exception_ptr(std::logic_error("logic_error"));

				try {
					std::rethrow_exception(ep);
				} 
				catch (...) {
					ep = std::current_exception();
					std::rethrow_exception(ep);
				}
			}
			EA_RESTORE_VC_WARNING()
		#endif
	#endif

	#if defined(EA_HAVE_CPP11_TYPE_TRAITS)
		// Some form of type traits have been supported by compilers since well before C++11. But C++11 introduced
		// a number of type traits that weren't previously supported by compilers. We require that full C++11 type
		// traits be supported. See the C++11 Standard, section 20.9.2.

		// We currently test a sampling of specific traits that didn't exist in preliminary standard library versions.
		bool ttResult = std::is_nothrow_move_constructible<int>::value;
		EATEST_VERIFY(ttResult);

		ttResult = std::is_standard_layout<int>::value;
		EATEST_VERIFY(ttResult);
	#endif

	return nErrorCount;
}


static int TestEAAlignment()
{
	// This test does a couple of allocations and for each allocation it determines
	// the minimal alignment. If this (local) minimum is less than the global minimum
	// then the global minimum is updated. After all the allocation sizes and iterations
	// it checks this minimum to make sure that the EABase EA_PLATFORM_MIN_MALLOC_ALIGNMENT
	// is at least that number, since you would never want to ask for finer grained 
	// allocations as malloc can't give them.

	int nErrorCount(0);

	const size_t MAX_SIZE = 128;
	const size_t NUM_ITERATIONS = 32;

	size_t minAlignment = MAX_SIZE;

	for(size_t size = 1; size <= MAX_SIZE; ++size)
	{
			
		for(size_t iteration = 0; iteration < NUM_ITERATIONS; ++iteration)
		{
			void* ptr = malloc(size);        
			size_t address = static_cast<size_t>(reinterpret_cast<uintptr_t>(ptr));

			size_t alignment = MAX_SIZE;
				
			do
			{
				if((address & (alignment - 1)) == 0)
				{
					break;
				}
				else
				{
					alignment >>= 1;
				}

			} while(alignment > 0);

			if(alignment < minAlignment)
				minAlignment = alignment;

			free(ptr);
		}
	} 

	EATEST_VERIFY_F(EA_PLATFORM_MIN_MALLOC_ALIGNMENT <= minAlignment,
					"'EA_PLATFORM_MIN_MALLOC_ALIGNMENT=%d' <= 'minAlignment=%d' failure on '%s'",
					EA_PLATFORM_MIN_MALLOC_ALIGNMENT, minAlignment, EA_PLATFORM_DESCRIPTION);

	return nErrorCount;
}




#include <EABase/eastdarg.h>
#include <EAStdC/EASprintf.h>
#include <EAStdC/EAString.h>


static void TestEAStdargReferenceHelp(char* p, va_list_reference args)
{
	EA::StdC::Sprintf(p, "%d", va_arg(args, int));
}

static void TestEAStdargReference(char* p1, char* p2, ...) // Must be called with two ints for ...
{
	va_list args;
	va_start(args, p2);
	TestEAStdargReferenceHelp(p1, args);    // We pass args to TestEAStdargReferenceHelp by reference, which results in args being 
	TestEAStdargReferenceHelp(p2, args);    // modified upon return. So upon this second call args should have used the first int arg.
	va_end(args);
}


static void TestEAStdargCopy(char* p1, char* p2, ...) // Must be called with two ints for ...
{
	va_list args, argsCopy;
	va_start(args, p2);
	va_copy(argsCopy, args);
	EA::StdC::Vsprintf(p1, "%d", args);
	EA::StdC::Vsprintf(p2, "%d", argsCopy);
	va_end(args);
	va_end(argsCopy);
}



static int TestEAStdarg()
{
	int nErrorCount(0);

	// VA_ARG_COUNT
	static_assert(VA_ARG_COUNT()  == 0, "VA_ARG_COUNT()");
	static_assert(VA_ARG_COUNT(1) == 1, "VA_ARG_COUNT(1)");
	static_assert(VA_ARG_COUNT(2, 2) == 2, "VA_ARG_COUNT(2)");
	static_assert(VA_ARG_COUNT(3, 3, 3) == 3, "VA_ARG_COUNT(3)");
	static_assert(VA_ARG_COUNT(4, 4, 4, 4) == 4, "VA_ARG_COUNT(4)");
	static_assert(VA_ARG_COUNT(5, 5, 5, 5, 5) == 5, "VA_ARG_COUNT(5)");


	char buffer1[64];
	char buffer2[64];

	// va_copy
	TestEAStdargCopy(buffer1, buffer2, 17, 99);
	EATEST_VERIFY((EA::StdC::AtoI32(buffer1) == 17) && (EA::StdC::AtoI32(buffer2) == 17));

	// va_list_reference
	TestEAStdargReference(buffer1, buffer2, 17, 99);
	EATEST_VERIFY((EA::StdC::AtoI32(buffer1) == 17) && (EA::StdC::AtoI32(buffer2) == 99));

	return nErrorCount;
}



static int TestEAUnits()
{
	int nErrorCount(0);

	static_assert(EA_BYTE(64) == 64, "SI units mismatch");
	static_assert(EA_BYTE(1000) == 1000, "SI units mismatch");

	static_assert(EA_KILOBYTE(1) != EA_KIBIBYTE(1), "SI units mismatch");
	static_assert(EA_MEGABYTE(1) != EA_MEBIBYTE(1), "SI units mismatch");
	static_assert(EA_GIGABYTE(1) != EA_GIBIBYTE(1), "SI units mismatch");

	static_assert((4 % EA_BYTE(4*10)) == 4, "Order of operations error"); //If unit macros aren't enclosed in parentheses, this will cause order of operation problems in this situation.
	static_assert((4 % EA_MEBIBYTE(4)) == 4, "Order of operations error"); //If unit macros aren't enclosed in parentheses, this will cause order of operation problems in this situation.
#ifndef EA_PROCESSOR_X86
	static_assert(EA_TERABYTE(1) != EA_TEBIBYTE(1), "SI units mismatch");
	static_assert(EA_PETABYTE(1) != EA_PEBIBYTE(1), "SI units mismatch");
	static_assert(EA_EXABYTE(1)  != EA_EXBIBYTE(1), "SI units mismatch");
#endif

	static_assert(EA_KILOBYTE(1) == 1000, "SI units mismatch");
	static_assert(EA_MEGABYTE(2) == EA_KILOBYTE(2) * 1000, "SI units mismatch");
	static_assert(EA_GIGABYTE(3) == EA_MEGABYTE(3) * 1000, "SI units mismatch");
#ifndef EA_PROCESSOR_X86
	static_assert(EA_TERABYTE(4) == EA_GIGABYTE(4) * 1000, "SI units mismatch");
	static_assert(EA_PETABYTE(5) == EA_TERABYTE(5) * 1000, "SI units mismatch");
	static_assert(EA_EXABYTE(6)  == EA_PETABYTE(6) * 1000, "SI units mismatch");
#endif

	static_assert(EA_KIBIBYTE(1) == 1024, "SI units mismatch");
	static_assert(EA_MEBIBYTE(2) == EA_KIBIBYTE(2) * 1024, "SI units mismatch");
	static_assert(EA_GIBIBYTE(3) == EA_MEBIBYTE(3) * 1024, "SI units mismatch");
#ifndef EA_PROCESSOR_X86
	static_assert(EA_TEBIBYTE(4) == EA_GIBIBYTE(4) * 1024, "SI units mismatch");
	static_assert(EA_PEBIBYTE(5) == EA_TEBIBYTE(5) * 1024, "SI units mismatch");
	static_assert(EA_EXBIBYTE(6) == EA_PEBIBYTE(6) * 1024, "SI units mismatch");
#endif

	return nErrorCount;
}



template<typename Int128T, typename MakeInt128T>
static void TestInt128T(MakeInt128T MakeInt128, const char* errorMsg, int& nErrorCount) 
{
	auto VERIFY = [&](bool result) { if(!result) DoError(nErrorCount, errorMsg); }; 
	const auto TestValue = MakeInt128(0x1234567812345678, 0x1234567812345678);
	const Int128T zero = MakeInt128(0, 0);
	const Int128T one = MakeInt128(0, 1);
	const Int128T two = MakeInt128(0, 2);
	const Int128T big = MakeInt128(0x1234567812345678, 0x1234567812345678);;
	const Int128T negative_one = MakeInt128(0xffffffffffffffff, 0xffffffffffffffff);
	const Int128T half_range = MakeInt128(0x0, 0xffffffffffffffff);

	{
		// Int128T a1 = 42.f;
		// Int128T a2 = 42.0f;
		// Int128T a3 = 42;
		// Int128T a4 = 42u;
		// Int128T a5 = 42ul;
		// Int128T a6 = 42ull;
	}

	// default ctor
	{
		{ Int128T a; (void)a; }
		{ Int128T a{}; (void)a; }

		static_assert(eastl::is_trivially_default_constructible_v<Int128T>, "128-bit integer failure");
	}

	// operator-
	{
		VERIFY(negative_one == -one);
	}

	// operator~
	{
		auto not_one = ~one;
		VERIFY(not_one == MakeInt128(0xffffffffffffffff, 0xfffffffffffffffe));
	}

	// operator+
	{
		VERIFY(zero == +zero);
		VERIFY(one  == +one);
		VERIFY(big  == +big);
	}

	// operator+ 
	// operator- 
	// operator* 
	// operator/ 
	// operator% 
	{
		auto i = MakeInt128(42, 42);

		i = i + one;
		VERIFY(i == MakeInt128(42, 43));

		i = i - one;
		VERIFY(i == MakeInt128(42, 42));

		i = i * two;
		VERIFY(i == MakeInt128(84, 84));

		i = i / two;
		VERIFY(i == MakeInt128(42, 42));
	}

	// operator== / operator!=
	{
		VERIFY(TestValue == MakeInt128(0x1234567812345678, 0x1234567812345678));
		VERIFY(TestValue == TestValue);
		VERIFY(MakeInt128(0x1, 0x1) != MakeInt128(0x1, 0x2));
	}

	// operator<
	{
		VERIFY(zero < one);
		VERIFY(one  < two);
		VERIFY(zero < two);
		VERIFY(zero < big);
		VERIFY(one  < big);

		VERIFY(MakeInt128(123, 122) < MakeInt128(123, 123));
		VERIFY(MakeInt128(122, 123) < MakeInt128(123, 123));
	}

	// operator> / operator>=
	{
		VERIFY(TestValue >  MakeInt128(0, 0x1234567812345678));
		VERIFY(TestValue >= MakeInt128(0, 0x1234567812345678));
		VERIFY(TestValue >= TestValue);
		VERIFY(TestValue >= TestValue);
	}

	// operator< / operator<=
	{
		VERIFY(MakeInt128(0, 0x1234567812345678) < TestValue);
		VERIFY(MakeInt128(0, 0x1234567812345678) <= TestValue);
		VERIFY(TestValue <= TestValue);
		VERIFY(TestValue <= TestValue);
	}

	// operator++
	{
		auto i      = MakeInt128(0, 0);
		VERIFY(i++ == MakeInt128(0, 0));
		VERIFY(++i == MakeInt128(0, 2));
		VERIFY(++i == MakeInt128(0, 3));
		VERIFY(i++ == MakeInt128(0, 3));

		{
			auto n1 = half_range;
			VERIFY(++n1 == MakeInt128(1, 0));
		}
	}

	// operator--
	{
		auto i      = MakeInt128(0, 5);
		VERIFY(i-- == MakeInt128(0, 4));
		VERIFY(--i == MakeInt128(0, 4));
		VERIFY(--i == MakeInt128(0, 3));
		VERIFY(i-- == MakeInt128(0, 2));

		{
			auto n1 = MakeInt128(1, 0);
			VERIFY(n1-- == half_range);
		}
	}

	// operator+=
	// operator-=
	// operator*=
	// operator/=	
	// operator%=
	{
		auto n = MakeInt128(0, 5);

		n += MakeInt128(0, 15);
		VERIFY(n == MakeInt128(0, 20));

		n -= MakeInt128(0, 18);
		VERIFY(n == MakeInt128(0, 2));

		n *= MakeInt128(0, 2);
		VERIFY(n == MakeInt128(0, 4));

		n /= MakeInt128(0, 2);
		VERIFY(n == MakeInt128(0, 2));

		n %= MakeInt128(0, 2);
		VERIFY(n == MakeInt128(0, 0));
	}

	// operator>> 
	// operator<< 
	// operator>>=
	// operator<<=
	{
		auto n = MakeInt128(0, 0x4);

		{
			auto a = n >> 1;
			VERIFY(a == MakeInt128(0, 0x2));

			a >>= 1;
			VERIFY(a == MakeInt128(0, 0x1));
		}

		{
			auto a = n << 1;
			VERIFY(a == MakeInt128(0, 0x8));

			a <<= 1;
			VERIFY(a == MakeInt128(0, 0x10));
		}

		{
			auto a = half_range;

			a <<= 1;
			VERIFY(a == MakeInt128(0x1, 0xfffffffffffffffe));
		}

		{
			auto a = half_range;
			a >>= 1;
			VERIFY(a == MakeInt128(0x0, 0x7fffffffffffffff));
		}
	}

	// operator^ 
	// operator| 
	// operator& 
	// operator^=
	// operator|=
	// operator&=
	{
		const auto n1 = MakeInt128(0xAAAAAAAAAAAAAAAA, 0xAAAAAAAAAAAAAAAA);
		const auto n2 = MakeInt128(0x5555555555555555, 0x5555555555555555);

		{
			auto i = n1 ^ n2; 
			VERIFY(i == negative_one);

			auto n3 = n1;
			n3 ^= n2;
			VERIFY(n3 == negative_one);
		}

		{
			auto i = n1 | n2; 
			VERIFY(i == negative_one);

			auto n3 = n1;
			n3 |= n2;
			VERIFY(n3 == negative_one);
		}

		{
			auto i = n1 & n2; 
			VERIFY(i == zero);

			auto n3 = n1;
			n3 &= n2;
			VERIFY(n3 == zero);
		}

	}

	// Test loop counter
	{
		{
			int counter = 0;
			Int128T i = MakeInt128(0,0);

			for (; i < MakeInt128(0,10); i++)
				counter++;

			VERIFY(i == MakeInt128(0, counter));
		}

		{
			// int counter = 0;

			// for (Int128T i = 0; i < 10; i++)
			//     counter++;

			// VERIFY(i == counter);
		}
	}
}



static int TestEAInt128_t()
{
	int nErrorCount(0);

	TestInt128T<uint128_t>(UINT128_C, "uint128_t test failure", nErrorCount);
	TestInt128T<int128_t>(INT128_C, "int128_t test failure", nErrorCount);

	return nErrorCount;
}



// EA_WCHAR_UNIQUE
template <typename T>
struct wchar_unique { enum { value = 1 }; };                        // if wchar_t is unique then wchar_unique<wchar_t>::value should be 1
template <> struct wchar_unique<char8_t> { enum { value = 0 }; };   // if wchar_unique is not unique then it should match one of the specializations and the value will be 0.
template <> struct wchar_unique<char16_t> { enum { value = 0 }; };
template <> struct wchar_unique<char32_t> { enum { value = 0 }; };
#if EA_WCHAR_UNIQUE
	static_assert( wchar_unique<wchar_t>::value == 1, "WCHAR_UNIQUE appears to be incorrectly defined to 1 by EABase" );
#else
	static_assert( wchar_unique<wchar_t>::value == 0, "WCHAR_UNIQUE appears to be incorrectly defined to 0 by EABase" );
#endif


//
// Tests for EA_IS_ENABLED
//
#define EABASE_TEST_FEATURE_A EA_ENABLED
#if EA_IS_ENABLED(EABASE_TEST_FEATURE_A)
	// Feature A is enabled
#else
	#error Error EABASE_TEST_FEATURE_A should be enabled.
#endif
// Make sure it is possible to successfully negate the test.
#if !EA_IS_ENABLED(EABASE_TEST_FEATURE_A)
	#error Error EABASE_TEST_FEATURE_A should be enabled.
#endif

#define EABASE_TEST_FEATURE_B EA_DISABLED
#if EA_IS_ENABLED(EABASE_TEST_FEATURE_B)
	#error Error EABASE_TEST_FEATURE_B should be disabled.
#endif
// Make sure it is possible to successfully negate the test.
#if !EA_IS_ENABLED(EABASE_TEST_FEATURE_B)
	// Feature B is not enabled
#else
	#error Error EABASE_TEST_FEATURE_B should be disabled.
#endif

// The test below should cause compilation to fail if it is uncommented.  However we can't
// obviously enable the test because it will break the build.  It should be tested manually
// if changes to EA_IS_ENABLED are made.
//
//   #if EA_IS_ENABLED(EABASE_TEST_FEATURE_WITH_NO_DEFINE)
//   #endif


int EAMain(int, char**)
{
	int nErrorCount = 0;
	int nTotalErrorCount = 0;


	nErrorCount = TestEABase();
	EA::EAMain::Report("EABase test failure count: %d\n\n", nErrorCount);
	nTotalErrorCount += nErrorCount;

	nErrorCount = TestEAResult();
	EA::EAMain::Report("EAResult test failure count: %d\n\n", nErrorCount);
	nTotalErrorCount += nErrorCount;

	nErrorCount = TestEAPlatform();
	EA::EAMain::Report("EAPlatform test failure count: %d\n\n", nErrorCount);
	nTotalErrorCount += nErrorCount;

	nErrorCount = TestEACompiler();
	EA::EAMain::Report("EACompiler test failure count: %d\n\n", nErrorCount);
	nTotalErrorCount += nErrorCount;

	nErrorCount = TestEACompilerTraits();
	EA::EAMain::Report("EACompilerTraits test failure count: %d\n\n", nErrorCount);
	nTotalErrorCount += nErrorCount;

	nErrorCount = TestNullPtr();
	EA::EAMain::Report("nullptr test failure count: %d\n\n", nErrorCount);
	nTotalErrorCount += nErrorCount;

	nErrorCount = TestEAHave();
	EA::EAMain::Report("EAHave test failure count: %d\n\n", nErrorCount);
	nTotalErrorCount += nErrorCount;

	nErrorCount = TestEAAlignment();
	EA::EAMain::Report("EAAlignment test failure count: %d\n\n", nErrorCount);
	nTotalErrorCount += nErrorCount;

	nErrorCount = TestEAStdarg();
	EA::EAMain::Report("EAStdarg test failure count: %d\n\n", nErrorCount);
	nTotalErrorCount += nErrorCount;

	nErrorCount = TestEAUnits();
	EA::EAMain::Report("EAUnits test failure count: %d\n\n", nErrorCount);
	nTotalErrorCount += nErrorCount;

	nErrorCount = TestEAInt128_t();
	EA::EAMain::Report("EAInt128_t test failure count: %d\n\n", nErrorCount);
	nTotalErrorCount += nErrorCount;


	if (nTotalErrorCount == 0)
		EA::EAMain::Report("\nAll tests completed successfully.\n");
	else
		EA::EAMain::Report("\nTests failed. Total error count: %d\n", nTotalErrorCount);
	
	return nTotalErrorCount;
}

EA_RESTORE_VC_WARNING() // for the following from above: EA_DISABLE_VC_WARNING(4265 4296 4310 4350 4481 4530 4625 4626 4996)