89#if (defined(_BIG_ENDIAN)||!defined(_LITTLE_ENDIAN)) && BYTE_ORDER==BIG_ENDIAN
90 EXPECT_EQ(0xefcdab8967452301,
htog((uint64_t)0xefcdab8967452301,
92 EXPECT_EQ(0x1032547698badcfe,
htog((uint64_t)0x1032547698badcfe,
94 EXPECT_EQ(0xb14171b771b01c0b,
htog((uint64_t)0xb14171b771b01c0b,
96 EXPECT_EQ(0xffffffff00000000,
htog((uint64_t)0xffffffff00000000,
98 EXPECT_EQ(0x5555555555555555,
htog((uint64_t)0x5555555555555555,
100 EXPECT_EQ(0xa0a0a0a0a0a0a0a0,
htog((uint64_t)0xa0a0a0a0a0a0a0a0,
102 EXPECT_EQ(0xefcd2301,
htog((uint32_t)0xefcd2301, ByteOrder::big));
103 EXPECT_EQ(0x1032dcfe,
htog((uint32_t)0x1032dcfe, ByteOrder::big));
104 EXPECT_EQ(0xb1411c0b,
htog((uint32_t)0xb1411c0b, ByteOrder::big));
105 EXPECT_EQ(0xffff0000,
htog((uint32_t)0xffff0000, ByteOrder::big));
106 EXPECT_EQ(0x55555555,
htog((uint32_t)0x55555555, ByteOrder::big));
107 EXPECT_EQ(0xa0a0a0a0,
htog((uint32_t)0xa0a0a0a0, ByteOrder::big));
108 EXPECT_EQ(0xef01,
htog((uint16_t)0xef01, ByteOrder::big));
109 EXPECT_EQ(0x10fe,
htog((uint16_t)0x10fe, ByteOrder::big));
110 EXPECT_EQ(0xb10b,
htog((uint16_t)0xb10b, ByteOrder::big));
111 EXPECT_EQ(0xff00,
htog((uint16_t)0xff00, ByteOrder::big));
112 EXPECT_EQ(0x5555,
htog((uint16_t)0x5555, ByteOrder::big));
113 EXPECT_EQ(0xa0a0,
htog((uint16_t)0xa0a0, ByteOrder::big));
114 EXPECT_EQ(0x0123456789abcdef,
htog((uint64_t)0xefcdab8967452301,
116 EXPECT_EQ(0xfedcba9876543210,
htog((uint64_t)0x1032547698badcfe,
118 EXPECT_EQ(0x0b1cb071b77141b1,
htog((uint64_t)0xb14171b771b01c0b,
120 EXPECT_EQ(0x00000000ffffffff,
htog((uint64_t)0xffffffff00000000,
122 EXPECT_EQ(0x5555555555555555,
htog((uint64_t)0x5555555555555555,
124 EXPECT_EQ(0xa0a0a0a0a0a0a0a0,
htog((uint64_t)0xa0a0a0a0a0a0a0a0,
126 EXPECT_EQ(0x0123cdef,
htog((uint32_t)0xefcd2301, ByteOrder::little));
127 EXPECT_EQ(0xfedc3210,
htog((uint32_t)0x1032dcfe, ByteOrder::little));
128 EXPECT_EQ(0x0b1c41b1,
htog((uint32_t)0xb1411c0b, ByteOrder::little));
129 EXPECT_EQ(0x0000ffff,
htog((uint32_t)0xffff0000, ByteOrder::little));
130 EXPECT_EQ(0x55555555,
htog((uint32_t)0x55555555, ByteOrder::little));
131 EXPECT_EQ(0xa0a0a0a0,
htog((uint32_t)0xa0a0a0a0, ByteOrder::little));
132 EXPECT_EQ(0x01ef,
htog((uint16_t)0xef01, ByteOrder::little));
133 EXPECT_EQ(0xfe10,
htog((uint16_t)0x10fe, ByteOrder::little));
134 EXPECT_EQ(0x0bb1,
htog((uint16_t)0xb10b, ByteOrder::little));
135 EXPECT_EQ(0x00ff,
htog((uint16_t)0xff00, ByteOrder::little));
136 EXPECT_EQ(0x5555,
htog((uint16_t)0x5555, ByteOrder::little));
137 EXPECT_EQ(0xa0a0,
htog((uint16_t)0xa0a0, ByteOrder::little));
138#elif defined(_LITTLE_ENDIAN) || BYTE_ORDER==LITTLE_ENDIAN
139 EXPECT_EQ(0x0123456789abcdef,
htog((uint64_t)0xefcdab8967452301,
141 EXPECT_EQ(0xfedcba9876543210,
htog((uint64_t)0x1032547698badcfe,
143 EXPECT_EQ(0x0b1cb071b77141b1,
htog((uint64_t)0xb14171b771b01c0b,
145 EXPECT_EQ(0x00000000ffffffff,
htog((uint64_t)0xffffffff00000000,
147 EXPECT_EQ(0x5555555555555555,
htog((uint64_t)0x5555555555555555,
149 EXPECT_EQ(0xa0a0a0a0a0a0a0a0,
htog((uint64_t)0xa0a0a0a0a0a0a0a0,
151 EXPECT_EQ(0x0123cdef,
htog((uint32_t)0xefcd2301, ByteOrder::big));
152 EXPECT_EQ(0xfedc3210,
htog((uint32_t)0x1032dcfe, ByteOrder::big));
153 EXPECT_EQ(0x0b1c41b1,
htog((uint32_t)0xb1411c0b, ByteOrder::big));
154 EXPECT_EQ(0x0000ffff,
htog((uint32_t)0xffff0000, ByteOrder::big));
155 EXPECT_EQ(0x55555555,
htog((uint32_t)0x55555555, ByteOrder::big));
156 EXPECT_EQ(0xa0a0a0a0,
htog((uint32_t)0xa0a0a0a0, ByteOrder::big));
157 EXPECT_EQ(0x01ef,
htog((uint16_t)0xef01, ByteOrder::big));
158 EXPECT_EQ(0xfe10,
htog((uint16_t)0x10fe, ByteOrder::big));
159 EXPECT_EQ(0x0bb1,
htog((uint16_t)0xb10b, ByteOrder::big));
160 EXPECT_EQ(0x00ff,
htog((uint16_t)0xff00, ByteOrder::big));
161 EXPECT_EQ(0x5555,
htog((uint16_t)0x5555, ByteOrder::big));
162 EXPECT_EQ(0xa0a0,
htog((uint16_t)0xa0a0, ByteOrder::big));
163 EXPECT_EQ(0xefcdab8967452301,
htog((uint64_t)0xefcdab8967452301,
165 EXPECT_EQ(0x1032547698badcfe,
htog((uint64_t)0x1032547698badcfe,
167 EXPECT_EQ(0xb14171b771b01c0b,
htog((uint64_t)0xb14171b771b01c0b,
169 EXPECT_EQ(0xffffffff00000000,
htog((uint64_t)0xffffffff00000000,
171 EXPECT_EQ(0x5555555555555555,
htog((uint64_t)0x5555555555555555,
173 EXPECT_EQ(0xa0a0a0a0a0a0a0a0,
htog((uint64_t)0xa0a0a0a0a0a0a0a0,
175 EXPECT_EQ(0xefcd2301,
htog((uint32_t)0xefcd2301, ByteOrder::little));
176 EXPECT_EQ(0x1032dcfe,
htog((uint32_t)0x1032dcfe, ByteOrder::little));
177 EXPECT_EQ(0xb1411c0b,
htog((uint32_t)0xb1411c0b, ByteOrder::little));
178 EXPECT_EQ(0xffff0000,
htog((uint32_t)0xffff0000, ByteOrder::little));
179 EXPECT_EQ(0x55555555,
htog((uint32_t)0x55555555, ByteOrder::little));
180 EXPECT_EQ(0xa0a0a0a0,
htog((uint32_t)0xa0a0a0a0, ByteOrder::little));
181 EXPECT_EQ(0xef01,
htog((uint16_t)0xef01, ByteOrder::little));
182 EXPECT_EQ(0x10fe,
htog((uint16_t)0x10fe, ByteOrder::little));
183 EXPECT_EQ(0xb10b,
htog((uint16_t)0xb10b, ByteOrder::little));
184 EXPECT_EQ(0xff00,
htog((uint16_t)0xff00, ByteOrder::little));
185 EXPECT_EQ(0x5555,
htog((uint16_t)0x5555, ByteOrder::little));
186 EXPECT_EQ(0xa0a0,
htog((uint16_t)0xa0a0, ByteOrder::little));
188 #error Invalid Endianess
194#if (defined(_BIG_ENDIAN)||!defined(_LITTLE_ENDIAN)) && BYTE_ORDER==BIG_ENDIAN
195 EXPECT_EQ(0xefcdab8967452301,
gtoh((uint64_t)0xefcdab8967452301,
197 EXPECT_EQ(0x1032547698badcfe,
gtoh((uint64_t)0x1032547698badcfe,
199 EXPECT_EQ(0xb14171b771b01c0b,
gtoh((uint64_t)0xb14171b771b01c0b,
201 EXPECT_EQ(0xffffffff00000000,
gtoh((uint64_t)0xffffffff00000000,
203 EXPECT_EQ(0x5555555555555555,
gtoh((uint64_t)0x5555555555555555,
205 EXPECT_EQ(0xa0a0a0a0a0a0a0a0,
gtoh((uint64_t)0xa0a0a0a0a0a0a0a0,
207 EXPECT_EQ(0xefcd2301,
gtoh((uint32_t)0xefcd2301, ByteOrder::big));
208 EXPECT_EQ(0x1032dcfe,
gtoh((uint32_t)0x1032dcfe, ByteOrder::big));
209 EXPECT_EQ(0xb1411c0b,
gtoh((uint32_t)0xb1411c0b, ByteOrder::big));
210 EXPECT_EQ(0xffff0000,
gtoh((uint32_t)0xffff0000, ByteOrder::big));
211 EXPECT_EQ(0x55555555,
gtoh((uint32_t)0x55555555, ByteOrder::big));
212 EXPECT_EQ(0xa0a0a0a0,
gtoh((uint32_t)0xa0a0a0a0, ByteOrder::big));
213 EXPECT_EQ(0xef01,
gtoh((uint16_t)0xef01, ByteOrder::big));
214 EXPECT_EQ(0x10fe,
gtoh((uint16_t)0x10fe, ByteOrder::big));
215 EXPECT_EQ(0xb10b,
gtoh((uint16_t)0xb10b, ByteOrder::big));
216 EXPECT_EQ(0xff00,
gtoh((uint16_t)0xff00, ByteOrder::big));
217 EXPECT_EQ(0x5555,
gtoh((uint16_t)0x5555, ByteOrder::big));
218 EXPECT_EQ(0xa0a0,
gtoh((uint16_t)0xa0a0, ByteOrder::big));
219 EXPECT_EQ(0x0123456789abcdef,
gtoh((uint64_t)0xefcdab8967452301,
221 EXPECT_EQ(0xfedcba9876543210,
gtoh((uint64_t)0x1032547698badcfe,
223 EXPECT_EQ(0x0b1cb071b77141b1,
gtoh((uint64_t)0xb14171b771b01c0b,
225 EXPECT_EQ(0x00000000ffffffff,
gtoh((uint64_t)0xffffffff00000000,
227 EXPECT_EQ(0x5555555555555555,
gtoh((uint64_t)0x5555555555555555,
229 EXPECT_EQ(0xa0a0a0a0a0a0a0a0,
gtoh((uint64_t)0xa0a0a0a0a0a0a0a0,
231 EXPECT_EQ(0x0123cdef,
gtoh((uint32_t)0xefcd2301, ByteOrder::little));
232 EXPECT_EQ(0xfedc3210,
gtoh((uint32_t)0x1032dcfe, ByteOrder::little));
233 EXPECT_EQ(0x0b1c41b1,
gtoh((uint32_t)0xb1411c0b, ByteOrder::little));
234 EXPECT_EQ(0x0000ffff,
gtoh((uint32_t)0xffff0000, ByteOrder::little));
235 EXPECT_EQ(0x55555555,
gtoh((uint32_t)0x55555555, ByteOrder::little));
236 EXPECT_EQ(0xa0a0a0a0,
gtoh((uint32_t)0xa0a0a0a0, ByteOrder::little));
237 EXPECT_EQ(0x01ef,
gtoh((uint16_t)0xef01, ByteOrder::little));
238 EXPECT_EQ(0xfe10,
gtoh((uint16_t)0x10fe, ByteOrder::little));
239 EXPECT_EQ(0x0bb1,
gtoh((uint16_t)0xb10b, ByteOrder::little));
240 EXPECT_EQ(0x00ff,
gtoh((uint16_t)0xff00, ByteOrder::little));
241 EXPECT_EQ(0x5555,
gtoh((uint16_t)0x5555, ByteOrder::little));
242 EXPECT_EQ(0xa0a0,
gtoh((uint16_t)0xa0a0, ByteOrder::little));
243#elif defined(_LITTLE_ENDIAN) || BYTE_ORDER==LITTLE_ENDIAN
244 EXPECT_EQ(0x0123456789abcdef,
gtoh((uint64_t)0xefcdab8967452301,
246 EXPECT_EQ(0xfedcba9876543210,
gtoh((uint64_t)0x1032547698badcfe,
248 EXPECT_EQ(0x0b1cb071b77141b1,
gtoh((uint64_t)0xb14171b771b01c0b,
250 EXPECT_EQ(0x00000000ffffffff,
gtoh((uint64_t)0xffffffff00000000,
252 EXPECT_EQ(0x5555555555555555,
gtoh((uint64_t)0x5555555555555555,
254 EXPECT_EQ(0xa0a0a0a0a0a0a0a0,
gtoh((uint64_t)0xa0a0a0a0a0a0a0a0,
256 EXPECT_EQ(0x0123cdef,
gtoh((uint32_t)0xefcd2301, ByteOrder::big));
257 EXPECT_EQ(0xfedc3210,
gtoh((uint32_t)0x1032dcfe, ByteOrder::big));
258 EXPECT_EQ(0x0b1c41b1,
gtoh((uint32_t)0xb1411c0b, ByteOrder::big));
259 EXPECT_EQ(0x0000ffff,
gtoh((uint32_t)0xffff0000, ByteOrder::big));
260 EXPECT_EQ(0x55555555,
gtoh((uint32_t)0x55555555, ByteOrder::big));
261 EXPECT_EQ(0xa0a0a0a0,
gtoh((uint32_t)0xa0a0a0a0, ByteOrder::big));
262 EXPECT_EQ(0x01ef,
gtoh((uint16_t)0xef01, ByteOrder::big));
263 EXPECT_EQ(0xfe10,
gtoh((uint16_t)0x10fe, ByteOrder::big));
264 EXPECT_EQ(0x0bb1,
gtoh((uint16_t)0xb10b, ByteOrder::big));
265 EXPECT_EQ(0x00ff,
gtoh((uint16_t)0xff00, ByteOrder::big));
266 EXPECT_EQ(0x5555,
gtoh((uint16_t)0x5555, ByteOrder::big));
267 EXPECT_EQ(0xa0a0,
gtoh((uint16_t)0xa0a0, ByteOrder::big));
268 EXPECT_EQ(0xefcdab8967452301,
gtoh((uint64_t)0xefcdab8967452301,
270 EXPECT_EQ(0x1032547698badcfe,
gtoh((uint64_t)0x1032547698badcfe,
272 EXPECT_EQ(0xb14171b771b01c0b,
gtoh((uint64_t)0xb14171b771b01c0b,
274 EXPECT_EQ(0xffffffff00000000,
gtoh((uint64_t)0xffffffff00000000,
276 EXPECT_EQ(0x5555555555555555,
gtoh((uint64_t)0x5555555555555555,
278 EXPECT_EQ(0xa0a0a0a0a0a0a0a0,
gtoh((uint64_t)0xa0a0a0a0a0a0a0a0,
280 EXPECT_EQ(0xefcd2301,
gtoh((uint32_t)0xefcd2301, ByteOrder::little));
281 EXPECT_EQ(0x1032dcfe,
gtoh((uint32_t)0x1032dcfe, ByteOrder::little));
282 EXPECT_EQ(0xb1411c0b,
gtoh((uint32_t)0xb1411c0b, ByteOrder::little));
283 EXPECT_EQ(0xffff0000,
gtoh((uint32_t)0xffff0000, ByteOrder::little));
284 EXPECT_EQ(0x55555555,
gtoh((uint32_t)0x55555555, ByteOrder::little));
285 EXPECT_EQ(0xa0a0a0a0,
gtoh((uint32_t)0xa0a0a0a0, ByteOrder::little));
286 EXPECT_EQ(0xef01,
gtoh((uint16_t)0xef01, ByteOrder::little));
287 EXPECT_EQ(0x10fe,
gtoh((uint16_t)0x10fe, ByteOrder::little));
288 EXPECT_EQ(0xb10b,
gtoh((uint16_t)0xb10b, ByteOrder::little));
289 EXPECT_EQ(0xff00,
gtoh((uint16_t)0xff00, ByteOrder::little));
290 EXPECT_EQ(0x5555,
gtoh((uint16_t)0x5555, ByteOrder::little));
291 EXPECT_EQ(0xa0a0,
gtoh((uint16_t)0xa0a0, ByteOrder::little));
293 #error Invalid Endianess