X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FOctet.hs;h=34f9d4f821e61997ccbdb2f1438c10a06c71b49a;hb=3e3f98ade03919d30e1dca739d14eec96a6bb990;hp=55f075e8a5810247dc9d7df2342b741ea6f82d30;hpb=eee156f562f9c1c1194a67cef12f146304d88ce9;p=hath.git diff --git a/src/Octet.hs b/src/Octet.hs index 55f075e..34f9d4f 100644 --- a/src/Octet.hs +++ b/src/Octet.hs @@ -4,18 +4,19 @@ module Octet ( octet_tests ) where -import Test.QuickCheck ( Gen ) -- Not re-exported by tasty import Test.Tasty ( TestTree, testGroup ) import Test.Tasty.HUnit ( (@?=), testCase ) import Test.Tasty.QuickCheck ( - Arbitrary(..), + Arbitrary( arbitrary ), + Gen, Property, (==>), testProperty ) -import Bit as B (Bit(..)) -import Maskable (Maskable(..)) -import Maskbits (Maskbits(..)) +import Bit as B( Bit( Zero, One) ) +import Maskable( Maskable( apply_mask) ) +import Maskbits( + Maskbits( Zero, One, Two, Three, Four, Five, Six, Seven, Eight ) ) -- | An Octet consists of eight bits. For our purposes, the most -- significant bit will come "first." That is, b1 is in the 2^7 @@ -153,7 +154,7 @@ instance Read Octet where octet_tests :: TestTree octet_tests = testGroup "Octet Tests" [ - test_octet_from_int1, + test_octet_to_enum1, test_octet_mask1, test_octet_mask2 ] @@ -189,13 +190,13 @@ prop_read_show_inverses = -- HUnit Tests -test_octet_from_int1 :: TestTree -test_octet_from_int1 = +test_octet_to_enum1 :: TestTree +test_octet_to_enum1 = testCase desc $ actual @?= expected where - desc = "octet_from_int 128 should parse as 10000000" + desc = "toEnum 128 should parse as 10000000" expected = Octet B.One B.Zero B.Zero B.Zero B.Zero B.Zero B.Zero B.Zero - actual = toEnum 128 + actual = toEnum 128 :: Octet test_octet_mask1 :: TestTree @@ -204,7 +205,7 @@ test_octet_mask1 = where desc = "The network bits of 255/4 should equal 240" expected = toEnum 240 :: Octet - actual = apply_mask (toEnum 255) Four B.Zero + actual = apply_mask (toEnum 255) Four B.Zero :: Octet test_octet_mask2 :: TestTree @@ -213,4 +214,4 @@ test_octet_mask2 = where desc = "The network bits of 255/1 should equal 128" expected = toEnum 128 :: Octet - actual = apply_mask (toEnum 255) Maskbits.One B.Zero + actual = apply_mask (toEnum 255) Maskbits.One B.Zero :: Octet