Skip to content

Commit

Permalink
Rename Size() to Written()
Browse files Browse the repository at this point in the history
  • Loading branch information
gagliardetto committed Oct 10, 2021
1 parent bd58268 commit cd0c943
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ func (e *Encoder) toWriter(bytes []byte) (err error) {
return
}

// Size returns the count of bytes written.
func (e *Encoder) Size() int {
// Written returns the count of bytes written.
func (e *Encoder) Written() int {
return e.count
}

Expand Down
12 changes: 6 additions & 6 deletions encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ func TestEncoder_Size(t *testing.T) {
buf := new(bytes.Buffer)

enc := NewBinEncoder(buf)
assert.Equal(t, enc.Size(), 0)
assert.Equal(t, enc.Written(), 0)
enc.Encode(SafeString("hello"))

assert.Equal(t, enc.Size(), 6)
assert.Equal(t, enc.Written(), 6)
enc.WriteBool(true)
assert.Equal(t, enc.Size(), 7)
assert.Equal(t, enc.Written(), 7)
}
{
buf := new(bytes.Buffer)

enc := NewBorshEncoder(buf)
assert.Equal(t, enc.Size(), 0)
assert.Equal(t, enc.Written(), 0)
enc.WriteByte(123)

assert.Equal(t, enc.Size(), 1)
assert.Equal(t, enc.Written(), 1)
enc.WriteBool(true)
assert.Equal(t, enc.Size(), 2)
assert.Equal(t, enc.Written(), 2)
}
}

Expand Down

0 comments on commit cd0c943

Please sign in to comment.