-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from Azure/dev
Release v0.12.0
- Loading branch information
Showing
37 changed files
with
1,666 additions
and
818 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package azblob | ||
|
||
import ( | ||
"errors" | ||
) | ||
|
||
type bytesWriter []byte | ||
|
||
func newBytesWriter(b []byte) bytesWriter { | ||
return b | ||
} | ||
|
||
func (c bytesWriter) WriteAt(b []byte, off int64) (int, error) { | ||
if off >= int64(len(c)) || off < 0 { | ||
return 0, errors.New("Offset value is out of range") | ||
} | ||
|
||
n := copy(c[int(off):], b) | ||
if n < len(b) { | ||
return n, errors.New("Not enough space for all bytes") | ||
} | ||
|
||
return n, nil | ||
} |
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,30 @@ | ||
package azblob | ||
|
||
import ( | ||
"bytes" | ||
|
||
chk "gopkg.in/check.v1" | ||
) | ||
|
||
func (s *aztestsSuite) TestBytesWriterWriteAt(c *chk.C) { | ||
b := make([]byte, 10) | ||
buffer := newBytesWriter(b) | ||
|
||
count, err := buffer.WriteAt([]byte{1, 2}, 10) | ||
c.Assert(err, chk.ErrorMatches, "Offset value is out of range") | ||
c.Assert(count, chk.Equals, 0) | ||
|
||
count, err = buffer.WriteAt([]byte{1, 2}, -1) | ||
c.Assert(err, chk.ErrorMatches, "Offset value is out of range") | ||
c.Assert(count, chk.Equals, 0) | ||
|
||
count, err = buffer.WriteAt([]byte{1, 2}, 9) | ||
c.Assert(err, chk.ErrorMatches, "Not enough space for all bytes") | ||
c.Assert(count, chk.Equals, 1) | ||
c.Assert(bytes.Compare(b, []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 1}), chk.Equals, 0) | ||
|
||
count, err = buffer.WriteAt([]byte{1, 2}, 8) | ||
c.Assert(err, chk.IsNil) | ||
c.Assert(count, chk.Equals, 2) | ||
c.Assert(bytes.Compare(b, []byte{0, 0, 0, 0, 0, 0, 0, 0, 1, 2}), chk.Equals, 0) | ||
} |
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.