X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FIPv4Address.hs;h=15e69665e7ab8e22c4bd027b401860d579cf3727;hb=18a81546e7c4ad10574918efb08b2e104e911d73;hp=7c4436781099b5be4ae98434b0455772145e9ab8;hpb=942b8ef3bc5830ca0defa62342d55550aea59934;p=hath.git diff --git a/src/IPv4Address.hs b/src/IPv4Address.hs index 7c44367..15e6966 100644 --- a/src/IPv4Address.hs +++ b/src/IPv4Address.hs @@ -180,10 +180,10 @@ ipv4address_to_int :: IPv4Address -> Int 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) @@ -346,7 +346,8 @@ ipv4address_tests = 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 = @@ -423,3 +424,10 @@ test_most_sig_bit_different2 = 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