diff options
| author | Shawn Smith <shawn.p.smith@gmail.com> | 2013-12-18 10:19:07 -0800 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2013-12-18 10:19:07 -0800 |
| commit | c22e79b37b95c1313ec9bee70147cade6461fb29 (patch) | |
| tree | 71bc0907ef5542951fe28466e195c3728e116474 /src/pkg/encoding | |
| parent | aa20d2629284ee73637598c9635ae2f8f7530d04 (diff) | |
| download | go-c22e79b37b95c1313ec9bee70147cade6461fb29.tar.xz | |
encoding/asn1: add more test cases for BitString.At and TestUTCTime, add test for ObjectIdentifier.Equal
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/42740043
Diffstat (limited to 'src/pkg/encoding')
| -rw-r--r-- | src/pkg/encoding/asn1/asn1_test.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/pkg/encoding/asn1/asn1_test.go b/src/pkg/encoding/asn1/asn1_test.go index f68804ebff..e59f997ef4 100644 --- a/src/pkg/encoding/asn1/asn1_test.go +++ b/src/pkg/encoding/asn1/asn1_test.go @@ -171,6 +171,12 @@ func TestBitStringAt(t *testing.T) { if bs.At(9) != 1 { t.Error("#4: Failed") } + if bs.At(-1) != 0 { + t.Error("#5: Failed") + } + if bs.At(17) != 0 { + t.Error("#6: Failed") + } } type bitStringRightAlignTest struct { @@ -238,6 +244,7 @@ var utcTestData = []timeTest{ {"910506164540+0730", true, time.Date(1991, 05, 06, 16, 45, 40, 0, time.FixedZone("", 7*60*60+30*60))}, {"910506234540Z", true, time.Date(1991, 05, 06, 23, 45, 40, 0, time.UTC)}, {"9105062345Z", true, time.Date(1991, 05, 06, 23, 45, 0, 0, time.UTC)}, + {"5105062345Z", true, time.Date(1951, 05, 06, 23, 45, 0, 0, time.UTC)}, {"a10506234540Z", false, time.Time{}}, {"91a506234540Z", false, time.Time{}}, {"9105a6234540Z", false, time.Time{}}, @@ -509,6 +516,38 @@ func TestRawStructs(t *testing.T) { } } +type oiEqualTest struct { + first ObjectIdentifier + second ObjectIdentifier + same bool +} + +var oiEqualTests = []oiEqualTest{ + { + ObjectIdentifier{1, 2, 3}, + ObjectIdentifier{1, 2, 3}, + true, + }, + { + ObjectIdentifier{1}, + ObjectIdentifier{1, 2, 3}, + false, + }, + { + ObjectIdentifier{1, 2, 3}, + ObjectIdentifier{10, 11, 12}, + false, + }, +} + +func TestObjectIdentifierEqual(t *testing.T) { + for _, o := range oiEqualTests { + if s := o.first.Equal(o.second); s != o.same { + t.Errorf("ObjectIdentifier.Equal: got: %t want: %t", s, o.same) + } + } +} + var derEncodedSelfSignedCert = Certificate{ TBSCertificate: TBSCertificate{ Version: 0, |
