本文整理汇总了Golang中github.com/tobinjt/assert.Equal函数的典型用法代码示例。如果您正苦于以下问题:Golang Equal函数的具体用法?Golang Equal怎么用?Golang Equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestSquareChain
func TestSquareChain(t *testing.T) {
cache := make([]uint, squareChainCacheSize)
cache[1] = 1
cache[89] = 89
assert.Equal(t, "squareChain(1)", uint(1), squareChain(1, cache))
assert.Equal(t, "squareChain(89)", uint(89), squareChain(89, cache))
assert.Equal(t, "squareChain(44)", uint(1), squareChain(44, cache))
assert.Equal(t, "squareChain(85)", uint(89), squareChain(85, cache))
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:9,代码来源:project-euler_test.go
示例2: TestFactorialBigIntCached
func TestFactorialBigIntCached(t *testing.T) {
cache := []*big.Int{big.NewInt(1), big.NewInt(1), big.NewInt(2), big.NewInt(6), nil, nil}
factorialBigIntCached(5, cache)
assert.Equal(t, "factorialBigIntCached(5, cache)", int64(120), cache[5].Int64())
p := cache[5]
factorialBigIntCached(5, cache)
assert.Equal(t, "do not overwrite", p, cache[5])
if cache[4] != nil {
t.Errorf("factorialBigIntCached(5, cache): cache[4]: got %v, want nil", cache[4])
}
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:11,代码来源:project-euler_test.go
示例3: TestNgons
func TestNgons(t *testing.T) {
gon := NewNGon(3)
gon.Set(0, []int{2, 5, 8})
gon.Set(1, []int{1, 6, 7})
gon.Set(2, []int{3, 4, 9})
assert.Equal(t, "gon.Get()", []int{2, 9, 6}, gon.Get(0))
assert.Equal(t, "gon.String()", "sum: 11: first: 1 1,6,4; 3,4,9; 2,9,6",
gon.String())
assert.Equal(t, "gon.Copy()", gon, gon.Copy())
actualInt, err := gon.ToInt()
assert.ErrIsNil(t, "gon.ToInt()", err)
assert.Equal(t, "gon.ToInt()", int64(164349296), actualInt)
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:13,代码来源:project-euler_test.go
示例4: TestNumPrimePartitions
func TestNumPrimePartitions(t *testing.T) {
sieve := SieveOfEratosthenes(50)
sopfCache := make(map[int]int)
nppCache := make(map[int]int)
assert.Equal(t, "NumPrimePartitions", 1,
NumPrimePartitions(2, sieve, nppCache, sopfCache))
assert.Equal(t, "NumPrimePartitions", 7,
NumPrimePartitions(12, sieve, nppCache, sopfCache))
assert.Equal(t, "NumPrimePartitions", 10,
NumPrimePartitions(14, sieve, nppCache, sopfCache))
assert.Equal(t, "NumPrimePartitions", 26,
NumPrimePartitions(20, sieve, nppCache, sopfCache))
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:13,代码来源:project-euler_test.go
示例5: TestTwoDPointHeap
func TestTwoDPointHeap(t *testing.T) {
n1 := TwoDPoint{cost: 1}
n2 := TwoDPoint{cost: 2}
n3 := TwoDPoint{cost: 3}
n4 := TwoDPoint{cost: 4}
h := &TwoDPointHeap{n2, n4, n1}
heap.Init(h)
assert.Equal(t, "Expecting n1", n1, heap.Pop(h))
heap.Push(h, n3)
assert.Equal(t, "Expecting n2", n2, heap.Pop(h))
assert.Equal(t, "Expecting n3", n3, heap.Pop(h))
assert.Equal(t, "Expecting n4", n4, heap.Pop(h))
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:14,代码来源:project-euler_test.go
示例6: TestSqrt
func TestSqrt(t *testing.T) {
expected := []int{1, 4, 1, 4, 2, 1, 3, 5, 6, 2}
assert.Equal(t, "SqrtPE80(2, 10)", expected, SqrtPE80(2, 10))
expected = []int{5}
assert.Equal(t, "SqrtPE80(25, 10)", expected, SqrtPE80(25, 10))
expected = []int{3, 1}
assert.Equal(t, "SqrtPE80(961, 10)", expected, SqrtPE80(961, 10))
expected = []int{1, 4, 1, 4, 2, 1, 3, 5, 6, 2, 3, 7, 3, 0, 9, 5, 0, 4,
8, 8, 0, 1, 6, 8, 8, 7, 2, 4, 2, 0, 9, 6, 9, 8, 0, 7, 8, 5, 6,
9, 6, 7, 1, 8, 7, 5, 3, 7, 6, 9, 4, 8, 0, 7, 3, 1, 7, 6, 6, 7,
9, 7, 3, 7, 9, 9, 0, 7, 3, 2, 4, 7, 8, 4, 6, 2, 1, 0, 7, 0, 3,
8, 8, 5, 0, 3, 8, 7, 5, 3, 4, 3, 2, 7, 6, 4, 1, 5, 7, 2}
assert.Equal(t, "SqrtPE80(2, 100)", expected, SqrtPE80(2, 100))
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:14,代码来源:project-euler_test.go
示例7: TestRomanNumeralsToUint
func TestRomanNumeralsToUint(t *testing.T) {
shouldAssert := []struct {
input string
msg string
}{
{input: "", msg: "empty string is invalid"},
{input: "JTXIV", msg: "unrecognised sequence: JTXIV"},
{input: "XIJI", msg: "unrecognised sequence: JI"},
{input: "DIXX", msg: "sequence \"X\" followed smaller sequence \"IX\""},
}
for _, test := range shouldAssert {
func() {
defer assert.Panics(t, "romanNumeralsToUint(\""+test.input+"\")",
test.msg)
_ = romanNumeralsToUint(test.input)
}()
}
valid := []struct {
input string
result uint
}{
{input: "III", result: 3},
{input: "V", result: 5},
{input: "X", result: 10},
{input: "XIX", result: 19},
{input: "LV", result: 55},
{input: "DCLXVI", result: 666},
{input: "MCMXCVII", result: 1997},
}
for _, test := range valid {
result := romanNumeralsToUint(test.input)
assert.Equal(t, "romanNumeralsToUint(\""+test.input+"\")", test.result, result)
}
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:35,代码来源:project-euler_test.go
示例8: TestGeneralisedpentagonalNumber
func TestGeneralisedpentagonalNumber(t *testing.T) {
expected := []int{0, 1, 2, 5, 7, 12, 15, 22, 26, 35, 40}
for number, result := range expected {
assert.Equal(t, "generalisedPentagonalNumber", result,
generalisedPentagonalNumber(number))
}
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:7,代码来源:project-euler_test.go
示例9: TestFillDiceRolls
func TestFillDiceRolls(t *testing.T) {
faces, position, rollsLeft := int64(2), int64(0), int64(2)
rolls := make([]int64, faces*rollsLeft*2)
fillDiceRolls(rolls, faces, position, rollsLeft)
expected := []int64{4, 0, 1, 2, 1, 2, 0, 2}
assert.Equal(t, "fillDiceRolls", expected, rolls)
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:8,代码来源:project-euler_test.go
示例10: TestReadLinesFromFile
func TestReadLinesFromFile(t *testing.T) {
fh := bytes.NewBufferString("1\n2 3\n")
expected := []string{"1", "2 3"}
actual := readLinesFromFile(fh)
assert.Equal(t, "readLinesFromFile bad result", expected, actual)
fh2 := iotest.TimeoutReader(bytes.NewBufferString("1\n2 3\n"))
defer assert.Panics(t, "readLinesFromFile() should panic on failure", "Reading lines failed")
_ = readLinesFromFile(fh2)
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:10,代码来源:project-euler_test.go
示例11: TestMakeChildren
func TestMakeChildren(t *testing.T) {
parent := PythagoreanTriple{a: 3, b: 4, c: 5}
expectedChildren := []PythagoreanTriple{
PythagoreanTriple{a: 5, b: 12, c: 13},
PythagoreanTriple{a: 21, b: 20, c: 29},
PythagoreanTriple{a: 15, b: 8, c: 17},
}
children := parent.MakeChildren()
assert.Equal(t, "MakeChildren", expectedChildren, children)
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:10,代码来源:project-euler_test.go
示例12: TestNumIntegerPartitions2
func TestNumIntegerPartitions2(t *testing.T) {
expected := []int64{1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 101,
135, 176, 231, 297, 385, 490, 627, 792, 1002, 1255, 1575, 1958,
2436, 3010, 3718, 4565, 5604, 6842, 8349, 10143, 12310, 14883,
17977, 21637, 26015, 31185, 37338, 44583, 53174, 63261, 75175,
89134, 105558, 124754, 147273, 173525}
for number, result := range expected {
assert.Equal(t, "NumIntegerPartitions2", result,
NumIntegerPartitions2(number).Int64())
}
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:11,代码来源:project-euler_test.go
示例13: TestNCRInt64
func TestNCRInt64(t *testing.T) {
tests := []struct {
n, r, e int64
}{
{1, 1, 1},
{4, 2, 6},
{7, 4, 35},
}
for _, test := range tests {
assert.Equal(t, fmt.Sprintf("nCrInt64(%v)", test.n), test.e, nCrInt64(test.n, test.r))
}
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:12,代码来源:project-euler_test.go
示例14: TestPermuteKOfN
func TestPermuteKOfN(t *testing.T) {
p := make([]bool, 4)
for _, test := range [][]bool{
{false, false, false, true},
{false, false, true, false},
{false, false, true, true},
{false, true, false, false},
{false, true, false, true},
{false, true, true, false},
{true, false, false, false},
{true, false, false, true},
{true, false, true, false},
{true, true, false, false},
} {
r := PermuteUpToKOfN(p, 2)
assert.Equal(t, "PermuteUpToKOfN", true, r)
assert.Equal(t, "PermuteUpToKOfN", test, p)
}
r := PermuteUpToKOfN(p, 2)
assert.Equal(t, "PermuteUpToKOfN", false, r)
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:21,代码来源:project-euler_test.go
示例15: TestFactorialBigIntCompareImplementations
func TestFactorialBigIntCompareImplementations(t *testing.T) {
size := 7
cached := make([]*big.Int, size)
uncached := make([]*big.Int, size)
expected := make([]*big.Int, size)
expected[0] = big.NewInt(1)
expected[1] = big.NewInt(1)
expected[2] = big.NewInt(2)
expected[3] = big.NewInt(6)
expected[4] = big.NewInt(24)
expected[5] = big.NewInt(120)
expected[6] = big.NewInt(720)
for i := 0; i < size; i++ {
uncached[i] = factorialBigInt(int64(i))
factorialBigIntCached(int64(i), cached)
}
assert.Equal(t, "cached", expected, cached)
assert.Equal(t, "uncached", expected, uncached)
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:21,代码来源:project-euler_test.go
示例16: TestGreatestCommonDenominator
func TestGreatestCommonDenominator(t *testing.T) {
tests := []struct {
a, b, expected int64
}{
{12, 8, 4},
{12, 7, 1},
{99, 44, 11},
}
for _, test := range tests {
assert.Equal(t, "GreatestCommonDenominator", test.expected,
GreatestCommonDenominator(test.a, test.b))
}
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:13,代码来源:project-euler_test.go
示例17: TestPermutable
func TestPermutable(t *testing.T) {
perm := NewIntPermutation([]int{1, 2, 3}, 2)
Permute(&perm)
expectedPerm := [][]int{
[]int{1, 2},
[]int{1, 3},
[]int{2, 1},
[]int{2, 3},
[]int{3, 1},
[]int{3, 2},
}
assert.Equal(t, "Permute()", expectedPerm, perm.dest)
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:13,代码来源:project-euler_test.go
示例18: TestParseTriangle
func TestParseTriangle(t *testing.T) {
fh := bytes.NewBufferString("1\n2 3\n")
triangle := parseTriangle(fh)
expected := [][]int{
[]int{1},
[]int{2, 3},
}
assert.Equal(t, "parseTriangle()", expected, triangle)
defer assert.Panics(t, "parseTriangle() should panic", "invalid syntax")
fh = bytes.NewBufferString("x\n")
triangle = parseTriangle(fh)
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:13,代码来源:project-euler_test.go
示例19: TestLogEveryN
func TestLogEveryN(t *testing.T) {
c := 0
o := logEveryNPrintFunc
logEveryNPrintFunc = func(format string, a ...interface{}) (n int, err error) {
c++
return 0, nil
}
for i := 0; i < 8; i++ {
logEveryN(3, "", 1)
}
assert.Equal(t, "logEveryN", 2, c)
logEveryNPrintFunc = o
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:13,代码来源:project-euler_test.go
示例20: TestFactorialBigInt
func TestFactorialBigInt(t *testing.T) {
tests := []struct {
n, e int64
}{
{1, 1},
{4, 24},
{7, 5040},
}
for _, test := range tests {
r := factorialBigInt(test.n)
assert.Equal(t, fmt.Sprintf("factorialBigInt(%v)", test.n), 0, r.Cmp(big.NewInt(test.e)))
}
}
开发者ID:tobinjt,项目名称:project-euler,代码行数:13,代码来源:project-euler_test.go
注:本文中的github.com/tobinjt/assert.Equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论