ipv4address_to_int addr =
(shifted_oct1) + (shifted_oct2) + (shifted_oct3) + oct4
where
- oct1 = octet_to_int (octet1 addr)
- oct2 = octet_to_int (octet2 addr)
- oct3 = octet_to_int (octet3 addr)
- oct4 = octet_to_int (octet4 addr)
+ oct1 = fromEnum (octet1 addr)
+ oct2 = fromEnum (octet2 addr)
+ oct3 = fromEnum (octet3 addr)
+ oct4 = fromEnum (octet4 addr)
shifted_oct1 = oct1 * 2^(24 :: Integer)
shifted_oct2 = oct2 * 2^(16 :: Integer)
test_maxBound,
test_minBound,
test_most_sig_bit_different1,
- test_most_sig_bit_different2 ]
+ test_most_sig_bit_different2,
+ test_to_enum ]
ipv4address_properties :: Test
ipv4address_properties =
bit = most_sig_bit_different addr1 addr2
+test_to_enum :: Test
+test_to_enum =
+ testCase desc $ assertEqual desc expected actual
+ where
+ desc = "192.168.0.0 in base-10 is 3232235520"
+ expected = mk_testaddr 192 168 0 0
+ actual = toEnum 3232235520