Browse Source

Abandon testing package for functions, pass exercise name as an argument (no more magic)

content-update
Xavier Petit 4 years ago committed by xpetit
parent
commit
101c5e8be5
  1. 8
      tests/go/abort_test.go
  2. 8
      tests/go/activebits_test.go
  3. 8
      tests/go/alphacount_test.go
  4. 8
      tests/go/any_test.go
  5. 8
      tests/go/appendrange_test.go
  6. 7
      tests/go/atoi_test.go
  7. 8
      tests/go/atoibase_test.go
  8. 7
      tests/go/basicatoi2_test.go
  9. 7
      tests/go/basicatoi_test.go
  10. 8
      tests/go/basicjoin_test.go
  11. 8
      tests/go/capitalize_test.go
  12. 8
      tests/go/collatzcountdown_test.go
  13. 8
      tests/go/compare_test.go
  14. 8
      tests/go/concat_test.go
  15. 8
      tests/go/concatparams_test.go
  16. 8
      tests/go/convertbase_test.go
  17. 8
      tests/go/countif_test.go
  18. 8
      tests/go/eightqueens_test.go
  19. 8
      tests/go/fibonacci_test.go
  20. 8
      tests/go/findnextprime_test.go
  21. 8
      tests/go/firstrune_test.go
  22. 8
      tests/go/foreach_test.go
  23. 8
      tests/go/index_test.go
  24. 8
      tests/go/isalpha_test.go
  25. 8
      tests/go/islower_test.go
  26. 8
      tests/go/isnegative_test.go
  27. 7
      tests/go/isnumeric_test.go
  28. 8
      tests/go/isprime_test.go
  29. 7
      tests/go/isprintable_test.go
  30. 7
      tests/go/issorted_test.go
  31. 8
      tests/go/isupper_test.go
  32. 7
      tests/go/iterativefactorial_test.go
  33. 12
      tests/go/iterativepower_test.go
  34. 8
      tests/go/itoa_test.go
  35. 12
      tests/go/itoabase_test.go
  36. 8
      tests/go/join_test.go
  37. 8
      tests/go/lastrune_test.go
  38. 8
      tests/go/makerange_test.go
  39. 8
      tests/go/map_test.go
  40. 8
      tests/go/max_test.go
  41. 7
      tests/go/nrune_test.go
  42. 8
      tests/go/printcomb2_test.go
  43. 8
      tests/go/printcomb_test.go
  44. 8
      tests/go/printcombn_test.go
  45. 8
      tests/go/printnbr_test.go
  46. 8
      tests/go/printnbrbase_test.go
  47. 8
      tests/go/printnbrinorder_test.go
  48. 8
      tests/go/printstr_test.go
  49. 7
      tests/go/printwordstables_test.go
  50. 8
      tests/go/raid1a_test.go
  51. 8
      tests/go/raid1b_test.go
  52. 8
      tests/go/raid1c_test.go
  53. 8
      tests/go/raid1d_test.go
  54. 8
      tests/go/raid1e_test.go
  55. 7
      tests/go/recursivefactorial_test.go
  56. 12
      tests/go/recursivepower_test.go
  57. 8
      tests/go/rot14_test.go
  58. 6
      tests/go/solutions/atoibaseprog/atoibaseprog_test.go
  59. 5
      tests/go/solutions/atoiprog/atoiprog_test.go
  60. 6
      tests/go/solutions/chunk/chunk_test.go
  61. 6
      tests/go/solutions/doppelgangerprog/doppelgangerprog_test.go
  62. 6
      tests/go/solutions/fib/fib_test.go
  63. 6
      tests/go/solutions/findprevprimeprog/findprevprimeprog_test.go
  64. 6
      tests/go/solutions/firstruneprog/firstruneprog_test.go
  65. 6
      tests/go/solutions/foldint/foldint_test.go
  66. 6
      tests/go/solutions/foreachprog/foreachprog_test.go
  67. 6
      tests/go/solutions/game23/game23_test.go
  68. 6
      tests/go/solutions/halfcontestprog/halfcontestprog_test.go
  69. 6
      tests/go/solutions/interestingnumber/interestingnumber_test.go
  70. 6
      tests/go/solutions/isanagram/isanagram_test.go
  71. 10
      tests/go/solutions/itoabaseprog/itoabaseprog_test.go
  72. 6
      tests/go/solutions/itoaprog/itoaprog_test.go
  73. 6
      tests/go/solutions/lastruneprog/lastruneprog_test.go
  74. 6
      tests/go/solutions/lcm/lcm_test.go
  75. 6
      tests/go/solutions/maxprog/maxprog_test.go
  76. 6
      tests/go/solutions/nauuo/nauuo_test.go
  77. 5
      tests/go/solutions/nruneprog/nruneprog_test.go
  78. 8
      tests/go/solutions/printmemory/printmemory_test.go
  79. 6
      tests/go/solutions/priorprime/priorprime_test.go
  80. 6
      tests/go/solutions/reachablenumberprog/reachablenumber_test.go
  81. 6
      tests/go/solutions/reduceint/reduceint_test.go
  82. 6
      tests/go/solutions/revivethreenums/revivethreenums_test.go
  83. 6
      tests/go/solutions/sliceprog/sliceprog_test.go
  84. 5
      tests/go/solutions/splitprog/splitprog_test.go
  85. 6
      tests/go/solutions/strlenprog/strlenprog_test.go
  86. 6
      tests/go/solutions/sweetproblem/sweetproblem_test.go
  87. 5
      tests/go/solutions/twosum/twosum_test.go
  88. 6
      tests/go/solutions/volumechanger/volumechanger_test.go
  89. 7
      tests/go/split_test.go
  90. 7
      tests/go/splitwhitespaces_test.go
  91. 8
      tests/go/sqrt_test.go
  92. 8
      tests/go/strlen_test.go
  93. 8
      tests/go/strrev_test.go
  94. 8
      tests/go/tolower_test.go
  95. 8
      tests/go/toupper_test.go
  96. 8
      tests/go/trimatoi_test.go
  97. 8
      tests/go/unmatch_test.go

8
tests/go/abort_test.go

