Browse Source

Fix test files

content-update
Xavier Petit 4 years ago committed by xpetit
parent
commit
d1e8e8acb8
  1. 3
      tests/go/test_chunk.go
  2. 3
      tests/go/test_fib.go
  3. 40
      tests/go/test_foldint.go
  4. 3
      tests/go/test_game23.go
  5. 3
      tests/go/test_interestingnumber.go
  6. 3
      tests/go/test_isanagram.go
  7. 3
      tests/go/test_lcm.go
  8. 3
      tests/go/test_nauuo.go
  9. 7
      tests/go/test_printmemory.go
  10. 3
      tests/go/test_priorprime.go
  11. 36
      tests/go/test_reduceint.go
  12. 3
      tests/go/test_revivethreenums.go
  13. 40
      tests/go/test_sweetproblem.go
  14. 3
      tests/go/test_twosum.go
  15. 3
      tests/go/test_volumechanger.go

3
tests/go/test_chunk.go

@ -4,6 +4,7 @@ import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
)
func randomSize() []int {
@ -36,6 +37,6 @@ func main() {
ch: 0,
})
for _, args := range table {
z01.Challenge("Chunk", Chunk, correct.Chunk, args.slice, args.ch)
z01.Challenge("Chunk", student.Chunk, correct.Chunk, args.slice, args.ch)
}
}

3
tests/go/test_fib.go

@ -4,6 +4,7 @@ import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
)
func main() {
@ -15,6 +16,6 @@ func main() {
}
table = append(table, z01.MultRandIntBetween(-100, 150)...)
for _, arg := range table {
z01.Challenge("Fib", Fib, correct.Fib, arg)
z01.Challenge("Fib", student.Fib, correct.Fib, arg)
}
}

40
tests/go/test_foldint.go

@ -4,13 +4,24 @@ import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
)
func main() {
f := []func(int, int) int{Add, Sub, Mul}
f := []func(int, int) int{
func(accumulator, currentValue int) int {
return accumulator + currentValue
},
func(accumulator, currentValue int) int {
return accumulator - currentValue
},
func(accumulator, currentValue int) int {
return currentValue * accumulator
},
}
type node struct {
arr []int
a []int
functions []func(int, int) int
n int
}
@ -19,41 +30,28 @@ func main() {
for i := 0; i < 8; i++ {
argInt = append(argInt, z01.MultRandIntBetween(0, 50)...)
val := node{
arr: argInt,
table = append(table, node{
a: argInt,
functions: f,
n: z01.RandIntBetween(0, 60),
}
table = append(table, val)
})
}
table = append(table, node{
arr: []int{1, 2, 3},
a: []int{1, 2, 3},
functions: f,
n: 93,
})
table = append(table, node{
arr: []int{0},
a: []int{0},
functions: f,
n: 93,
})
for _, v := range table {
for _, f := range v.functions {
z01.Challenge("FoldInt", FoldInt, correct.FoldInt, f, v.arr, v.n)
z01.Challenge("FoldInt", student.FoldInt, correct.FoldInt, f, v.a, v.n)
}
}
}
func Add(accumulator, currentValue int) int {
return accumulator + currentValue
}
func Sub(accumulator, currentValue int) int {
return accumulator - currentValue
}
func Mul(accumulator, currentValue int) int {
return currentValue * accumulator
}

3
tests/go/test_game23.go

@ -4,6 +4,7 @@ import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
)
func nd(a, b int) int {
@ -55,6 +56,6 @@ func main() {
table = append(table, value)
}
for _, arg := range table {
z01.Challenge("Game23", Game23, correct.Game23, arg.init, arg.fin)
z01.Challenge("Game23", student.Game23, correct.Game23, arg.init, arg.fin)
}
}

3
tests/go/test_interestingnumber.go

@ -4,6 +4,7 @@ import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
)
func main() {
@ -16,6 +17,6 @@ func main() {
table = append(table, z01.MultRandIntBetween(1, 1500)...)
for _, arg := range table {
z01.Challenge("InterestingNumber", InterestingNumber, correct.InterestingNumber, arg)
z01.Challenge("InterestingNumber", student.InterestingNumber, correct.InterestingNumber, arg)
}
}

3
tests/go/test_isanagram.go

@ -4,6 +4,7 @@ import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
)
func main() {
@ -33,6 +34,6 @@ func main() {
}
for _, arg := range table {
z01.Challenge("IsAnagram", IsAnagram, correct.IsAnagram, arg[0], arg[1])
z01.Challenge("IsAnagram", student.IsAnagram, correct.IsAnagram, arg[0], arg[1])
}
}

3
tests/go/test_lcm.go

@ -4,6 +4,7 @@ import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
)
func main() {
@ -23,6 +24,6 @@ func main() {
}
for _, arg := range table {
z01.Challenge("Lcm", Lcm, correct.Lcm, arg[0], arg[1])
z01.Challenge("Lcm", student.Lcm, correct.Lcm, arg[0], arg[1])
}
}

3
tests/go/test_nauuo.go

@ -4,6 +4,7 @@ import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
)
func main() {
@ -27,6 +28,6 @@ func main() {
})
}
for _, arg := range table {
z01.Challenge("Nauuo", Nauuo, correct.Nauuo, arg.plus, arg.minus, arg.rand)
z01.Challenge("Nauuo", student.Nauuo, correct.Nauuo, arg.plus, arg.minus, arg.rand)
}
}

