where
import Data.Maybe (fromJust)
-import Test.HUnit
-import Test.QuickCheck
+
+import Test.HUnit (assertEqual)
+import Test.Framework (Test, testGroup)
+import Test.Framework.Providers.HUnit (testCase)
+
+import Test.QuickCheck (Arbitrary(..), Gen)
import Bit as B
import Maskable
-- HUnit Tests
test_octet_from_int1 :: Test
test_octet_from_int1 =
- TestCase $ assertEqual "octet_from_int 128 should parse as 10000000" oct1 oct2
+ testCase desc $ assertEqual desc oct1 oct2
where
+ desc = "octet_from_int 128 should parse as 10000000"
oct1 = Octet B.One B.Zero B.Zero B.Zero B.Zero B.Zero B.Zero B.Zero
oct2 = fromJust $ octet_from_int 128
test_octet_mask1 :: Test
test_octet_mask1 =
- TestCase $
- assertEqual
- "The network bits of 255/4 should equal 240"
- oct2
- (apply_mask oct1 Four B.Zero)
+ testCase desc $
+ assertEqual desc oct2 (apply_mask oct1 Four B.Zero)
where
+ desc = "The network bits of 255/4 should equal 240"
oct1 = fromJust $ octet_from_int 255
oct2 = fromJust $ octet_from_int 240
test_octet_mask2 :: Test
test_octet_mask2 =
- TestCase $
- assertEqual
- "The network bits of 255/1 should equal 128"
- oct2
- (apply_mask oct1 Maskbits.One B.Zero)
+ testCase desc $
+ assertEqual desc oct2 (apply_mask oct1 Maskbits.One B.Zero)
where
+ desc = "The network bits of 255/1 should equal 128"
oct1 = fromJust $ octet_from_int 255
oct2 = fromJust $ octet_from_int 128
-octet_tests :: [Test]
+octet_tests :: Test
octet_tests =
- [ test_octet_from_int1,
+ testGroup "Octet Tests" [
+ test_octet_from_int1,
test_octet_mask1,
test_octet_mask2 ]