@ -1,18 +1,16 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestAbort(t *testing.T) {
func main() {
arg := z01.MultRandInt()
arg = append(arg, z01.RandInt())
for i := 0; i < 15; i++ {
z01.Challenge(t, student.Abort, solutions.Abort, arg[0], arg[1], arg[2], arg[3], arg[4])
z01.Challenge("Abort", student.Abort, solutions.Abort, arg[0], arg[1], arg[2], arg[3], arg[4])
arg = z01.MultRandInt()
arg = append(arg, z01.RandInt())
}

8
tests/go/activebits_test.go

@ -1,14 +1,12 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestActiveBits(t *testing.T) {
func main() {
args := []int{z01.RandIntBetween(2, 20)}
for i := 0; i < 20; i++ {
@ -16,6 +14,6 @@ func TestActiveBits(t *testing.T) {
}
for _, v := range args {
z01.Challenge(t, student.ActiveBits, solutions.ActiveBits, v)
z01.Challenge("ActiveBits", student.ActiveBits, solutions.ActiveBits, v)
}
}

8
tests/go/alphacount_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestAlphaCount(t *testing.T) {
func main() {
var arr []string
for l := 0; l < 7; l++ {
a := z01.RandIntBetween(5, 20)
@ -24,6 +22,6 @@ func TestAlphaCount(t *testing.T) {
arr = append(arr, "Hello 78 World! 4455 /")
for i := 0; i < len(arr); i++ {
z01.Challenge(t, student.AlphaCount, solutions.AlphaCount, arr[i])
z01.Challenge("AlphaCount", student.AlphaCount, solutions.AlphaCount, arr[i])
}
}

8
tests/go/any_test.go

@ -1,14 +1,12 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestAny(t *testing.T) {
func main() {
functionsArray := []func(string) bool{solutions.IsNumeric, solutions.IsLower, solutions.IsUpper}
type node struct {
@ -61,6 +59,6 @@ func TestAny(t *testing.T) {
)
for _, arg := range table {
z01.Challenge(t, student.Any, solutions.Any, arg.f, arg.arr)
z01.Challenge("Any", student.Any, solutions.Any, arg.f, arg.arr)
}
}

8
tests/go/appendrange_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestAppendRange(t *testing.T) {
func main() {
type node struct {
min int
max int
@ -46,6 +44,6 @@ func TestAppendRange(t *testing.T) {
)
for _, arg := range table {
z01.Challenge(t, student.AppendRange, solutions.AppendRange, arg.min, arg.max)
z01.Challenge("AppendRange", student.AppendRange, solutions.AppendRange, arg.min, arg.max)
}
}

7
tests/go/atoi_test.go

@ -1,8 +1,7 @@
package student_test
package main
import (
"strconv"
"testing"
"github.com/01-edu/z01"
@ -10,7 +9,7 @@ import (
student "./student"
)
func TestAtoi(t *testing.T) {
func main() {
table := make([]string, 30)
for i := range table {
table[i] = strconv.Itoa(z01.RandInt())
@ -34,6 +33,6 @@ func TestAtoi(t *testing.T) {
"123a45",
)
for _, arg := range table {
z01.Challenge(t, student.Atoi, solutions.Atoi, arg)
z01.Challenge("Atoi", student.Atoi, solutions.Atoi, arg)
}
}

8
tests/go/atoibase_test.go

@ -1,8 +1,6 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
@ -10,7 +8,7 @@ import (
)
// this is the function that creates the TESTS
func TestAtoiBase(t *testing.T) {
func main() {
type node struct {
s string
base string
@ -44,6 +42,6 @@ func TestAtoiBase(t *testing.T) {
node{s: "bbbbbab", base: "-ab"},
)
for _, arg := range table {
z01.Challenge(t, student.AtoiBase, solutions.AtoiBase, arg.s, arg.base)
z01.Challenge("AtoiBase", student.AtoiBase, solutions.AtoiBase, arg.s, arg.base)
}
}

7
tests/go/basicatoi2_test.go

@ -1,8 +1,7 @@
package student_test
package main
import (
"strconv"
"testing"
"github.com/01-edu/z01"
@ -10,7 +9,7 @@ import (
student "./student"
)
func TestBasicAtoi2(t *testing.T) {
func main() {
table := make([]string, 30)
for i := range table {
table[i] = strconv.Itoa(z01.RandPosZ())
@ -28,6 +27,6 @@ func TestBasicAtoi2(t *testing.T) {
"123.0",
)
for _, arg := range table {
z01.Challenge(t, student.BasicAtoi2, solutions.BasicAtoi2, arg)
z01.Challenge("BasicAtoi2", student.BasicAtoi2, solutions.BasicAtoi2, arg)
}
}

7
tests/go/basicatoi_test.go

@ -1,8 +1,7 @@
package student_test
package main
import (
"strconv"
"testing"
"github.com/01-edu/z01"
@ -10,7 +9,7 @@ import (
student "./student"
)
func TestBasicAtoi(t *testing.T) {
func main() {
table := make([]string, 30)
for i := range table {
table[i] = strconv.Itoa(z01.RandPosZ())
@ -24,6 +23,6 @@ func TestBasicAtoi(t *testing.T) {
"000000",
)
for _, arg := range table {
z01.Challenge(t, student.BasicAtoi, solutions.BasicAtoi, arg)
z01.Challenge("BasicAtoi", student.BasicAtoi, solutions.BasicAtoi, arg)
}
}

8
tests/go/basicjoin_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestBasicJoin(t *testing.T) {
func main() {
table := [][]string{}
// 30 valid pair of ramdom slice of strings to concatenate
@ -20,6 +18,6 @@ func TestBasicJoin(t *testing.T) {
[]string{"Hello!", " How are you?", "well and yourself?"},
)
for _, arg := range table {
z01.Challenge(t, student.BasicJoin, solutions.BasicJoin, arg)
z01.Challenge("BasicJoin", student.BasicJoin, solutions.BasicJoin, arg)
}
}

8
tests/go/capitalize_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestCapitalize(t *testing.T) {
func main() {
table := append(
z01.MultRandASCII(),
"Hello! How are you? How+are+things+4you?",
@ -21,6 +19,6 @@ func TestCapitalize(t *testing.T) {
"9a LALALA!",
)
for _, arg := range table {
z01.Challenge(t, student.Capitalize, solutions.Capitalize, arg)
z01.Challenge("Capitalize", student.Capitalize, solutions.Capitalize, arg)
}
}

8
tests/go/collatzcountdown_test.go

@ -1,14 +1,12 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestCollatzCountdown(t *testing.T) {
func main() {
args := []int{z01.RandIntBetween(-6, 20)}
args = append(args, -5, 0)
for i := 0; i < 20; i++ {
@ -16,6 +14,6 @@ func TestCollatzCountdown(t *testing.T) {
}
for _, v := range args {
z01.Challenge(t, student.CollatzCountdown, solutions.CollatzCountdown, v)
z01.Challenge("CollatzCountdown", student.CollatzCountdown, solutions.CollatzCountdown, v)
}
}

8
tests/go/compare_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestCompare(t *testing.T) {
func main() {
type node struct {
s string
toCompare string
@ -47,6 +45,6 @@ func TestCompare(t *testing.T) {
)
for _, arg := range table {
z01.Challenge(t, student.Compare, solutions.Compare, arg.s, arg.toCompare)
z01.Challenge("Compare", student.Compare, solutions.Compare, arg.s, arg.toCompare)
}
}

8
tests/go/concat_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestConcat(t *testing.T) {
func main() {
table := [][]string{}
// 30 valid pair of ramdom strings to concatenate
@ -21,6 +19,6 @@ func TestConcat(t *testing.T) {
[]string{"Hello!", " How are you?"},
)
for _, arg := range table {
z01.Challenge(t, student.Concat, solutions.Concat, arg[0], arg[1])
z01.Challenge("Concat", student.Concat, solutions.Concat, arg[0], arg[1])
}
}

8
tests/go/concatparams_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestConcatParams(t *testing.T) {
func main() {
table := [][]string{}
//30 random slice of strings
@ -23,6 +21,6 @@ func TestConcatParams(t *testing.T) {
)
for _, arg := range table {
z01.Challenge(t, student.ConcatParams, solutions.ConcatParams, arg)
z01.Challenge("ConcatParams", student.ConcatParams, solutions.ConcatParams, arg)
}
}

8
tests/go/convertbase_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestConvertBase(t *testing.T) {
func main() {
type node struct {
nbr string
baseFrom string
@ -36,6 +34,6 @@ func TestConvertBase(t *testing.T) {
)
for _, arg := range table {
z01.Challenge(t, student.ConvertBase, solutions.ConvertBase, arg.nbr, arg.baseFrom, arg.baseTo)
z01.Challenge("ConvertBase", student.ConvertBase, solutions.ConvertBase, arg.nbr, arg.baseFrom, arg.baseTo)
}
}

8
tests/go/countif_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestCountIf(t *testing.T) {
func main() {
functionsArray := []func(string) bool{solutions.IsNumeric, solutions.IsLower, solutions.IsUpper}
type node struct {
@ -62,6 +60,6 @@ func TestCountIf(t *testing.T) {
)
for _, arg := range table {
z01.Challenge(t, student.CountIf, solutions.CountIf, arg.f, arg.arr)
z01.Challenge("CountIf", student.CountIf, solutions.CountIf, arg.f, arg.arr)
}
}

8
tests/go/eightqueens_test.go

@ -1,14 +1,12 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestEightQueens(t *testing.T) {
z01.Challenge(t, student.EightQueens, solutions.EightQueens)
func main() {
z01.Challenge("EightQueens", student.EightQueens, solutions.EightQueens)
}

8
tests/go/fibonacci_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestFibonacci(t *testing.T) {
func main() {
table := append(
z01.MultRandIntBetween(0, 25),
4,
@ -17,6 +15,6 @@ func TestFibonacci(t *testing.T) {
-5,
)
for _, arg := range table {
z01.Challenge(t, student.Fibonacci, solutions.Fibonacci, arg)
z01.Challenge("Fibonacci", student.Fibonacci, solutions.Fibonacci, arg)
}
}

8
tests/go/findnextprime_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestFindNextPrime(t *testing.T) {
func main() {
table := append(
z01.MultRandIntBetween(-1000000, 1000000),
0,
@ -31,6 +29,6 @@ func TestFindNextPrime(t *testing.T) {
1000000088,
)
for _, arg := range table {
z01.Challenge(t, student.FindNextPrime, solutions.FindNextPrime, arg)
z01.Challenge("FindNextPrime", student.FindNextPrime, solutions.FindNextPrime, arg)
}
}

8
tests/go/firstrune_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestFirstRune(t *testing.T) {
func main() {
table := append(
z01.MultRandASCII(),
"Hello!",
@ -18,6 +16,6 @@ func TestFirstRune(t *testing.T) {
"♥01",
)
for _, arg := range table {
z01.Challenge(t, student.FirstRune, solutions.FirstRune, arg)
z01.Challenge("FirstRune", student.FirstRune, solutions.FirstRune, arg)
}
}

8
tests/go/foreach_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestForEach(t *testing.T) {
func main() {
functionsArray := []func(int){solutions.Add0, solutions.Add1, solutions.Add2, solutions.Add3}
type node struct {
@ -36,6 +34,6 @@ func TestForEach(t *testing.T) {
})
for _, arg := range table {
z01.Challenge(t, student.ForEach, solutions.ForEach, arg.f, arg.arr)
z01.Challenge("ForEach", student.ForEach, solutions.ForEach, arg.f, arg.arr)
}
}

8
tests/go/index_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestIndex(t *testing.T) {
func main() {
type node struct {
s string
toFind string
@ -49,6 +47,6 @@ func TestIndex(t *testing.T) {
)
for _, arg := range table {
z01.Challenge(t, student.Index, solutions.Index, arg.s, arg.toFind)
z01.Challenge("Index", student.Index, solutions.Index, arg.s, arg.toFind)
}
}

8
tests/go/isalpha_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestIsAlpha(t *testing.T) {
func main() {
table := append(
z01.MultRandASCII(),
"Hello! €How are you?",
@ -23,6 +21,6 @@ func TestIsAlpha(t *testing.T) {
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!",
)
for _, arg := range table {
z01.Challenge(t, student.IsAlpha, solutions.IsAlpha, arg)
z01.Challenge("IsAlpha", student.IsAlpha, solutions.IsAlpha, arg)
}
}

8
tests/go/islower_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestIsLower(t *testing.T) {
func main() {
// 15 unvalid strings in the table
table := z01.MultRandASCII()
@ -42,6 +40,6 @@ func TestIsLower(t *testing.T) {
"hello!",
)
for _, arg := range table {
z01.Challenge(t, student.IsLower, solutions.IsLower, arg)
z01.Challenge("IsLower", student.IsLower, solutions.IsLower, arg)
}
}

8
tests/go/isnegative_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestIsNegative(t *testing.T) {
func main() {
table := append(
z01.MultRandInt(),
z01.MinInt,
@ -17,6 +15,6 @@ func TestIsNegative(t *testing.T) {
0,
)
for _, arg := range table {
z01.Challenge(t, student.IsNegative, solutions.IsNegative, arg)
z01.Challenge("IsNegative", student.IsNegative, solutions.IsNegative, arg)
}
}

7
tests/go/isnumeric_test.go

@ -1,8 +1,7 @@
package student_test
package main
import (
"strconv"
"testing"
"github.com/01-edu/z01"
@ -10,7 +9,7 @@ import (
student "./student"
)
func TestIsNumeric(t *testing.T) {
func main() {
// 15 unvalid strings in the table
table := z01.MultRandASCII()
@ -35,6 +34,6 @@ func TestIsNumeric(t *testing.T) {
"01,02,03",
)
for _, arg := range table {
z01.Challenge(t, student.IsNumeric, solutions.IsNumeric, arg)
z01.Challenge("IsNumeric", student.IsNumeric, solutions.IsNumeric, arg)
}
}

8
tests/go/isprime_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestIsPrime(t *testing.T) {
func main() {
table := append(
z01.MultRandIntBetween(-1000000, 1000000),
0,
@ -30,6 +28,6 @@ func TestIsPrime(t *testing.T) {
1000000087,
)
for _, arg := range table {
z01.Challenge(t, student.IsPrime, solutions.IsPrime, arg)
z01.Challenge("IsPrime", student.IsPrime, solutions.IsPrime, arg)
}
}

7
tests/go/isprintable_test.go

@ -1,8 +1,7 @@
package student_test
package main
import (
"math/rand"
"testing"
"github.com/01-edu/z01"
@ -10,7 +9,7 @@ import (
student "./student"
)
func TestIsPrintable(t *testing.T) {
func main() {
// 15 unvalid strings in the table
table := z01.MultRandASCII()
@ -45,6 +44,6 @@ func TestIsPrintable(t *testing.T) {
"\n",
)
for _, arg := range table {
z01.Challenge(t, student.IsPrintable, solutions.IsPrintable, arg)
z01.Challenge("IsPrintable", student.IsPrintable, solutions.IsPrintable, arg)
}
}

7
tests/go/issorted_test.go

@ -1,8 +1,7 @@
package student_test
package main
import (
"sort"
"testing"
"github.com/01-edu/z01"
@ -10,7 +9,7 @@ import (
student "./student"
)
func TestIsSorted(t *testing.T) {
func main() {
functionsArray := []func(int, int) int{solutions.IsSortedByDiff, solutions.IsSortedBy1, solutions.IsSortedBy10}
type node struct {
@ -76,6 +75,6 @@ func TestIsSorted(t *testing.T) {
})
for _, arg := range table {
z01.Challenge(t, student.IsSorted, solutions.IsSorted, arg.f, arg.arr)
z01.Challenge("IsSorted", student.IsSorted, solutions.IsSorted, arg.f, arg.arr)
}
}

8
tests/go/isupper_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestIsUpper(t *testing.T) {
func main() {
// 15 unvalid strings in the table
table := z01.MultRandASCII()
@ -44,6 +42,6 @@ func TestIsUpper(t *testing.T) {
"HELLO!",
)
for _, arg := range table {
z01.Challenge(t, student.IsUpper, solutions.IsUpper, arg)
z01.Challenge("IsUpper", student.IsUpper, solutions.IsUpper, arg)
}
}

7
tests/go/iterativefactorial_test.go

@ -1,8 +1,7 @@
package student_test
package main
import (
"math/bits"
"testing"
"github.com/01-edu/z01"
@ -10,7 +9,7 @@ import (
student "./student"
)
func TestIterativeFactorial(t *testing.T) {
func main() {
table := append(
z01.MultRandInt(),
z01.IntRange(0, 12)...,
@ -19,6 +18,6 @@ func TestIterativeFactorial(t *testing.T) {
table = append(table, z01.IntRange(13, 20)...)
}
for _, arg := range table {
z01.Challenge(t, student.IterativeFactorial, solutions.IterativeFactorial, arg)
z01.Challenge("IterativeFactorial", student.IterativeFactorial, solutions.IterativeFactorial, arg)
}
}

12
tests/go/iterativepower_test.go

@ -1,22 +1,20 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestIterativePower(t *testing.T) {
func main() {
i := 0
for i < 30 {
nb := z01.RandIntBetween(-8, 8)
power := z01.RandIntBetween(-10, 10)
z01.Challenge(t, student.IterativePower, solutions.IterativePower, nb, power)
z01.Challenge("IterativePower", student.IterativePower, solutions.IterativePower, nb, power)
i++
}
z01.Challenge(t, student.IterativePower, solutions.IterativePower, 0, 0)
z01.Challenge(t, student.IterativePower, solutions.IterativePower, 0, 1)
z01.Challenge("IterativePower", student.IterativePower, solutions.IterativePower, 0, 0)
z01.Challenge("IterativePower", student.IterativePower, solutions.IterativePower, 0, 1)
}

8
tests/go/itoa_test.go

@ -1,16 +1,14 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestItoa(t *testing.T) {
func main() {
for i := 0; i < 50; i++ {
arg := z01.RandIntBetween(-2000000000, 2000000000)
z01.Challenge(t, student.Itoa, solutions.Itoa, arg)
z01.Challenge("Itoa", student.Itoa, solutions.Itoa, arg)
}
}

12
tests/go/itoabase_test.go

@ -1,23 +1,21 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestItoaBase(t *testing.T) {
func main() {
for i := 0; i < 30; i++ {
value := z01.RandIntBetween(-1000000, 1000000)
base := z01.RandIntBetween(2, 16)
z01.Challenge(t, student.ItoaBase, solutions.ItoaBase, value, base)
z01.Challenge("ItoaBase", student.ItoaBase, solutions.ItoaBase, value, base)
}
for i := 0; i < 5; i++ {
base := z01.RandIntBetween(2, 16)
z01.Challenge(t, student.ItoaBase, solutions.ItoaBase, z01.MaxInt, base)
z01.Challenge(t, student.ItoaBase, solutions.ItoaBase, z01.MinInt, base)
z01.Challenge("ItoaBase", student.ItoaBase, solutions.ItoaBase, z01.MaxInt, base)
z01.Challenge("ItoaBase", student.ItoaBase, solutions.ItoaBase, z01.MinInt, base)
}
}

8
tests/go/join_test.go

@ -1,14 +1,12 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestJoin(t *testing.T) {
func main() {
arg1 := []string{"hello", "how", "are", "you", "doing"}
arg2 := []string{"fine", "and", "you"}
arg3 := []string{"I'm", "O.K."}
@ -22,6 +20,6 @@ func TestJoin(t *testing.T) {
//random position for the array of separators
posS := z01.RandIntBetween(0, len(seps)-1)
z01.Challenge(t, student.Join, solutions.Join, args[posA], seps[posS])
z01.Challenge("Join", student.Join, solutions.Join, args[posA], seps[posS])
}
}

8
tests/go/lastrune_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestLastRune(t *testing.T) {
func main() {
table := z01.MultRandASCII()
table = append(table,
"Hello!",
@ -18,6 +16,6 @@ func TestLastRune(t *testing.T) {
z01.RandStr(z01.RandIntBetween(1, 15), z01.RandAlnum()),
)
for _, arg := range table {
z01.Challenge(t, student.LastRune, solutions.LastRune, arg)
z01.Challenge("LastRune", student.LastRune, solutions.LastRune, arg)
}
}

8
tests/go/makerange_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestMakeRange(t *testing.T) {
func main() {
type node struct {
min int
max int
@ -45,6 +43,6 @@ func TestMakeRange(t *testing.T) {
node{min: 10, max: 5},
)
for _, arg := range table {
z01.Challenge(t, student.MakeRange, solutions.MakeRange, arg.min, arg.max)
z01.Challenge("MakeRange", student.MakeRange, solutions.MakeRange, arg.min, arg.max)
}
}

8
tests/go/map_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestMap(t *testing.T) {
func main() {
functionsArray := []func(int) bool{solutions.IsPositive, solutions.IsNegative0, solutions.IsPrime}
type node struct {
@ -34,6 +32,6 @@ func TestMap(t *testing.T) {
})
for _, arg := range table {
z01.Challenge(t, student.Map, solutions.Map, arg.f, arg.arr)
z01.Challenge("Map", student.Map, solutions.Map, arg.f, arg.arr)
}
}

8
tests/go/max_test.go

@ -1,19 +1,17 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestMax(t *testing.T) {
func main() {
args := []int{z01.RandInt()}
limit := z01.RandIntBetween(20, 50)
for i := 0; i < limit; i++ {
args = append(args, z01.RandInt())
}
z01.Challenge(t, student.Max, solutions.Max, args)
z01.Challenge("Max", student.Max, solutions.Max, args)
}

7
tests/go/nrune_test.go

@ -1,8 +1,7 @@
package student_test
package main
import (
"math/rand"
"testing"
"github.com/01-edu/z01"
@ -10,7 +9,7 @@ import (
student "./student"
)
func TestNRune(t *testing.T) {
func main() {
type node struct {
word string
n int
@ -40,6 +39,6 @@ func TestNRune(t *testing.T) {
)
for _, arg := range table {
z01.Challenge(t, student.NRune, solutions.NRune, arg.word, arg.n)
z01.Challenge("NRune", student.NRune, solutions.NRune, arg.word, arg.n)
}
}

8
tests/go/printcomb2_test.go

@ -1,14 +1,12 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestPrintComb2(t *testing.T) {
z01.Challenge(t, student.PrintComb2, solutions.PrintComb2)
func main() {
z01.Challenge("PrintComb2", student.PrintComb2, solutions.PrintComb2)
}

8
tests/go/printcomb_test.go

@ -1,14 +1,12 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestPrintComb(t *testing.T) {
z01.Challenge(t, student.PrintComb, solutions.PrintComb)
func main() {
z01.Challenge("PrintComb", student.PrintComb, solutions.PrintComb)
}

8
tests/go/printcombn_test.go

@ -1,17 +1,15 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestPrintCombN(t *testing.T) {
func main() {
table := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
for _, arg := range table {
z01.Challenge(t, student.PrintCombN, solutions.PrintCombN, arg)
z01.Challenge("PrintCombN", student.PrintCombN, solutions.PrintCombN, arg)
}
}

8
tests/go/printnbr_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestPrintNbr(t *testing.T) {
func main() {
table := append(
z01.MultRandInt(),
z01.MinInt,
@ -17,6 +15,6 @@ func TestPrintNbr(t *testing.T) {
0,
)
for _, arg := range table {
z01.Challenge(t, student.PrintNbr, solutions.PrintNbr, arg)
z01.Challenge("PrintNbr", student.PrintNbr, solutions.PrintNbr, arg)
}
}

8
tests/go/printnbrbase_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestPrintNbrBase(t *testing.T) {
func main() {
type node struct {
n int
base string
@ -46,6 +44,6 @@ func TestPrintNbrBase(t *testing.T) {
node{n: z01.MinInt, base: "0123456789"},
)
for _, arg := range table {
z01.Challenge(t, student.PrintNbrBase, solutions.PrintNbrBase, arg.n, arg.base)
z01.Challenge("PrintNbrBase", student.PrintNbrBase, solutions.PrintNbrBase, arg.n, arg.base)
}
}

8
tests/go/printnbrinorder_test.go

@ -1,14 +1,12 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestPrintNbrInOrder(t *testing.T) {
func main() {
table := append(
z01.MultRandIntBetween(0, z01.MaxInt),
z01.MaxInt,
@ -17,6 +15,6 @@ func TestPrintNbrInOrder(t *testing.T) {
0,
)
for _, arg := range table {
z01.Challenge(t, student.PrintNbrInOrder, solutions.PrintNbrInOrder, arg)
z01.Challenge("PrintNbrInOrder", student.PrintNbrInOrder, solutions.PrintNbrInOrder, arg)
}
}

8
tests/go/printstr_test.go

@ -1,18 +1,16 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestPrintStr(t *testing.T) {
func main() {
table := z01.MultRandASCII()
table = append(table, "Hello World!")
for _, arg := range table {
z01.Challenge(t, student.PrintStr, solutions.PrintStr, arg)
z01.Challenge("PrintStr", student.PrintStr, solutions.PrintStr, arg)
}
}

7
tests/go/printwordstables_test.go

@ -1,8 +1,7 @@
package student_test
package main
import (
"strings"
"testing"
"github.com/01-edu/z01"
@ -10,7 +9,7 @@ import (
student "./student"
)
func TestPrintWordsTables(t *testing.T) {
func main() {
table := [][]string{}
//30 random slice of slice of strings
@ -23,6 +22,6 @@ func TestPrintWordsTables(t *testing.T) {
[]string{"Hello", "how", "are", "you?"})
for _, arg := range table {
z01.Challenge(t, student.PrintWordsTables, solutions.PrintWordsTables, arg)
z01.Challenge("PrintWordsTables", student.PrintWordsTables, solutions.PrintWordsTables, arg)
}
}

8
tests/go/raid1a_test.go

@ -1,14 +1,12 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestRaid1a(t *testing.T) {
func main() {
// testing examples of subjects
table := []int{
5, 3,
@ -28,7 +26,7 @@ func TestRaid1a(t *testing.T) {
//Tests all possibilities including 0 0, -x y, x -y
for i := 0; i < len(table); i = i + 2 {
if i != len(table)-1 {
z01.Challenge(t, solutions.Raid1a, student.Raid1a, table[i], table[i+1])
z01.Challenge("Raid1a", solutions.Raid1a, student.Raid1a, table[i], table[i+1])
}
}
}

8
tests/go/raid1b_test.go

@ -1,14 +1,12 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestRaid1b(t *testing.T) {
func main() {
// testing examples of subjects
table := []int{
5, 3,
@ -28,7 +26,7 @@ func TestRaid1b(t *testing.T) {
//Tests all possibilities including 0 0, -x y, x -y
for i := 0; i < len(table); i = i + 2 {
if i != len(table)-1 {
z01.Challenge(t, solutions.Raid1b, student.Raid1b, table[i], table[i+1])
z01.Challenge("Raid1b", solutions.Raid1b, student.Raid1b, table[i], table[i+1])
}
}
}

8
tests/go/raid1c_test.go

@ -1,14 +1,12 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestRaid1c(t *testing.T) {
func main() {
// testing examples of subjects
table := []int{
5, 3,
@ -28,7 +26,7 @@ func TestRaid1c(t *testing.T) {
//Tests all possibilities including 0 0, -x y, x -y
for i := 0; i < len(table); i = i + 2 {
if i != len(table)-1 {
z01.Challenge(t, solutions.Raid1c, student.Raid1c, table[i], table[i+1])
z01.Challenge("Raid1c", solutions.Raid1c, student.Raid1c, table[i], table[i+1])
}
}
}

8
tests/go/raid1d_test.go

@ -1,14 +1,12 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestRaid1d(t *testing.T) {
func main() {
// testing examples of subjects
table := []int{
5, 3,
@ -28,7 +26,7 @@ func TestRaid1d(t *testing.T) {
//Tests all possibilities including 0 0, -x y, x -y
for i := 0; i < len(table); i = i + 2 {
if i != len(table)-1 {
z01.Challenge(t, solutions.Raid1d, student.Raid1d, table[i], table[i+1])
z01.Challenge("Raid1d", solutions.Raid1d, student.Raid1d, table[i], table[i+1])
}
}
}

8
tests/go/raid1e_test.go

@ -1,14 +1,12 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestRaid1e(t *testing.T) {
func main() {
// testing examples of subjects
table := []int{
5, 3,
@ -28,7 +26,7 @@ func TestRaid1e(t *testing.T) {
//Tests all possibilities including 0 0, -x y, x -y
for i := 0; i < len(table); i = i + 2 {
if i != len(table)-1 {
z01.Challenge(t, solutions.Raid1e, student.Raid1e, table[i], table[i+1])
z01.Challenge("Raid1e", solutions.Raid1e, student.Raid1e, table[i], table[i+1])
}
}
}

7
tests/go/recursivefactorial_test.go

@ -1,8 +1,7 @@
package student_test
package main
import (
"math/bits"
"testing"
"github.com/01-edu/z01"
@ -10,7 +9,7 @@ import (
student "./student"
)
func TestRecursiveFactorial(t *testing.T) {
func main() {
table := append(
z01.MultRandInt(),
z01.IntRange(0, 12)...,
@ -19,6 +18,6 @@ func TestRecursiveFactorial(t *testing.T) {
table = append(table, z01.IntRange(13, 20)...)
}
for _, arg := range table {
z01.Challenge(t, student.RecursiveFactorial, solutions.RecursiveFactorial, arg)
z01.Challenge("RecursiveFactorial", student.RecursiveFactorial, solutions.RecursiveFactorial, arg)
}
}

12
tests/go/recursivepower_test.go

@ -1,22 +1,20 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestRecursivePower(t *testing.T) {
func main() {
i := 0
for i < 30 {
nb := z01.RandIntBetween(-8, 8)
power := z01.RandIntBetween(-10, 10)
z01.Challenge(t, student.RecursivePower, solutions.RecursivePower, nb, power)
z01.Challenge("RecursivePower", student.RecursivePower, solutions.RecursivePower, nb, power)
i++
}
z01.Challenge(t, student.RecursivePower, solutions.RecursivePower, 0, 0)
z01.Challenge(t, student.RecursivePower, solutions.RecursivePower, 0, 1)
z01.Challenge("RecursivePower", student.RecursivePower, solutions.RecursivePower, 0, 0)
z01.Challenge("RecursivePower", student.RecursivePower, solutions.RecursivePower, 0, 1)
}

8
tests/go/rot14_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solution "./solutions"
student "./student"
)
func TestRot14(t *testing.T) {
func main() {
type nodeTest struct {
data []string
}
@ -24,7 +22,7 @@ func TestRot14(t *testing.T) {
for _, arg := range table {
for _, s := range arg.data {
z01.Challenge(t, solution.Rot14, student.Rot14, s)
z01.Challenge("Rot14", solution.Rot14, student.Rot14, s)
}
}
}

6
tests/go/solutions/atoibaseprog/atoibaseprog_test.go

@ -1,15 +1,13 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions"
)
// this is the function that creates the TESTS
func TestAtoiBaseProg(t *testing.T) {
func main() {
type node struct {
s string
base string
@ -43,6 +41,6 @@ func TestAtoiBaseProg(t *testing.T) {
node{s: "bbbbbab", base: "-ab"},
)
for _, arg := range table {
z01.Challenge(t, AtoiBase, solutions.AtoiBase, arg.s, arg.base)
z01.Challenge("AtoiBaseProg", AtoiBase, solutions.AtoiBase, arg.s, arg.base)
}
}

5
tests/go/solutions/atoiprog/atoiprog_test.go

@ -2,14 +2,13 @@ package main
import (
"strconv"
"testing"
"github.com/01-edu/z01"
solutions "../../solutions"
)
func TestAtoiProg(t *testing.T) {
func main() {
table := make([]string, 30)
for i := range table {
table[i] = strconv.Itoa(z01.RandInt())
@ -33,6 +32,6 @@ func TestAtoiProg(t *testing.T) {
"123a45",
)
for _, arg := range table {
z01.Challenge(t, Atoi, solutions.Atoi, arg)
z01.Challenge("AtoiProg", Atoi, solutions.Atoi, arg)
}
}

6
tests/go/solutions/chunk/chunk_test.go

@ -1,8 +1,6 @@
package main
import (
"testing"
solutions "../../solutions"
"github.com/01-edu/z01"
)
@ -15,7 +13,7 @@ func randomSize() []int {
return randSlice
}
func TestChunk(t *testing.T) {
func main() {
type node struct {
slice []int
ch int
@ -37,6 +35,6 @@ func TestChunk(t *testing.T) {
ch: 0,
})
for _, args := range table {
z01.Challenge(t, Chunk, solutions.Chunk, args.slice, args.ch)
z01.Challenge("Chunk", Chunk, solutions.Chunk, args.slice, args.ch)
}
}

6
tests/go/solutions/doppelgangerprog/doppelgangerprog_test.go

@ -1,8 +1,6 @@
package main
import (
"testing"
solutions "../../solutions"
"github.com/01-edu/z01"
)
@ -11,7 +9,7 @@ type node struct {
big, little string
}
func TestDoppelGangerProg(t *testing.T) {
func main() {
table := []node{}
table = append(table,
@ -48,6 +46,6 @@ func TestDoppelGangerProg(t *testing.T) {
}
for _, arg := range table {
z01.Challenge(t, DoppelGanger, solutions.DoppelGanger, arg.big, arg.little)
z01.Challenge("DoppelGangerProg", DoppelGanger, solutions.DoppelGanger, arg.big, arg.little)
}
}

6
tests/go/solutions/fib/fib_test.go

@ -1,14 +1,12 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions" // This line is not necessary when testing an exercise with a program
)
func TestFib(t *testing.T) {
func main() {
// Declaration of the node that is going to take the group of arguments that are going to
// inputed during each iteration of a Challenge between the student and the staff solution.
// (note: a node is not always necessary but in this case it makes the writing of the test easier)
@ -54,7 +52,7 @@ func TestFib(t *testing.T) {
// be the ChallengeMainExam function)
for _, arg := range table {
z01.Challenge(t, Fib, solutions.Fib, arg.n)
z01.Challenge("Fib", Fib, solutions.Fib, arg.n)
}
// the z01.Challenge function is here applied to each argument of the table. It musts contains:

6
tests/go/solutions/findprevprimeprog/findprevprimeprog_test.go

@ -1,19 +1,17 @@
package main
import (
"testing"
solutions "../../solutions"
"github.com/01-edu/z01"
)
func TestFindPrevPrimeProg(t *testing.T) {
func main() {
array := []int{5, 4, 1}
for i := 0; i < 7; i++ {
array = append(array, z01.RandIntBetween(0, 99999))
}
for i := 0; i < len(array); i++ {
z01.Challenge(t, FindPrevPrime, solutions.FindPrevPrime, array[i])
z01.Challenge("FindPrevPrimeProg", FindPrevPrime, solutions.FindPrevPrime, array[i])
}
}

6
tests/go/solutions/firstruneprog/firstruneprog_test.go

@ -1,14 +1,12 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions"
)
func TestFirstRuneProg(t *testing.T) {
func main() {
table := append(
z01.MultRandASCII(),
"Hello!",
@ -17,6 +15,6 @@ func TestFirstRuneProg(t *testing.T) {
"♥01",
)
for _, arg := range table {
z01.Challenge(t, FirstRune, solutions.FirstRune, arg)
z01.Challenge("FirstRuneProg", FirstRune, solutions.FirstRune, arg)
}
}

6
tests/go/solutions/foldint/foldint_test.go

@ -1,13 +1,11 @@
package main
import (
"testing"
solutions "../../solutions"
"github.com/01-edu/z01"
)
func TestFoldInt(t *testing.T) {
func main() {
f := []func(int, int) int{Add, Sub, Mul}
type node struct {
@ -42,7 +40,7 @@ func TestFoldInt(t *testing.T) {
for _, v := range table {
for _, f := range v.functions {
z01.Challenge(t, FoldInt, solutions.FoldInt, f, v.arr, v.n)
z01.Challenge("FoldInt", FoldInt, solutions.FoldInt, f, v.arr, v.n)
}
}
}

6
tests/go/solutions/foreachprog/foreachprog_test.go

@ -1,14 +1,12 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions"
)
func TestForEachProg(t *testing.T) {
func main() {
functionsArray := []func(int){solutions.Add0, solutions.Add1, solutions.Add2, solutions.Add3}
type node struct {
@ -35,6 +33,6 @@ func TestForEachProg(t *testing.T) {
})
for _, arg := range table {
z01.Challenge(t, ForEach, solutions.ForEach, arg.f, arg.arr)
z01.Challenge("ForEachProg", ForEach, solutions.ForEach, arg.f, arg.arr)
}
}

6
tests/go/solutions/game23/game23_test.go

@ -1,8 +1,6 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions" // This line is not necessary when testing an exercise with a program
@ -25,7 +23,7 @@ func nd(a, b int) int {
return -1
}
func TestGame23(t *testing.T) {
func main() {
// Declaration of the node that is going to take the group of arguments that are going to
// inputed during each iteration of a Challenge between the student and the staff solution.
// (note: a node is not always necessary but in this case it makes the writing of the test easier)
@ -94,7 +92,7 @@ func TestGame23(t *testing.T) {
// be the ChallengeMainExam function)
for _, arg := range table {
z01.Challenge(t, Game23, solutions.Game23, arg.init, arg.fin)
z01.Challenge("Game23", Game23, solutions.Game23, arg.init, arg.fin)
}
// the z01.Challenge function is here applied to each argument of the table. It musts contains:

6
tests/go/solutions/halfcontestprog/halfcontestprog_test.go

@ -1,14 +1,12 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions" // This line is not necessary when testing an exercise with a program
)
func TestHalfContestProg(t *testing.T) {
func main() {
type node struct {
h1 int
m1 int
@ -48,6 +46,6 @@ func TestHalfContestProg(t *testing.T) {
// be the ChallengeMainExam function)
for _, arg := range table {
z01.Challenge(t, Halfcontest, solutions.Halfcontest, arg.h1, arg.m1, arg.h2, arg.m2)
z01.Challenge("HalfContestProg", Halfcontest, solutions.Halfcontest, arg.h1, arg.m1, arg.h2, arg.m2)
}
}

6
tests/go/solutions/interestingnumber/interestingnumber_test.go

@ -1,14 +1,12 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions" // This line is not necessary when testing an exercise with a program
)
func TestInterestingNumber(t *testing.T) {
func main() {
type node struct {
n int
}
@ -37,6 +35,6 @@ func TestInterestingNumber(t *testing.T) {
}
for _, arg := range table {
z01.Challenge(t, InterestingNumber, solutions.InterestingNumber, arg.n)
z01.Challenge("InterestingNumber", InterestingNumber, solutions.InterestingNumber, arg.n)
}
}

6
tests/go/solutions/isanagram/isanagram_test.go

@ -1,14 +1,12 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions" // This line is not necessary when testing an exercise with a program
)
func TestAnagram(t *testing.T) {
func main() {
type node struct {
s string
t string
@ -45,6 +43,6 @@ func TestAnagram(t *testing.T) {
}
for _, arg := range table {
z01.Challenge(t, IsAnagram, solutions.IsAnagram, arg.s, arg.t)
z01.Challenge("IsAnagram", IsAnagram, solutions.IsAnagram, arg.s, arg.t)
}
}

10
tests/go/solutions/itoabaseprog/itoabaseprog_test.go

@ -1,22 +1,20 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions"
)
func TestItoaBaseProg(t *testing.T) {
func main() {
for i := 0; i < 30; i++ {
value := z01.RandIntBetween(-1000000, 1000000)
base := z01.RandIntBetween(2, 16)
z01.Challenge(t, ItoaBase, solutions.ItoaBase, value, base)
z01.Challenge("ItoaBaseProg", ItoaBase, solutions.ItoaBase, value, base)
}
for i := 0; i < 5; i++ {
base := z01.RandIntBetween(2, 16)
z01.Challenge(t, ItoaBase, solutions.ItoaBase, z01.MaxInt, base)
z01.Challenge(t, ItoaBase, solutions.ItoaBase, z01.MinInt, base)
z01.Challenge("ItoaBaseProg", ItoaBase, solutions.ItoaBase, z01.MaxInt, base)
z01.Challenge("ItoaBaseProg", ItoaBase, solutions.ItoaBase, z01.MinInt, base)
}
}

6
tests/go/solutions/itoaprog/itoaprog_test.go

@ -1,16 +1,14 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions"
)
func TestItoaProg(t *testing.T) {
func main() {
for i := 0; i < 50; i++ {
arg := z01.RandIntBetween(-2000000000, 2000000000)
z01.Challenge(t, Itoa, solutions.Itoa, arg)
z01.Challenge("ItoaProg", Itoa, solutions.Itoa, arg)
}
}

6
tests/go/solutions/lastruneprog/lastruneprog_test.go

@ -1,14 +1,12 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions"
)
func TestLastRuneProg(t *testing.T) {
func main() {
table := z01.MultRandASCII()
table = append(table,
"Hello!",
@ -17,6 +15,6 @@ func TestLastRuneProg(t *testing.T) {
z01.RandStr(z01.RandIntBetween(1, 15), z01.RandAlnum()),
)
for _, arg := range table {
z01.Challenge(t, LastRune, solutions.LastRune, arg)
z01.Challenge("LastRuneProg", LastRune, solutions.LastRune, arg)
}
}

6
tests/go/solutions/lcm/lcm_test.go

@ -1,14 +1,12 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions" // This line is not necessary when testing an exercise with a program
)
func TestLcm(t *testing.T) {
func main() {
type node struct {
first int
second int
@ -36,6 +34,6 @@ func TestLcm(t *testing.T) {
}
for _, arg := range table {
z01.Challenge(t, Lcm, solutions.Lcm, arg.first, arg.second)
z01.Challenge("Lcm", Lcm, solutions.Lcm, arg.first, arg.second)
}
}

6
tests/go/solutions/maxprog/maxprog_test.go

@ -1,19 +1,17 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions"
)
func TestMaxProg(t *testing.T) {
func main() {
args := []int{z01.RandInt()}
limit := z01.RandIntBetween(20, 50)
for i := 0; i < limit; i++ {
args = append(args, z01.RandInt())
}
z01.Challenge(t, Max, solutions.Max, args)
z01.Challenge("MaxProg", Max, solutions.Max, args)
}

6
tests/go/solutions/nauuo/nauuo_test.go

@ -1,14 +1,12 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions" // This line is not necessary when testing an exercise with a program
)
func TestNauuo(t *testing.T) {
func main() {
// Declaration of the node that is going to take the group of arguments that are going to
// inputed during each iteration of a Challenge between the student and the staff solution.
// (note: a node is not always necessary but in this case it makes the writing of the test easier)
@ -58,7 +56,7 @@ func TestNauuo(t *testing.T) {
// be the ChallengeMainExam function)
for _, arg := range table {
z01.Challenge(t, Nauuo, solutions.Nauuo, arg.plus, arg.minus, arg.rand)
z01.Challenge("Nauuo", Nauuo, solutions.Nauuo, arg.plus, arg.minus, arg.rand)
}
// the z01.Challenge function is here applied to each argument of the table. It musts contains:

5
tests/go/solutions/nruneprog/nruneprog_test.go

@ -2,14 +2,13 @@ package main
import (
"math/rand"
"testing"
"github.com/01-edu/z01"
solutions "../../solutions"
)
func TestNRuneProg(t *testing.T) {
func main() {
type node struct {
word string
n int
@ -39,6 +38,6 @@ func TestNRuneProg(t *testing.T) {
)
for _, arg := range table {
z01.Challenge(t, NRune, solutions.NRune, arg.word, arg.n)
z01.Challenge("NRuneProg", NRune, solutions.NRune, arg.word, arg.n)
}
}

8
tests/go/solutions/printmemory/printmemory_test.go

@ -1,22 +1,20 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions"
)
func TestPrintMemory(t *testing.T) {
func main() {
var table [10]int
for j := 0; j < 5; j++ {
for i := 0; i < 10; i++ {
table[i] = z01.RandIntBetween(0, 1000)
}
z01.Challenge(t, PrintMemory, solutions.PrintMemory, table)
z01.Challenge("PrintMemory", PrintMemory, solutions.PrintMemory, table)
}
table2 := [10]int{104, 101, 108, 108, 111, 16, 21, 42}
z01.Challenge(t, PrintMemory, solutions.PrintMemory, table2)
z01.Challenge("PrintMemory", PrintMemory, solutions.PrintMemory, table2)
}

6
tests/go/solutions/priorprime/priorprime_test.go

@ -1,14 +1,12 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions" // This line is not necessary when testing an exercise with a program
)
func TestPriorprime(t *testing.T) {
func main() {
// Declaration of the node that is going to take the group of arguments that are going to
// inputed during each iteration of a Challenge between the student and the staff solution.
// (note: a node is not always necessary but in this case it makes the writing of the test easier)
@ -56,7 +54,7 @@ func TestPriorprime(t *testing.T) {
// be the ChallengeMainExam function)
for _, arg := range table {
z01.Challenge(t, Priorprime, solutions.Priorprime, arg.first)
z01.Challenge("Priorprime", Priorprime, solutions.Priorprime, arg.first)
}
// the z01.Challenge function is here applied to each argument of the table. It musts contains:

6
tests/go/solutions/reachablenumberprog/reachablenumber_test.go

@ -1,14 +1,12 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions" // This line is not necessary when testing an exercise with a program
)
func TestReachableNumber(t *testing.T) {
func main() {
type node struct {
n int
}
@ -41,6 +39,6 @@ func TestReachableNumber(t *testing.T) {
// be the ChallengeMainExam function)
for _, arg := range table {
z01.Challenge(t, Reachablenumber, solutions.Reachablenumber, arg.n)
z01.Challenge("ReachableNumber", Reachablenumber, solutions.Reachablenumber, arg.n)
}
}

6
tests/go/solutions/reduceint/reduceint_test.go

@ -1,13 +1,11 @@
package main
import (
"testing"
solutions "../../solutions"
"github.com/01-edu/z01"
)
func TestReduceInt(t *testing.T) {
func main() {
f := []func(int, int) int{Add, Sub, Mul}
argInt := []int{}
@ -28,7 +26,7 @@ func TestReduceInt(t *testing.T) {
for _, v := range table {
for _, f := range v.functions {
z01.Challenge(t, ReduceInt, solutions.ReduceInt, f, v.arr)
z01.Challenge("ReduceInt", ReduceInt, solutions.ReduceInt, f, v.arr)
}
}
}

6
tests/go/solutions/revivethreenums/revivethreenums_test.go

@ -1,14 +1,12 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions" // This line is not necessary when testing an exercise with a program
)
func TestRevivethreenums(t *testing.T) {
func main() {
type node struct {
a int
b int
@ -48,6 +46,6 @@ func TestRevivethreenums(t *testing.T) {
// be the ChallengeMainExam function)
for _, arg := range table {
z01.Challenge(t, Revive_three_nums, solutions.Revive_three_nums, arg.a, arg.b, arg.c, arg.d)
z01.Challenge("Revivethreenums", Revive_three_nums, solutions.Revive_three_nums, arg.a, arg.b, arg.c, arg.d)
}
}

6
tests/go/solutions/sliceprog/sliceprog_test.go

@ -1,14 +1,12 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions"
)
func TestSliceProg(t *testing.T) {
func main() {
arr := [][]interface{}{
{
[]string{"coding", "algorithm", "ascii", "package", "golang"},
@ -42,6 +40,6 @@ func TestSliceProg(t *testing.T) {
}
for _, a := range arr {
z01.Challenge(t, Slice, solutions.Slice, a...)
z01.Challenge("SliceProg", Slice, solutions.Slice, a...)
}
}

5
tests/go/solutions/splitprog/splitprog_test.go

@ -3,14 +3,13 @@ package main
import (
"math/rand"
"strings"
"testing"
"github.com/01-edu/z01"
solutions "../../solutions"
)
func TestSplitProg(t *testing.T) {
func main() {
separators := []string{"!=HA=!",
"!==!",
" ",
@ -40,6 +39,6 @@ func TestSplitProg(t *testing.T) {
node{str: "HelloHAhowHAareHAyou?", sep: "HA"})
for _, arg := range table {
z01.Challenge(t, Split, solutions.Split, arg.str, arg.sep)
z01.Challenge("SplitProg", Split, solutions.Split, arg.str, arg.sep)
}
}

6
tests/go/solutions/strlenprog/strlenprog_test.go

@ -1,13 +1,11 @@
package main
import (
"testing"
solutions "../../solutions"
"github.com/01-edu/z01"
)
func TestStrLenProg(t *testing.T) {
func main() {
randomStringCharset := "a b c d e f g h ijklmnopqrstuvwxyz A B C D E FGHIJKLMNOPRSTUVWXYZ"
table := []string{}
@ -20,6 +18,6 @@ func TestStrLenProg(t *testing.T) {
table = append(table, randomStringCharset)
for _, s := range table {
z01.Challenge(t, StrLen, solutions.StrLen, s)
z01.Challenge("StrLenProg", StrLen, solutions.StrLen, s)
}
}

6
tests/go/solutions/sweetproblem/sweetproblem_test.go

@ -1,14 +1,12 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions" // This line is not necessary when testing an exercise with a program
)
func TestSweetProblem(t *testing.T) {
func main() {
type node struct {
red int
green int
@ -54,6 +52,6 @@ func TestSweetProblem(t *testing.T) {
// be the ChallengeMainExam function)
for _, arg := range table {
z01.Challenge(t, Sweetproblem, solutions.Sweetproblem, arg.red, arg.green, arg.blue)
z01.Challenge("SweetProblem", Sweetproblem, solutions.Sweetproblem, arg.red, arg.green, arg.blue)
}
}

5
tests/go/solutions/twosum/twosum_test.go

@ -2,16 +2,15 @@ package main
import (
"math/rand"
"testing"
solutions "../../solutions"
"github.com/01-edu/z01"
)
func TestTwoSum(t *testing.T) {
func main() {
for i := 0; i < 20; i++ {
token := rand.Perm(20)
target := rand.Intn(30)
z01.Challenge(t, TwoSum, solutions.TwoSum, token, target)
z01.Challenge("TwoSum", TwoSum, solutions.TwoSum, token, target)
}
}

6
tests/go/solutions/volumechanger/volumechanger_test.go

@ -1,14 +1,12 @@
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "../../solutions" // This line is not necessary when testing an exercise with a program
)
func TestVolumechanger(t *testing.T) {
func main() {
type node struct {
init int
fin int
@ -42,6 +40,6 @@ func TestVolumechanger(t *testing.T) {
// be the ChallengeMainExam function)
for _, arg := range table {
z01.Challenge(t, Volumechanger, solutions.Volumechanger, arg.init, arg.fin)
z01.Challenge("Volumechanger", Volumechanger, solutions.Volumechanger, arg.init, arg.fin)
}
}

7
tests/go/split_test.go

@ -1,9 +1,8 @@
package student_test
package main
import (
"math/rand"
"strings"
"testing"
"github.com/01-edu/z01"
@ -11,7 +10,7 @@ import (
student "./student"
)
func TestSplit(t *testing.T) {
func main() {
separators := []string{"!=HA=!",
"!==!",
" ",
@ -41,6 +40,6 @@ func TestSplit(t *testing.T) {
node{str: "HelloHAhowHAareHAyou?", sep: "HA"})
for _, arg := range table {
z01.Challenge(t, student.Split, solutions.Split, arg.str, arg.sep)
z01.Challenge("Split", student.Split, solutions.Split, arg.str, arg.sep)
}
}

7
tests/go/splitwhitespaces_test.go

@ -1,8 +1,7 @@
package student_test
package main
import (
"strings"
"testing"
"github.com/01-edu/z01"
@ -10,7 +9,7 @@ import (
student "./student"
)
func TestSplitWhiteSpaces(t *testing.T) {
func main() {
table := []string{}
//30 random slice of strings
@ -23,6 +22,6 @@ func TestSplitWhiteSpaces(t *testing.T) {
"Hello how are you?")
for _, arg := range table {
z01.Challenge(t, student.SplitWhiteSpaces, solutions.SplitWhiteSpaces, arg)
z01.Challenge("SplitWhiteSpaces", student.SplitWhiteSpaces, solutions.SplitWhiteSpaces, arg)
}
}

8
tests/go/sqrt_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestSqrt(t *testing.T) {
func main() {
table := append(
z01.MultRandIntBetween(-1000000, 1000000),
0,
@ -28,6 +26,6 @@ func TestSqrt(t *testing.T) {
100,
)
for _, arg := range table {
z01.Challenge(t, student.Sqrt, solutions.Sqrt, arg)
z01.Challenge("Sqrt", student.Sqrt, solutions.Sqrt, arg)
}
}

8
tests/go/strlen_test.go

@ -1,14 +1,12 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestStrLen(t *testing.T) {
func main() {
randomStringCharset := "a b c d e f g h ijklmnopqrstuvwxyz A B C D E FGHIJKLMNOPRSTUVWXYZ"
table := []string{}
@ -21,6 +19,6 @@ func TestStrLen(t *testing.T) {
table = append(table, randomStringCharset)
for _, s := range table {
z01.Challenge(t, solutions.StrLen, student.StrLen, s)
z01.Challenge("StrLen", solutions.StrLen, student.StrLen, s)
}
}

8
tests/go/strrev_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestStrRev(t *testing.T) {
func main() {
table := append(
z01.MultRandASCII(),
"Hello!",
@ -17,6 +15,6 @@ func TestStrRev(t *testing.T) {
"Hola!",
)
for _, arg := range table {
z01.Challenge(t, student.StrRev, solutions.StrRev, arg)
z01.Challenge("StrRev", student.StrRev, solutions.StrRev, arg)
}
}

8
tests/go/tolower_test.go

@ -1,20 +1,18 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestToLower(t *testing.T) {
func main() {
table := append(
z01.MultRandASCII(),
"Hello! How are you?",
)
for _, arg := range table {
z01.Challenge(t, student.ToLower, solutions.ToLower, arg)
z01.Challenge("ToLower", student.ToLower, solutions.ToLower, arg)
}
}

8
tests/go/toupper_test.go

@ -1,15 +1,13 @@
package student_test
package main
import (
"testing"
"github.com/01-edu/z01"
solutions "./solutions"
student "./student"
)
func TestToUpper(t *testing.T) {
func main() {
table := z01.MultRandASCII()
table = append(table,
@ -17,6 +15,6 @@ func TestToUpper(t *testing.T) {
)
for _, arg := range table {
z01.Challenge(t, student.ToUpper, solutions.ToUpper, arg)
z01.Challenge("ToUpper", student.ToUpper, solutions.ToUpper, arg)
}
}

8
tests/go/trimatoi_test.go

@ -1,14 +1,12 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestTrimAtoi(t *testing.T) {
func main() {
array := []string{"",
"12345",
"str123ing45",
@ -20,7 +18,7 @@ func TestTrimAtoi(t *testing.T) {
z01.RandAlnum()}
array = stringsToTrimAtoi(array)
for i := range array {
z01.Challenge(t, student.TrimAtoi, solutions.TrimAtoi, array[i])
z01.Challenge("TrimAtoi", student.TrimAtoi, solutions.TrimAtoi, array[i])
}
}

8
tests/go/unmatch_test.go

@ -1,14 +1,12 @@
package student_test
package main
import (
"testing"
solutions "./solutions"
student "./student"
"github.com/01-edu/z01"
)
func TestUnmatch(t *testing.T) {
func main() {
arg1 := []int{1, 1, 2, 3, 4, 3, 4}
arg2 := []int{1, 1, 2, 4, 3, 4, 2, 3, 4}
arg3 := []int{1, 2, 1, 1, 4, 5, 5, 4, 1, 7}
@ -26,6 +24,6 @@ func TestUnmatch(t *testing.T) {
args := [][]int{arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8}
for _, v := range args {
z01.Challenge(t, student.Unmatch, solutions.Unmatch, v)
z01.Challenge("Unmatch", student.Unmatch, solutions.Unmatch, v)
}
}

Loading…
Cancel
Save