util/cmpx: add package with cmp-like things from future Go releases
Updates #8296 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
1c4a047ad0
commit
12f8c98823
24
util/cmpx/cmpx_test.go
Normal file
24
util/cmpx/cmpx_test.go
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
package cmpx
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestOr(t *testing.T) {
|
||||
if g, w := Or[string](), ""; g != w {
|
||||
t.Errorf("got %v; want %v", g, w)
|
||||
}
|
||||
if g, w := Or[int](), 0; g != w {
|
||||
t.Errorf("got %v; want %v", g, w)
|
||||
}
|
||||
if g, w := Or("", "foo", "bar"), "foo"; g != w {
|
||||
t.Errorf("got %v; want %v", g, w)
|
||||
}
|
||||
if g, w := Or("foo", "bar"), "foo"; g != w {
|
||||
t.Errorf("got %v; want %v", g, w)
|
||||
}
|
||||
if g, w := Or("", "", "bar"), "bar"; g != w {
|
||||
t.Errorf("got %v; want %v", g, w)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user