From: Michael Orlitzky Date: Mon, 17 Apr 2017 12:02:28 +0000 (-0400) Subject: Add Ord instance tests for IPv4Address. X-Git-Tag: 0.4.0~8 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=0aa85b3d0ae468def9ee478579cd6558aea5cde3;p=hath.git Add Ord instance tests for IPv4Address. --- diff --git a/src/IPv4Address.hs b/src/IPv4Address.hs index 80a499e..7e50212 100644 --- a/src/IPv4Address.hs +++ b/src/IPv4Address.hs @@ -341,6 +341,10 @@ ipv4address_tests = test_minBound, test_most_sig_bit_different1, test_most_sig_bit_different2, + test_ord_instance1, + test_ord_instance2, + test_ord_instance3, + test_ord_instance4, test_to_enum ] ipv4address_properties :: TestTree @@ -429,3 +433,45 @@ test_to_enum = desc = "192.168.0.0 in base-10 is 3232235520" expected = mk_testaddr 192 168 0 0 actual = toEnum 3232235520 :: IPv4Address + + +test_ord_instance1 :: TestTree +test_ord_instance1 = + testCase desc $ actual @?= expected + where + desc = "127.0.0.0 is less than 127.0.0.1" + addr1 = mk_testaddr 127 0 0 0 + addr2 = mk_testaddr 127 0 0 1 + expected = True + actual = addr1 <= addr2 + + +test_ord_instance2 :: TestTree +test_ord_instance2 = + testCase desc $ actual @?= expected + where + desc = "127.0.0.0 is less than 127.0.1.0" + addr1 = mk_testaddr 127 0 0 0 + addr2 = mk_testaddr 127 0 1 0 + expected = True + actual = addr1 <= addr2 + +test_ord_instance3 :: TestTree +test_ord_instance3 = + testCase desc $ actual @?= expected + where + desc = "127.0.0.0 is less than 127.1.0.0" + addr1 = mk_testaddr 127 0 0 0 + addr2 = mk_testaddr 127 1 0 0 + expected = True + actual = addr1 <= addr2 + +test_ord_instance4 :: TestTree +test_ord_instance4 = + testCase desc $ actual @?= expected + where + desc = "127.0.0.0 is less than 128.0.0.0" + addr1 = mk_testaddr 127 0 0 0 + addr2 = mk_testaddr 128 0 0 0 + expected = True + actual = addr1 <= addr2