aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-07-14 23:22:04 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-07-14 23:22:04 +0200
commit6d033680eb74abe871e7b261e6911d646f9e365b (patch)
tree8c6e72f422aacc24320827d243651a1a60c6b5b2
parenta1a7ee2520f375ab85a6e2a4a170e7e5116be1f4 (diff)
Rename Bits into BitString
-rw-r--r--ber/bitstring.go (renamed from ber/bits.go)8
-rw-r--r--ber/bitstring_test.go (renamed from ber/bits_test.go)12
2 files changed, 10 insertions, 10 deletions
diff --git a/ber/bits.go b/ber/bitstring.go
index 180228d..2195143 100644
--- a/ber/bits.go
+++ b/ber/bitstring.go
@@ -1,9 +1,9 @@
package ber
// BitString
-type Bits []bool
+type BitString []bool
-func UnmarshalBitString(b []byte) (bs Bits) {
+func UnmarshalBitString(b []byte) (bs BitString) {
padding := int(b[0])
length := (len(b)-1)*8 - padding
for i := 0; i < length; i++ {
@@ -15,7 +15,7 @@ func UnmarshalBitString(b []byte) (bs Bits) {
return
}
-func MarshalBitString(bs Bits) (b []byte) {
+func MarshalBitString(bs BitString) (b []byte) {
padding := (8 - len(bs)%8) % 8
length := len(bs) / 8
if padding != 0 {
@@ -33,7 +33,7 @@ func MarshalBitString(bs Bits) (b []byte) {
return
}
-func (bs Bits) String() (s string) {
+func (bs BitString) String() (s string) {
bmap := map[bool]string{
true: "1",
false: "0",
diff --git a/ber/bits_test.go b/ber/bitstring_test.go
index c20b3db..ae4051d 100644
--- a/ber/bits_test.go
+++ b/ber/bitstring_test.go
@@ -7,28 +7,28 @@ import (
type bitTest struct {
bytes []byte
- bits Bits
+ bits BitString
}
var bitTestData = []bitTest{
{
[]byte{0, 8, 0},
- Bits{
+ BitString{
false, false, false, false, true, false, false, false,
false, false, false, false, false, false, false, false,
},
},
{
[]byte{7, 0x80},
- Bits{true},
+ BitString{true},
},
{
[]byte{4, 0x20},
- Bits{false, false, true, false},
+ BitString{false, false, true, false},
},
}
-func bitsEqual(a, b Bits) bool {
+func bitsEqual(a, b BitString) bool {
if len(a) != len(b) {
return false
}
@@ -40,7 +40,7 @@ func bitsEqual(a, b Bits) bool {
return true
}
-func TestBits(t *testing.T) {
+func TestBitString(t *testing.T) {
for _, test := range bitTestData {
bi := UnmarshalBitString(test.bytes)
if !bitsEqual(bi, test.bits) {