-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not padding signed bit when encode integers (#1)
* return errors if L of TLV less than 0 * Do not padding signed bit when encode number values
- Loading branch information
1 parent
089c695
commit bcc7d6d
Showing
13 changed files
with
355 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package y3 | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestEncoderWriteTagErrorSeqID(t *testing.T) { | ||
enc := &encoder{ | ||
seqID: 0x40, | ||
} | ||
assert.PanicsWithError(t, "sid should be in [0..0x3F]", enc.writeTag) | ||
} | ||
|
||
func TestEncoderWriteTagIsNode(t *testing.T) { | ||
enc := &encoder{ | ||
seqID: 0x00, | ||
isNode: true, | ||
buf: new(bytes.Buffer), | ||
} | ||
enc.writeTag() | ||
assert.EqualValues(t, 0x80, enc.seqID) | ||
} | ||
|
||
func TestEncoderWriteTagIsPrimitive(t *testing.T) { | ||
enc := &encoder{ | ||
seqID: 0x00, | ||
buf: new(bytes.Buffer), | ||
} | ||
enc.writeTag() | ||
assert.EqualValues(t, 0x00, enc.seqID) | ||
} | ||
|
||
func TestEncoderWriteTagIsSlice(t *testing.T) { | ||
enc := &encoder{ | ||
seqID: 0x00, | ||
isArray: true, | ||
buf: new(bytes.Buffer), | ||
} | ||
enc.writeTag() | ||
assert.EqualValues(t, 0x40, enc.seqID) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.