diff options
Diffstat (limited to 'vendor/github.com/miekg/dns/edns_test.go')
-rw-r--r-- | vendor/github.com/miekg/dns/edns_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/vendor/github.com/miekg/dns/edns_test.go b/vendor/github.com/miekg/dns/edns_test.go index 5fd75abb4..c290b0c8a 100644 --- a/vendor/github.com/miekg/dns/edns_test.go +++ b/vendor/github.com/miekg/dns/edns_test.go @@ -7,10 +7,46 @@ func TestOPTTtl(t *testing.T) { e.Hdr.Name = "." e.Hdr.Rrtype = TypeOPT + // verify the default setting of DO=0 if e.Do() { t.Errorf("DO bit should be zero") } + // There are 6 possible invocations of SetDo(): + // + // 1. Starting with DO=0, using SetDo() + // 2. Starting with DO=0, using SetDo(true) + // 3. Starting with DO=0, using SetDo(false) + // 4. Starting with DO=1, using SetDo() + // 5. Starting with DO=1, using SetDo(true) + // 6. Starting with DO=1, using SetDo(false) + + // verify that invoking SetDo() sets DO=1 (TEST #1) + e.SetDo() + if !e.Do() { + t.Errorf("DO bit should be non-zero") + } + // verify that using SetDo(true) works when DO=1 (TEST #5) + e.SetDo(true) + if !e.Do() { + t.Errorf("DO bit should still be non-zero") + } + // verify that we can use SetDo(false) to set DO=0 (TEST #6) + e.SetDo(false) + if e.Do() { + t.Errorf("DO bit should be zero") + } + // verify that if we call SetDo(false) when DO=0 that it is unchanged (TEST #3) + e.SetDo(false) + if e.Do() { + t.Errorf("DO bit should still be zero") + } + // verify that using SetDo(true) works for DO=0 (TEST #2) + e.SetDo(true) + if !e.Do() { + t.Errorf("DO bit should be non-zero") + } + // verify that using SetDo() works for DO=1 (TEST #4) e.SetDo() if !e.Do() { t.Errorf("DO bit should be non-zero") |