From fc67c4b981930a377f8a26a5a1f2c0ccd5dd1514 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sun, 15 Jun 2014 20:39:23 +0100 Subject: [PATCH] Add Class parsing test function --- parse_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/parse_test.go b/parse_test.go index f4400e29..8a617dd7 100644 --- a/parse_test.go +++ b/parse_test.go @@ -430,6 +430,31 @@ func TestQuotes(t *testing.T) { } } +func TestParseClass(t *testing.T) { + tests := map[string]string{ + "t.example.com. IN A 127.0.0.1": "t.example.com. 3600 IN A 127.0.0.1", + "t.example.com. CS A 127.0.0.1": "t.example.com. 3600 CS A 127.0.0.1", + "t.example.com. CH A 127.0.0.1": "t.example.com. 3600 CH A 127.0.0.1", + // ClassANY can not occur in zone files + // "t.example.com. ANY A 127.0.0.1": "t.example.com. 3600 ANY A 127.0.0.1", + "t.example.com. NONE A 127.0.0.1": "t.example.com. 3600 NONE A 127.0.0.1", + } + for i, o := range tests { + rr, e := NewRR(i) + if e != nil { + t.Log("Failed to parse RR: " + e.Error()) + t.Fail() + continue + } + if rr.String() != o { + t.Logf("`%s' should be equal to\n`%s', but is\n`%s'\n", i, o, rr.String()) + t.Fail() + } else { + t.Logf("RR is OK: `%s'", rr.String()) + } + } +} + func TestBrace(t *testing.T) { tests := map[string]string{ "(miek.nl.) 3600 IN A 127.0.1.1": "miek.nl.\t3600\tIN\tA\t127.0.1.1",