summaryrefslogtreecommitdiff
path: root/src/ints/udl_test.cpp
blob: acb4f760796daf51a2d3c396794c8ab2b1a2f03b (plain) (blame)
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
#include "udl.hpp"
//    udl_test.cpp - Testsuite for a user-defined integer suffixes
//
//    Copyright © 2014 Ben Longbons <b.r.longbons@gmail.com>
//
//    This file is part of The Mana World (Athena server)
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

#include <gtest/gtest.h>

#include "../compat/cast.hpp"

#include "../poison.hpp"

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
TEST(ints, smc)
{
    {
        ints::SignedMagnitudeConstant<false, 0> i;
        (void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        (void)static_cast<uint8_t>(i);
        (void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0> i;
        (void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        (void)static_cast<uint8_t>(i);
        (void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0x7e> i;
        (void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        (void)static_cast<uint8_t>(i);
        (void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0x7e> i;
        (void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0x7f> i;
        (void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        (void)static_cast<uint8_t>(i);
        (void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0x7f> i;
        (void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0x80> i;
        //(void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        (void)static_cast<uint8_t>(i);
        (void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0x80> i;
        (void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0xfe> i;
        //(void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        (void)static_cast<uint8_t>(i);
        (void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0xfe> i;
        //(void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0xff> i;
        //(void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        (void)static_cast<uint8_t>(i);
        (void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0xff> i;
        //(void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false,0x100> i;
        //(void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        (void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true, 0x100> i;
        //(void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0x7ffe> i;
        //(void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        (void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0x7ffe> i;
        //(void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0x7fff> i;
        //(void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        (void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0x7fff> i;
        //(void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0x8000> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        (void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0x8000> i;
        //(void)static_cast<int8_t>(i);
        (void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0xfffe> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        (void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0xfffe> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0xffff> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        (void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0xffff> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false,0x10000> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        //(void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true, 0x10000> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0x7ffffffe> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        //(void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0x7ffffffe> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0x7fffffff> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        //(void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0x7fffffff> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0x80000000> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        //(void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0x80000000> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        (void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0xfffffffe> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        //(void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0xfffffffe> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0xffffffff> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        //(void)static_cast<uint16_t>(i);
        (void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0xffffffff> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false,0x100000000> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        //(void)static_cast<uint16_t>(i);
        //(void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true, 0x100000000> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0x7ffffffffffffffe> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        //(void)static_cast<uint16_t>(i);
        //(void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0x7ffffffffffffffe> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0x7fffffffffffffff> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        //(void)static_cast<uint16_t>(i);
        //(void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0x7fffffffffffffff> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0x8000000000000000> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        //(void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        //(void)static_cast<uint16_t>(i);
        //(void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0x8000000000000000> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        (void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0xfffffffffffffffe> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        //(void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        //(void)static_cast<uint16_t>(i);
        //(void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0xfffffffffffffffe> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        //(void)static_cast<int64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<false, 0xffffffffffffffff> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        //(void)static_cast<int64_t>(i);
        //(void)static_cast<uint8_t>(i);
        //(void)static_cast<uint16_t>(i);
        //(void)static_cast<uint32_t>(i);
        (void)static_cast<uint64_t>(i);
    }
    {
        ints::SignedMagnitudeConstant<true,  0xffffffffffffffff> i;
        //(void)static_cast<int8_t>(i);
        //(void)static_cast<int16_t>(i);
        //(void)static_cast<int32_t>(i);
        //(void)static_cast<int64_t>(i);
    }
    {
        //ints::SignedMagnitudeConstant<false,0x10000000000000000> i;
    }
    {
        //ints::SignedMagnitudeConstant<true, 0x10000000000000000> i;
    }
}
#pragma GCC diagnostic pop

TEST(ints, constant)
{
    // gtest is funny with conversions
    assert(0_const == (ints::SignedMagnitudeConstant<false, 0>{}));
    assert(1_const == (ints::SignedMagnitudeConstant<false, 1>{}));
    assert(1_const == (ints::SignedMagnitudeConstant<false, 1>{}));
}

TEST(ints, udl8)
{
    EXPECT_EQ(0b00000000_u8, maybe_cast<uint8_t>(0b00000000U));
    EXPECT_EQ(0b00000001_u8, maybe_cast<uint8_t>(0b00000001U));
    EXPECT_EQ(0b11111110_u8, maybe_cast<uint8_t>(0b11111110U));
    EXPECT_EQ(0b11111111_u8, maybe_cast<uint8_t>(0b11111111U));
    EXPECT_EQ(-0b10000000_n8, maybe_cast<int8_t>(-0b10000000));
    EXPECT_EQ(-0b01111111_n8, maybe_cast<int8_t>(-0b01111111));
    EXPECT_EQ(-0b00000001_n8, maybe_cast<int8_t>(-0b00000001));
    EXPECT_EQ(+0b00000000_p8, maybe_cast<int8_t>(0b00000000));
    EXPECT_EQ(+0b00000001_p8, maybe_cast<int8_t>(0b00000001));
    EXPECT_EQ(+0b01111110_p8, maybe_cast<int8_t>(0b01111110));
    EXPECT_EQ(+0b01111111_p8, maybe_cast<int8_t>(0b01111111));

    EXPECT_EQ(0B00000000_u8, maybe_cast<uint8_t>(0B00000000U));
    EXPECT_EQ(0B00000001_u8, maybe_cast<uint8_t>(0B00000001U));
    EXPECT_EQ(0B11111110_u8, maybe_cast<uint8_t>(0B11111110U));
    EXPECT_EQ(0B11111111_u8, maybe_cast<uint8_t>(0B11111111U));
    EXPECT_EQ(-0B10000000_n8, maybe_cast<int8_t>(-0B10000000));
    EXPECT_EQ(-0B01111111_n8, maybe_cast<int8_t>(-0B01111111));
    EXPECT_EQ(-0B00000001_n8, maybe_cast<int8_t>(-0B00000001));
    EXPECT_EQ(+0B00000000_p8, maybe_cast<int8_t>(0B00000000));
    EXPECT_EQ(+0B00000001_p8, maybe_cast<int8_t>(0B00000001));
    EXPECT_EQ(+0B01111110_p8, maybe_cast<int8_t>(0B01111110));
    EXPECT_EQ(+0B01111111_p8, maybe_cast<int8_t>(0B01111111));

    EXPECT_EQ(0000_u8, maybe_cast<uint8_t>(0000U));
    EXPECT_EQ(0001_u8, maybe_cast<uint8_t>(0001U));
    EXPECT_EQ(0376_u8, maybe_cast<uint8_t>(0376U));
    EXPECT_EQ(0377_u8, maybe_cast<uint8_t>(0377U));
    EXPECT_EQ(-0200_n8, maybe_cast<int8_t>(-0200));
    EXPECT_EQ(-0177_n8, maybe_cast<int8_t>(-0177));
    EXPECT_EQ(-0001_n8, maybe_cast<int8_t>(-0001));
    EXPECT_EQ(+0000_p8, maybe_cast<int8_t>(0000));
    EXPECT_EQ(+0001_p8, maybe_cast<int8_t>(0001));
    EXPECT_EQ(+0176_p8, maybe_cast<int8_t>(0176));
    EXPECT_EQ(+0177_p8, maybe_cast<int8_t>(0177));

    EXPECT_EQ(0_u8, maybe_cast<uint8_t>(0U));
    EXPECT_EQ(1_u8, maybe_cast<uint8_t>(1U));
    EXPECT_EQ(254_u8, maybe_cast<uint8_t>(254U));
    EXPECT_EQ(255_u8, maybe_cast<uint8_t>(255U));
    EXPECT_EQ(-128_n8, maybe_cast<int8_t>(-128));
    EXPECT_EQ(-127_n8, maybe_cast<int8_t>(-127));
    EXPECT_EQ(-1_n8, maybe_cast<int8_t>(-1));
    EXPECT_EQ(+0_p8, maybe_cast<int8_t>(0));
    EXPECT_EQ(+1_p8, maybe_cast<int8_t>(1));
    EXPECT_EQ(+126_p8, maybe_cast<int8_t>(126));
    EXPECT_EQ(+127_p8, maybe_cast<int8_t>(127));

    EXPECT_EQ(0x00_u8, maybe_cast<uint8_t>(0x00U));
    EXPECT_EQ(0x01_u8, maybe_cast<uint8_t>(0x01U));
    EXPECT_EQ(0xfe_u8, maybe_cast<uint8_t>(0xfeU));
    EXPECT_EQ(0xff_u8, maybe_cast<uint8_t>(0xffU));
    EXPECT_EQ(-0x80_n8, maybe_cast<int8_t>(-0x80));
    EXPECT_EQ(-0x7f_n8, maybe_cast<int8_t>(-0x7f));
    EXPECT_EQ(-0x01_n8, maybe_cast<int8_t>(-0x01));
    EXPECT_EQ(+0x00_p8, maybe_cast<int8_t>(0x00));
    EXPECT_EQ(+0x01_p8, maybe_cast<int8_t>(0x01));
    EXPECT_EQ(+0x7e_p8, maybe_cast<int8_t>(0x7e));
    EXPECT_EQ(+0x7f_p8, maybe_cast<int8_t>(0x7f));

    EXPECT_EQ(0X00_u8, maybe_cast<uint8_t>(0X00U));
    EXPECT_EQ(0X01_u8, maybe_cast<uint8_t>(0X01U));
    EXPECT_EQ(0XFE_u8, maybe_cast<uint8_t>(0XFEU));
    EXPECT_EQ(0XFF_u8, maybe_cast<uint8_t>(0XFFU));
    EXPECT_EQ(-0X80_n8, maybe_cast<int8_t>(-0X80));
    EXPECT_EQ(-0X7F_n8, maybe_cast<int8_t>(-0X7F));
    EXPECT_EQ(-0X01_n8, maybe_cast<int8_t>(-0X01));
    EXPECT_EQ(+0X00_p8, maybe_cast<int8_t>(0X00));
    EXPECT_EQ(+0X01_p8, maybe_cast<int8_t>(0X01));
    EXPECT_EQ(+0X7E_p8, maybe_cast<int8_t>(0X7E));
    EXPECT_EQ(+0X7F_p8, maybe_cast<int8_t>(0X7F));
}

TEST(ints, udl16)
{
    EXPECT_EQ(0b0000000000000000_u16, maybe_cast<uint16_t>(0b0000000000000000U));
    EXPECT_EQ(0b0000000000000001_u16, maybe_cast<uint16_t>(0b0000000000000001U));
    EXPECT_EQ(0b1111111111111110_u16, maybe_cast<uint16_t>(0b1111111111111110U));
    EXPECT_EQ(0b1111111111111111_u16, maybe_cast<uint16_t>(0b1111111111111111U));
    EXPECT_EQ(-0b1000000000000000_n16, maybe_cast<int16_t>(-0b1000000000000000));
    EXPECT_EQ(-0b0111111111111111_n16, maybe_cast<int16_t>(-0b0111111111111111));
    EXPECT_EQ(-0b0000000000000001_n16, maybe_cast<int16_t>(-0b0000000000000001));
    EXPECT_EQ(+0b0000000000000000_p16, maybe_cast<int16_t>(0b0000000000000000));
    EXPECT_EQ(+0b0000000000000001_p16, maybe_cast<int16_t>(0b0000000000000001));
    EXPECT_EQ(+0b0111111111111110_p16, maybe_cast<int16_t>(0b0111111111111110));
    EXPECT_EQ(+0b0111111111111111_p16, maybe_cast<int16_t>(0b0111111111111111));

    EXPECT_EQ(0B0000000000000000_u16, maybe_cast<uint16_t>(0B0000000000000000U));
    EXPECT_EQ(0B0000000000000001_u16, maybe_cast<uint16_t>(0B0000000000000001U));
    EXPECT_EQ(0B1111111111111110_u16, maybe_cast<uint16_t>(0B1111111111111110U));
    EXPECT_EQ(0B1111111111111111_u16, maybe_cast<uint16_t>(0B1111111111111111U));
    EXPECT_EQ(-0B1000000000000000_n16, maybe_cast<int16_t>(-0B1000000000000000));
    EXPECT_EQ(-0B0111111111111111_n16, maybe_cast<int16_t>(-0B0111111111111111));
    EXPECT_EQ(-0B0000000000000001_n16, maybe_cast<int16_t>(-0B0000000000000001));
    EXPECT_EQ(+0B0000000000000000_p16, maybe_cast<int16_t>(0B0000000000000000));
    EXPECT_EQ(+0B0000000000000001_p16, maybe_cast<int16_t>(0B0000000000000001));
    EXPECT_EQ(+0B0111111111111110_p16, maybe_cast<int16_t>(0B0111111111111110));
    EXPECT_EQ(+0B0111111111111111_p16, maybe_cast<int16_t>(0B0111111111111111));

    EXPECT_EQ(0000000_u16, maybe_cast<uint16_t>(0000000U));
    EXPECT_EQ(0000001_u16, maybe_cast<uint16_t>(0000001U));
    EXPECT_EQ(0177776_u16, maybe_cast<uint16_t>(0177776U));
    EXPECT_EQ(0177777_u16, maybe_cast<uint16_t>(0177777U));
    EXPECT_EQ(-0100000_n16, maybe_cast<int16_t>(-0100000));
    EXPECT_EQ(-0077777_n16, maybe_cast<int16_t>(-0077777));
    EXPECT_EQ(-0000001_n16, maybe_cast<int16_t>(-0000001));
    EXPECT_EQ(+000000_p16, maybe_cast<int16_t>(000000));
    EXPECT_EQ(+000001_p16, maybe_cast<int16_t>(000001));
    EXPECT_EQ(+077776_p16, maybe_cast<int16_t>(077776));
    EXPECT_EQ(+077777_p16, maybe_cast<int16_t>(077777));

    EXPECT_EQ(0_u16, maybe_cast<uint16_t>(0U));
    EXPECT_EQ(1_u16, maybe_cast<uint16_t>(1U));
    EXPECT_EQ(65534_u16, maybe_cast<uint16_t>(65534U));
    EXPECT_EQ(65535_u16, maybe_cast<uint16_t>(65535U));
    EXPECT_EQ(-32768_n16, maybe_cast<int16_t>(-32768));
    EXPECT_EQ(-32767_n16, maybe_cast<int16_t>(-32767));
    EXPECT_EQ(-1_n16, maybe_cast<int16_t>(-1));
    EXPECT_EQ(+0_p16, maybe_cast<int16_t>(0));
    EXPECT_EQ(+1_p16, maybe_cast<int16_t>(1));
    EXPECT_EQ(+32766_p16, maybe_cast<int16_t>(32766));
    EXPECT_EQ(+32767_p16, maybe_cast<int16_t>(32767));

    EXPECT_EQ(0x0000_u16, maybe_cast<uint16_t>(0x0000U));
    EXPECT_EQ(0x0001_u16, maybe_cast<uint16_t>(0x0001U));
    EXPECT_EQ(0xfffe_u16, maybe_cast<uint16_t>(0xfffeU));
    EXPECT_EQ(0xffff_u16, maybe_cast<uint16_t>(0xffffU));
    EXPECT_EQ(-0x8000_n16, maybe_cast<int16_t>(-0x8000));
    EXPECT_EQ(-0x7fff_n16, maybe_cast<int16_t>(-0x7fff));
    EXPECT_EQ(-0x0001_n16, maybe_cast<int16_t>(-0x0001));
    EXPECT_EQ(+0x0000_p16, maybe_cast<int16_t>(0x0000));
    EXPECT_EQ(+0x0001_p16, maybe_cast<int16_t>(0x0001));
    EXPECT_EQ(+0x7ffe_p16, maybe_cast<int16_t>(0x7ffe));
    EXPECT_EQ(+0x7fff_p16, maybe_cast<int16_t>(0x7fff));

    EXPECT_EQ(0X0000_u16, maybe_cast<uint16_t>(0X0000U));
    EXPECT_EQ(0X0001_u16, maybe_cast<uint16_t>(0X0001U));
    EXPECT_EQ(0XFFFE_u16, maybe_cast<uint16_t>(0XFFFEU));
    EXPECT_EQ(0XFFFF_u16, maybe_cast<uint16_t>(0XFFFFU));
    EXPECT_EQ(-0X8000_n16, maybe_cast<int16_t>(-0X8000));
    EXPECT_EQ(-0X7FFF_n16, maybe_cast<int16_t>(-0X7FFF));
    EXPECT_EQ(-0X0001_n16, maybe_cast<int16_t>(-0X0001));
    EXPECT_EQ(+0X0000_p16, maybe_cast<int16_t>(0X0000));
    EXPECT_EQ(+0X0001_p16, maybe_cast<int16_t>(0X0001));
    EXPECT_EQ(+0X7FFE_p16, maybe_cast<int16_t>(0X7FFE));
    EXPECT_EQ(+0X7FFF_p16, maybe_cast<int16_t>(0X7FFF));
}

TEST(ints, udl32)
{
    EXPECT_EQ(0b00000000000000000000000000000000_u32, maybe_cast<uint32_t>(0b00000000000000000000000000000000U));
    EXPECT_EQ(0b00000000000000000000000000000001_u32, maybe_cast<uint32_t>(0b00000000000000000000000000000001U));
    EXPECT_EQ(0b11111111111111111111111111111110_u32, maybe_cast<uint32_t>(0b11111111111111111111111111111110U));
    EXPECT_EQ(0b11111111111111111111111111111111_u32, maybe_cast<uint32_t>(0b11111111111111111111111111111111U));
    EXPECT_EQ(-0b10000000000000000000000000000000_n32, maybe_cast<int32_t>(-0b10000000000000000000000000000000));
    EXPECT_EQ(-0b01111111111111111111111111111111_n32, maybe_cast<int32_t>(-0b01111111111111111111111111111111));
    EXPECT_EQ(-0b00000000000000000000000000000001_n32, maybe_cast<int32_t>(-0b00000000000000000000000000000001));
    EXPECT_EQ(+0b00000000000000000000000000000000_p32, maybe_cast<int32_t>(0b00000000000000000000000000000000));
    EXPECT_EQ(+0b00000000000000000000000000000001_p32, maybe_cast<int32_t>(0b00000000000000000000000000000001));
    EXPECT_EQ(+0b01111111111111111111111111111110_p32, maybe_cast<int32_t>(0b01111111111111111111111111111110));
    EXPECT_EQ(+0b01111111111111111111111111111111_p32, maybe_cast<int32_t>(0b01111111111111111111111111111111));

    EXPECT_EQ(0B00000000000000000000000000000000_u32, maybe_cast<uint32_t>(0B00000000000000000000000000000000U));
    EXPECT_EQ(0B00000000000000000000000000000001_u32, maybe_cast<uint32_t>(0B00000000000000000000000000000001U));
    EXPECT_EQ(0B11111111111111111111111111111110_u32, maybe_cast<uint32_t>(0B11111111111111111111111111111110U));
    EXPECT_EQ(0B11111111111111111111111111111111_u32, maybe_cast<uint32_t>(0B11111111111111111111111111111111U));
    EXPECT_EQ(-0B10000000000000000000000000000000_n32, maybe_cast<int32_t>(-0B10000000000000000000000000000000));
    EXPECT_EQ(-0B01111111111111111111111111111111_n32, maybe_cast<int32_t>(-0B01111111111111111111111111111111));
    EXPECT_EQ(-0B00000000000000000000000000000001_n32, maybe_cast<int32_t>(-0B00000000000000000000000000000001));
    EXPECT_EQ(+0B00000000000000000000000000000000_p32, maybe_cast<int32_t>(0B00000000000000000000000000000000));
    EXPECT_EQ(+0B00000000000000000000000000000001_p32, maybe_cast<int32_t>(0B00000000000000000000000000000001));
    EXPECT_EQ(+0B01111111111111111111111111111110_p32, maybe_cast<int32_t>(0B01111111111111111111111111111110));
    EXPECT_EQ(+0B01111111111111111111111111111111_p32, maybe_cast<int32_t>(0B01111111111111111111111111111111));

    EXPECT_EQ(000000000000_u32, maybe_cast<uint32_t>(000000000000U));
    EXPECT_EQ(000000000001_u32, maybe_cast<uint32_t>(000000000001U));
    EXPECT_EQ(037777777776_u32, maybe_cast<uint32_t>(037777777776U));
    EXPECT_EQ(037777777777_u32, maybe_cast<uint32_t>(037777777777U));
    EXPECT_EQ(-020000000000_n32, maybe_cast<int32_t>(-020000000000));
    EXPECT_EQ(-017777777777_n32, maybe_cast<int32_t>(-017777777777));
    EXPECT_EQ(-000000000001_n32, maybe_cast<int32_t>(-000000000001));
    EXPECT_EQ(+000000000000_p32, maybe_cast<int32_t>(000000000000));
    EXPECT_EQ(+000000000001_p32, maybe_cast<int32_t>(000000000001));
    EXPECT_EQ(+017777777776_p32, maybe_cast<int32_t>(017777777776));
    EXPECT_EQ(+017777777777_p32, maybe_cast<int32_t>(017777777777));

    EXPECT_EQ(0_u32, maybe_cast<uint32_t>(0U));
    EXPECT_EQ(1_u32, maybe_cast<uint32_t>(1U));
    EXPECT_EQ(4294967294_u32, maybe_cast<uint32_t>(4294967294U));
    EXPECT_EQ(4294967295_u32, maybe_cast<uint32_t>(4294967295U));
    EXPECT_EQ(-2147483648_n32, maybe_cast<int32_t>(-2147483648));
    EXPECT_EQ(-2147483647_n32, maybe_cast<int32_t>(-2147483647));
    EXPECT_EQ(-1_n32, maybe_cast<int32_t>(-1));
    EXPECT_EQ(+0_p32, maybe_cast<int32_t>(0));
    EXPECT_EQ(+1_p32, maybe_cast<int32_t>(1));
    EXPECT_EQ(+2147483646_p32, maybe_cast<int32_t>(2147483646));
    EXPECT_EQ(+2147483647_p32, maybe_cast<int32_t>(2147483647));

    EXPECT_EQ(0x00000000_u32, maybe_cast<uint32_t>(0x00000000U));
    EXPECT_EQ(0x00000001_u32, maybe_cast<uint32_t>(0x00000001U));
    EXPECT_EQ(0xfffffffe_u32, maybe_cast<uint32_t>(0xfffffffeU));
    EXPECT_EQ(0xffffffff_u32, maybe_cast<uint32_t>(0xffffffffU));
    EXPECT_EQ(-0x80000000_n32, maybe_cast<int32_t>(-0x80000000));
    EXPECT_EQ(-0x7fffffff_n32, maybe_cast<int32_t>(-0x7fffffff));
    EXPECT_EQ(-0x00000001_n32, maybe_cast<int32_t>(-0x00000001));
    EXPECT_EQ(+0x00000000_p32, maybe_cast<int32_t>(0x00000000));
    EXPECT_EQ(+0x00000001_p32, maybe_cast<int32_t>(0x00000001));
    EXPECT_EQ(+0x7ffffffe_p32, maybe_cast<int32_t>(0x7ffffffe));
    EXPECT_EQ(+0x7fffffff_p32, maybe_cast<int32_t>(0x7fffffff));

    EXPECT_EQ(0X00000000_u32, maybe_cast<uint32_t>(0X00000000U));
    EXPECT_EQ(0X00000001_u32, maybe_cast<uint32_t>(0X00000001U));
    EXPECT_EQ(0XFFFFFFFE_u32, maybe_cast<uint32_t>(0XFFFFFFFEU));
    EXPECT_EQ(0XFFFFFFFF_u32, maybe_cast<uint32_t>(0XFFFFFFFFU));
    EXPECT_EQ(-0X80000000_n32, maybe_cast<int32_t>(-0X80000000));
    EXPECT_EQ(-0X7FFFFFFF_n32, maybe_cast<int32_t>(-0X7FFFFFFF));
    EXPECT_EQ(-0X00000001_n32, maybe_cast<int32_t>(-0X00000001));
    EXPECT_EQ(+0X00000000_p32, maybe_cast<int32_t>(0X00000000));
    EXPECT_EQ(+0X00000001_p32, maybe_cast<int32_t>(0X00000001));
    EXPECT_EQ(+0X7FFFFFFE_p32, maybe_cast<int32_t>(0X7FFFFFFE));
    EXPECT_EQ(+0X7FFFFFFF_p32, maybe_cast<int32_t>(0X7FFFFFFF));
}

TEST(ints, udl64)
{
    EXPECT_EQ(0b0000000000000000000000000000000000000000000000000000000000000000_u64, maybe_cast<uint64_t>(0b0000000000000000000000000000000000000000000000000000000000000000U));
    EXPECT_EQ(0b0000000000000000000000000000000000000000000000000000000000000001_u64, maybe_cast<uint64_t>(0b0000000000000000000000000000000000000000000000000000000000000001U));
    EXPECT_EQ(0b1111111111111111111111111111111111111111111111111111111111111110_u64, maybe_cast<uint64_t>(0b1111111111111111111111111111111111111111111111111111111111111110U));
    EXPECT_EQ(0b1111111111111111111111111111111111111111111111111111111111111111_u64, maybe_cast<uint64_t>(0b1111111111111111111111111111111111111111111111111111111111111111U));
    EXPECT_EQ(-0b1000000000000000000000000000000000000000000000000000000000000000_n64, maybe_cast<int64_t>(-0b1000000000000000000000000000000000000000000000000000000000000000));
    EXPECT_EQ(-0b0111111111111111111111111111111111111111111111111111111111111111_n64, maybe_cast<int64_t>(-0b0111111111111111111111111111111111111111111111111111111111111111));
    EXPECT_EQ(-0b0000000000000000000000000000000000000000000000000000000000000001_n64, maybe_cast<int64_t>(-0b0000000000000000000000000000000000000000000000000000000000000001));
    EXPECT_EQ(+0b0000000000000000000000000000000000000000000000000000000000000000_p64, maybe_cast<int64_t>(0b0000000000000000000000000000000000000000000000000000000000000000));
    EXPECT_EQ(+0b0000000000000000000000000000000000000000000000000000000000000001_p64, maybe_cast<int64_t>(0b0000000000000000000000000000000000000000000000000000000000000001));
    EXPECT_EQ(+0b0111111111111111111111111111111111111111111111111111111111111110_p64, maybe_cast<int64_t>(0b0111111111111111111111111111111111111111111111111111111111111110));
    EXPECT_EQ(+0b0111111111111111111111111111111111111111111111111111111111111111_p64, maybe_cast<int64_t>(0b0111111111111111111111111111111111111111111111111111111111111111));

    EXPECT_EQ(0B0000000000000000000000000000000000000000000000000000000000000000_u64, maybe_cast<uint64_t>(0B0000000000000000000000000000000000000000000000000000000000000000U));
    EXPECT_EQ(0B0000000000000000000000000000000000000000000000000000000000000001_u64, maybe_cast<uint64_t>(0B0000000000000000000000000000000000000000000000000000000000000001U));
    EXPECT_EQ(0B1111111111111111111111111111111111111111111111111111111111111110_u64, maybe_cast<uint64_t>(0B1111111111111111111111111111111111111111111111111111111111111110U));
    EXPECT_EQ(0B1111111111111111111111111111111111111111111111111111111111111111_u64, maybe_cast<uint64_t>(0B1111111111111111111111111111111111111111111111111111111111111111U));
    EXPECT_EQ(-0B1000000000000000000000000000000000000000000000000000000000000000_n64, maybe_cast<int64_t>(-0B1000000000000000000000000000000000000000000000000000000000000000));
    EXPECT_EQ(-0B0111111111111111111111111111111111111111111111111111111111111111_n64, maybe_cast<int64_t>(-0B0111111111111111111111111111111111111111111111111111111111111111));
    EXPECT_EQ(-0B0000000000000000000000000000000000000000000000000000000000000001_n64, maybe_cast<int64_t>(-0B0000000000000000000000000000000000000000000000000000000000000001));
    EXPECT_EQ(+0B0000000000000000000000000000000000000000000000000000000000000000_p64, maybe_cast<int64_t>(0B0000000000000000000000000000000000000000000000000000000000000000));
    EXPECT_EQ(+0B0000000000000000000000000000000000000000000000000000000000000001_p64, maybe_cast<int64_t>(0B0000000000000000000000000000000000000000000000000000000000000001));
    EXPECT_EQ(+0B0111111111111111111111111111111111111111111111111111111111111110_p64, maybe_cast<int64_t>(0B0111111111111111111111111111111111111111111111111111111111111110));
    EXPECT_EQ(+0B0111111111111111111111111111111111111111111111111111111111111111_p64, maybe_cast<int64_t>(0B0111111111111111111111111111111111111111111111111111111111111111));

    EXPECT_EQ(00000000000000000000000_u64, maybe_cast<uint64_t>(00000000000000000000000U));
    EXPECT_EQ(00000000000000000000001_u64, maybe_cast<uint64_t>(00000000000000000000001U));
    EXPECT_EQ(01777777777777777777776_u64, maybe_cast<uint64_t>(01777777777777777777776U));
    EXPECT_EQ(01777777777777777777777_u64, maybe_cast<uint64_t>(01777777777777777777777U));
    EXPECT_EQ(-01000000000000000000000_n64, maybe_cast<int64_t>(-01000000000000000000000));
    EXPECT_EQ(-00777777777777777777777_n64, maybe_cast<int64_t>(-00777777777777777777777));
    EXPECT_EQ(-00000000000000000000001_n64, maybe_cast<int64_t>(-000000000000000000000001));
    EXPECT_EQ(+0000000000000000000000_p64, maybe_cast<int64_t>(0000000000000000000000));
    EXPECT_EQ(+0000000000000000000001_p64, maybe_cast<int64_t>(0000000000000000000001));
    EXPECT_EQ(+0777777777777777777776_p64, maybe_cast<int64_t>(0777777777777777777776));
    EXPECT_EQ(+0777777777777777777777_p64, maybe_cast<int64_t>(0777777777777777777777));

    EXPECT_EQ(0_u64, maybe_cast<uint64_t>(0U));
    EXPECT_EQ(1_u64, maybe_cast<uint64_t>(1U));
    EXPECT_EQ(18446744073709551614_u64, maybe_cast<uint64_t>(18446744073709551614U));
    EXPECT_EQ(18446744073709551615_u64, maybe_cast<uint64_t>(18446744073709551615U));
    EXPECT_EQ(-9223372036854775808_n64, maybe_cast<int64_t>(-9223372036854775808U));
    EXPECT_EQ(-9223372036854775807_n64, maybe_cast<int64_t>(-9223372036854775807));
    EXPECT_EQ(-1_n64, maybe_cast<int64_t>(-1));
    EXPECT_EQ(+0_p64, maybe_cast<int64_t>(0));
    EXPECT_EQ(+1_p64, maybe_cast<int64_t>(1));
    EXPECT_EQ(+9223372036854775806_p64, maybe_cast<int64_t>(9223372036854775806));
    EXPECT_EQ(+9223372036854775807_p64, maybe_cast<int64_t>(9223372036854775807));

    EXPECT_EQ(0x0000000000000000_u64, maybe_cast<uint64_t>(0x0000000000000000U));
    EXPECT_EQ(0x0000000000000001_u64, maybe_cast<uint64_t>(0x0000000000000001U));
    EXPECT_EQ(0xfffffffffffffffe_u64, maybe_cast<uint64_t>(0xfffffffffffffffeU));
    EXPECT_EQ(0xffffffffffffffff_u64, maybe_cast<uint64_t>(0xffffffffffffffffU));
    EXPECT_EQ(-0x8000000000000000_n64, maybe_cast<int64_t>(-0x8000000000000000));
    EXPECT_EQ(-0x7fffffffffffffff_n64, maybe_cast<int64_t>(-0x7fffffffffffffff));
    EXPECT_EQ(-0x0000000000000001_n64, maybe_cast<int64_t>(-0x0000000000000001));
    EXPECT_EQ(+0x0000000000000000_p64, maybe_cast<int64_t>(0x0000000000000000));
    EXPECT_EQ(+0x0000000000000001_p64, maybe_cast<int64_t>(0x0000000000000001));
    EXPECT_EQ(+0x7ffffffffffffffe_p64, maybe_cast<int64_t>(0x7ffffffffffffffe));
    EXPECT_EQ(+0x7fffffffffffffff_p64, maybe_cast<int64_t>(0x7fffffffffffffff));

    EXPECT_EQ(0X0000000000000000_u64, maybe_cast<uint64_t>(0X0000000000000000U));
    EXPECT_EQ(0X0000000000000001_u64, maybe_cast<uint64_t>(0X0000000000000001U));
    EXPECT_EQ(0XFFFFFFFFFFFFFFFE_u64, maybe_cast<uint64_t>(0XFFFFFFFFFFFFFFFEU));
    EXPECT_EQ(0XFFFFFFFFFFFFFFFF_u64, maybe_cast<uint64_t>(0XFFFFFFFFFFFFFFFFU));
    EXPECT_EQ(-0X8000000000000000_n64, maybe_cast<int64_t>(-0X8000000000000000));
    EXPECT_EQ(-0X7FFFFFFFFFFFFFFF_n64, maybe_cast<int64_t>(-0X7FFFFFFFFFFFFFFF));
    EXPECT_EQ(-0X0000000000000001_n64, maybe_cast<int64_t>(-0X0000000000000001));
    EXPECT_EQ(+0X0000000000000000_p64, maybe_cast<int64_t>(0X0000000000000000));
    EXPECT_EQ(+0X0000000000000001_p64, maybe_cast<int64_t>(0X0000000000000001));
    EXPECT_EQ(+0X7FFFFFFFFFFFFFFE_p64, maybe_cast<int64_t>(0X7FFFFFFFFFFFFFFE));
    EXPECT_EQ(+0X7FFFFFFFFFFFFFFF_p64, maybe_cast<int64_t>(0X7FFFFFFFFFFFFFFF));
}