mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 20:47:49 +00:00
bumping test coverage, adding more tests.
Signed-off-by: Dave Shanley <dave@quobix.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/pb33f/libopenapi/index"
|
||||
@@ -1615,11 +1616,19 @@ x-tacos: [1,2,3]`
|
||||
}
|
||||
|
||||
type test_fresh struct {
|
||||
val string
|
||||
val string
|
||||
thang *bool
|
||||
}
|
||||
|
||||
func (f test_fresh) Hash() [32]byte {
|
||||
return sha256.Sum256([]byte(f.val))
|
||||
var data []string
|
||||
if f.val != "" {
|
||||
data = append(data, f.val)
|
||||
}
|
||||
if f.thang != nil {
|
||||
data = append(data, fmt.Sprintf("%v", *f.thang))
|
||||
}
|
||||
return sha256.Sum256([]byte(strings.Join(data, "|")))
|
||||
}
|
||||
func TestAreEqual(t *testing.T) {
|
||||
assert.True(t, AreEqual(test_fresh{val: "hello"}, test_fresh{val: "hello"}))
|
||||
@@ -1637,6 +1646,17 @@ func TestGenerateHashString(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestGenerateHashString_Pointer(t *testing.T) {
|
||||
|
||||
val := true
|
||||
assert.Equal(t, "b5bea41b6c623f7c09f1bf24dcae58ebab3c0cdd90ad966bc43a45b44867e12b",
|
||||
GenerateHashString(test_fresh{thang: &val}))
|
||||
|
||||
assert.Equal(t, "b5bea41b6c623f7c09f1bf24dcae58ebab3c0cdd90ad966bc43a45b44867e12b",
|
||||
GenerateHashString(&val))
|
||||
|
||||
}
|
||||
|
||||
func TestSetReference(t *testing.T) {
|
||||
|
||||
type testObj struct {
|
||||
|
||||
Reference in New Issue
Block a user