7
tests/go/test_printmemory.go

@ -4,6 +4,7 @@ import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
)
func main() {
@ -13,8 +14,10 @@ func main() {
for i := 0; i < 10; i++ {
table[i] = z01.RandIntBetween(0, 1000)
}
z01.Challenge("PrintMemory", PrintMemory, correct.PrintMemory, table)
z01.Challenge("PrintMemory", student.PrintMemory, correct.PrintMemory, table)
}
table2 := [10]int{104, 101, 108, 108, 111, 16, 21, 42}
z01.Challenge("PrintMemory", PrintMemory, correct.PrintMemory, table2)
z01.Challenge("PrintMemory", student.PrintMemory, correct.PrintMemory, table2)
}
// TODO: this can be simplified a lot

3
tests/go/test_priorprime.go

@ -4,6 +4,7 @@ import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
)
func main() {
@ -17,6 +18,6 @@ func main() {
}
table = append(table, z01.MultRandIntBetween(0, 1000))
for _, arg := range table {
z01.Challenge("PriorPrime", PriorPrime, correct.PriorPrime, arg)
z01.Challenge("PriorPrime", student.PriorPrime, correct.PriorPrime, arg)
}
}

36
tests/go/test_reduceint.go

@ -4,42 +4,40 @@ import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
)
func main() {
f := []func(int, int) int{Add, Sub, Mul}
f := []func(int, int) int{
func(accumulator, currentValue int) int {
return accumulator + currentValue
},
func(accumulator, currentValue int) int {
return accumulator - currentValue
},
func(accumulator, currentValue int) int {
return currentValue * accumulator
},
}
argInt := []int{}
type node struct {
arr []int
a []int
functions []func(int, int) int
}
table := []node{}
for i := 0; i < 4; i++ {
argInt = z01.MultRandIntBetween(0, 50)
val := node{
arr: argInt,
table = append(table, node{
a: argInt,
functions: f,
}
table = append(table, val)
})
}
for _, v := range table {
for _, f := range v.functions {
z01.Challenge("ReduceInt", ReduceInt, correct.ReduceInt, f, v.arr)
z01.Challenge("ReduceInt", student.ReduceInt, correct.ReduceInt, f, v.a)
}
}
}
func Add(accumulator, currentValue int) int {
return accumulator + currentValue
}
func Sub(accumulator, currentValue int) int {
return accumulator - currentValue
}
func Mul(accumulator, currentValue int) int {
return currentValue * accumulator
}

3
tests/go/test_revivethreenums.go

@ -4,6 +4,7 @@ import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
)
func main() {
@ -25,6 +26,6 @@ func main() {
})
}
for _, arg := range table {
z01.Challenge("Revivethreenums", ReviveThreeNums, correct.ReviveThreeNums, arg[0], arg[1], arg[2], arg[3])
z01.Challenge("Revivethreenums", student.ReviveThreeNums, correct.ReviveThreeNums, arg[0], arg[1], arg[2], arg[3])
}
}

40
tests/go/test_sweetproblem.go

@ -4,6 +4,7 @@ import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
)
func main() {
@ -13,33 +14,30 @@ func main() {
blue int
}
table := []node{}
table = append(table,
node{50, 43, 20},
node{10, 0, 0},
node{0, 10, 0},
node{0, 0, 10},
node{10, 1, 0},
node{0, 10, 1},
node{1, 0, 10},
node{10, 2, 0},
node{2, 10, 0},
node{0, 2, 10},
node{13, 13, 0},
node{10, 9, 0},
node{5, 9, 2},
)
table := []node{
{50, 43, 20},
{10, 0, 0},
{0, 10, 0},
{0, 0, 10},
{10, 1, 0},
{0, 10, 1},
{1, 0, 10},
{10, 2, 0},
{2, 10, 0},
{0, 2, 10},
{13, 13, 0},
{10, 9, 0},
{5, 9, 2},
}
for i := 0; i < 15; i++ {
value := node{
table = append(table, node{
red: z01.RandIntBetween(0, 30),
green: z01.RandIntBetween(0, 30),
blue: z01.RandIntBetween(0, 30),
}
table = append(table, value)
})
}
for _, arg := range table {
z01.Challenge("SweetProblem", Sweetproblem, correct.Sweetproblem, arg.red, arg.green, arg.blue)
z01.Challenge("SweetProblem", student.Sweetproblem, correct.Sweetproblem, arg.red, arg.green, arg.blue)
}
}

3
tests/go/test_twosum.go

@ -6,12 +6,13 @@ import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
)
func main() {
for i := 0; i < 20; i++ {
token := rand.Perm(20)
target := rand.Intn(30)
z01.Challenge("TwoSum", TwoSum, correct.TwoSum, token, target)
z01.Challenge("TwoSum", student.TwoSum, correct.TwoSum, token, target)
}
}

3
tests/go/test_volumechanger.go

@ -4,6 +4,7 @@ import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
)
func main() {
@ -20,6 +21,6 @@ func main() {
})
}
for _, arg := range table {
z01.Challenge("Volumechanger", Volumechanger, correct.Volumechanger, arg[0], arg[1])
z01.Challenge("Volumechanger", student.Volumechanger, correct.Volumechanger, arg[0], arg[1])
}
}

Loading…
Cancel
Save