MCPcopy Index your code
hub / github.com/python/cpython / test_from_hex

Method test_from_hex

Lib/test/test_float.py:1262–1559  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1260
1261
1262 def test_from_hex(self):
1263 MIN = self.MIN
1264 MAX = self.MAX
1265 TINY = self.TINY
1266 EPS = self.EPS
1267
1268 # two spellings of infinity, with optional signs; case-insensitive
1269 self.identical(fromHex('inf'), INF)
1270 self.identical(fromHex('+Inf'), INF)
1271 self.identical(fromHex('-INF'), -INF)
1272 self.identical(fromHex('iNf'), INF)
1273 self.identical(fromHex('Infinity'), INF)
1274 self.identical(fromHex('+INFINITY'), INF)
1275 self.identical(fromHex('-infinity'), -INF)
1276 self.identical(fromHex('-iNFiNitY'), -INF)
1277
1278 # nans with optional sign; case insensitive
1279 self.identical(fromHex('nan'), NAN)
1280 self.identical(fromHex('+NaN'), NAN)
1281 self.identical(fromHex('-NaN'), NAN)
1282 self.identical(fromHex('-nAN'), NAN)
1283
1284 # variations in input format
1285 self.identical(fromHex('1'), 1.0)
1286 self.identical(fromHex('+1'), 1.0)
1287 self.identical(fromHex('1.'), 1.0)
1288 self.identical(fromHex('1.0'), 1.0)
1289 self.identical(fromHex('1.0p0'), 1.0)
1290 self.identical(fromHex('01'), 1.0)
1291 self.identical(fromHex('01.'), 1.0)
1292 self.identical(fromHex('0x1'), 1.0)
1293 self.identical(fromHex('0x1.'), 1.0)
1294 self.identical(fromHex('0x1.0'), 1.0)
1295 self.identical(fromHex('+0x1.0'), 1.0)
1296 self.identical(fromHex('0x1p0'), 1.0)
1297 self.identical(fromHex('0X1p0'), 1.0)
1298 self.identical(fromHex('0X1P0'), 1.0)
1299 self.identical(fromHex('0x1P0'), 1.0)
1300 self.identical(fromHex('0x1.p0'), 1.0)
1301 self.identical(fromHex('0x1.0p0'), 1.0)
1302 self.identical(fromHex('0x.1p4'), 1.0)
1303 self.identical(fromHex('0x.1p04'), 1.0)
1304 self.identical(fromHex('0x.1p004'), 1.0)
1305 self.identical(fromHex('0x1p+0'), 1.0)
1306 self.identical(fromHex('0x1P-0'), 1.0)
1307 self.identical(fromHex('+0x1p0'), 1.0)
1308 self.identical(fromHex('0x01p0'), 1.0)
1309 self.identical(fromHex('0x1p00'), 1.0)
1310 self.identical(fromHex(' 0x1p0 '), 1.0)
1311 self.identical(fromHex('\n 0x1p0'), 1.0)
1312 self.identical(fromHex('0x1p0 \t'), 1.0)
1313 self.identical(fromHex('0xap0'), 10.0)
1314 self.identical(fromHex('0xAp0'), 10.0)
1315 self.identical(fromHex('0xaP0'), 10.0)
1316 self.identical(fromHex('0xAP0'), 10.0)
1317 self.identical(fromHex('0xbep0'), 190.0)
1318 self.identical(fromHex('0xBep0'), 190.0)
1319 self.identical(fromHex('0xbEp0'), 190.0)

Callers

nothing calls this directly

Calls 2

identicalMethod · 0.95
assertRaisesMethod · 0.45

Tested by

no test coverage detected