]> gitweb @ CieloNegro.org - haskell-dns.git/blobdiff - DNSUnitTest.hs
Add DNSUnitTest.hs
[haskell-dns.git] / DNSUnitTest.hs
diff --git a/DNSUnitTest.hs b/DNSUnitTest.hs
new file mode 100644 (file)
index 0000000..b388345
--- /dev/null
@@ -0,0 +1,46 @@
+import           Data.Binary
+import qualified Data.ByteString.Lazy as LBS
+import           Data.Word
+import           Network.DNS.Message
+import           Test.HUnit
+
+
+parseMsg :: [Word8] -> Message
+parseMsg = decode . LBS.pack
+
+
+testData :: [Test]
+testData = [ (parseMsg [ 0x22, 0x79, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00
+                       , 0x00, 0x00, 0x00, 0x00, 0x04, 0x6D, 0x61, 0x69
+                       , 0x6C, 0x0A, 0x63, 0x69, 0x65, 0x6C, 0x6F, 0x6E
+                       , 0x65, 0x67, 0x72, 0x6F, 0x03, 0x6F, 0x72, 0x67
+                       , 0x00, 0x00, 0x05, 0x00, 0x01
+                       ]
+              ~?=
+              Message {
+                msgHeader = Header {
+                              hdMessageID             = 8825
+                            , hdMessageType           = Query
+                            , hdOpcode                = StandardQuery
+                            , hdIsAuthoritativeAnswer = False
+                            , hdIsTruncated           = False
+                            , hdIsRecursionDesired    = True
+                            , hdIsRecursionAvailable  = False
+                            , hdResponseCode          = NoError
+                            }
+              , msgQuestions   = [ Question {
+                                     qName  = mkDomainName "mail.cielonegro.org."
+                                   , qType  = mkQueryType CNAME
+                                   , qClass = IN
+                                   }
+                                 ]
+              , msgAnswers     = []
+              , msgAuthorities = []
+              , msgAdditionals = []
+              }
+             )
+           ]
+
+
+main :: IO ()
+main = runTestTT (test testData) >> return ()
\ No newline at end of file