Browse Source

Use local lib, rename imports

content-update
Xavier Petit 4 years ago committed by xpetit
parent
commit
b6c0e8a914
  1. 17
      tests/go/func/test_abort.go
  2. 15
      tests/go/func/test_activebits.go
  3. 13
      tests/go/func/test_addlinkednumbers.go
  4. 11
      tests/go/func/test_advancedsortwordarr.go
  5. 15
      tests/go/func/test_alphacount.go
  6. 19
      tests/go/func/test_any.go
  7. 17
      tests/go/func/test_appendrange.go
  8. 15
      tests/go/func/test_atoi.go
  9. 10
      tests/go/func/test_atoibase.go
  10. 13
      tests/go/func/test_basicatoi.go
  11. 13
      tests/go/func/test_basicatoi2.go
  12. 11
      tests/go/func/test_basicjoin.go
  13. 4
      tests/go/func/test_btreeapplybylevel.go
  14. 4
      tests/go/func/test_btreeapplyinorder.go
  15. 4
      tests/go/func/test_btreeapplypostorder.go
  16. 4
      tests/go/func/test_btreeapplypreorder.go
  17. 9
      tests/go/func/test_btreedeletenode.go
  18. 9
      tests/go/func/test_btreeinsertdata.go
  19. 33
      tests/go/func/test_btreeisbinary.go
  20. 33
      tests/go/func/test_btreelevelcount.go
  21. 33
      tests/go/func/test_btreemax.go
  22. 35
      tests/go/func/test_btreemin.go
  23. 23
      tests/go/func/test_btreesearchitem.go
  24. 11
      tests/go/func/test_btreetransplant.go
  25. 11
      tests/go/func/test_capitalize.go
  26. 13
      tests/go/func/test_changeorder.go
  27. 15
      tests/go/func/test_chunk.go
  28. 13
      tests/go/func/test_collatzcountdown.go
  29. 19
      tests/go/func/test_compact.go
  30. 15
      tests/go/func/test_compare.go
  31. 11
      tests/go/func/test_concat.go
  32. 11
      tests/go/func/test_concatparams.go
  33. 12
      tests/go/func/test_convertbase.go
  34. 19
      tests/go/func/test_countif.go
  35. 11
      tests/go/func/test_createelem.go
  36. 15
      tests/go/func/test_divmod.go
  37. 21
      tests/go/func/test_doppelganger.go
  38. 9
      tests/go/func/test_eightqueens.go
  39. 17
      tests/go/func/test_enigma.go
  40. 11
      tests/go/func/test_fib.go
  41. 11
      tests/go/func/test_fibonacci.go
  42. 11
      tests/go/func/test_findnextprime.go
  43. 11
      tests/go/func/test_findprevprime.go
  44. 11
      tests/go/func/test_firstrune.go
  45. 13
      tests/go/func/test_foldint.go
  46. 13
      tests/go/func/test_foreach.go
  47. 13
      tests/go/func/test_game23.go
  48. 17
      tests/go/func/test_halfcontest.go
  49. 19
      tests/go/func/test_index.go
  50. 11
      tests/go/func/test_interestingnumber.go
  51. 9
      tests/go/func/test_inverttree.go
  52. 11
      tests/go/func/test_isalpha.go
  53. 13
      tests/go/func/test_isanagram.go
  54. 15
      tests/go/func/test_islower.go
  55. 15
      tests/go/func/test_isnegative.go
  56. 13
      tests/go/func/test_isnumeric.go
  57. 11
      tests/go/func/test_isprime.go
  58. 13
      tests/go/func/test_isprintable.go
  59. 21
      tests/go/func/test_issorted.go
  60. 15
      tests/go/func/test_isupper.go
  61. 15
      tests/go/func/test_iterativefactorial.go
  62. 17
      tests/go/func/test_iterativepower.go
  63. 11
      tests/go/func/test_itoa.go
  64. 19
      tests/go/func/test_itoabase.go
  65. 13
      tests/go/func/test_join.go
  66. 13
      tests/go/func/test_lastrune.go
  67. 13
      tests/go/func/test_lcm.go
  68. 21
      tests/go/func/test_listat.go
  69. 9
      tests/go/func/test_listclear.go
  70. 11
      tests/go/func/test_listfind.go
  71. 11
      tests/go/func/test_listforeach.go
  72. 15
      tests/go/func/test_listforeachif.go
  73. 9
      tests/go/func/test_listlast.go
  74. 21
      tests/go/func/test_listmerge.go
  75. 11
      tests/go/func/test_listpushback.go
  76. 11
      tests/go/func/test_listpushfront.go
  77. 13
      tests/go/func/test_listremoveif.go
  78. 11
      tests/go/func/test_listreverse.go
  79. 9
      tests/go/func/test_listsize.go
  80. 13
      tests/go/func/test_listsort.go
  81. 17
      tests/go/func/test_makerange.go
  82. 13
      tests/go/func/test_map.go
  83. 15
      tests/go/func/test_max.go
  84. 9
      tests/go/func/test_merge.go
  85. 15
      tests/go/func/test_nauuo.go
  86. 11
      tests/go/func/test_nrune.go
  87. 7
      tests/go/func/test_pointone.go
  88. 9
      tests/go/func/test_printcomb.go
  89. 9
      tests/go/func/test_printcomb2.go
  90. 9
      tests/go/func/test_printcombn.go
  91. 13
      tests/go/func/test_printmemory.go
  92. 15
      tests/go/func/test_printnbr.go
  93. 16
      tests/go/func/test_printnbrbase.go
  94. 13
      tests/go/func/test_printnbrinorder.go
  95. 11
      tests/go/func/test_printstr.go
  96. 11
      tests/go/func/test_printwordstables.go
  97. 11
      tests/go/func/test_priorprime.go
  98. 11
      tests/go/func/test_raid1a.go
  99. 11
      tests/go/func/test_raid1b.go
  100. 11
      tests/go/func/test_raid1c.go
  101. Some files were not shown because too many files changed in this diff diff.show_more

17
tests/go/func/test_abort.go

@ -1,18 +1,17 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
arg := z01.MultRandInt()
arg = append(arg, z01.RandInt())
arg := lib.MultRandInt()
arg = append(arg, lib.RandInt())
for i := 0; i < 15; i++ {
z01.Challenge("Abort", student.Abort, correct.Abort, arg[0], arg[1], arg[2], arg[3], arg[4])
arg = z01.MultRandInt()
arg = append(arg, z01.RandInt())
lib.Challenge("Abort", student.Abort, correct.Abort, arg[0], arg[1], arg[2], arg[3], arg[4])
arg = lib.MultRandInt()
arg = append(arg, lib.RandInt())
}
}

15
tests/go/func/test_activebits.go

@ -1,18 +1,17 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
args := []int{z01.RandIntBetween(2, 20)}
args = append(args, z01.MultRandIntBetween(2, 20)...)
args = append(args, z01.MultRandIntBetween(2, 20)...)
args := []int{lib.RandIntBetween(2, 20)}
args = append(args, lib.MultRandIntBetween(2, 20)...)
args = append(args, lib.MultRandIntBetween(2, 20)...)
for _, v := range args {
z01.Challenge("ActiveBits", student.ActiveBits, correct.ActiveBits, v)
lib.Challenge("ActiveBits", student.ActiveBits, correct.ActiveBits, v)
}
}

13
tests/go/func/test_addlinkednumbers.go

