bytes: document Compare/Equal semantics for nil arguments, and add tests.

R=golang-dev, bradfitz, r, r
CC=golang-dev
https://golang.org/cl/5676090
This commit is contained in:
David Symonds 2012-02-18 17:39:40 +11:00
parent f18b0b0c16
commit 85f2d18a72
2 changed files with 26 additions and 17 deletions

View file

@ -13,6 +13,7 @@ import (
// Compare returns an integer comparing the two byte arrays lexicographically.
// The result will be 0 if a==b, -1 if a < b, and +1 if a > b
// A nil argument is equivalent to an empty slice.
func Compare(a, b []byte) int {
m := len(a)
if m > len(b) {
@ -37,6 +38,7 @@ func Compare(a, b []byte) int {
}
// Equal returns a boolean reporting whether a == b.
// A nil argument is equivalent to an empty slice.
func Equal(a, b []byte) bool
func equalPortable(a, b []byte) bool {