diff options
Diffstat (limited to '')
-rw-r--r-- | src/guuid.go | 5 | ||||
-rw-r--r-- | tests/guuid.go | 15 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/guuid.go b/src/guuid.go index 7d69fca..0d20021 100644 --- a/src/guuid.go +++ b/src/guuid.go @@ -53,6 +53,11 @@ func New() UUID { return uuid } +func NewBytes() []byte { + id := New() + return id[:] +} + func (uuid UUID) String() string { dst := [uuidEncodedLength]byte { 0, 0, 0, 0, diff --git a/tests/guuid.go b/tests/guuid.go index 6470fca..ca20b49 100644 --- a/tests/guuid.go +++ b/tests/guuid.go @@ -167,6 +167,20 @@ func test_New() { }) } +func test_NewBytes() { + testStart("NewBytes()") + + testing("the slice has the same length of the original array", func() { + array := New() + slice := NewBytes() + assertEq(len(slice), len(array)) + }) + + testing("we get the correct byte count", func() { + assertEq(len(NewBytes()), UUIDByteCount) + }) +} + func test_String() { testStart("UUID.String()") @@ -242,6 +256,7 @@ func test_FromString() { func MainTest() { test_NewFrom() test_New() + test_NewBytes() test_String() test_FromString() } |