@ -3,9 +3,8 @@ package main
import (
"strconv"
"github.com/01-edu/z01"
correct "./correct"
"../lib"
"./correct"
)
type stuNode = NodeAddL
@ -87,18 +86,18 @@ func compareNodes(stuResult *stuNode, solResult *solNode, num1, num2 int) {
}
if stuResult != nil && solResult == nil {
stuNum := stuNodeString(stuResult)
z01.Fatalf("\nAddLinkedNumbers(%v, %v) == %v instead of %v\n\n",
lib.Fatalf("\nAddLinkedNumbers(%v, %v) == %v instead of %v\n\n",
num1, num2, stuNum, "")
}
if stuResult == nil && solResult != nil {
solNum := solNodeString(solResult)
z01.Fatalf("\nAddLinkedNumbers(%v, %v) == %v instead of %v\n\n",
lib.Fatalf("\nAddLinkedNumbers(%v, %v) == %v instead of %v\n\n",
num1, num2, "", solNum)
}
stuNum := stuNodeString(stuResult)
solNum := solNodeString(solResult)
if stuNum != solNum {
z01.Fatalf("\nAddLinkedNumbers(%v, %v) == %v instead of %v\n\n",
lib.Fatalf("\nAddLinkedNumbers(%v, %v) == %v instead of %v\n\n",
num1, num2, stuNum, solNum)
}
}
@ -107,7 +106,7 @@ func main() {
args := [][2]int{{315, 592}}
for i := 0; i < 15; i++ {
args = append(args, [2]int{z01.RandPosZ(), z01.RandPosZ()})
args = append(args, [2]int{lib.RandPosZ(), lib.RandPosZ()})
}
for _, arg := range args {

11
tests/go/func/test_advancedsortwordarr.go

@ -4,16 +4,15 @@ import (
"reflect"
"strings"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := [][]string{{"a", "A", "1", "b", "B", "2", "c", "C", "3"}}
table = append(table, z01.MultMultRandWords()...)
table = append(table, lib.MultMultRandWords()...)
for _, org := range table {
// copy for using the solution function
@ -28,7 +27,7 @@ func main() {
student.AdvancedSortWordArr(cp_stu, strings.Compare)
if !reflect.DeepEqual(cp_stu, cp_sol) {
z01.Fatalf("%s(%v) == %v instead of %v\n",
lib.Fatalf("%s(%v) == %v instead of %v\n",
"AdvancedSortWordArr",
org,
cp_stu,

15
tests/go/func/test_alphacount.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -13,12 +12,12 @@ func main() {
"Hello 78 World! 4455 /",
}
for l := 0; l < 7; l++ {
a := z01.RandIntBetween(5, 20)
b := z01.RandASCII()
table = append(table, z01.RandStr(a, b))
a := lib.RandIntBetween(5, 20)
b := lib.RandASCII()
table = append(table, lib.RandStr(a, b))
}
for _, arg := range table {
z01.Challenge("AlphaCount", student.AlphaCount, correct.AlphaCount, arg)
lib.Challenge("AlphaCount", student.AlphaCount, correct.AlphaCount, arg)
}
}

19
tests/go/func/test_any.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -18,29 +17,29 @@ func main() {
table := []node{}
for i := 0; i < 5; i++ {
function := functions[z01.RandIntBetween(0, len(functions)-1)]
function := functions[lib.RandIntBetween(0, len(functions)-1)]
table = append(table, node{
f: function,
a: z01.MultRandWords(),
a: lib.MultRandWords(),
})
}
for i := 0; i < 5; i++ {
table = append(table, node{
f: correct.IsNumeric,
a: z01.MultRandDigit(),
a: lib.MultRandDigit(),
})
}
for i := 0; i < 5; i++ {
table = append(table, node{
f: correct.IsLower,
a: z01.MultRandLower(),
a: lib.MultRandLower(),
})
}
for i := 0; i < 5; i++ {
table = append(table, node{
f: correct.IsUpper,
a: z01.MultRandUpper(),
a: lib.MultRandUpper(),
})
}
@ -56,6 +55,6 @@ func main() {
)
for _, arg := range table {
z01.Challenge("Any", student.Any, correct.Any, arg.f, arg.a)
lib.Challenge("Any", student.Any, correct.Any, arg.f, arg.a)
}
}

17
tests/go/func/test_appendrange.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -16,8 +15,8 @@ func main() {
// 15 random pairs of ints for a Valid Range
for i := 0; i < 15; i++ {
minVal := z01.RandIntBetween(-10000000, 1000000)
gap := z01.RandIntBetween(1, 20)
minVal := lib.RandIntBetween(-10000000, 1000000)
gap := lib.RandIntBetween(1, 20)
val := node{
min: minVal,
max: minVal + gap,
@ -27,8 +26,8 @@ func main() {
// 15 random pairs of ints with ||invalid range||
for i := 0; i < 15; i++ {
minVal := z01.RandIntBetween(-10000000, 1000000)
gap := z01.RandIntBetween(1, 20)
minVal := lib.RandIntBetween(-10000000, 1000000)
gap := lib.RandIntBetween(1, 20)
val := node{
min: minVal,
max: minVal - gap,
@ -44,6 +43,6 @@ func main() {
)
for _, arg := range table {
z01.Challenge("AppendRange", student.AppendRange, correct.AppendRange, arg.min, arg.max)
lib.Challenge("AppendRange", student.AppendRange, correct.AppendRange, arg.min, arg.max)
}
}

15
tests/go/func/test_atoi.go

@ -3,20 +3,19 @@ package main
import (
"strconv"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := make([]string, 30)
for i := range table {
table[i] = strconv.Itoa(z01.RandInt())
table[i] = strconv.Itoa(lib.RandInt())
}
table = append(table,
strconv.Itoa(z01.MinInt),
strconv.Itoa(z01.MaxInt),
strconv.Itoa(lib.MinInt),
strconv.Itoa(lib.MaxInt),
"",
"-",
"+",
@ -33,6 +32,6 @@ func main() {
"123a45",
)
for _, arg := range table {
z01.Challenge("Atoi", student.Atoi, correct.Atoi, arg)
lib.Challenge("Atoi", student.Atoi, correct.Atoi, arg)
}
}

10
tests/go/func/test_atoibase.go

@ -1,12 +1,10 @@
package main
import (
"github.com/01-edu/z01"
"../lib"
"./base"
correct "./correct"
student "./student"
"./correct"
"./student"
)
// this is the function that creates the TESTS
@ -44,7 +42,7 @@ func main() {
node{s: "bbbbbab", base: "-ab"},
)
for _, arg := range table {
z01.Challenge("AtoiBase", student.AtoiBase, correct.AtoiBase, arg.s, arg.base)
lib.Challenge("AtoiBase", student.AtoiBase, correct.AtoiBase, arg.s, arg.base)
}
}

13
tests/go/func/test_basicatoi.go

@ -3,19 +3,18 @@ package main
import (
"strconv"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := make([]string, 30)
for i := range table {
table[i] = strconv.Itoa(z01.RandPosZ())
table[i] = strconv.Itoa(lib.RandPosZ())
}
table = append(table,
strconv.Itoa(z01.MaxInt),
strconv.Itoa(lib.MaxInt),
"",
"0",
"12345",
@ -23,6 +22,6 @@ func main() {
"000000",
)
for _, arg := range table {
z01.Challenge("BasicAtoi", student.BasicAtoi, correct.BasicAtoi, arg)
lib.Challenge("BasicAtoi", student.BasicAtoi, correct.BasicAtoi, arg)
}
}

13
tests/go/func/test_basicatoi2.go

@ -3,19 +3,18 @@ package main
import (
"strconv"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := make([]string, 30)
for i := range table {
table[i] = strconv.Itoa(z01.RandPosZ())
table[i] = strconv.Itoa(lib.RandPosZ())
}
table = append(table,
strconv.Itoa(z01.MaxInt),
strconv.Itoa(lib.MaxInt),
"",
"0",
"Invalid123",
@ -27,6 +26,6 @@ func main() {
"123.0",
)
for _, arg := range table {
z01.Challenge("BasicAtoi2", student.BasicAtoi2, correct.BasicAtoi2, arg)
lib.Challenge("BasicAtoi2", student.BasicAtoi2, correct.BasicAtoi2, arg)
}
}

11
tests/go/func/test_basicjoin.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -12,12 +11,12 @@ func main() {
// 30 valid pair of ramdom slice of strings to concatenate
for i := 0; i < 30; i++ {
table = append(table, z01.MultRandASCII())
table = append(table, lib.MultRandASCII())
}
table = append(table,
[]string{"Hello!", " How are you?", "well and yourself?"},
)
for _, arg := range table {
z01.Challenge("BasicJoin", student.BasicJoin, correct.BasicJoin, arg)
lib.Challenge("BasicJoin", student.BasicJoin, correct.BasicJoin, arg)
}
}

4
tests/go/func/test_btreeapplybylevel.go

@ -3,8 +3,8 @@ package main
import (
"fmt"
correct "./correct"
student "./student"
"./correct"
"./student"
)
func main() {

4
tests/go/func/test_btreeapplyinorder.go

@ -3,8 +3,8 @@ package main
import (
"fmt"
correct "./correct"
student "./student"
"./correct"
"./student"
)
func main() {

4
tests/go/func/test_btreeapplypostorder.go

@ -3,8 +3,8 @@ package main
import (
"fmt"
correct "./correct"
student "./student"
"./correct"
"./student"
)
func main() {

4
tests/go/func/test_btreeapplypreorder.go

@ -3,8 +3,8 @@ package main
import (
"fmt"
correct "./correct"
student "./student"
"./correct"
"./student"
)
func main() {

9
tests/go/func/test_btreedeletenode.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func parentListDelete(root *student.TreeNode) string {
@ -80,7 +79,7 @@ func formatSubTree_delete(root *student.TreeNode, prefix string) string {
}
func errorMessage_delete(fn interface{}, deleted string, rootOr, root *correct.TreeNode, rootS *student.TreeNode) {
z01.Fatalf("%s(\n%s, %s\n) ==\n%s instead of\n%s\n",
lib.Fatalf("%s(\n%s, %s\n) ==\n%s instead of\n%s\n",
"BTreeDeleteNode",
correct.FormatTree(rootOr),
deleted,

9
tests/go/func/test_btreeinsertdata.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func parentListInsert(root *student.TreeNode) string {
@ -80,7 +79,7 @@ func formatSubTree_insert(root *student.TreeNode, prefix string) string {
}
func errorMessage_insert(fn interface{}, inserted string, root *correct.TreeNode, rootS *student.TreeNode) {
z01.Fatalf("%s(\n%s, %s\n) ==\n%s instead of\n%s\n",
lib.Fatalf("%s(\n%s, %s\n) ==\n%s instead of\n%s\n",
"BTreeInsertData",
correct.FormatTree(root),
inserted,

33
tests/go/func/test_btreeisbinary.go

@ -3,10 +3,9 @@ package main
import (
"reflect"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func BTreeMinStu(root *student.TreeNode) *student.TreeNode {
@ -17,7 +16,7 @@ func BTreeMinStu(root *student.TreeNode) *student.TreeNode {
}
func errorMessage_isbin(fn interface{}, root, a *correct.TreeNode, b *student.TreeNode) {
z01.Fatalf("%s(\n%s\n) == %s instead of %s\n",
lib.Fatalf("%s(\n%s\n) == %s instead of %s\n",
"BTreeIsBinary",
correct.FormatTree(root),
b.Data,
@ -27,31 +26,31 @@ func errorMessage_isbin(fn interface{}, root, a *correct.TreeNode, b *student.Tr
func CompareNode_isbin(fn interface{}, arg1, a *correct.TreeNode, b *student.TreeNode) {
if a == nil || b == nil {
z01.Fatalf("Expected %v instead of %v\n", a, b)
lib.Fatalf("Expected %v instead of %v\n", a, b)
}
if a.Data != b.Data {
errorMessage_isbin(fn, arg1, a, b)
}
if a.Parent != nil && b.Parent != nil && a.Parent.Data != b.Parent.Data {
errorMessage_isbin(fn, arg1, a, b)
z01.Fatalf("Expected parent value %v instead of %v\n", a.Parent.Data, b.Parent.Data)
lib.Fatalf("Expected parent value %v instead of %v\n", a.Parent.Data, b.Parent.Data)
}
if (a.Parent == nil && b.Parent != nil) || (a.Parent != nil && b.Parent == nil) {
z01.Fatalf("Expected parent value %v instead of %v\n", a.Parent, b.Parent)
lib.Fatalf("Expected parent value %v instead of %v\n", a.Parent, b.Parent)
}
if a.Right != nil && b.Right != nil && a.Right.Data != b.Right.Data {
errorMessage_isbin(fn, arg1, a, b)
z01.Fatalf("Expected right child value %v instead of %v\n", a.Right.Data, b.Right.Data)
lib.Fatalf("Expected right child value %v instead of %v\n", a.Right.Data, b.Right.Data)
}
if (a.Right == nil && b.Right != nil) || (a.Right != nil && b.Right == nil) {
z01.Fatalf("Expected right child value %v instead of %v\n", a.Right, b.Right)
lib.Fatalf("Expected right child value %v instead of %v\n", a.Right, b.Right)
}
if a.Left != nil && b.Left != nil && a.Left.Data != b.Left.Data {
errorMessage_isbin(fn, arg1, a, b)
z01.Fatalf("Expected left child value %v instead of %v\n", a.Left, b.Left)
lib.Fatalf("Expected left child value %v instead of %v\n", a.Left, b.Left)
}
if (a.Left == nil && b.Left != nil) || (a.Left != nil && b.Left == nil) {
z01.Fatalf("Expected left child value %v instead of %v\n", a, b)
lib.Fatalf("Expected left child value %v instead of %v\n", a, b)
}
}
@ -59,8 +58,8 @@ func CompareReturn_isbin(fn1, fn2 interface{}, arg1 *correct.TreeNode, arg2 inte
arar1 := []interface{}{arg1}
arar2 := []interface{}{arg2}
out1 := z01.Monitor(fn1, arar1)
out2 := z01.Monitor(fn2, arar2)
out1 := lib.Monitor(fn1, arar1)
out2 := lib.Monitor(fn2, arar2)
for i, v := range out1.Results {
switch str := v.(type) {
@ -68,11 +67,11 @@ func CompareReturn_isbin(fn1, fn2 interface{}, arg1 *correct.TreeNode, arg2 inte
CompareNode_isbin(fn1, arg1, str, out2.Results[i].(*student.TreeNode))
default:
if !reflect.DeepEqual(str, out2.Results[i]) {
z01.Fatalf("%s(\n%s) == %s instead of %s\n",
lib.Fatalf("%s(\n%s) == %s instead of %s\n",
"BTreeIsBinary",
correct.FormatTree(arg1),
z01.Format(out2.Results...),
z01.Format(out1.Results...),
lib.Format(out2.Results...),
lib.Format(out1.Results...),
)
}
}

33
tests/go/func/test_btreelevelcount.go

@ -3,14 +3,13 @@ package main
import (
"reflect"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func errorMessage_level(fn interface{}, root, a *correct.TreeNode, b *student.TreeNode) {
z01.Fatalf("%s(\n%s\n) == %s instead of %s\n",
lib.Fatalf("%s(\n%s\n) == %s instead of %s\n",
"BTreeLevelCount",
correct.FormatTree(root),
b.Data,
@ -20,7 +19,7 @@ func errorMessage_level(fn interface{}, root, a *correct.TreeNode, b *student.Tr
func CompareNode_level(fn interface{}, arg1, a *correct.TreeNode, b *student.TreeNode) {
if a == nil || b == nil {
z01.Fatalf("Expected %v instead of %v\n", a, b)
lib.Fatalf("Expected %v instead of %v\n", a, b)
return
}
@ -31,28 +30,28 @@ func CompareNode_level(fn interface{}, arg1, a *correct.TreeNode, b *student.Tre
if a.Parent != nil && b.Parent != nil {
if a.Parent.Data != b.Parent.Data {
errorMessage_level(fn, arg1, a, b)
z01.Fatalf("Expected parent value %v instead of %v\n", a.Parent.Data, b.Parent.Data)
lib.Fatalf("Expected parent value %v instead of %v\n", a.Parent.Data, b.Parent.Data)
}
} else if (a.Parent == nil && b.Parent != nil) || (a.Parent != nil && b.Parent == nil) {
z01.Fatalf("Expected parent value %v instead of %v\n", a.Parent, b.Parent)
lib.Fatalf("Expected parent value %v instead of %v\n", a.Parent, b.Parent)
}
if a.Right != nil && b.Right != nil {
if a.Right.Data != b.Right.Data {
errorMessage_level(fn, arg1, a, b)
z01.Fatalf("Expected right child value %v instead of %v\n", a.Right.Data, b.Right.Data)
lib.Fatalf("Expected right child value %v instead of %v\n", a.Right.Data, b.Right.Data)
}
} else if (a.Right == nil && b.Right != nil) || (a.Right != nil && b.Right == nil) {
z01.Fatalf("Expected right child value %v instead of %v\n", a.Right, b.Right)
lib.Fatalf("Expected right child value %v instead of %v\n", a.Right, b.Right)
}
if a.Left != nil && b.Left != nil {
if a.Left.Data != b.Left.Data {
errorMessage_level(fn, arg1, a, b)
z01.Fatalf("Expected left child value %v instead of %v\n", a.Left, b.Left)
lib.Fatalf("Expected left child value %v instead of %v\n", a.Left, b.Left)
}
} else if (a.Left == nil && b.Left != nil) || (a.Left != nil && b.Left == nil) {
z01.Fatalf("Expected left child value %v instead of %v\n", a, b)
lib.Fatalf("Expected left child value %v instead of %v\n", a, b)
}
}
@ -60,8 +59,8 @@ func CompareReturn_level(fn1, fn2 interface{}, arg1 *correct.TreeNode, arg2 inte
arar1 := []interface{}{arg1}
arar2 := []interface{}{arg2}
out1 := z01.Monitor(fn1, arar1)
out2 := z01.Monitor(fn2, arar2)
out1 := lib.Monitor(fn1, arar1)
out2 := lib.Monitor(fn2, arar2)
for i, v := range out1.Results {
switch str := v.(type) {
@ -69,11 +68,11 @@ func CompareReturn_level(fn1, fn2 interface{}, arg1 *correct.TreeNode, arg2 inte
CompareNode_level(fn1, arg1, str, out2.Results[i].(*student.TreeNode))
default:
if !reflect.DeepEqual(str, out2.Results[i]) {
z01.Fatalf("%s(\n%s) == %s instead of %s\n",
lib.Fatalf("%s(\n%s) == %s instead of %s\n",
"BTreeLevelCount",
correct.FormatTree(arg1),
z01.Format(out2.Results...),
z01.Format(out1.Results...),
lib.Format(out2.Results...),
lib.Format(out1.Results...),
)
}
}

33
tests/go/func/test_btreemax.go

@ -3,14 +3,13 @@ package main
import (
"reflect"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func errorMessage_max(fn interface{}, root, a *correct.TreeNode, b *student.TreeNode) {
z01.Fatalf("%s(\n%s) == %s instead of %s\n",
lib.Fatalf("%s(\n%s) == %s instead of %s\n",
"BTreeMax",
correct.FormatTree(root),
b.Data,
@ -20,7 +19,7 @@ func errorMessage_max(fn interface{}, root, a *correct.TreeNode, b *student.Tree
func CompareNode_max(fn interface{}, arg1, a *correct.TreeNode, b *student.TreeNode) {
if a == nil || b == nil {
z01.Fatalf("Expected %v instead of %v\n", a, b)
lib.Fatalf("Expected %v instead of %v\n", a, b)
return
}
@ -31,28 +30,28 @@ func CompareNode_max(fn interface{}, arg1, a *correct.TreeNode, b *student.TreeN
if a.Parent != nil && b.Parent != nil {
if a.Parent.Data != b.Parent.Data {
errorMessage_max(fn, arg1, a, b)
z01.Fatalf("Expected parent value %v instead of %v\n", a.Parent.Data, b.Parent.Data)
lib.Fatalf("Expected parent value %v instead of %v\n", a.Parent.Data, b.Parent.Data)
}
} else if (a.Parent == nil && b.Parent != nil) || (a.Parent != nil && b.Parent == nil) {
z01.Fatalf("Expected parent value %v instead of %v\n", a.Parent, b.Parent)
lib.Fatalf("Expected parent value %v instead of %v\n", a.Parent, b.Parent)
}
if a.Right != nil && b.Right != nil {
if a.Right.Data != b.Right.Data {
errorMessage_max(fn, arg1, a, b)
z01.Fatalf("Expected right child value %v instead of %v\n", a.Right.Data, b.Right.Data)
lib.Fatalf("Expected right child value %v instead of %v\n", a.Right.Data, b.Right.Data)
}
} else if (a.Right == nil && b.Right != nil) || (a.Right != nil && b.Right == nil) {
z01.Fatalf("Expected right child value %v instead of %v\n", a.Right, b.Right)
lib.Fatalf("Expected right child value %v instead of %v\n", a.Right, b.Right)
}
if a.Left != nil && b.Left != nil {
if a.Left.Data != b.Left.Data {
errorMessage_max(fn, arg1, a, b)
z01.Fatalf("Expected left child value %v instead of %v\n", a.Left, b.Left)
lib.Fatalf("Expected left child value %v instead of %v\n", a.Left, b.Left)
}
} else if (a.Left == nil && b.Left != nil) || (a.Left != nil && b.Left == nil) {
z01.Fatalf("Expected left child value %v instead of %v\n", a, b)
lib.Fatalf("Expected left child value %v instead of %v\n", a, b)
}
}
@ -60,8 +59,8 @@ func CompareReturn_max(fn1, fn2 interface{}, arg1 *correct.TreeNode, arg2 interf
arar1 := []interface{}{arg1}
arar2 := []interface{}{arg2}
out1 := z01.Monitor(fn1, arar1)
out2 := z01.Monitor(fn2, arar2)
out1 := lib.Monitor(fn1, arar1)
out2 := lib.Monitor(fn2, arar2)
for i, v := range out1.Results {
switch str := v.(type) {
@ -69,11 +68,11 @@ func CompareReturn_max(fn1, fn2 interface{}, arg1 *correct.TreeNode, arg2 interf
CompareNode_max(fn1, arg1, str, out2.Results[i].(*student.TreeNode))
default:
if !reflect.DeepEqual(str, out2.Results[i]) {
z01.Fatalf("%s(\n%s) == %s instead of\n %s\n",
lib.Fatalf("%s(\n%s) == %s instead of\n %s\n",
"BTreeMax",
correct.FormatTree(arg1),
z01.Format(out2.Results...),
z01.Format(out1.Results...),
lib.Format(out2.Results...),
lib.Format(out1.Results...),
)
}
}

35
tests/go/func/test_btreemin.go

@ -3,14 +3,13 @@ package main
import (
"reflect"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func errorMessage_min(fn interface{}, root, a *correct.TreeNode, b *student.TreeNode) {
z01.Fatalf("%s(\n%s) == %s instead of %s\n",
lib.Fatalf("%s(\n%s) == %s instead of %s\n",
"BTreeMin",
correct.FormatTree(root),
b.Data,
@ -20,7 +19,7 @@ func errorMessage_min(fn interface{}, root, a *correct.TreeNode, b *student.Tree
func CompareNode_min(fn interface{}, arg1, a *correct.TreeNode, b *student.TreeNode) {
if a == nil || b == nil {
z01.Fatalf("Expected %v instead of %v\n", a, b)
lib.Fatalf("Expected %v instead of %v\n", a, b)
return
}
@ -31,28 +30,28 @@ func CompareNode_min(fn interface{}, arg1, a *correct.TreeNode, b *student.TreeN
if a.Parent != nil && b.Parent != nil {
if a.Parent.Data != b.Parent.Data {
errorMessage_min(fn, arg1, a, b)
z01.Fatalf("Expected parent value %v instead of %v\n", a.Parent.Data, b.Parent.Data)
lib.Fatalf("Expected parent value %v instead of %v\n", a.Parent.Data, b.Parent.Data)
}
} else if (a.Parent == nil && b.Parent != nil) || (a.Parent != nil && b.Parent == nil) {
z01.Fatalf("Expected parent value %v instead of %v\n", a.Parent, b.Parent)
lib.Fatalf("Expected parent value %v instead of %v\n", a.Parent, b.Parent)
}
if a.Right != nil && b.Right != nil {
if a.Right.Data != b.Right.Data {
errorMessage_min(fn, arg1, a, b)
z01.Fatalf("Expected right child value %v instead of %v\n", a.Right.Data, b.Right.Data)
lib.Fatalf("Expected right child value %v instead of %v\n", a.Right.Data, b.Right.Data)
}
} else if (a.Right == nil && b.Right != nil) || (a.Right != nil && b.Right == nil) {
z01.Fatalf("Expected right child value %v instead of %v\n", a.Right, b.Right)
lib.Fatalf("Expected right child value %v instead of %v\n", a.Right, b.Right)
}
if a.Left != nil && b.Left != nil {
if a.Left.Data != b.Left.Data {
errorMessage_min(fn, arg1, a, b)
z01.Fatalf("Expected left child value %v instead of %v\n", a.Left, b.Left)
lib.Fatalf("Expected left child value %v instead of %v\n", a.Left, b.Left)
}
} else if (a.Left == nil && b.Left != nil) || (a.Left != nil && b.Left == nil) {
z01.Fatalf("Expected left child value %v instead of %v\n", a, b)
lib.Fatalf("Expected left child value %v instead of %v\n", a, b)
}
}
@ -60,8 +59,8 @@ func CompareReturn_min(fn1, fn2, arg1, arg2 interface{}) {
arar1 := []interface{}{arg1}
arar2 := []interface{}{arg2}
out1 := z01.Monitor(fn1, arar1)
out2 := z01.Monitor(fn2, arar2)
out1 := lib.Monitor(fn1, arar1)
out2 := lib.Monitor(fn2, arar2)
for i, v := range out1.Results {
switch str := v.(type) {
@ -69,11 +68,11 @@ func CompareReturn_min(fn1, fn2, arg1, arg2 interface{}) {
CompareNode_min(fn1, arg1.(*correct.TreeNode), str, out2.Results[i].(*student.TreeNode))
default:
if !reflect.DeepEqual(str, out2.Results[i]) {
z01.Fatalf("%s(%s) == %s instead of %s\n",
lib.Fatalf("%s(%s) == %s instead of %s\n",
"BTreeMin",
z01.Format(arg1),
z01.Format(out2.Results...),
z01.Format(out1.Results...),
lib.Format(arg1),
lib.Format(out2.Results...),
lib.Format(out1.Results...),
)
}
}

23
tests/go/func/test_btreesearchitem.go

@ -1,17 +1,16 @@
package main
import (
"github.com/01-edu/z01"
"fmt"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func errorMessage_search(fn interface{}, root, a *correct.TreeNode, b *student.TreeNode,
seaVal string) {
z01.Fatalf("%s(\n%s\n, %s) == %s instead of %s\n",
lib.Fatalf("%s(\n%s\n, %s) == %s instead of %s\n",
"BTreeSearchItem",
correct.FormatTree(root),
seaVal,
@ -27,7 +26,7 @@ func CompareNode_search(fn interface{}, arg1, a *correct.TreeNode, b *student.Tr
}
if (a == nil && b != nil) || (b == nil && a != nil) {
z01.Fatalf("Expected %v instead of %v\n", a, b)
lib.Fatalf("Expected %v instead of %v\n", a, b)
return
}
@ -38,31 +37,31 @@ func CompareNode_search(fn interface{}, arg1, a *correct.TreeNode, b *student.Tr
if a.Parent != nil && b.Parent != nil {
if a.Parent.Data != b.Parent.Data {
errorMessage_search(fn, arg1, a, b, seaVal)
z01.Fatalf("Expected parent value %v instead of %v\n", a.Parent.Data, b.Parent.Data)
lib.Fatalf("Expected parent value %v instead of %v\n", a.Parent.Data, b.Parent.Data)
fmt.Println("Parent.Data", a.Parent.Data, b.Parent.Data)
}
} else if (a.Parent == nil && b.Parent != nil) || (a.Parent != nil && b.Parent == nil) {
z01.Fatalf("Expected parent value %v instead of %v\n", a.Parent, b.Parent)
lib.Fatalf("Expected parent value %v instead of %v\n", a.Parent, b.Parent)
}
if a.Right != nil && b.Right != nil {
if a.Right.Data != b.Right.Data {
errorMessage_search(fn, arg1, a, b, seaVal)
z01.Fatalf("Expected right child value %v instead of %v\n", a.Right.Data, b.Right.Data)
lib.Fatalf("Expected right child value %v instead of %v\n", a.Right.Data, b.Right.Data)
fmt.Println("Right.Data", a.Right.Data, b.Right.Data)
}
} else if (a.Right == nil && b.Right != nil) || (a.Right != nil && b.Right == nil) {
z01.Fatalf("Expected right child value %v instead of %v\n", a.Right, b.Right)
lib.Fatalf("Expected right child value %v instead of %v\n", a.Right, b.Right)
}
if a.Left != nil && b.Left != nil {
if a.Left.Data != b.Left.Data {
errorMessage_search(fn, arg1, a, b, seaVal)
z01.Fatalf("Expected left child value %v instead of %v\n", a.Left, b.Left)
lib.Fatalf("Expected left child value %v instead of %v\n", a.Left, b.Left)
fmt.Println("Left.Data", a.Left.Data, b.Left.Data)
}
} else if (a.Left == nil && b.Left != nil) || (a.Left != nil && b.Left == nil) {
z01.Fatalf("Expected left child value %v instead of %v\n", a, b)
lib.Fatalf("Expected left child value %v instead of %v\n", a, b)
}
}

11
tests/go/func/test_btreetransplant.go

@ -1,12 +1,11 @@
package main
import (
"github.com/01-edu/z01"
"fmt"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func parentListTransp(root *student.TreeNode) string {
@ -82,7 +81,7 @@ func formatSubTree_transp(root *student.TreeNode, prefix string) string {
}
func errorMessage_transp(fn interface{}, root, sel, repl *correct.TreeNode, rootA *correct.TreeNode, rootAS *student.TreeNode) {
z01.Fatalf("%s(\nRoot:\n %s, Selected:\n%s, Replacement:\n%s\n) ==\n%s instead of\n%s\n",
lib.Fatalf("%s(\nRoot:\n %s, Selected:\n%s, Replacement:\n%s\n) ==\n%s instead of\n%s\n",
"BTreeTransplant",
correct.FormatTree(root),
correct.FormatTree(sel),
@ -104,7 +103,7 @@ func CompareTrees_transp(fn interface{}, root, sel, repl *correct.TreeNode, root
if parentSol != parentStu {
fmt.Println("Tree:\n", solTree)
z01.Fatalf("Expected\n%s instead of\n%s\n", parentSol, parentStu)
lib.Fatalf("Expected\n%s instead of\n%s\n", parentSol, parentStu)
}
}

11
tests/go/func/test_capitalize.go

@ -1,15 +1,14 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := append(
z01.MultRandASCII(),
lib.MultRandASCII(),
"Hello! How are you? How+are+things+4you?",
"Hello! How are you?",
"a",
@ -19,6 +18,6 @@ func main() {
"9a LALALA!",
)
for _, arg := range table {
z01.Challenge("Capitalize", student.Capitalize, correct.Capitalize, arg)
lib.Challenge("Capitalize", student.Capitalize, correct.Capitalize, arg)
}
}

13
tests/go/func/test_changeorder.go

@ -3,9 +3,8 @@ package main
import (
"strconv"
"github.com/01-edu/z01"
correct "./correct"
"../lib"
"./correct"
)
type stuNode = NodeAddL
@ -77,25 +76,25 @@ func compareNodes(stuResult *stuNode, solResult *solNode, num1 int) {
}
if stuResult != nil && solResult == nil {
stuNum := stuListToNum(stuResult)
z01.Fatalf("\nChangeorder(%s) == %v instead of %v\n\n",
lib.Fatalf("\nChangeorder(%s) == %v instead of %v\n\n",
solList, stuNum, "")
}
if stuResult == nil && solResult != nil {
solNum := solListToNum(solResult)
z01.Fatalf("\nChangeorder(%s) == %v instead of %v\n\n",
lib.Fatalf("\nChangeorder(%s) == %v instead of %v\n\n",
solList, "", solNum)
}
stuNum := stuListToNum(stuResult)
solNum := solListToNum(solResult)
if stuNum != solNum {
z01.Fatalf("\nChangeorder(%s) == %v instead of %v\n\n",
lib.Fatalf("\nChangeorder(%s) == %v instead of %v\n\n",
solList, stuNum, solNum)
}
}
func main() {
table := []int{1234567}
table = append(table, z01.MultRandIntBetween(0, 1000000000)...)
table = append(table, lib.MultRandIntBetween(0, 1000000000)...)
for _, arg := range table {
stuResult := Changeorder(stuNumToList(arg))

15
tests/go/func/test_chunk.go

@ -1,16 +1,15 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func randomSize() []int {
randSlice := []int{}
for i := 0; i <= z01.RandIntBetween(0, 20); i++ {
randSlice = append(randSlice, z01.RandInt())
for i := 0; i <= lib.RandIntBetween(0, 20); i++ {
randSlice = append(randSlice, lib.RandInt())
}
return randSlice
}
@ -25,7 +24,7 @@ func main() {
for i := 0; i <= 7; i++ {
value := node{
slice: randomSize(),
ch: z01.RandIntBetween(0, 10),
ch: lib.RandIntBetween(0, 10),
}
table = append(table, value)
}
@ -37,6 +36,6 @@ func main() {
ch: 0,
})
for _, args := range table {
z01.Challenge("Chunk", student.Chunk, correct.Chunk, args.slice, args.ch)
lib.Challenge("Chunk", student.Chunk, correct.Chunk, args.slice, args.ch)
}
}

13
tests/go/func/test_collatzcountdown.go

@ -1,20 +1,19 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
args := []int{z01.RandIntBetween(-6, 20)}
args := []int{lib.RandIntBetween(-6, 20)}
args = append(args, -5, 0)
for i := 0; i < 20; i++ {
args = append(args, z01.RandIntBetween(2, 20))
args = append(args, lib.RandIntBetween(2, 20))
}
for _, v := range args {
z01.Challenge("CollatzCountdown", student.CollatzCountdown, correct.CollatzCountdown, v)
lib.Challenge("CollatzCountdown", student.CollatzCountdown, correct.CollatzCountdown, v)
}
}

19
tests/go/func/test_compact.go

@ -3,25 +3,24 @@ package main
import (
"reflect"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
arg := [][]string{{"hello", "", "hi", "", "salut", "", ""}}
for i := 0; i < 20; i++ {
n := z01.RandIntBetween(5, 20) // random size of the slice
n := lib.RandIntBetween(5, 20) // random size of the slice
orig := make([]string, n) // slice with the original value
num_pos := z01.RandIntBetween(1, n-1) // random number of positions to be written
num_pos := lib.RandIntBetween(1, n-1) // random number of positions to be written
for i := 0; i < num_pos; i++ {
word := z01.RandWords() // random string value
rand_pos := z01.RandIntBetween(0, n-1) // random position in the slice
word := lib.RandWords() // random string value
rand_pos := lib.RandIntBetween(0, n-1) // random position in the slice
orig[rand_pos] = word
}
arg = append(arg, orig)
@ -38,14 +37,14 @@ func main() {
stu_size := student.Compact(&sli_stu)
if !reflect.DeepEqual(sli_stu, sli_sol) {
z01.Fatalf("Produced slice: %v, instead of %v\n",
lib.Fatalf("Produced slice: %v, instead of %v\n",
sli_stu,
sli_sol,
)
}
if sol_size != stu_size {
z01.Fatalf("%s(%v) == %v instead of %v\n",
lib.Fatalf("%s(%v) == %v instead of %v\n",
"Compact",
v,
sli_stu,

15
tests/go/func/test_compare.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -17,7 +16,7 @@ func main() {
// the first 15 values are returning 0 for this test
for i := 0; i < 15; i++ {
wordToTest := z01.RandASCII()
wordToTest := lib.RandASCII()
val := node{
s: wordToTest,
@ -28,8 +27,8 @@ func main() {
// the next 15 values are supposed to return 1 or -1 for this test
for i := 0; i < 15; i++ {
wordToTest := z01.RandASCII()
wrongMatch := z01.RandASCII()
wordToTest := lib.RandASCII()
wrongMatch := lib.RandASCII()
val := node{
s: wordToTest,
@ -45,6 +44,6 @@ func main() {
)
for _, arg := range table {
z01.Challenge("Compare", student.Compare, correct.Compare, arg.s, arg.toCompare)
lib.Challenge("Compare", student.Compare, correct.Compare, arg.s, arg.toCompare)
}
}

11
tests/go/func/test_concat.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -12,13 +11,13 @@ func main() {
// 30 valid pair of ramdom strings to concatenate
for i := 0; i < 30; i++ {
value := []string{z01.RandASCII(), z01.RandASCII()}
value := []string{lib.RandASCII(), lib.RandASCII()}
table = append(table, value)
}
table = append(table,
[]string{"Hello!", " How are you?"},
)
for _, arg := range table {
z01.Challenge("Concat", student.Concat, correct.Concat, arg[0], arg[1])
lib.Challenge("Concat", student.Concat, correct.Concat, arg[0], arg[1])
}
}

11
tests/go/func/test_concatparams.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -12,9 +11,9 @@ func main() {
// 30 random slice of strings
for i := 0; i < 30; i++ {
table = append(table, z01.MultRandASCII())
table = append(table, lib.MultRandASCII())
}
for _, arg := range table {
z01.Challenge("ConcatParams", student.ConcatParams, correct.ConcatParams, arg)
lib.Challenge("ConcatParams", student.ConcatParams, correct.ConcatParams, arg)
}
}

12
tests/go/func/test_convertbase.go

@ -1,12 +1,10 @@
package main
import (
"github.com/01-edu/z01"
"../lib"
"./base"
correct "./correct"
student "./student"
"./correct"
"./student"
)
func main() {
@ -20,7 +18,7 @@ func main() {
for i := 0; i < 30; i++ {
validBaseToInput1 := base.Valid()
validBaseToInput2 := base.Valid()
str := base.ConvertNbr(z01.RandIntBetween(0, 1000000), validBaseToInput1)
str := base.ConvertNbr(lib.RandIntBetween(0, 1000000), validBaseToInput1)
val := node{
nbr: str,
baseFrom: validBaseToInput1,
@ -36,7 +34,7 @@ func main() {
)
for _, arg := range table {
z01.Challenge("ConvertBase", student.ConvertBase, correct.ConvertBase, arg.nbr, arg.baseFrom, arg.baseTo)
lib.Challenge("ConvertBase", student.ConvertBase, correct.ConvertBase, arg.nbr, arg.baseFrom, arg.baseTo)
}
}

19
tests/go/func/test_countif.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -18,17 +17,17 @@ func main() {
table := []node{}
for i := 0; i < 5; i++ {
function := functions[z01.RandIntBetween(0, len(functions)-1)]
function := functions[lib.RandIntBetween(0, len(functions)-1)]
val := node{
f: function,
arr: z01.MultRandWords(),
arr: lib.MultRandWords(),
}
table = append(table, val)
}
for i := 0; i < 5; i++ {
val := node{
f: correct.IsNumeric,
arr: z01.MultRandDigit(),
arr: lib.MultRandDigit(),
}
table = append(table, val)
}
@ -36,14 +35,14 @@ func main() {
for i := 0; i < 5; i++ {
val := node{
f: correct.IsLower,
arr: z01.MultRandLower(),
arr: lib.MultRandLower(),
}
table = append(table, val)
}
for i := 0; i < 5; i++ {
val := node{
f: correct.IsUpper,
arr: z01.MultRandUpper(),
arr: lib.MultRandUpper(),
}
table = append(table, val)
}
@ -60,6 +59,6 @@ func main() {
)
for _, arg := range table {
z01.Challenge("CountIf", student.CountIf, correct.CountIf, arg.f, arg.arr)
lib.Challenge("CountIf", student.CountIf, correct.CountIf, arg.f, arg.arr)
}
}

11
tests/go/func/test_createelem.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
// the structs from the other packages
@ -20,7 +19,7 @@ func main() {
table := [][]int{{{132423}}}
for i := 0; i < 5; i++ {
table = append(table, z01.MultRandIntBetween(-1000000, 10000000))
table = append(table, lib.MultRandIntBetween(-1000000, 10000000))
}
for _, items := range table {
@ -30,7 +29,7 @@ func main() {
}
if n1.Data != n2.Data {
z01.Fatalf("CreateElem == %d instead of %d\n", n1, n2)
lib.Fatalf("CreateElem == %d instead of %d\n", n1, n2)
}
}
}

15
tests/go/func/test_divmod.go

@ -1,24 +1,23 @@
package main
import (
"github.com/01-edu/z01"
student "./student"
"../lib"
"./student"
)
func main() {
i := 0
for i < z01.SliceLen {
a := z01.RandInt()
b := z01.RandInt()
for i < lib.SliceLen {
a := lib.RandInt()
b := lib.RandInt()
var div int
var mod int
student.DivMod(a, b, &div, &mod)
if div != a/b {
z01.Fatalf("DivMod(%d, %d, &div, &mod), div == %d instead of %d", a, b, div, a/b)
lib.Fatalf("DivMod(%d, %d, &div, &mod), div == %d instead of %d", a, b, div, a/b)
}
if mod != a%b {
z01.Fatalf("DivMod(%d, %d, &div, &mod), mod == %d instead of %d", a, b, mod, a%b)
lib.Fatalf("DivMod(%d, %d, &div, &mod), mod == %d instead of %d", a, b, mod, a%b)
}
i++
}

21
tests/go/func/test_doppelganger.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
type node struct {
@ -21,10 +20,10 @@ func main() {
)
for i := 0; i < 10; i++ {
l := z01.RandIntBetween(5, 30)
big := z01.RandStr(l, "qwertyuiopasdfghjklzxcvbnm")
start := z01.RandIntBetween(0, l-1)
end := z01.RandIntBetween(start+1, l-1)
l := lib.RandIntBetween(5, 30)
big := lib.RandStr(l, "qwertyuiopasdfghjklzxcvbnm")
start := lib.RandIntBetween(0, l-1)
end := lib.RandIntBetween(start+1, l-1)
little := big[start:end]
value := node{
@ -36,8 +35,8 @@ func main() {
}
for i := 0; i < 10; i++ {
big := z01.RandStr(z01.RandIntBetween(5, 30), "qwertyuiopasdfghjklzxcvbnm")
little := z01.RandStr(z01.RandIntBetween(1, 29), "qwertyuiopasdfghjklzxcvbnm")
big := lib.RandStr(lib.RandIntBetween(5, 30), "qwertyuiopasdfghjklzxcvbnm")
little := lib.RandStr(lib.RandIntBetween(1, 29), "qwertyuiopasdfghjklzxcvbnm")
value := node{
big: big,
@ -48,6 +47,6 @@ func main() {
}
for _, arg := range table {
z01.Challenge("DoppelGanger", student.DoppelGanger, correct.DoppelGanger, arg.big, arg.little)
lib.Challenge("DoppelGanger", student.DoppelGanger, correct.DoppelGanger, arg.big, arg.little)
}
}

9
tests/go/func/test_eightqueens.go

@ -1,12 +1,11 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
z01.Challenge("EightQueens", student.EightQueens, correct.EightQueens)
lib.Challenge("EightQueens", student.EightQueens, correct.EightQueens)
}

17
tests/go/func/test_enigma.go

@ -1,14 +1,13 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
args := append([]int, z01.MultRandIntBetween(2, 20)...)
args := append([]int, lib.MultRandIntBetween(2, 20)...)
aval := args[0]
x := args[0]
@ -41,25 +40,25 @@ func main() {
correct.Decript(a, b, c, d)
if aval != ***a {
z01.Fatalf("Expected ***a = %d instead of %d\n",
lib.Fatalf("Expected ***a = %d instead of %d\n",
aval,
***a,
)
}
if bval != *b {
z01.Fatalf("Expected *b = %d instead of %d\n",
lib.Fatalf("Expected *b = %d instead of %d\n",
bval,
*b,
)
}
if cval != *******c {
z01.Fatalf("Expected *******c = %d instead of %d\n",
lib.Fatalf("Expected *******c = %d instead of %d\n",
cval,
*******c,
)
}
if dval != ****d {
z01.Fatalf("Expected ****d = %d instead of %d\n",
lib.Fatalf("Expected ****d = %d instead of %d\n",
dval,
****d,
)

11
tests/go/func/test_fib.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -14,8 +13,8 @@ func main() {
9,
2,
}
table = append(table, z01.MultRandIntBetween(-100, 150)...)
table = append(table, lib.MultRandIntBetween(-100, 150)...)
for _, arg := range table {
z01.Challenge("Fib", student.Fib, correct.Fib, arg)
lib.Challenge("Fib", student.Fib, correct.Fib, arg)
}
}

11
tests/go/func/test_fibonacci.go

@ -1,20 +1,19 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := append(
z01.MultRandIntBetween(0, 25),
lib.MultRandIntBetween(0, 25),
4,
5,
-5,
)
for _, arg := range table {
z01.Challenge("Fibonacci", student.Fibonacci, correct.Fibonacci, arg)
lib.Challenge("Fibonacci", student.Fibonacci, correct.Fibonacci, arg)
}
}

11
tests/go/func/test_findnextprime.go

@ -1,15 +1,14 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := append(
z01.MultRandIntBetween(-1000000, 1000000),
lib.MultRandIntBetween(-1000000, 1000000),
0,
1,
2,
@ -29,6 +28,6 @@ func main() {
1000000088,
)
for _, arg := range table {
z01.Challenge("FindNextPrime", student.FindNextPrime, correct.FindNextPrime, arg)
lib.Challenge("FindNextPrime", student.FindNextPrime, correct.FindNextPrime, arg)
}
}

11
tests/go/func/test_findprevprime.go

@ -1,15 +1,14 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
a := append(z01.MultRandIntBetween(0, 99999), 5, 4, 1)
a := append(lib.MultRandIntBetween(0, 99999), 5, 4, 1)
for _, elem := range a {
z01.Challenge("FindPrevPrime", student.FindPrevPrime, correct.FindPrevPrime, elem)
lib.Challenge("FindPrevPrime", student.FindPrevPrime, correct.FindPrevPrime, elem)
}
}

11
tests/go/func/test_firstrune.go

@ -1,21 +1,20 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := append(
z01.MultRandASCII(),
lib.MultRandASCII(),
"Hello!",
"Salut!",
"Ola!",
"♥01",
)
for _, arg := range table {
z01.Challenge("FirstRune", student.FirstRune, correct.FirstRune, arg)
lib.Challenge("FirstRune", student.FirstRune, correct.FirstRune, arg)
}
}

13
tests/go/func/test_foldint.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -29,11 +28,11 @@ func main() {
table := []node{}
for i := 0; i < 8; i++ {
argInt = append(argInt, z01.MultRandIntBetween(0, 50)...)
argInt = append(argInt, lib.MultRandIntBetween(0, 50)...)
table = append(table, node{
a: argInt,
functions: f,
n: z01.RandIntBetween(0, 60),
n: lib.RandIntBetween(0, 60),
})
}
@ -51,7 +50,7 @@ func main() {
for _, v := range table {
for _, f := range v.functions {
z01.Challenge("FoldInt", student.FoldInt, correct.FoldInt, f, v.a, v.n)
lib.Challenge("FoldInt", student.FoldInt, correct.FoldInt, f, v.a, v.n)
}
}
}

13
tests/go/func/test_foreach.go

@ -3,10 +3,9 @@ package main
import (
"fmt"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func add0(i int) {
@ -34,10 +33,10 @@ func main() {
// 15 random slice of random ints with a random function from selection
for i := 0; i < 15; i++ {
function := functions[z01.RandIntBetween(0, len(functions)-1)]
function := functions[lib.RandIntBetween(0, len(functions)-1)]
table = append(table, node{
f: function,
a: z01.MultRandIntBetween(-1000000, 1000000),
a: lib.MultRandIntBetween(-1000000, 1000000),
})
}
@ -47,6 +46,6 @@ func main() {
})
for _, arg := range table {
z01.Challenge("ForEach", student.ForEach, correct.ForEach, arg.f, arg.a)
lib.Challenge("ForEach", student.ForEach, correct.ForEach, arg.f, arg.a)
}
}

13
tests/go/func/test_game23.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func nd(a, b int) int {
@ -37,8 +36,8 @@ func main() {
for i := 0; i < 20; i++ {
table = append(table, node{
init: z01.RandIntBetween(1, 1000),
fin: z01.RandIntBetween(1, 1000),
init: lib.RandIntBetween(1, 1000),
fin: lib.RandIntBetween(1, 1000),
})
}
@ -56,6 +55,6 @@ func main() {
table = append(table, value)
}
for _, arg := range table {
z01.Challenge("Game23", student.Game23, correct.Game23, arg.init, arg.fin)
lib.Challenge("Game23", student.Game23, correct.Game23, arg.init, arg.fin)
}
}

17
tests/go/func/test_halfcontest.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -21,14 +20,14 @@ func main() {
for i := 0; i < 20; i++ {
table = append(table, node{
h1: z01.RandIntBetween(0, 10),
m1: z01.RandIntBetween(0, 59),
h2: z01.RandIntBetween(11, 23),
m2: z01.RandIntBetween(0, 59),
h1: lib.RandIntBetween(0, 10),
m1: lib.RandIntBetween(0, 59),
h2: lib.RandIntBetween(11, 23),
m2: lib.RandIntBetween(0, 59),
})
}
for _, arg := range table {
z01.Challenge("HalfContest", student.HalfContest, correct.HalfContest, arg.h1, arg.m1, arg.h2, arg.m2)
lib.Challenge("HalfContest", student.HalfContest, correct.HalfContest, arg.h1, arg.m1, arg.h2, arg.m2)
}
}

19
tests/go/func/test_index.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -17,9 +16,9 @@ func main() {
// the first 15 values are valid for this test
for i := 0; i < 15; i++ {
wordToTest := z01.RandASCII()
firstLetterIndex := z01.RandIntBetween(0, (len(wordToTest)-1)/2)
lastLetterIndex := z01.RandIntBetween(firstLetterIndex, len(wordToTest)-1)
wordToTest := lib.RandASCII()
firstLetterIndex := lib.RandIntBetween(0, (len(wordToTest)-1)/2)
lastLetterIndex := lib.RandIntBetween(firstLetterIndex, len(wordToTest)-1)
val := node{
s: wordToTest,
@ -30,8 +29,8 @@ func main() {
// the next 15 values are supposed to be invalid for this test
for i := 0; i < 15; i++ {
wordToTest := z01.RandASCII()
wrongMatch := z01.RandASCII()
wordToTest := lib.RandASCII()
wrongMatch := lib.RandASCII()
val := node{
s: wordToTest,
@ -47,6 +46,6 @@ func main() {
)
for _, arg := range table {
z01.Challenge("Index", student.Index, correct.Index, arg.s, arg.toFind)
lib.Challenge("Index", student.Index, correct.Index, arg.s, arg.toFind)
}
}

11
tests/go/func/test_interestingnumber.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -14,9 +13,9 @@ func main() {
9,
2,
}
table = append(table, z01.MultRandIntBetween(1, 1500)...)
table = append(table, lib.MultRandIntBetween(1, 1500)...)
for _, arg := range table {
z01.Challenge("InterestingNumber", student.InterestingNumber, correct.InterestingNumber, arg)
lib.Challenge("InterestingNumber", student.InterestingNumber, correct.InterestingNumber, arg)
}
}

9
tests/go/func/test_inverttree.go

@ -6,9 +6,8 @@ import (
"math/rand"
"strconv"
"github.com/01-edu/z01"
correct "./correct"
"../lib"
"./correct"
)
type stuNode = TNode
@ -156,8 +155,8 @@ func main() {
if !IsIdentical(tree, TestTree) {
tree1 := returnSolTree(temp)
tree2 := returnStuTree(tmp)
z01.Fatalf("\n\"%v\" instead of \"%v\"\n\n", tree1, tree2)
// z01.Fatalf("\nError\n\n")
lib.Fatalf("\n\"%v\" instead of \"%v\"\n\n", tree1, tree2)
// lib.Fatalf("\nError\n\n")
}
}
}

11
tests/go/func/test_isalpha.go

@ -1,15 +1,14 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := append(
z01.MultRandASCII(),
lib.MultRandASCII(),
"Hello! €How are you?",
"a",
"z",
@ -21,6 +20,6 @@ func main() {
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!",
)
for _, arg := range table {
z01.Challenge("IsAlpha", student.IsAlpha, correct.IsAlpha, arg)
lib.Challenge("IsAlpha", student.IsAlpha, correct.IsAlpha, arg)
}
}

13
tests/go/func/test_isanagram.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -28,12 +27,12 @@ func main() {
}
for i := 0; i < 15; i++ {
table = append(table, [2]string{
z01.RandStr(z01.RandIntBetween(15, 20), "qwertyuiopasdfghjklzxcvbnm "),
z01.RandStr(z01.RandIntBetween(15, 20), "qwertyuiopasdfghjklzxcvbnm "),
lib.RandStr(lib.RandIntBetween(15, 20), "qwertyuiopasdfghjklzxcvbnm "),
lib.RandStr(lib.RandIntBetween(15, 20), "qwertyuiopasdfghjklzxcvbnm "),
})
}
for _, arg := range table {
z01.Challenge("IsAnagram", student.IsAnagram, correct.IsAnagram, arg[0], arg[1])
lib.Challenge("IsAnagram", student.IsAnagram, correct.IsAnagram, arg[0], arg[1])
}
}

15
tests/go/func/test_islower.go

@ -1,20 +1,19 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
// 15 unvalid strings in the table
table := z01.MultRandASCII()
table := lib.MultRandASCII()
// 15 valid lowercase strings of random size between 1 and 20 letters in the table
for i := 0; i < 15; i++ {
size := z01.RandIntBetween(1, 20)
randLow := z01.RandLower()
size := lib.RandIntBetween(1, 20)
randLow := lib.RandLower()
if len(randLow) <= size {
table = append(table, randLow)
} else {
@ -40,6 +39,6 @@ func main() {
"hello!",
)
for _, arg := range table {
z01.Challenge("IsLower", student.IsLower, correct.IsLower, arg)
lib.Challenge("IsLower", student.IsLower, correct.IsLower, arg)
}
}

15
tests/go/func/test_isnegative.go

@ -1,20 +1,19 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := append(
z01.MultRandInt(),
z01.MinInt,
z01.MaxInt,
lib.MultRandInt(),
lib.MinInt,
lib.MaxInt,
0,
)
for _, arg := range table {
z01.Challenge("IsNegative", student.IsNegative, correct.IsNegative, arg)
lib.Challenge("IsNegative", student.IsNegative, correct.IsNegative, arg)
}
}

13
tests/go/func/test_isnumeric.go

@ -3,19 +3,18 @@ package main
import (
"strconv"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
// 15 unvalid strings in the table
table := z01.MultRandASCII()
table := lib.MultRandASCII()
// 15 valid strings in the table
for i := 0; i < 15; i++ {
table = append(table, strconv.Itoa(z01.RandIntBetween(0, 1000000)))
table = append(table, strconv.Itoa(lib.RandIntBetween(0, 1000000)))
}
// Special cases added to table
@ -34,6 +33,6 @@ func main() {
"01,02,03",
)
for _, arg := range table {
z01.Challenge("IsNumeric", student.IsNumeric, correct.IsNumeric, arg)
lib.Challenge("IsNumeric", student.IsNumeric, correct.IsNumeric, arg)
}
}

11
tests/go/func/test_isprime.go

@ -1,15 +1,14 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := append(
z01.MultRandIntBetween(-1000000, 1000000),
lib.MultRandIntBetween(-1000000, 1000000),
0,
1,
2,
@ -28,6 +27,6 @@ func main() {
1000000087,
)
for _, arg := range table {
z01.Challenge("IsPrime", student.IsPrime, correct.IsPrime, arg)
lib.Challenge("IsPrime", student.IsPrime, correct.IsPrime, arg)
}
}

13
tests/go/func/test_isprintable.go

@ -3,20 +3,19 @@ package main
import (
"math/rand"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
// 15 unvalid strings in the table
table := z01.MultRandASCII()
table := lib.MultRandASCII()
// 15 valid lowercase strings of random size between 1 and 20 letters in the table
for i := 0; i < 15; i++ {
letters := []rune("\a\b\f\r\n\v\t")
size := z01.RandIntBetween(1, 20)
size := lib.RandIntBetween(1, 20)
r := make([]rune, size)
for i := range r {
r[i] = letters[rand.Intn(len(letters))]
@ -44,6 +43,6 @@ func main() {
"\n",
)
for _, arg := range table {
z01.Challenge("IsPrintable", student.IsPrintable, correct.IsPrintable, arg)
lib.Challenge("IsPrintable", student.IsPrintable, correct.IsPrintable, arg)
}
}

21
tests/go/func/test_issorted.go

@ -3,10 +3,9 @@ package main
import (
"sort"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func isSortedBy1(a, b int) int {
@ -45,18 +44,18 @@ func main() {
// 5 unordered slices
for i := 0; i < 5; i++ {
function := functions[z01.RandIntBetween(0, len(functions)-1)]
function := functions[lib.RandIntBetween(0, len(functions)-1)]
val := node{
f: function,
a: z01.MultRandIntBetween(-1000000, 1000000),
a: lib.MultRandIntBetween(-1000000, 1000000),
}
table = append(table, val)
}
// 5 slices ordered in ascending order
for i := 0; i < 5; i++ {
function := functions[z01.RandIntBetween(0, len(functions)-1)]
ordered := z01.MultRandIntBetween(-1000000, 1000000)
function := functions[lib.RandIntBetween(0, len(functions)-1)]
ordered := lib.MultRandIntBetween(-1000000, 1000000)
sort.Ints(ordered)
val := node{
@ -68,8 +67,8 @@ func main() {
// 5 slices ordered in descending order
for i := 0; i < 5; i++ {
function := functions[z01.RandIntBetween(0, len(functions)-1)]
reversed := z01.MultRandIntBetween(-1000000, 1000000)
function := functions[lib.RandIntBetween(0, len(functions)-1)]
reversed := lib.MultRandIntBetween(-1000000, 1000000)
sort.Sort(sort.Reverse(sort.IntSlice(reversed)))
val := node{
f: function,
@ -99,6 +98,6 @@ func main() {
})
for _, arg := range table {
z01.Challenge("IsSorted", student.IsSorted, correct.IsSorted, arg.f, arg.a)
lib.Challenge("IsSorted", student.IsSorted, correct.IsSorted, arg.f, arg.a)
}
}

15
tests/go/func/test_isupper.go

@ -1,20 +1,19 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
// 15 unvalid strings in the table
table := z01.MultRandASCII()
table := lib.MultRandASCII()
// 15 valid lowercase strings of random size between 1 and 20 letters in the table
for i := 0; i < 15; i++ {
size := z01.RandIntBetween(1, 20)
randLow := z01.RandLower()
size := lib.RandIntBetween(1, 20)
randLow := lib.RandLower()
if len(randLow) <= size {
table = append(table, randLow)
} else {
@ -42,6 +41,6 @@ func main() {
"HELLO!",
)
for _, arg := range table {
z01.Challenge("IsUpper", student.IsUpper, correct.IsUpper, arg)
lib.Challenge("IsUpper", student.IsUpper, correct.IsUpper, arg)
}
}

15
tests/go/func/test_iterativefactorial.go

@ -3,21 +3,20 @@ package main
import (
"math/bits"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := append(
z01.MultRandInt(),
z01.IntRange(0, 12)...,
lib.MultRandInt(),
lib.IntRange(0, 12)...,
)
if bits.UintSize == 64 {
table = append(table, z01.IntRange(13, 20)...)
table = append(table, lib.IntRange(13, 20)...)
}
for _, arg := range table {
z01.Challenge("IterativeFactorial", student.IterativeFactorial, correct.IterativeFactorial, arg)
lib.Challenge("IterativeFactorial", student.IterativeFactorial, correct.IterativeFactorial, arg)
}
}

17
tests/go/func/test_iterativepower.go

@ -1,20 +1,19 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
i := 0
for i < 30 {
nb := z01.RandIntBetween(-8, 8)
power := z01.RandIntBetween(-10, 10)
z01.Challenge("IterativePower", student.IterativePower, correct.IterativePower, nb, power)
nb := lib.RandIntBetween(-8, 8)
power := lib.RandIntBetween(-10, 10)
lib.Challenge("IterativePower", student.IterativePower, correct.IterativePower, nb, power)
i++
}
z01.Challenge("IterativePower", student.IterativePower, correct.IterativePower, 0, 0)
z01.Challenge("IterativePower", student.IterativePower, correct.IterativePower, 0, 1)
lib.Challenge("IterativePower", student.IterativePower, correct.IterativePower, 0, 0)
lib.Challenge("IterativePower", student.IterativePower, correct.IterativePower, 0, 1)
}

11
tests/go/func/test_itoa.go

@ -1,15 +1,14 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
for i := 0; i < 50; i++ {
arg := z01.RandIntBetween(-2000000000, 2000000000)
z01.Challenge("Itoa", student.Itoa, correct.Itoa, arg)
arg := lib.RandIntBetween(-2000000000, 2000000000)
lib.Challenge("Itoa", student.Itoa, correct.Itoa, arg)
}
}

19
tests/go/func/test_itoabase.go

@ -1,21 +1,20 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
for i := 0; i < 30; i++ {
value := z01.RandIntBetween(-1000000, 1000000)
base := z01.RandIntBetween(2, 16)
z01.Challenge("ItoaBase", student.ItoaBase, correct.ItoaBase, value, base)
value := lib.RandIntBetween(-1000000, 1000000)
base := lib.RandIntBetween(2, 16)
lib.Challenge("ItoaBase", student.ItoaBase, correct.ItoaBase, value, base)
}
for i := 0; i < 5; i++ {
base := z01.RandIntBetween(2, 16)
z01.Challenge("ItoaBase", student.ItoaBase, correct.ItoaBase, z01.MaxInt, base)
z01.Challenge("ItoaBase", student.ItoaBase, correct.ItoaBase, z01.MinInt, base)
base := lib.RandIntBetween(2, 16)
lib.Challenge("ItoaBase", student.ItoaBase, correct.ItoaBase, lib.MaxInt, base)
lib.Challenge("ItoaBase", student.ItoaBase, correct.ItoaBase, lib.MinInt, base)
}
}

13
tests/go/func/test_join.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -18,10 +17,10 @@ func main() {
for i := 0; i < 5; i++ {
// random position for the slice of arguments
posA := z01.RandIntBetween(0, len(args)-1)
posA := lib.RandIntBetween(0, len(args)-1)
// random position for the slice of separators
posS := z01.RandIntBetween(0, len(seps)-1)
posS := lib.RandIntBetween(0, len(seps)-1)
z01.Challenge("Join", student.Join, correct.Join, args[posA], seps[posS])
lib.Challenge("Join", student.Join, correct.Join, args[posA], seps[posS])
}
}

13
tests/go/func/test_lastrune.go

@ -1,21 +1,20 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := z01.MultRandASCII()
table := lib.MultRandASCII()
table = append(table,
"Hello!",
"Salut!",
"Ola!",
z01.RandStr(z01.RandIntBetween(1, 15), z01.RandAlnum()),
lib.RandStr(lib.RandIntBetween(1, 15), lib.RandAlnum()),
)
for _, arg := range table {
z01.Challenge("LastRune", student.LastRune, correct.LastRune, arg)
lib.Challenge("LastRune", student.LastRune, correct.LastRune, arg)
}
}

13
tests/go/func/test_lcm.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -18,12 +17,12 @@ func main() {
for i := 0; i < 15; i++ {
table = append(table, [2]int{
z01.RandIntBetween(0, 1000),
z01.RandIntBetween(0, 1000),
lib.RandIntBetween(0, 1000),
lib.RandIntBetween(0, 1000),
})
}
for _, arg := range table {
z01.Challenge("Lcm", student.Lcm, correct.Lcm, arg[0], arg[1])
lib.Challenge("Lcm", student.Lcm, correct.Lcm, arg[0], arg[1])
}
}

21
tests/go/func/test_listat.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
type Node5 = student.NodeL
@ -41,11 +40,11 @@ func comparFuncNode5(solutionList *NodeS5, l1 *Node5, l2 *NodeS5, arg int) {
return
}
if l1 != nil && l2 == nil {
z01.Fatalf("\nListAt(%s, %d) == %v instead of %v\n\n",
lib.Fatalf("\nListAt(%s, %d) == %v instead of %v\n\n",
correct.ListToString(solutionList), arg, l1, l2)
}
if l1.Data != l2.Data {
z01.Fatalf("\nListAt(%s, %d) == %v instead of %v\n\n",
lib.Fatalf("\nListAt(%s, %d) == %v instead of %v\n\n",
correct.ListToString(solutionList), arg, l1.Data, l2.Data)
}
}
@ -64,21 +63,21 @@ func main() {
for i := 0; i < 4; i++ {
table = append(table, nodeTest{
data: correct.ConvertIntToInterface(z01.MultRandInt()),
pos: z01.RandIntBetween(1, 12),
data: correct.ConvertIntToInterface(lib.MultRandInt()),
pos: lib.RandIntBetween(1, 12),
})
}
for i := 0; i < 4; i++ {
table = append(table, nodeTest{
data: correct.ConvertIntToStringface(z01.MultRandWords()),
pos: z01.RandIntBetween(1, 12),
data: correct.ConvertIntToStringface(lib.MultRandWords()),
pos: lib.RandIntBetween(1, 12),
})
}
table = append(table, nodeTest{
data: []interface{}{"I", 1, "something", 2},
pos: z01.RandIntBetween(1, 4),
pos: lib.RandIntBetween(1, 4),
})
for _, arg := range table {

9
tests/go/func/test_listclear.go

@ -3,10 +3,9 @@ package main
import (
"strconv"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
type Node4 = student.NodeL
@ -76,7 +75,7 @@ func main() {
student.ListClear(link2)
if link2.Head != nil {
z01.Fatalf("\nstudent list:%s\nlist:%s\n\nListClear() == %v instead of %v\n\n",
lib.Fatalf("\nstudent list:%s\nlist:%s\n\nListClear() == %v instead of %v\n\n",
listToStringStu5(link2), correct.ListToString(link1.Head), link2.Head, link1.Head)
}
}

11
tests/go/func/test_listfind.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
type Node9 = student.NodeL
@ -57,7 +56,7 @@ func main() {
if aux1 != nil || aux2 != nil {
if *aux1 != *aux2 {
z01.Fatalf("ListFind(ref: %s) == %s instead of %s\n", arg.Data[(len(arg.Data)-1)/2], *aux1, *aux2)
lib.Fatalf("ListFind(ref: %s) == %s instead of %s\n", arg.Data[(len(arg.Data)-1)/2], *aux1, *aux2)
}
}
}
@ -73,7 +72,7 @@ func main() {
aux2 := correct.ListFind(link1, "lksdf", correct.CompStr)
if aux1 != nil && aux2 != nil {
if *aux1 != *aux2 {
z01.Fatalf("ListFind(ref: lksdf) == %s instead of %s\n", *aux1, *aux2)
lib.Fatalf("ListFind(ref: lksdf) == %s instead of %s\n", *aux1, *aux2)
}
}
}

11
tests/go/func/test_listforeach.go

@ -3,10 +3,9 @@ package main
import (
"strconv"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
type Node7 = student.NodeL
@ -57,11 +56,11 @@ func comparFuncList7(l1 *List7, l2 *ListS7, f func(*Node7)) {
funcName := correct.GetName(f)
for l1.Head != nil || l2.Head != nil {
if (l1.Head == nil && l2.Head != nil) || (l1.Head != nil && l2.Head == nil) {
z01.Fatalf("\nstudent list: %s\nlist: %s\nfunction used: %s\n\nListForEach() == %v instead of %v\n\n",
lib.Fatalf("\nstudent list: %s\nlist: %s\nfunction used: %s\n\nListForEach() == %v instead of %v\n\n",
listToStringStu8(l2), correct.ListToString(l1.Head), funcName, l2.Head, l1.Head)
}
if l1.Head.Data != l2.Head.Data {
z01.Fatalf("\nstudent list: %s\nlist: %s\nfunction used: %s\n\nListForEach() == %v instead of %v\n\n",
lib.Fatalf("\nstudent list: %s\nlist: %s\nfunction used: %s\n\nListForEach() == %v instead of %v\n\n",
listToStringStu8(l2), correct.ListToString(l1.Head), funcName, l2.Head.Data, l1.Head.Data)
}
l1.Head = l1.Head.Next

15
tests/go/func/test_listforeachif.go

@ -3,10 +3,9 @@ package main
import (
"strconv"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
type Node8 = student.NodeL
@ -86,11 +85,11 @@ func comparFuncList8(l1 *List8, l2 *ListS8, f func(*Node8) bool, comp func(*Node
funcComp := correct.GetName(comp)
for l1.Head != nil || l2.Head != nil {
if (l1.Head == nil && l2.Head != nil) || (l1.Head != nil && l2.Head == nil) {
z01.Fatalf("\nstudent list:%s\nlist:%s\nfunction f used: %s\nfunction comp: %s\n\nListForEachIf() == %v instead of %v\n\n",
lib.Fatalf("\nstudent list:%s\nlist:%s\nfunction f used: %s\nfunction comp: %s\n\nListForEachIf() == %v instead of %v\n\n",
listToStringStu7(l2), correct.ListToString(l1.Head), funcComp, funcFName, l2.Head, l1.Head)
}
if l1.Head.Data != l2.Head.Data {
z01.Fatalf("\nstudent list:%s\nlist:%s\nfunction f used: %s\nfunction comp: %s\n\nListForEachIf() == %v instead of %v\n\n",
lib.Fatalf("\nstudent list:%s\nlist:%s\nfunction f used: %s\nfunction comp: %s\n\nListForEachIf() == %v instead of %v\n\n",
listToStringStu7(l2), correct.ListToString(l1.Head), funcComp, funcFName, l2.Head.Data, l1.Head.Data)
}
l1.Head = l1.Head.Next
@ -113,14 +112,14 @@ func main() {
// just numbers/ints
for i := 0; i < 3; i++ {
val := correct.NodeTest{
Data: correct.ConvertIntToInterface(z01.MultRandInt()),
Data: correct.ConvertIntToInterface(lib.MultRandInt()),
}
table = append(table, val)
}
// just strings
for i := 0; i < 3; i++ {
val := correct.NodeTest{
Data: correct.ConvertIntToStringface(z01.MultRandWords()),
Data: correct.ConvertIntToStringface(lib.MultRandWords()),
}
table = append(table, val)
}

9
tests/go/func/test_listlast.go

@ -3,10 +3,9 @@ package main
import (
"strconv"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
type Node3 = student.NodeL
@ -70,7 +69,7 @@ func main() {
aux2 := student.ListLast(link2)
if aux1 != aux2 {
z01.Fatalf("\nlist:%s\n\nListLast() == %v instead of %v\n\n",
lib.Fatalf("\nlist:%s\n\nListLast() == %v instead of %v\n\n",
listToStringStu9(link2), aux2, aux1)
}
link1 = &List3{}

21
tests/go/func/test_listmerge.go

@ -3,10 +3,9 @@ package main
import (
"strconv"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
type Node11 = student.NodeL
@ -60,11 +59,11 @@ func listPushBackTest11(l1 *ListS11, l2 *List11, data interface{}) {
func comparFuncList11(l1 *List11, l2 *ListS11) {
for l1.Head != nil || l2.Head != nil {
if (l1.Head == nil && l2.Head != nil) || (l1.Head != nil && l2.Head == nil) {
z01.Fatalf("\nstudent list:%s\nlist:%s\n\nListMerge() == %v instead of %v\n\n",
lib.Fatalf("\nstudent list:%s\nlist:%s\n\nListMerge() == %v instead of %v\n\n",
listToStringStu(l2), correct.ListToString(l1.Head), l2.Head, l1.Head)
}
if l1.Head.Data != l2.Head.Data {
z01.Fatalf("\nstudent list:%s\nlist:%s\n\nListMerge() == %v instead of %v\n\n",
lib.Fatalf("\nstudent list:%s\nlist:%s\n\nListMerge() == %v instead of %v\n\n",
listToStringStu(l2), correct.ListToString(l1.Head), l2.Head.Data, l1.Head.Data)
}
l1.Head = l1.Head.Next
@ -91,22 +90,22 @@ func main() {
})
table = append(table,
nodeTest{
data1: correct.ConvertIntToInterface(z01.MultRandInt()),
data1: correct.ConvertIntToInterface(lib.MultRandInt()),
data2: []interface{}{},
})
// jut ints
for i := 0; i < 3; i++ {
val := nodeTest{
data1: correct.ConvertIntToInterface(z01.MultRandInt()),
data2: correct.ConvertIntToInterface(z01.MultRandInt()),
data1: correct.ConvertIntToInterface(lib.MultRandInt()),
data2: correct.ConvertIntToInterface(lib.MultRandInt()),
}
table = append(table, val)
}
// just strings
for i := 0; i < 2; i++ {
val := nodeTest{
data1: correct.ConvertIntToStringface(z01.MultRandWords()),
data2: correct.ConvertIntToStringface(z01.MultRandWords()),
data1: correct.ConvertIntToStringface(lib.MultRandWords()),
data2: correct.ConvertIntToStringface(lib.MultRandWords()),
}
table = append(table, val)
}

11
tests/go/func/test_listpushback.go

@ -3,10 +3,9 @@ package main
import (
"strconv"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
type ListS = correct.List
@ -32,11 +31,11 @@ func listToStringStu10(l *List) string {
func comparFuncList(l *ListS, l1 *List, data []interface{}) {
for l.Head != nil || l1.Head != nil {
if (l.Head == nil && l1.Head != nil) || (l.Head != nil && l1.Head == nil) {
z01.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListPushBack()== %v instead of %v\n\n",
lib.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListPushBack()== %v instead of %v\n\n",
data, listToStringStu10(l1), correct.ListToString(l.Head), l1.Head, l.Head)
}
if l.Head.Data != l1.Head.Data {
z01.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListPushBack()== %v instead of %v\n\n",
lib.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListPushBack()== %v instead of %v\n\n",
data, listToStringStu10(l1), correct.ListToString(l.Head), l1.Head.Data, l.Head.Data)
}
l.Head = l.Head.Next

11
tests/go/func/test_listpushfront.go

@ -3,10 +3,9 @@ package main
import (
"strconv"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
type ListSa = correct.List
@ -32,11 +31,11 @@ func listToStringStu11(l *Lista) string {
func comparFuncList1(l *Lista, l1 *ListSa, data []interface{}) {
for l.Head != nil || l1.Head != nil {
if (l.Head == nil && l1.Head != nil) || (l.Head != nil && l1.Head == nil) {
z01.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListPushFront()== %v instead of %v\n\n",
lib.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListPushFront()== %v instead of %v\n\n",
data, listToStringStu11(l), correct.ListToString(l1.Head), l.Head, l1.Head)
}
if l.Head.Data != l1.Head.Data {
z01.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListPushFront()== %v instead of %v\n\n",
lib.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListPushFront()== %v instead of %v\n\n",
data, listToStringStu11(l), correct.ListToString(l1.Head), l.Head, l1.Head)
}
l1.Head = l1.Head.Next

13
tests/go/func/test_listremoveif.go

@ -3,10 +3,9 @@ package main
import (
"strconv"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
type Node10 = student.NodeL
@ -56,11 +55,11 @@ func listPushBackTest10(l *ListS10, l1 *List10, data interface{}) {
func comparFuncList10(l *List10, l1 *ListS10, data interface{}) {
for l.Head != nil || l1.Head != nil {
if (l.Head == nil && l1.Head != nil) || (l.Head != nil && l1.Head == nil) {
z01.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListRemoveIf() == %v instead of %v\n\n",
lib.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListRemoveIf() == %v instead of %v\n\n",
data, listToStringStu12(l1), correct.ListToString(l.Head), l1.Head, l.Head)
}
if l.Head.Data != l1.Head.Data {
z01.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListRemoveIf() == %v instead of %v\n\n",
lib.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListRemoveIf() == %v instead of %v\n\n",
data, listToStringStu12(l1), correct.ListToString(l.Head), l1.Head.Data, l.Head.Data)
}
l.Head = l.Head.Next
@ -89,7 +88,7 @@ func main() {
}
aux := len(arg.Data) - 1
index = z01.RandIntBetween(0, aux)
index = lib.RandIntBetween(0, aux)
if link1.Head != nil && link2.Head != nil {
cho := arg.Data[index]
student.ListRemoveIf(link2, cho)

11
tests/go/func/test_listreverse.go

@ -3,10 +3,9 @@ package main
import (
"strconv"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
type Node6 = student.NodeL
@ -33,11 +32,11 @@ func listToStringStu13(l *ListS6) string {
func comparFuncList6(l *List6, l1 *ListS6) {
for l.Head != nil || l1.Head != nil {
if (l.Head == nil && l1.Head != nil) || (l.Head != nil && l1.Head == nil) {
z01.Fatalf("\nstudent list:%s\nlist:%s\n\nListReverse() == %v instead of %v\n\n",
lib.Fatalf("\nstudent list:%s\nlist:%s\n\nListReverse() == %v instead of %v\n\n",
listToStringStu13(l1), correct.ListToString(l.Head), l1.Head, l.Head)
}
if l.Head.Data != l1.Head.Data {
z01.Fatalf("\nstudent list:%s\nlist:%s\n\nListReverse() == %v instead of %v\n\n",
lib.Fatalf("\nstudent list:%s\nlist:%s\n\nListReverse() == %v instead of %v\n\n",
listToStringStu13(l1), correct.ListToString(l.Head), l1.Head.Data, l.Head.Data)
}
l.Head = l.Head.Next

9
tests/go/func/test_listsize.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
type Node2 = student.NodeL
@ -53,7 +52,7 @@ func main() {
aux := correct.ListSize(link)
aux2 := student.ListSize(link2)
if aux != aux2 {
z01.Fatalf("ListSize(%v) == %d instead of %d\n", correct.ListToString(link.Head), aux2, aux)
lib.Fatalf("ListSize(%v) == %d instead of %d\n", correct.ListToString(link.Head), aux2, aux)
}
link = &List2{}
link2 = &ListS2{}

13
tests/go/func/test_listsort.go

@ -3,10 +3,9 @@ package main
import (
"strconv"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
type NodeI12 = student.NodeI
@ -51,11 +50,11 @@ func nodePushBackListInt12(l1 *NodeI12, l2 *NodeIS12, data int) {
func comparFuncNodeInt12(l1 *NodeI12, l2 *NodeIS12) {
for l1 != nil || l2 != nil {
if (l1 == nil && l2 != nil) || (l1 != nil && l2 == nil) {
z01.Fatalf("\nstudent list:%s\nlist:%s\n\nListSort() == %v instead of %v\n\n",
lib.Fatalf("\nstudent list:%s\nlist:%s\n\nListSort() == %v instead of %v\n\n",
printListStudent(l1), correct.PrintList(l2), l1, l2)
}
if l1.Data != l2.Data {
z01.Fatalf("\nstudent list:%s\nlist:%s\n\nListSort() == %v instead of %v\n\n",
lib.Fatalf("\nstudent list:%s\nlist:%s\n\nListSort() == %v instead of %v\n\n",
printListStudent(l1), correct.PrintList(l2), l1.Data, l2.Data)
}
l1 = l1.Next
@ -75,7 +74,7 @@ func main() {
// just numbers/ints
for i := 0; i < 2; i++ {
table = append(table, nodeTest{z01.MultRandInt()})
table = append(table, nodeTest{lib.MultRandInt()})
}
table = append(table, nodeTest{[]int{5, 4, 3, 2, 1}})

17
tests/go/func/test_makerange.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -17,8 +16,8 @@ func main() {
// 15 random pairs of ints for a Valid Range
for i := 0; i < 15; i++ {
minVal := z01.RandIntBetween(-10000000, 1000000)
gap := z01.RandIntBetween(1, 20)
minVal := lib.RandIntBetween(-10000000, 1000000)
gap := lib.RandIntBetween(1, 20)
val := node{
min: minVal,
max: minVal + gap,
@ -27,8 +26,8 @@ func main() {
}
// 15 random pairs of ints with ||invalid range||
for i := 0; i < 15; i++ {
minVal := z01.RandIntBetween(-10000000, 1000000)
gap := z01.RandIntBetween(1, 20)
minVal := lib.RandIntBetween(-10000000, 1000000)
gap := lib.RandIntBetween(1, 20)
val := node{
min: minVal,
max: minVal - gap,
@ -43,6 +42,6 @@ func main() {
node{min: 10, max: 5},
)
for _, arg := range table {
z01.Challenge("MakeRange", student.MakeRange, correct.MakeRange, arg.min, arg.max)
lib.Challenge("MakeRange", student.MakeRange, correct.MakeRange, arg.min, arg.max)
}
}

13
tests/go/func/test_map.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -18,10 +17,10 @@ func main() {
table := []node{}
for i := 0; i < 15; i++ {
function := functions[z01.RandIntBetween(0, len(functions)-1)]
function := functions[lib.RandIntBetween(0, len(functions)-1)]
val := node{
f: function,
arr: z01.MultRandIntBetween(-1000000, 1000000),
arr: lib.MultRandIntBetween(-1000000, 1000000),
}
table = append(table, val)
}
@ -32,6 +31,6 @@ func main() {
})
for _, arg := range table {
z01.Challenge("Map", student.Map, correct.Map, arg.f, arg.arr)
lib.Challenge("Map", student.Map, correct.Map, arg.f, arg.arr)
}
}

15
tests/go/func/test_max.go

@ -1,18 +1,17 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
args := []int{z01.RandInt()}
limit := z01.RandIntBetween(20, 50)
args := []int{lib.RandInt()}
limit := lib.RandIntBetween(20, 50)
for i := 0; i < limit; i++ {
args = append(args, z01.RandInt())
args = append(args, lib.RandInt())
}
z01.Challenge("Max", student.Max, correct.Max, args)
lib.Challenge("Max", student.Max, correct.Max, args)
}

9
tests/go/func/test_merge.go

@ -4,9 +4,8 @@ import (
"math/rand"
"strconv"
"github.com/01-edu/z01"
correct "./correct"
"../lib"
"./correct"
)
type stuTreeNode = TreeNodeM
@ -147,7 +146,7 @@ func compareTrees(stuResult *stuTreeNode, solResult, solTree1, solTree2 *solTree
tree2 := returnSolTree(solTree2)
stuTree := returnStuTree(stuResult)
solTree := returnSolTree(solResult)
z01.Fatalf("\nMergeTrees(\"%v\", \"%v\") == \"%v\" instead of \"%v\"\n\n", tree1, tree2, stuTree, solTree)
lib.Fatalf("\nMergeTrees(\"%v\", \"%v\") == \"%v\" instead of \"%v\"\n\n", tree1, tree2, stuTree, solTree)
}
}
@ -159,7 +158,7 @@ func main() {
table := []node{}
for i := 0; i < 15; i++ {
value := node{z01.RandIntBetween(10, 15), z01.RandIntBetween(1, 10)}
value := node{lib.RandIntBetween(10, 15), lib.RandIntBetween(1, 10)}
table = append(table, value)
}
for _, arg := range table {

15
tests/go/func/test_nauuo.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -22,12 +21,12 @@ func main() {
for i := 0; i < 15; i++ {
table = append(table, node{
plus: z01.RandIntBetween(0, 10),
minus: z01.RandIntBetween(0, 10),
rand: z01.RandIntBetween(0, 10),
plus: lib.RandIntBetween(0, 10),
minus: lib.RandIntBetween(0, 10),
rand: lib.RandIntBetween(0, 10),
})
}
for _, arg := range table {
z01.Challenge("Nauuo", student.Nauuo, correct.Nauuo, arg.plus, arg.minus, arg.rand)
lib.Challenge("Nauuo", student.Nauuo, correct.Nauuo, arg.plus, arg.minus, arg.rand)
}
}

11
tests/go/func/test_nrune.go

@ -3,10 +3,9 @@ package main
import (
"math/rand"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -18,7 +17,7 @@ func main() {
table := []node{}
for i := 0; i < 30; i++ {
wordToInput := z01.RandASCII()
wordToInput := lib.RandASCII()
val := node{
word: wordToInput,
n: rand.Intn(len(wordToInput)) + 1,
@ -39,6 +38,6 @@ func main() {
)
for _, arg := range table {
z01.Challenge("NRune", student.NRune, correct.NRune, arg.word, arg.n)
lib.Challenge("NRune", student.NRune, correct.NRune, arg.word, arg.n)
}
}

7
tests/go/func/test_pointone.go

@ -1,15 +1,14 @@
package main
import (
"github.com/01-edu/z01"
student "./student"
"../lib"
"./student"
)
func main() {
n := 0
student.PointOne(&n)
if n != 1 {
z01.Fatalf("PointOne(&n), n == %d instead of 1\n", n)
lib.Fatalf("PointOne(&n), n == %d instead of 1\n", n)
}
}

9
tests/go/func/test_printcomb.go

@ -1,12 +1,11 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
z01.Challenge("PrintComb", student.PrintComb, correct.PrintComb)
lib.Challenge("PrintComb", student.PrintComb, correct.PrintComb)
}

9
tests/go/func/test_printcomb2.go

@ -1,12 +1,11 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
z01.Challenge("PrintComb2", student.PrintComb2, correct.PrintComb2)
lib.Challenge("PrintComb2", student.PrintComb2, correct.PrintComb2)
}

9
tests/go/func/test_printcombn.go

@ -1,15 +1,14 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
for _, arg := range table {
z01.Challenge("PrintCombN", student.PrintCombN, correct.PrintCombN, arg)
lib.Challenge("PrintCombN", student.PrintCombN, correct.PrintCombN, arg)
}
}

13
tests/go/func/test_printmemory.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -12,12 +11,12 @@ func main() {
for j := 0; j < 5; j++ {
for i := 0; i < 10; i++ {
table[i] = z01.RandIntBetween(0, 1000)
table[i] = lib.RandIntBetween(0, 1000)
}
z01.Challenge("PrintMemory", student.PrintMemory, correct.PrintMemory, table)
lib.Challenge("PrintMemory", student.PrintMemory, correct.PrintMemory, table)
}
table2 := [10]int{104, 101, 108, 108, 111, 16, 21, 42}
z01.Challenge("PrintMemory", student.PrintMemory, correct.PrintMemory, table2)
lib.Challenge("PrintMemory", student.PrintMemory, correct.PrintMemory, table2)
}
// TODO: this can be simplified a lot

15
tests/go/func/test_printnbr.go

@ -1,20 +1,19 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := append(
z01.MultRandInt(),
z01.MinInt,
z01.MaxInt,
lib.MultRandInt(),
lib.MinInt,
lib.MaxInt,
0,
)
for _, arg := range table {
z01.Challenge("PrintNbr", student.PrintNbr, correct.PrintNbr, arg)
lib.Challenge("PrintNbr", student.PrintNbr, correct.PrintNbr, arg)
}
}

16
tests/go/func/test_printnbrbase.go

@ -1,12 +1,10 @@
package main
import (
"github.com/01-edu/z01"
"../lib"
"./base"
correct "./correct"
student "./student"
"./correct"
"./student"
)
func main() {
@ -21,7 +19,7 @@ func main() {
for i := 0; i < 15; i++ {
validBaseToInput := base.Valid()
val := node{
n: z01.RandIntBetween(-1000000, 1000000),
n: lib.RandIntBetween(-1000000, 1000000),
base: validBaseToInput,
}
table = append(table, val)
@ -31,7 +29,7 @@ func main() {
for i := 0; i < 15; i++ {
invalidBaseToInput := base.Invalid()
val := node{
n: z01.RandIntBetween(-1000000, 1000000),
n: lib.RandIntBetween(-1000000, 1000000),
base: invalidBaseToInput,
}
table = append(table, val)
@ -43,10 +41,10 @@ func main() {
node{n: 125, base: "0123456789ABCDEF"},
node{n: -125, base: "choumi"},
node{n: 125, base: "-ab"},
node{n: z01.MinInt, base: "0123456789"},
node{n: lib.MinInt, base: "0123456789"},
)
for _, arg := range table {
z01.Challenge("PrintNbrBase", student.PrintNbrBase, correct.PrintNbrBase, arg.n, arg.base)
lib.Challenge("PrintNbrBase", student.PrintNbrBase, correct.PrintNbrBase, arg.n, arg.base)
}
}

13
tests/go/func/test_printnbrinorder.go

@ -1,21 +1,20 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := append(
z01.MultRandIntBetween(0, z01.MaxInt),
z01.MaxInt,
lib.MultRandIntBetween(0, lib.MaxInt),
lib.MaxInt,
321,
321321,
0,
)
for _, arg := range table {
z01.Challenge("PrintNbrInOrder", student.PrintNbrInOrder, correct.PrintNbrInOrder, arg)
lib.Challenge("PrintNbrInOrder", student.PrintNbrInOrder, correct.PrintNbrInOrder, arg)
}
}

11
tests/go/func/test_printstr.go

@ -1,16 +1,15 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
table := z01.MultRandASCII()
table := lib.MultRandASCII()
table = append(table, "Hello World!")
for _, arg := range table {
z01.Challenge("PrintStr", student.PrintStr, correct.PrintStr, arg)
lib.Challenge("PrintStr", student.PrintStr, correct.PrintStr, arg)
}
}

11
tests/go/func/test_printwordstables.go

@ -3,10 +3,9 @@ package main
import (
"strings"
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -14,7 +13,7 @@ func main() {
// 30 random slice of slice of strings
for i := 0; i < 30; i++ {
val := correct.SplitWhiteSpaces(strings.Join(z01.MultRandASCII(), " "))
val := correct.SplitWhiteSpaces(strings.Join(lib.MultRandASCII(), " "))
table = append(table, val)
}
@ -22,6 +21,6 @@ func main() {
[]string{"Hello", "how", "are", "you?"})
for _, arg := range table {
z01.Challenge("PrintWordsTables", student.PrintWordsTables, correct.PrintWordsTables, arg)
lib.Challenge("PrintWordsTables", student.PrintWordsTables, correct.PrintWordsTables, arg)
}
}

11
tests/go/func/test_priorprime.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -16,8 +15,8 @@ func main() {
1,
2,
}
table = append(table, z01.MultRandIntBetween(0, 1000))
table = append(table, lib.MultRandIntBetween(0, 1000))
for _, arg := range table {
z01.Challenge("PriorPrime", student.PriorPrime, correct.PriorPrime, arg)
lib.Challenge("PriorPrime", student.PriorPrime, correct.PriorPrime, arg)
}
}

11
tests/go/func/test_raid1a.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -21,13 +20,13 @@ func main() {
0, 0,
-1, 6,
6, -1,
z01.RandIntBetween(1, 20), z01.RandIntBetween(1, 20),
lib.RandIntBetween(1, 20), lib.RandIntBetween(1, 20),
)
// Tests all possibilities including 0 0, -x y, x -y
for i := 0; i < len(table); i += 2 {
if i != len(table)-1 {
z01.Challenge("Raid1a", correct.Raid1a, student.Raid1a, table[i], table[i+1])
lib.Challenge("Raid1a", correct.Raid1a, student.Raid1a, table[i], table[i+1])
}
}
}

11
tests/go/func/test_raid1b.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -21,13 +20,13 @@ func main() {
0, 0,
-1, 6,
6, -1,
z01.RandIntBetween(1, 20), z01.RandIntBetween(1, 20),
lib.RandIntBetween(1, 20), lib.RandIntBetween(1, 20),
)
// Tests all possibilities including 0 0, -x y, x -y
for i := 0; i < len(table); i += 2 {
if i != len(table)-1 {
z01.Challenge("Raid1b", correct.Raid1b, student.Raid1b, table[i], table[i+1])
lib.Challenge("Raid1b", correct.Raid1b, student.Raid1b, table[i], table[i+1])
}
}
}

11
tests/go/func/test_raid1c.go

@ -1,10 +1,9 @@
package main
import (
"github.com/01-edu/z01"
correct "./correct"
student "./student"
"../lib"
"./correct"
"./student"
)
func main() {
@ -21,13 +20,13 @@ func main() {
0, 0,
-1, 6,
6, -1,
z01.RandIntBetween(1, 20), z01.RandIntBetween(1, 20),
lib.RandIntBetween(1, 20), lib.RandIntBetween(1, 20),
)
// Tests all possibilities including 0 0, -x y, x -y
for i := 0; i < len(table); i += 2 {
if i != len(table)-1 {
z01.Challenge("Raid1c", correct.Raid1c, student.Raid1c, table[i], table[i+1])
lib.Challenge("Raid1c", correct.Raid1c, student.Raid1c, table[i], table[i+1])
}
}
}

Some files were not shown because too many files changed in this diff diff.show_more

Loading…
Cancel
Save