@@ -23,62 +23,95 @@ class ConjTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
2323public:
2424 typedef CFPT (*ConjFunc)(CFPT);
2525
26- void testSpecialNumbers (ConjFunc func) {
26+ void testSpecialNumbers (ConjFunc func) {
2727 EXPECT_CFP_EQ (func (CFPT (aNaN + 67 .123i)), CFPT (aNaN - 67 .123i));
2828 EXPECT_CFP_EQ (func (CFPT (neg_aNaN + 78 .319i)), CFPT (neg_aNaN - 78 .319i));
2929 EXPECT_CFP_EQ (func (CFPT (sNaN + 7813 .131i)), CFPT (sNaN - 7813 .131i));
3030 EXPECT_CFP_EQ (func (CFPT (neg_sNaN + 7824 .152i)), CFPT (neg_sNaN - 7824 .152i));
3131 EXPECT_CFP_EQ (func (CFPT (inf + 9024 .2442i)), CFPT (inf - 9024 .2442i));
3232 EXPECT_CFP_EQ (func (CFPT (neg_inf + 8923 .124i)), CFPT (neg_inf - 8923 .124i));
33- EXPECT_CFP_EQ (func (CFPT (min_normal + 782 .124i)), CFPT (min_normal - 782 .124i));
34- EXPECT_CFP_EQ (func (CFPT (max_normal + 2141 .2352i)), CFPT (max_normal - 2141 .2352i));
35- EXPECT_CFP_EQ (func (CFPT (neg_max_normal + 341 .134i)), CFPT (neg_max_normal - 341 .134i));
36- EXPECT_CFP_EQ (func (CFPT (min_denormal + 781 .142i)), CFPT (min_denormal - 781 .142i));
37- EXPECT_CFP_EQ (func (CFPT (neg_min_denormal + 781 .134i)), CFPT (neg_min_denormal - 781 .134i));
38- EXPECT_CFP_EQ (func (CFPT (max_denormal + 1241 .112i)), CFPT (max_denormal - 1241 .112i));
33+ EXPECT_CFP_EQ (func (CFPT (min_normal + 782 .124i)),
34+ CFPT (min_normal - 782 .124i));
35+ EXPECT_CFP_EQ (func (CFPT (max_normal + 2141 .2352i)),
36+ CFPT (max_normal - 2141 .2352i));
37+ EXPECT_CFP_EQ (func (CFPT (neg_max_normal + 341 .134i)),
38+ CFPT (neg_max_normal - 341 .134i));
39+ EXPECT_CFP_EQ (func (CFPT (min_denormal + 781 .142i)),
40+ CFPT (min_denormal - 781 .142i));
41+ EXPECT_CFP_EQ (func (CFPT (neg_min_denormal + 781 .134i)),
42+ CFPT (neg_min_denormal - 781 .134i));
43+ EXPECT_CFP_EQ (func (CFPT (max_denormal + 1241 .112i)),
44+ CFPT (max_denormal - 1241 .112i));
3945 EXPECT_CFP_EQ (func (CFPT (zero + 121 .121i)), CFPT (zero - 121 .121i));
4046 EXPECT_CFP_EQ (func (CFPT (67.123 + aNaN * 1 .0i)), CFPT (67.123 - aNaN * 1 .0i));
41- EXPECT_CFP_EQ (func (CFPT (78.319 + neg_aNaN * 1 .0i)), CFPT (78.319 - neg_aNaN * 1 .0i));
42- EXPECT_CFP_EQ (func (CFPT (7813.131 + sNaN * 1 .0i)), CFPT (7813.131 - sNaN * 1 .0i));
43- EXPECT_CFP_EQ (func (CFPT (7824.152 + neg_sNaN * 1 .0i)), CFPT (7824.152 - neg_sNaN * 1 .0i));
44- EXPECT_CFP_EQ (func (CFPT (9024.2442 + inf * 1 .0i)), CFPT (9024.2442 - inf * 1 .0i));
45- EXPECT_CFP_EQ (func (CFPT (8923.124 + neg_inf * 1 .0i)), CFPT (8923.124 - neg_inf * 1 .0i));
46- EXPECT_CFP_EQ (func (CFPT (782.124 + min_normal * 1 .0i)), CFPT (782.124 - min_normal * 1 .0i));
47- EXPECT_CFP_EQ (func (CFPT (2141.2352 + max_normal * 1 .0i)), CFPT (2141.2352 - max_normal * 1 .0i));
48- EXPECT_CFP_EQ (func (CFPT (341.134 + neg_max_normal * 1 .0i)), CFPT (341.134 - neg_max_normal * 1 .0i));
49- EXPECT_CFP_EQ (func (CFPT (781.142 + min_denormal * 1 .0i)), CFPT (781.142 - min_denormal * 1 .0i));
50- EXPECT_CFP_EQ (func (CFPT (781.134 + neg_min_denormal * 1 .0i)), CFPT (781.134 - neg_min_denormal * 1 .0i));
51- EXPECT_CFP_EQ (func (CFPT (1241.112 + max_denormal * 1 .0i)), CFPT (1241.112 - max_denormal * 1 .0i));
52- EXPECT_CFP_EQ (func (CFPT (121.121 + zero * 1 .0i)), CFPT (121.121 - zero * 1 .0i));
47+ EXPECT_CFP_EQ (func (CFPT (78.319 + neg_aNaN * 1 .0i)),
48+ CFPT (78.319 - neg_aNaN * 1 .0i));
49+ EXPECT_CFP_EQ (func (CFPT (7813.131 + sNaN * 1 .0i)),
50+ CFPT (7813.131 - sNaN * 1 .0i));
51+ EXPECT_CFP_EQ (func (CFPT (7824.152 + neg_sNaN * 1 .0i)),
52+ CFPT (7824.152 - neg_sNaN * 1 .0i));
53+ EXPECT_CFP_EQ (func (CFPT (9024.2442 + inf * 1 .0i)),
54+ CFPT (9024.2442 - inf * 1 .0i));
55+ EXPECT_CFP_EQ (func (CFPT (8923.124 + neg_inf * 1 .0i)),
56+ CFPT (8923.124 - neg_inf * 1 .0i));
57+ EXPECT_CFP_EQ (func (CFPT (782.124 + min_normal * 1 .0i)),
58+ CFPT (782.124 - min_normal * 1 .0i));
59+ EXPECT_CFP_EQ (func (CFPT (2141.2352 + max_normal * 1 .0i)),
60+ CFPT (2141.2352 - max_normal * 1 .0i));
61+ EXPECT_CFP_EQ (func (CFPT (341.134 + neg_max_normal * 1 .0i)),
62+ CFPT (341.134 - neg_max_normal * 1 .0i));
63+ EXPECT_CFP_EQ (func (CFPT (781.142 + min_denormal * 1 .0i)),
64+ CFPT (781.142 - min_denormal * 1 .0i));
65+ EXPECT_CFP_EQ (func (CFPT (781.134 + neg_min_denormal * 1 .0i)),
66+ CFPT (781.134 - neg_min_denormal * 1 .0i));
67+ EXPECT_CFP_EQ (func (CFPT (1241.112 + max_denormal * 1 .0i)),
68+ CFPT (1241.112 - max_denormal * 1 .0i));
69+ EXPECT_CFP_EQ (func (CFPT (121.121 + zero * 1 .0i)),
70+ CFPT (121.121 - zero * 1 .0i));
5371 EXPECT_CFP_EQ (func (CFPT (0.0 - 0 .0i)), CFPT (0.0 + 0 .0i));
5472 EXPECT_CFP_EQ (func (CFPT (0.0 + 0 .0i)), CFPT (0.0 - 0 .0i));
5573 EXPECT_CFP_EQ (func (CFPT (-0.0 - 0 .0i)), CFPT (-0.0 + 0 .0i));
5674 // This test passes because -0.0 + 0.0i is actually
5775 // CMPLX(-0.0, 0.0) + CMPLX(0.0, 0.0) = CMPLX(-0.0 + 0.0, 0.0) = 0.0 + 0.0i
5876 EXPECT_CFP_EQ (func (CFPT (-0.0 + 0 .0i)), CFPT (0.0 - 0 .0i));
59-
60- }
77+ }
6178
6279 void testRoundedNumbers (ConjFunc func) {
63- EXPECT_CFP_EQ (func ((CFPT)(4523.1413 + 12413 .1414i)), CFPT (4523.1413 - 12413 .1414i));
64- EXPECT_CFP_EQ (func ((CFPT)(-4523.1413 + 12413 .1414i)), CFPT (-4523.1413 - 12413 .1414i));
65- EXPECT_CFP_EQ (func ((CFPT)(4523.1413 - 12413 .1414i)), CFPT (4523.1413 + 12413 .1414i));
66- EXPECT_CFP_EQ (func ((CFPT)(-4523.1413 - 12413 .1414i)), CFPT (-4523.1413 + 12413 .1414i));
80+ EXPECT_CFP_EQ (func ((CFPT)(4523.1413 + 12413 .1414i)),
81+ CFPT (4523.1413 - 12413 .1414i));
82+ EXPECT_CFP_EQ (func ((CFPT)(-4523.1413 + 12413 .1414i)),
83+ CFPT (-4523.1413 - 12413 .1414i));
84+ EXPECT_CFP_EQ (func ((CFPT)(4523.1413 - 12413 .1414i)),
85+ CFPT (4523.1413 + 12413 .1414i));
86+ EXPECT_CFP_EQ (func ((CFPT)(-4523.1413 - 12413 .1414i)),
87+ CFPT (-4523.1413 + 12413 .1414i));
6788
68- EXPECT_CFP_EQ (func ((CFPT)(3210.5678 + 9876 .5432i)), CFPT (3210.5678 - 9876 .5432i));
69- EXPECT_CFP_EQ (func ((CFPT)(-3210.5678 + 9876 .5432i)), CFPT (-3210.5678 - 9876 .5432i));
70- EXPECT_CFP_EQ (func ((CFPT)(3210.5678 - 9876 .5432i)), CFPT (3210.5678 + 9876 .5432i));
71- EXPECT_CFP_EQ (func ((CFPT)(-3210.5678 - 9876 .5432i)), CFPT (-3210.5678 + 9876 .5432i));
89+ EXPECT_CFP_EQ (func ((CFPT)(3210.5678 + 9876 .5432i)),
90+ CFPT (3210.5678 - 9876 .5432i));
91+ EXPECT_CFP_EQ (func ((CFPT)(-3210.5678 + 9876 .5432i)),
92+ CFPT (-3210.5678 - 9876 .5432i));
93+ EXPECT_CFP_EQ (func ((CFPT)(3210.5678 - 9876 .5432i)),
94+ CFPT (3210.5678 + 9876 .5432i));
95+ EXPECT_CFP_EQ (func ((CFPT)(-3210.5678 - 9876 .5432i)),
96+ CFPT (-3210.5678 + 9876 .5432i));
7297
73- EXPECT_CFP_EQ (func ((CFPT)(1234.4321 + 4321 .1234i)), CFPT (1234.4321 - 4321 .1234i));
74- EXPECT_CFP_EQ (func ((CFPT)(-1234.4321 + 4321 .1234i)), CFPT (-1234.4321 - 4321 .1234i));
75- EXPECT_CFP_EQ (func ((CFPT)(1234.4321 - 4321 .1234i)), CFPT (1234.4321 + 4321 .1234i));
76- EXPECT_CFP_EQ (func ((CFPT)(-1234.4321 - 4321 .1234i)), CFPT (-1234.4321 + 4321 .1234i));
98+ EXPECT_CFP_EQ (func ((CFPT)(1234.4321 + 4321 .1234i)),
99+ CFPT (1234.4321 - 4321 .1234i));
100+ EXPECT_CFP_EQ (func ((CFPT)(-1234.4321 + 4321 .1234i)),
101+ CFPT (-1234.4321 - 4321 .1234i));
102+ EXPECT_CFP_EQ (func ((CFPT)(1234.4321 - 4321 .1234i)),
103+ CFPT (1234.4321 + 4321 .1234i));
104+ EXPECT_CFP_EQ (func ((CFPT)(-1234.4321 - 4321 .1234i)),
105+ CFPT (-1234.4321 + 4321 .1234i));
77106
78- EXPECT_CFP_EQ (func ((CFPT)(6789.1234 + 8765 .6789i)), CFPT (6789.1234 - 8765 .6789i));
79- EXPECT_CFP_EQ (func ((CFPT)(-6789.1234 + 8765 .6789i)), CFPT (-6789.1234 - 8765 .6789i));
80- EXPECT_CFP_EQ (func ((CFPT)(6789.1234 - 8765 .6789i)), CFPT (6789.1234 + 8765 .6789i));
81- EXPECT_CFP_EQ (func ((CFPT)(-6789.1234 - 8765 .6789i)), CFPT (-6789.1234 + 8765 .6789i));
107+ EXPECT_CFP_EQ (func ((CFPT)(6789.1234 + 8765 .6789i)),
108+ CFPT (6789.1234 - 8765 .6789i));
109+ EXPECT_CFP_EQ (func ((CFPT)(-6789.1234 + 8765 .6789i)),
110+ CFPT (-6789.1234 - 8765 .6789i));
111+ EXPECT_CFP_EQ (func ((CFPT)(6789.1234 - 8765 .6789i)),
112+ CFPT (6789.1234 + 8765 .6789i));
113+ EXPECT_CFP_EQ (func ((CFPT)(-6789.1234 - 8765 .6789i)),
114+ CFPT (-6789.1234 + 8765 .6789i));
82115 }
83116};
84117
0 commit comments