Browse Source

tests/correct -> solutions #2

pull/768/head
xpetit 4 years ago
parent
commit
a2b5d1a95e
No known key found for this signature in database
GPG Key ID: 97C60669182C17A5
  1. 2
      test-go/solutions/btree.go
  2. 2
      test-go/solutions/challenge.go
  3. 2
      test-go/solutions/listat.go
  4. 2
      test-go/solutions/listclear.go
  5. 2
      test-go/solutions/listfind.go
  6. 2
      test-go/solutions/listforeach.go
  7. 2
      test-go/solutions/listforeachif.go
  8. 2
      test-go/solutions/listlast.go
  9. 2
      test-go/solutions/listmerge.go
  10. 2
      test-go/solutions/listpushback.go
  11. 2
      test-go/solutions/listpushfront.go
  12. 2
      test-go/solutions/listremoveif.go
  13. 2
      test-go/solutions/listreverse.go
  14. 2
      test-go/solutions/listsize.go
  15. 2
      test-go/solutions/listsort.go
  16. 2
      test-go/solutions/sortedlistmerge.go
  17. 2
      test-go/solutions/sortlistinsert.go
  18. 8
      test-go/tests/btreeapplybylevel_test/main.go
  19. 8
      test-go/tests/btreeapplyinorder_test/main.go
  20. 8
      test-go/tests/btreeapplypostorder_test/main.go
  21. 8
      test-go/tests/btreeapplypreorder_test/main.go
  22. 24
      test-go/tests/btreedeletenode_test/main.go
  23. 18
      test-go/tests/btreeinsertdata_test/main.go
  24. 30
      test-go/tests/btreeisbinary_test/main.go
  25. 20
      test-go/tests/btreelevelcount_test/main.go
  26. 20
      test-go/tests/btreemax_test/main.go
  27. 18
      test-go/tests/btreemin_test/main.go
  28. 16
      test-go/tests/btreesearchitem_test/main.go
  29. 36
      test-go/tests/btreetransplant_test/main.go
  30. 16
      test-go/tests/listat_test/main.go
  31. 18
      test-go/tests/listclear_test/main.go
  32. 16
      test-go/tests/listfind_test/main.go
  33. 24
      test-go/tests/listforeach_test/main.go
  34. 34
      test-go/tests/listforeachif_test/main.go
  35. 16
      test-go/tests/listlast_test/main.go
  36. 22
      test-go/tests/listmerge_test/main.go
  37. 16
      test-go/tests/listpushback_test/main.go
  38. 16
      test-go/tests/listpushfront_test/main.go
  39. 20
      test-go/tests/listremoveif_test/main.go
  40. 16
      test-go/tests/listreverse_test/main.go
  41. 16
      test-go/tests/listsize_test/main.go
  42. 10
      test-go/tests/listsort_test/main.go
  43. 14
      test-go/tests/sortedlistmerge_test/main.go
  44. 12
      test-go/tests/sortlistinsert_test/main.go

2
test-go/solutions/btree.go

@ -1,4 +1,4 @@
package correct package solutions
type TreeNode struct { type TreeNode struct {
Left, Right, Parent *TreeNode Left, Right, Parent *TreeNode

2
test-go/solutions/challenge.go

@ -1,4 +1,4 @@
package correct package solutions
import ( import (
"reflect" "reflect"

2
test-go/solutions/listat.go

@ -1,4 +1,4 @@
package correct package solutions
// returs the node in a given position // returs the node in a given position
func ListAt(l *NodeL, nbr int) *NodeL { func ListAt(l *NodeL, nbr int) *NodeL {

2
test-go/solutions/listclear.go

@ -1,4 +1,4 @@
package correct package solutions
func ListClear(l *List) { func ListClear(l *List) {
temp := l.Head temp := l.Head

2
test-go/solutions/listfind.go

@ -1,4 +1,4 @@
package correct package solutions
// finds the element and returns the first data from the node that is a string // finds the element and returns the first data from the node that is a string
func ListFind(l *List, ref interface{}, comp func(a, b interface{}) bool) *interface{} { func ListFind(l *List, ref interface{}, comp func(a, b interface{}) bool) *interface{} {

2
test-go/solutions/listforeach.go

@ -1,4 +1,4 @@
package correct package solutions
// applies a function in argument to each element of the linked list // applies a function in argument to each element of the linked list
func ListForEach(l *List, f func(*NodeL)) { func ListForEach(l *List, f func(*NodeL)) {

2
test-go/solutions/listforeachif.go

@ -1,4 +1,4 @@
package correct package solutions
// compare each element of the linked list to see if it is a String // compare each element of the linked list to see if it is a String
func IsPositive_node(node *NodeL) bool { func IsPositive_node(node *NodeL) bool {

2
test-go/solutions/listlast.go

@ -1,4 +1,4 @@
package correct package solutions
// gives the last element of the list // gives the last element of the list
func ListLast(l *List) interface{} { func ListLast(l *List) interface{} {

2
test-go/solutions/listmerge.go

@ -1,4 +1,4 @@
package correct package solutions
// merges the 2 lists in one (in the end of the first list) // merges the 2 lists in one (in the end of the first list)
func ListMerge(l1 *List, l2 *List) { func ListMerge(l1 *List, l2 *List) {

2
test-go/solutions/listpushback.go

@ -1,4 +1,4 @@
package correct package solutions
type NodeL struct { type NodeL struct {
Data interface{} Data interface{}

2
test-go/solutions/listpushfront.go

@ -1,4 +1,4 @@
package correct package solutions
// inserts node on the first position of the list // inserts node on the first position of the list
func ListPushFront(l *List, data interface{}) { func ListPushFront(l *List, data interface{}) {

2
test-go/solutions/listremoveif.go

@ -1,4 +1,4 @@
package correct package solutions
// removes all elements that are equal to the data_ref // removes all elements that are equal to the data_ref
func ListRemoveIf(l *List, data_ref interface{}) { func ListRemoveIf(l *List, data_ref interface{}) {

2
test-go/solutions/listreverse.go

@ -1,4 +1,4 @@
package correct package solutions
func ListReverse(l *List) { func ListReverse(l *List) {
current := l.Head current := l.Head

2
test-go/solutions/listsize.go

@ -1,4 +1,4 @@
package correct package solutions
func ListSize(l *List) int { func ListSize(l *List) int {
count := 0 count := 0

2
test-go/solutions/listsort.go

@ -1,4 +1,4 @@
package correct package solutions
func ListSort(l *NodeI) *NodeI { func ListSort(l *NodeI) *NodeI {
head := l head := l

2
test-go/solutions/sortedlistmerge.go

@ -1,4 +1,4 @@
package correct package solutions
func SortedListMerge(l1 *NodeI, l2 *NodeI) *NodeI { func SortedListMerge(l1 *NodeI, l2 *NodeI) *NodeI {
if l1 == nil { if l1 == nil {

2
test-go/solutions/sortlistinsert.go

@ -1,4 +1,4 @@
package correct package solutions
// structures for the linked lists // structures for the linked lists
type NodeI struct { type NodeI struct {

8
test-go/tests/btreeapplybylevel_test/main.go

@ -5,19 +5,19 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
func main() { func main() {
root := &correct.TreeNode{Data: "04"} root := &solutions.TreeNode{Data: "04"}
rootS := &student.TreeNode{Data: "04"} rootS := &student.TreeNode{Data: "04"}
ins := []string{"01", "07", "05", "12", "02", "03", "10"} ins := []string{"01", "07", "05", "12", "02", "03", "10"}
for _, v := range ins { for _, v := range ins {
root = correct.BTreeInsertData(root, v) root = solutions.BTreeInsertData(root, v)
rootS = student.BTreeInsertData(rootS, v) rootS = student.BTreeInsertData(rootS, v)
} }
correct.ChallengeTree("BTreeApplyByLevel", correct.BTreeApplyByLevel, student.BTreeApplyByLevel, root, rootS, fmt.Print) solutions.ChallengeTree("BTreeApplyByLevel", solutions.BTreeApplyByLevel, student.BTreeApplyByLevel, root, rootS, fmt.Print)
} }

8
test-go/tests/btreeapplyinorder_test/main.go

@ -5,11 +5,11 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
func main() { func main() {
root := &correct.TreeNode{Data: "08"} root := &solutions.TreeNode{Data: "08"}
rootS := &student.TreeNode{Data: "08"} rootS := &student.TreeNode{Data: "08"}
pos := []string{ pos := []string{
"x", "x",
@ -26,9 +26,9 @@ func main() {
} }
for _, arg := range pos { for _, arg := range pos {
root = correct.BTreeInsertData(root, arg) root = solutions.BTreeInsertData(root, arg)
rootS = student.BTreeInsertData(rootS, arg) rootS = student.BTreeInsertData(rootS, arg)
} }
correct.ChallengeTree("BTreeApplyInorder", correct.BTreeApplyInorder, student.BTreeApplyInorder, root, rootS, fmt.Println) solutions.ChallengeTree("BTreeApplyInorder", solutions.BTreeApplyInorder, student.BTreeApplyInorder, root, rootS, fmt.Println)
} }

8
test-go/tests/btreeapplypostorder_test/main.go

@ -5,11 +5,11 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
func main() { func main() {
root := &correct.TreeNode{Data: "08"} root := &solutions.TreeNode{Data: "08"}
rootS := &student.TreeNode{Data: "08"} rootS := &student.TreeNode{Data: "08"}
pos := []string{ pos := []string{
"x", "x",
@ -26,9 +26,9 @@ func main() {
} }
for _, arg := range pos { for _, arg := range pos {
root = correct.BTreeInsertData(root, arg) root = solutions.BTreeInsertData(root, arg)
rootS = student.BTreeInsertData(rootS, arg) rootS = student.BTreeInsertData(rootS, arg)
} }
correct.ChallengeTree("BTreeApplyPostorder", correct.BTreeApplyPostorder, student.BTreeApplyPostorder, root, rootS, fmt.Println) solutions.ChallengeTree("BTreeApplyPostorder", solutions.BTreeApplyPostorder, student.BTreeApplyPostorder, root, rootS, fmt.Println)
} }

8
test-go/tests/btreeapplypreorder_test/main.go

@ -5,11 +5,11 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
func main() { func main() {
root := &correct.TreeNode{Data: "08"} root := &solutions.TreeNode{Data: "08"}
rootS := &student.TreeNode{Data: "08"} rootS := &student.TreeNode{Data: "08"}
pos := []string{ pos := []string{
"x", "x",
@ -26,9 +26,9 @@ func main() {
} }
for _, arg := range pos { for _, arg := range pos {
root = correct.BTreeInsertData(root, arg) root = solutions.BTreeInsertData(root, arg)
rootS = student.BTreeInsertData(rootS, arg) rootS = student.BTreeInsertData(rootS, arg)
} }
correct.ChallengeTree("BTreeApplyPreorder", correct.BTreeApplyPreorder, student.BTreeApplyPreorder, root, rootS, fmt.Println) solutions.ChallengeTree("BTreeApplyPreorder", solutions.BTreeApplyPreorder, student.BTreeApplyPreorder, root, rootS, fmt.Println)
} }

24
test-go/tests/btreedeletenode_test/main.go

@ -4,7 +4,7 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
func parentListDelete(root *student.TreeNode) string { func parentListDelete(root *student.TreeNode) string {
@ -79,17 +79,17 @@ func formatSubTree_delete(root *student.TreeNode, prefix string) string {
return res return res
} }
func errorMessage_delete(fn interface{}, deleted string, rootOr, root *correct.TreeNode, rootS *student.TreeNode) { func errorMessage_delete(fn interface{}, deleted string, rootOr, root *solutions.TreeNode, rootS *student.TreeNode) {
lib.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", "BTreeDeleteNode",
correct.FormatTree(rootOr), solutions.FormatTree(rootOr),
deleted, deleted,
FormatTree_delete(rootS), FormatTree_delete(rootS),
correct.FormatTree(root), solutions.FormatTree(root),
) )
} }
func CompareTrees_delete(fn interface{}, deleted string, rootOr, root *correct.TreeNode, rootS *student.TreeNode) { func CompareTrees_delete(fn interface{}, deleted string, rootOr, root *solutions.TreeNode, rootS *student.TreeNode) {
sel := student.BTreeSearchItem(rootS, deleted) sel := student.BTreeSearchItem(rootS, deleted)
if !student.BTreeIsBinary(rootS) || sel != nil { if !student.BTreeIsBinary(rootS) || sel != nil {
@ -98,23 +98,23 @@ func CompareTrees_delete(fn interface{}, deleted string, rootOr, root *correct.T
} }
func main() { func main() {
root := &correct.TreeNode{Data: "04"} root := &solutions.TreeNode{Data: "04"}
rootS := &student.TreeNode{Data: "04"} rootS := &student.TreeNode{Data: "04"}
rootOr := &correct.TreeNode{Data: "04"} rootOr := &solutions.TreeNode{Data: "04"}
ins := []string{"01", "07", "05", "12", "02", "03", "10"} ins := []string{"01", "07", "05", "12", "02", "03", "10"}
for _, v := range ins { for _, v := range ins {
root = correct.BTreeInsertData(root, v) root = solutions.BTreeInsertData(root, v)
rootS = student.BTreeInsertData(rootS, v) rootS = student.BTreeInsertData(rootS, v)
rootOr = correct.BTreeInsertData(rootOr, v) rootOr = solutions.BTreeInsertData(rootOr, v)
} }
selected := correct.BTreeSearchItem(root, "04") selected := solutions.BTreeSearchItem(root, "04")
selectedS := student.BTreeSearchItem(rootS, "04") selectedS := student.BTreeSearchItem(rootS, "04")
root = correct.BTreeDeleteNode(root, selected) root = solutions.BTreeDeleteNode(root, selected)
rootS = student.BTreeDeleteNode(rootS, selectedS) rootS = student.BTreeDeleteNode(rootS, selectedS)
fn := interface{}(correct.BTreeDeleteNode) fn := interface{}(solutions.BTreeDeleteNode)
CompareTrees_delete(fn, selected.Data, rootOr, root, rootS) CompareTrees_delete(fn, selected.Data, rootOr, root, rootS)
} }

18
test-go/tests/btreeinsertdata_test/main.go

@ -4,7 +4,7 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
func parentListInsert(root *student.TreeNode) string { func parentListInsert(root *student.TreeNode) string {
@ -79,18 +79,18 @@ func formatSubTree_insert(root *student.TreeNode, prefix string) string {
return res return res
} }
func errorMessage_insert(fn interface{}, inserted string, root *correct.TreeNode, rootS *student.TreeNode) { func errorMessage_insert(fn interface{}, inserted string, root *solutions.TreeNode, rootS *student.TreeNode) {
lib.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", "BTreeInsertData",
correct.FormatTree(root), solutions.FormatTree(root),
inserted, inserted,
FormatTree_insert(rootS), FormatTree_insert(rootS),
correct.FormatTree(root), solutions.FormatTree(root),
) )
} }
func CompareTrees_insert(fn interface{}, inserted string, root *correct.TreeNode, rootS *student.TreeNode) { func CompareTrees_insert(fn interface{}, inserted string, root *solutions.TreeNode, rootS *student.TreeNode) {
solTree := correct.FormatTree(root) solTree := solutions.FormatTree(root)
stuTree := FormatTree_insert(rootS) stuTree := FormatTree_insert(rootS)
if solTree != stuTree { if solTree != stuTree {
@ -99,7 +99,7 @@ func CompareTrees_insert(fn interface{}, inserted string, root *correct.TreeNode
} }
func main() { func main() {
root := &correct.TreeNode{Data: "08"} root := &solutions.TreeNode{Data: "08"}
rootS := &student.TreeNode{Data: "08"} rootS := &student.TreeNode{Data: "08"}
var pos []string var pos []string
@ -117,9 +117,9 @@ func main() {
"a", "a",
"d", "d",
) )
fn := interface{}(correct.BTreeInsertData) fn := interface{}(solutions.BTreeInsertData)
for _, arg := range pos { for _, arg := range pos {
root = correct.BTreeInsertData(root, arg) root = solutions.BTreeInsertData(root, arg)
rootS = student.BTreeInsertData(rootS, arg) rootS = student.BTreeInsertData(rootS, arg)
CompareTrees_insert(fn, arg, root, rootS) CompareTrees_insert(fn, arg, root, rootS)
} }

30
test-go/tests/btreeisbinary_test/main.go

@ -6,7 +6,7 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
func BTreeMinStu(root *student.TreeNode) *student.TreeNode { func BTreeMinStu(root *student.TreeNode) *student.TreeNode {
@ -16,16 +16,16 @@ func BTreeMinStu(root *student.TreeNode) *student.TreeNode {
return BTreeMinStu(root.Left) return BTreeMinStu(root.Left)
} }
func errorMessage_isbin(fn interface{}, root, a *correct.TreeNode, b *student.TreeNode) { func errorMessage_isbin(fn interface{}, root, a *solutions.TreeNode, b *student.TreeNode) {
lib.Fatalf("%s(\n%s\n) == %s instead of %s\n", lib.Fatalf("%s(\n%s\n) == %s instead of %s\n",
"BTreeIsBinary", "BTreeIsBinary",
correct.FormatTree(root), solutions.FormatTree(root),
b.Data, b.Data,
a.Data, a.Data,
) )
} }
func CompareNode_isbin(fn interface{}, arg1, a *correct.TreeNode, b *student.TreeNode) { func CompareNode_isbin(fn interface{}, arg1, a *solutions.TreeNode, b *student.TreeNode) {
if a == nil || b == nil { if a == nil || b == nil {
lib.Fatalf("Expected %v instead of %v\n", a, b) lib.Fatalf("Expected %v instead of %v\n", a, b)
} }
@ -55,7 +55,7 @@ func CompareNode_isbin(fn interface{}, arg1, a *correct.TreeNode, b *student.Tre
} }
} }
func CompareReturn_isbin(fn1, fn2 interface{}, arg1 *correct.TreeNode, arg2 interface{}) { func CompareReturn_isbin(fn1, fn2 interface{}, arg1 *solutions.TreeNode, arg2 interface{}) {
arar1 := []interface{}{arg1} arar1 := []interface{}{arg1}
arar2 := []interface{}{arg2} arar2 := []interface{}{arg2}
@ -64,13 +64,13 @@ func CompareReturn_isbin(fn1, fn2 interface{}, arg1 *correct.TreeNode, arg2 inte
for i, v := range out1.Results { for i, v := range out1.Results {
switch str := v.(type) { switch str := v.(type) {
case *correct.TreeNode: case *solutions.TreeNode:
CompareNode_isbin(fn1, arg1, str, out2.Results[i].(*student.TreeNode)) CompareNode_isbin(fn1, arg1, str, out2.Results[i].(*student.TreeNode))
default: default:
if !reflect.DeepEqual(str, out2.Results[i]) { if !reflect.DeepEqual(str, out2.Results[i]) {
lib.Fatalf("%s(\n%s) == %s instead of %s\n", lib.Fatalf("%s(\n%s) == %s instead of %s\n",
"BTreeIsBinary", "BTreeIsBinary",
correct.FormatTree(arg1), solutions.FormatTree(arg1),
lib.Format(out2.Results...), lib.Format(out2.Results...),
lib.Format(out1.Results...), lib.Format(out1.Results...),
) )
@ -80,31 +80,31 @@ func CompareReturn_isbin(fn1, fn2 interface{}, arg1 *correct.TreeNode, arg2 inte
} }
func main() { func main() {
root := &correct.TreeNode{Data: "04"} root := &solutions.TreeNode{Data: "04"}
rootS := &student.TreeNode{Data: "04"} rootS := &student.TreeNode{Data: "04"}
ins := []string{"01", "07", "05", "12", "02", "03", "10"} ins := []string{"01", "07", "05", "12", "02", "03", "10"}
for _, v := range ins { for _, v := range ins {
root = correct.BTreeInsertData(root, v) root = solutions.BTreeInsertData(root, v)
rootS = student.BTreeInsertData(rootS, v) rootS = student.BTreeInsertData(rootS, v)
} }
CompareReturn_isbin(correct.BTreeIsBinary, student.BTreeIsBinary, root, rootS) CompareReturn_isbin(solutions.BTreeIsBinary, student.BTreeIsBinary, root, rootS)
rootNB := &correct.TreeNode{Data: "04"} rootNB := &solutions.TreeNode{Data: "04"}
rootNB_stu := &student.TreeNode{Data: "04"} rootNB_stu := &student.TreeNode{Data: "04"}
// Test a non-binarysearch tree // Test a non-binarysearch tree
for _, v := range ins { for _, v := range ins {
rootNB = correct.BTreeInsertData(rootNB, v) rootNB = solutions.BTreeInsertData(rootNB, v)
rootNB_stu = student.BTreeInsertData(rootNB_stu, v) rootNB_stu = student.BTreeInsertData(rootNB_stu, v)
} }
min := correct.BTreeMin(rootNB) min := solutions.BTreeMin(rootNB)
minStu := BTreeMinStu(rootNB_stu) minStu := BTreeMinStu(rootNB_stu)
min.Left = &correct.TreeNode{Data: "123"} min.Left = &solutions.TreeNode{Data: "123"}
minStu.Left = &student.TreeNode{Data: "123"} minStu.Left = &student.TreeNode{Data: "123"}
CompareReturn_isbin(correct.BTreeIsBinary, student.BTreeIsBinary, rootNB, rootNB_stu) CompareReturn_isbin(solutions.BTreeIsBinary, student.BTreeIsBinary, rootNB, rootNB_stu)
} }

20
test-go/tests/btreelevelcount_test/main.go

@ -6,19 +6,19 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
func errorMessage_level(fn interface{}, root, a *correct.TreeNode, b *student.TreeNode) { func errorMessage_level(fn interface{}, root, a *solutions.TreeNode, b *student.TreeNode) {
lib.Fatalf("%s(\n%s\n) == %s instead of %s\n", lib.Fatalf("%s(\n%s\n) == %s instead of %s\n",
"BTreeLevelCount", "BTreeLevelCount",
correct.FormatTree(root), solutions.FormatTree(root),
b.Data, b.Data,
a.Data, a.Data,
) )
} }
func CompareNode_level(fn interface{}, arg1, a *correct.TreeNode, b *student.TreeNode) { func CompareNode_level(fn interface{}, arg1, a *solutions.TreeNode, b *student.TreeNode) {
if a == nil || b == nil { if a == nil || b == nil {
lib.Fatalf("Expected %v instead of %v\n", a, b) lib.Fatalf("Expected %v instead of %v\n", a, b)
return return
@ -56,7 +56,7 @@ func CompareNode_level(fn interface{}, arg1, a *correct.TreeNode, b *student.Tre
} }
} }
func CompareReturn_level(fn1, fn2 interface{}, arg1 *correct.TreeNode, arg2 interface{}) { func CompareReturn_level(fn1, fn2 interface{}, arg1 *solutions.TreeNode, arg2 interface{}) {
arar1 := []interface{}{arg1} arar1 := []interface{}{arg1}
arar2 := []interface{}{arg2} arar2 := []interface{}{arg2}
@ -65,13 +65,13 @@ func CompareReturn_level(fn1, fn2 interface{}, arg1 *correct.TreeNode, arg2 inte
for i, v := range out1.Results { for i, v := range out1.Results {
switch str := v.(type) { switch str := v.(type) {
case *correct.TreeNode: case *solutions.TreeNode:
CompareNode_level(fn1, arg1, str, out2.Results[i].(*student.TreeNode)) CompareNode_level(fn1, arg1, str, out2.Results[i].(*student.TreeNode))
default: default:
if !reflect.DeepEqual(str, out2.Results[i]) { if !reflect.DeepEqual(str, out2.Results[i]) {
lib.Fatalf("%s(\n%s) == %s instead of %s\n", lib.Fatalf("%s(\n%s) == %s instead of %s\n",
"BTreeLevelCount", "BTreeLevelCount",
correct.FormatTree(arg1), solutions.FormatTree(arg1),
lib.Format(out2.Results...), lib.Format(out2.Results...),
lib.Format(out1.Results...), lib.Format(out1.Results...),
) )
@ -81,14 +81,14 @@ func CompareReturn_level(fn1, fn2 interface{}, arg1 *correct.TreeNode, arg2 inte
} }
func main() { func main() {
root := &correct.TreeNode{Data: "04"} root := &solutions.TreeNode{Data: "04"}
rootS := &student.TreeNode{Data: "04"} rootS := &student.TreeNode{Data: "04"}
ins := []string{"01", "07", "05", "12", "02", "03", "10"} ins := []string{"01", "07", "05", "12", "02", "03", "10"}
for _, v := range ins { for _, v := range ins {
root = correct.BTreeInsertData(root, v) root = solutions.BTreeInsertData(root, v)
rootS = student.BTreeInsertData(rootS, v) rootS = student.BTreeInsertData(rootS, v)
CompareReturn_level(correct.BTreeLevelCount, student.BTreeLevelCount, root, rootS) CompareReturn_level(solutions.BTreeLevelCount, student.BTreeLevelCount, root, rootS)
} }
} }

20
test-go/tests/btreemax_test/main.go

@ -6,19 +6,19 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
func errorMessage_max(fn interface{}, root, a *correct.TreeNode, b *student.TreeNode) { func errorMessage_max(fn interface{}, root, a *solutions.TreeNode, b *student.TreeNode) {
lib.Fatalf("%s(\n%s) == %s instead of %s\n", lib.Fatalf("%s(\n%s) == %s instead of %s\n",
"BTreeMax", "BTreeMax",
correct.FormatTree(root), solutions.FormatTree(root),
b.Data, b.Data,
a.Data, a.Data,
) )
} }
func CompareNode_max(fn interface{}, arg1, a *correct.TreeNode, b *student.TreeNode) { func CompareNode_max(fn interface{}, arg1, a *solutions.TreeNode, b *student.TreeNode) {
if a == nil || b == nil { if a == nil || b == nil {
lib.Fatalf("Expected %v instead of %v\n", a, b) lib.Fatalf("Expected %v instead of %v\n", a, b)
return return
@ -56,7 +56,7 @@ func CompareNode_max(fn interface{}, arg1, a *correct.TreeNode, b *student.TreeN
} }
} }
func CompareReturn_max(fn1, fn2 interface{}, arg1 *correct.TreeNode, arg2 interface{}) { func CompareReturn_max(fn1, fn2 interface{}, arg1 *solutions.TreeNode, arg2 interface{}) {
arar1 := []interface{}{arg1} arar1 := []interface{}{arg1}
arar2 := []interface{}{arg2} arar2 := []interface{}{arg2}
@ -65,13 +65,13 @@ func CompareReturn_max(fn1, fn2 interface{}, arg1 *correct.TreeNode, arg2 interf
for i, v := range out1.Results { for i, v := range out1.Results {
switch str := v.(type) { switch str := v.(type) {
case *correct.TreeNode: case *solutions.TreeNode:
CompareNode_max(fn1, arg1, str, out2.Results[i].(*student.TreeNode)) CompareNode_max(fn1, arg1, str, out2.Results[i].(*student.TreeNode))
default: default:
if !reflect.DeepEqual(str, out2.Results[i]) { if !reflect.DeepEqual(str, out2.Results[i]) {
lib.Fatalf("%s(\n%s) == %s instead of\n %s\n", lib.Fatalf("%s(\n%s) == %s instead of\n %s\n",
"BTreeMax", "BTreeMax",
correct.FormatTree(arg1), solutions.FormatTree(arg1),
lib.Format(out2.Results...), lib.Format(out2.Results...),
lib.Format(out1.Results...), lib.Format(out1.Results...),
) )
@ -81,15 +81,15 @@ func CompareReturn_max(fn1, fn2 interface{}, arg1 *correct.TreeNode, arg2 interf
} }
func main() { func main() {
root := &correct.TreeNode{Data: "04"} root := &solutions.TreeNode{Data: "04"}
rootS := &student.TreeNode{Data: "04"} rootS := &student.TreeNode{Data: "04"}
ins := []string{"01", "07", "05", "12", "02", "03", "10"} ins := []string{"01", "07", "05", "12", "02", "03", "10"}
for _, v := range ins { for _, v := range ins {
root = correct.BTreeInsertData(root, v) root = solutions.BTreeInsertData(root, v)
rootS = student.BTreeInsertData(rootS, v) rootS = student.BTreeInsertData(rootS, v)
} }
CompareReturn_max(correct.BTreeMax, student.BTreeMax, root, rootS) CompareReturn_max(solutions.BTreeMax, student.BTreeMax, root, rootS)
} }

18
test-go/tests/btreemin_test/main.go

@ -6,19 +6,19 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
func errorMessage_min(fn interface{}, root, a *correct.TreeNode, b *student.TreeNode) { func errorMessage_min(fn interface{}, root, a *solutions.TreeNode, b *student.TreeNode) {
lib.Fatalf("%s(\n%s) == %s instead of %s\n", lib.Fatalf("%s(\n%s) == %s instead of %s\n",
"BTreeMin", "BTreeMin",
correct.FormatTree(root), solutions.FormatTree(root),
b.Data, b.Data,
a.Data, a.Data,
) )
} }
func CompareNode_min(fn interface{}, arg1, a *correct.TreeNode, b *student.TreeNode) { func CompareNode_min(fn interface{}, arg1, a *solutions.TreeNode, b *student.TreeNode) {
if a == nil || b == nil { if a == nil || b == nil {
lib.Fatalf("Expected %v instead of %v\n", a, b) lib.Fatalf("Expected %v instead of %v\n", a, b)
return return
@ -65,8 +65,8 @@ func CompareReturn_min(fn1, fn2, arg1, arg2 interface{}) {
for i, v := range out1.Results { for i, v := range out1.Results {
switch str := v.(type) { switch str := v.(type) {
case *correct.TreeNode: case *solutions.TreeNode:
CompareNode_min(fn1, arg1.(*correct.TreeNode), str, out2.Results[i].(*student.TreeNode)) CompareNode_min(fn1, arg1.(*solutions.TreeNode), str, out2.Results[i].(*student.TreeNode))
default: default:
if !reflect.DeepEqual(str, out2.Results[i]) { if !reflect.DeepEqual(str, out2.Results[i]) {
lib.Fatalf("%s(%s) == %s instead of %s\n", lib.Fatalf("%s(%s) == %s instead of %s\n",
@ -81,15 +81,15 @@ func CompareReturn_min(fn1, fn2, arg1, arg2 interface{}) {
} }
func main() { func main() {
root := &correct.TreeNode{Data: "04"} root := &solutions.TreeNode{Data: "04"}
rootS := &student.TreeNode{Data: "04"} rootS := &student.TreeNode{Data: "04"}
ins := []string{"03", "02", "01", "07", "05", "12", "10"} ins := []string{"03", "02", "01", "07", "05", "12", "10"}
for _, v := range ins { for _, v := range ins {
root = correct.BTreeInsertData(root, v) root = solutions.BTreeInsertData(root, v)
rootS = student.BTreeInsertData(rootS, v) rootS = student.BTreeInsertData(rootS, v)
} }
CompareReturn_min(correct.BTreeMin, student.BTreeMin, root, rootS) CompareReturn_min(solutions.BTreeMin, student.BTreeMin, root, rootS)
} }

16
test-go/tests/btreesearchitem_test/main.go

@ -6,21 +6,21 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
func errorMessage_search(fn interface{}, root, a *correct.TreeNode, b *student.TreeNode, func errorMessage_search(fn interface{}, root, a *solutions.TreeNode, b *student.TreeNode,
seaVal string) { seaVal string) {
lib.Fatalf("%s(\n%s\n, %s) == %s instead of %s\n", lib.Fatalf("%s(\n%s\n, %s) == %s instead of %s\n",
"BTreeSearchItem", "BTreeSearchItem",
correct.FormatTree(root), solutions.FormatTree(root),
seaVal, seaVal,
b.Data, b.Data,
a.Data, a.Data,
) )
} }
func CompareNode_search(fn interface{}, arg1, a *correct.TreeNode, b *student.TreeNode, func CompareNode_search(fn interface{}, arg1, a *solutions.TreeNode, b *student.TreeNode,
seaVal string) { seaVal string) {
if a == nil && b == nil { if a == nil && b == nil {
return return
@ -67,20 +67,20 @@ func CompareNode_search(fn interface{}, arg1, a *correct.TreeNode, b *student.Tr
} }
func main() { func main() {
root := &correct.TreeNode{Data: "04"} root := &solutions.TreeNode{Data: "04"}
rootS := &student.TreeNode{Data: "04"} rootS := &student.TreeNode{Data: "04"}
ins := []string{"01", "07", "05", "12", "02", "03", "10"} ins := []string{"01", "07", "05", "12", "02", "03", "10"}
for _, v := range ins { for _, v := range ins {
root = correct.BTreeInsertData(root, v) root = solutions.BTreeInsertData(root, v)
rootS = student.BTreeInsertData(rootS, v) rootS = student.BTreeInsertData(rootS, v)
} }
fn := interface{}(correct.BTreeSearchItem) fn := interface{}(solutions.BTreeSearchItem)
ins = append(ins, "322") ins = append(ins, "322")
for _, v := range ins { for _, v := range ins {
selectedSol := correct.BTreeSearchItem(root, v) selectedSol := solutions.BTreeSearchItem(root, v)
selectedStu := student.BTreeSearchItem(rootS, v) selectedStu := student.BTreeSearchItem(rootS, v)
CompareNode_search(fn, root, selectedSol, selectedStu, v) CompareNode_search(fn, root, selectedSol, selectedStu, v)
} }

36
test-go/tests/btreetransplant_test/main.go

@ -6,7 +6,7 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
func parentListTransp(root *student.TreeNode) string { func parentListTransp(root *student.TreeNode) string {
@ -81,25 +81,25 @@ func formatSubTree_transp(root *student.TreeNode, prefix string) string {
return res return res
} }
func errorMessage_transp(fn interface{}, root, sel, repl *correct.TreeNode, rootA *correct.TreeNode, rootAS *student.TreeNode) { func errorMessage_transp(fn interface{}, root, sel, repl *solutions.TreeNode, rootA *solutions.TreeNode, rootAS *student.TreeNode) {
lib.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", "BTreeTransplant",
correct.FormatTree(root), solutions.FormatTree(root),
correct.FormatTree(sel), solutions.FormatTree(sel),
correct.FormatTree(repl), solutions.FormatTree(repl),
FormatTree_transp(rootAS), FormatTree_transp(rootAS),
correct.FormatTree(rootA), solutions.FormatTree(rootA),
) )
} }
func CompareTrees_transp(fn interface{}, root, sel, repl *correct.TreeNode, rootA *correct.TreeNode, rootAS *student.TreeNode) { func CompareTrees_transp(fn interface{}, root, sel, repl *solutions.TreeNode, rootA *solutions.TreeNode, rootAS *student.TreeNode) {
solTree := correct.FormatTree(rootA) solTree := solutions.FormatTree(rootA)
stuTree := FormatTree_transp(rootAS) stuTree := FormatTree_transp(rootAS)
if solTree != stuTree { if solTree != stuTree {
errorMessage_transp(fn, root, sel, repl, rootA, rootAS) errorMessage_transp(fn, root, sel, repl, rootA, rootAS)
} }
parentSol := correct.ParentList(rootA) parentSol := solutions.ParentList(rootA)
parentStu := parentListTransp(rootAS) parentStu := parentListTransp(rootAS)
if parentSol != parentStu { if parentSol != parentStu {
@ -109,11 +109,11 @@ func CompareTrees_transp(fn interface{}, root, sel, repl *correct.TreeNode, root
} }
func main() { func main() {
root := &correct.TreeNode{Data: "04"} root := &solutions.TreeNode{Data: "04"}
rootS := &student.TreeNode{Data: "04"} rootS := &student.TreeNode{Data: "04"}
rootOr := &correct.TreeNode{Data: "04"} rootOr := &solutions.TreeNode{Data: "04"}
replacement := &correct.TreeNode{Data: "55"} replacement := &solutions.TreeNode{Data: "55"}
replacementS := &student.TreeNode{Data: "55"} replacementS := &student.TreeNode{Data: "55"}
ins := []string{"01", "07", "05", "12", "02", "03", "10"} ins := []string{"01", "07", "05", "12", "02", "03", "10"}
@ -121,21 +121,21 @@ func main() {
rep := []string{"33", "12", "15", "60"} rep := []string{"33", "12", "15", "60"}
for _, v := range ins { for _, v := range ins {
root = correct.BTreeInsertData(root, v) root = solutions.BTreeInsertData(root, v)
rootS = student.BTreeInsertData(rootS, v) rootS = student.BTreeInsertData(rootS, v)
rootOr = correct.BTreeInsertData(rootOr, v) rootOr = solutions.BTreeInsertData(rootOr, v)
} }
for _, v := range rep { for _, v := range rep {
replacement = correct.BTreeInsertData(replacement, v) replacement = solutions.BTreeInsertData(replacement, v)
replacementS = student.BTreeInsertData(replacementS, v) replacementS = student.BTreeInsertData(replacementS, v)
} }
selected := correct.BTreeSearchItem(root, "07") selected := solutions.BTreeSearchItem(root, "07")
selectedS := student.BTreeSearchItem(rootS, "07") selectedS := student.BTreeSearchItem(rootS, "07")
root = correct.BTreeTransplant(root, selected, replacement) root = solutions.BTreeTransplant(root, selected, replacement)
rootS = student.BTreeTransplant(rootS, selectedS, replacementS) rootS = student.BTreeTransplant(rootS, selectedS, replacementS)
fn := interface{}(correct.BTreeTransplant) fn := interface{}(solutions.BTreeTransplant)
CompareTrees_transp(fn, rootOr, selected, replacement, root, rootS) CompareTrees_transp(fn, rootOr, selected, replacement, root, rootS)
} }

16
test-go/tests/listat_test/main.go

@ -4,12 +4,12 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
type ( type (
Node5 = student.NodeL Node5 = student.NodeL
NodeS5 = correct.NodeL NodeS5 = solutions.NodeL
) )
func nodePushBackList5(l1 *Node5, l2 *NodeS5, data interface{}) (*Node5, *NodeS5) { func nodePushBackList5(l1 *Node5, l2 *NodeS5, data interface{}) (*Node5, *NodeS5) {
@ -44,15 +44,15 @@ func comparFuncNode5(solutionList *NodeS5, l1 *Node5, l2 *NodeS5, arg int) {
} }
if l1 != nil && l2 == nil { if l1 != nil && l2 == nil {
lib.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) solutions.ListToString(solutionList), arg, l1, l2)
} }
if l1.Data != l2.Data { if l1.Data != l2.Data {
lib.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) solutions.ListToString(solutionList), arg, l1.Data, l2.Data)
} }
} }
// finds an element of a correct.ListS using a given position // finds an element of a solutions.ListS using a given position
func main() { func main() {
var link1 *Node5 var link1 *Node5
var link2 *NodeS5 var link2 *NodeS5
@ -66,14 +66,14 @@ func main() {
for i := 0; i < 4; i++ { for i := 0; i < 4; i++ {
table = append(table, nodeTest{ table = append(table, nodeTest{
data: correct.ConvertIntToInterface(lib.MultRandInt()), data: solutions.ConvertIntToInterface(lib.MultRandInt()),
pos: lib.RandIntBetween(1, 12), pos: lib.RandIntBetween(1, 12),
}) })
} }
for i := 0; i < 4; i++ { for i := 0; i < 4; i++ {
table = append(table, nodeTest{ table = append(table, nodeTest{
data: correct.ConvertIntToStringface(lib.MultRandWords()), data: solutions.ConvertIntToStringface(lib.MultRandWords()),
pos: lib.RandIntBetween(1, 12), pos: lib.RandIntBetween(1, 12),
}) })
} }
@ -89,7 +89,7 @@ func main() {
} }
result1 := student.ListAt(link1, arg.pos) result1 := student.ListAt(link1, arg.pos)
result2 := correct.ListAt(link2, arg.pos) result2 := solutions.ListAt(link2, arg.pos)
comparFuncNode5(link2, result1, result2, arg.pos) comparFuncNode5(link2, result1, result2, arg.pos)
link1 = nil link1 = nil

18
test-go/tests/listclear_test/main.go

@ -6,13 +6,13 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
type ( type (
Node4 = student.NodeL Node4 = student.NodeL
List4 = correct.List List4 = solutions.List
NodeS4 = correct.NodeL NodeS4 = solutions.NodeL
ListS4 = student.List ListS4 = student.List
) )
@ -55,17 +55,17 @@ func listPushBackTest4(l1 *ListS4, l2 *List4, data interface{}) {
} }
} }
// simply cleans the linked correct.ListS // simply cleans the linked solutions.ListS
func main() { func main() {
link1 := &List4{} link1 := &List4{}
link2 := &ListS4{} link2 := &ListS4{}
table := []correct.NodeTest{} table := []solutions.NodeTest{}
table = correct.ElementsToTest(table) table = solutions.ElementsToTest(table)
table = append(table, table = append(table,
correct.NodeTest{ solutions.NodeTest{
Data: []interface{}{"I", 1, "something", 2}, Data: []interface{}{"I", 1, "something", 2},
}, },
) )
@ -74,12 +74,12 @@ func main() {
for i := 0; i < len(arg.Data); i++ { for i := 0; i < len(arg.Data); i++ {
listPushBackTest4(link2, link1, arg.Data[i]) listPushBackTest4(link2, link1, arg.Data[i])
} }
correct.ListClear(link1) solutions.ListClear(link1)
student.ListClear(link2) student.ListClear(link2)
if link2.Head != nil { if link2.Head != nil {
lib.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) listToStringStu5(link2), solutions.ListToString(link1.Head), link2.Head, link1.Head)
} }
} }
} }

16
test-go/tests/listfind_test/main.go

@ -4,13 +4,13 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
type ( type (
Node9 = student.NodeL Node9 = student.NodeL
List9 = correct.List List9 = solutions.List
NodeS9 = correct.NodeL NodeS9 = solutions.NodeL
ListS9 = student.List ListS9 = student.List
) )
@ -41,10 +41,10 @@ func main() {
link1 := &List9{} link1 := &List9{}
link2 := &ListS9{} link2 := &ListS9{}
table := []correct.NodeTest{} table := []solutions.NodeTest{}
table = correct.ElementsToTest(table) table = solutions.ElementsToTest(table)
table = append(table, table = append(table,
correct.NodeTest{ solutions.NodeTest{
Data: []interface{}{"hello", "hello1", "hello2", "hello3"}, Data: []interface{}{"hello", "hello1", "hello2", "hello3"},
}, },
) )
@ -55,7 +55,7 @@ func main() {
} }
if len(arg.Data) != 0 { if len(arg.Data) != 0 {
aux1 := student.ListFind(link2, arg.Data[(len(arg.Data)-1)/2], student.CompStr) aux1 := student.ListFind(link2, arg.Data[(len(arg.Data)-1)/2], student.CompStr)
aux2 := correct.ListFind(link1, arg.Data[(len(arg.Data)-1)/2], correct.CompStr) aux2 := solutions.ListFind(link1, arg.Data[(len(arg.Data)-1)/2], solutions.CompStr)
if aux1 != nil || aux2 != nil { if aux1 != nil || aux2 != nil {
if *aux1 != *aux2 { if *aux1 != *aux2 {
@ -72,7 +72,7 @@ func main() {
} }
aux1 := student.ListFind(link2, "lksdf", student.CompStr) aux1 := student.ListFind(link2, "lksdf", student.CompStr)
aux2 := correct.ListFind(link1, "lksdf", correct.CompStr) aux2 := solutions.ListFind(link1, "lksdf", solutions.CompStr)
if aux1 != nil && aux2 != nil { if aux1 != nil && aux2 != nil {
if *aux1 != *aux2 { if *aux1 != *aux2 {
lib.Fatalf("ListFind(ref: lksdf) == %s instead of %s\n", *aux1, *aux2) lib.Fatalf("ListFind(ref: lksdf) == %s instead of %s\n", *aux1, *aux2)

24
test-go/tests/listforeach_test/main.go

@ -6,13 +6,13 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
type ( type (
Node7 = student.NodeL Node7 = student.NodeL
List7 = correct.List List7 = solutions.List
NodeS7 = correct.NodeL NodeS7 = solutions.NodeL
ListS7 = student.List ListS7 = student.List
) )
@ -56,29 +56,29 @@ func listPushBackTest7(l1 *ListS7, l2 *List7, data interface{}) {
} }
func comparFuncList7(l1 *List7, l2 *ListS7, f func(*Node7)) { func comparFuncList7(l1 *List7, l2 *ListS7, f func(*Node7)) {
funcName := correct.GetName(f) funcName := solutions.GetName(f)
for l1.Head != nil || l2.Head != nil { for l1.Head != nil || l2.Head != nil {
if (l1.Head == nil && l2.Head != nil) || (l1.Head != nil && l2.Head == nil) { if (l1.Head == nil && l2.Head != nil) || (l1.Head != nil && l2.Head == nil) {
lib.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) listToStringStu8(l2), solutions.ListToString(l1.Head), funcName, l2.Head, l1.Head)
} }
if l1.Head.Data != l2.Head.Data { if l1.Head.Data != l2.Head.Data {
lib.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) listToStringStu8(l2), solutions.ListToString(l1.Head), funcName, l2.Head.Data, l1.Head.Data)
} }
l1.Head = l1.Head.Next l1.Head = l1.Head.Next
l2.Head = l2.Head.Next l2.Head = l2.Head.Next
} }
} }
// applies a function to the correct.ListS // applies a function to the solutions.ListS
func main() { func main() {
link1 := &List7{} link1 := &List7{}
link2 := &ListS7{} link2 := &ListS7{}
table := []correct.NodeTest{} table := []solutions.NodeTest{}
table = correct.ElementsToTest(table) table = solutions.ElementsToTest(table)
table = append(table, table = append(table,
correct.NodeTest{ solutions.NodeTest{
Data: []interface{}{"I", 1, "something", 2}, Data: []interface{}{"I", 1, "something", 2},
}, },
) )
@ -87,12 +87,12 @@ func main() {
listPushBackTest7(link2, link1, arg.Data[i]) listPushBackTest7(link2, link1, arg.Data[i])
} }
student.ListForEach(link2, student.Add2_node) student.ListForEach(link2, student.Add2_node)
correct.ListForEach(link1, correct.Add2_node) solutions.ListForEach(link1, solutions.Add2_node)
comparFuncList7(link1, link2, student.Add2_node) comparFuncList7(link1, link2, student.Add2_node)
student.ListForEach(link2, student.Subtract3_node) student.ListForEach(link2, student.Subtract3_node)
correct.ListForEach(link1, correct.Subtract3_node) solutions.ListForEach(link1, solutions.Subtract3_node)
comparFuncList7(link1, link2, student.Subtract3_node) comparFuncList7(link1, link2, student.Subtract3_node)

34
test-go/tests/listforeachif_test/main.go

@ -6,13 +6,13 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
type ( type (
Node8 = student.NodeL Node8 = student.NodeL
List8 = correct.List List8 = solutions.List
NodeS8 = correct.NodeL NodeS8 = solutions.NodeL
ListS8 = student.List ListS8 = student.List
) )
@ -84,50 +84,50 @@ func listPushBackTest8(l1 *ListS8, l2 *List8, data interface{}) {
} }
func comparFuncList8(l1 *List8, l2 *ListS8, f func(*Node8) bool, comp func(*Node8)) { func comparFuncList8(l1 *List8, l2 *ListS8, f func(*Node8) bool, comp func(*Node8)) {
funcFName := correct.GetName(f) funcFName := solutions.GetName(f)
funcComp := correct.GetName(comp) funcComp := solutions.GetName(comp)
for l1.Head != nil || l2.Head != nil { for l1.Head != nil || l2.Head != nil {
if (l1.Head == nil && l2.Head != nil) || (l1.Head != nil && l2.Head == nil) { if (l1.Head == nil && l2.Head != nil) || (l1.Head != nil && l2.Head == nil) {
lib.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) listToStringStu7(l2), solutions.ListToString(l1.Head), funcComp, funcFName, l2.Head, l1.Head)
} }
if l1.Head.Data != l2.Head.Data { if l1.Head.Data != l2.Head.Data {
lib.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) listToStringStu7(l2), solutions.ListToString(l1.Head), funcComp, funcFName, l2.Head.Data, l1.Head.Data)
} }
l1.Head = l1.Head.Next l1.Head = l1.Head.Next
l2.Head = l2.Head.Next l2.Head = l2.Head.Next
} }
} }
// applies a function to an element of the linked correct.ListS // applies a function to an element of the linked solutions.ListS
func main() { func main() {
link1 := &ListS8{} link1 := &ListS8{}
link2 := &List8{} link2 := &List8{}
table := []correct.NodeTest{} table := []solutions.NodeTest{}
table = append(table, table = append(table,
correct.NodeTest{ solutions.NodeTest{
Data: []interface{}{}, Data: []interface{}{},
}, },
) )
// just numbers/ints // just numbers/ints
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
val := correct.NodeTest{ val := solutions.NodeTest{
Data: correct.ConvertIntToInterface(lib.MultRandInt()), Data: solutions.ConvertIntToInterface(lib.MultRandInt()),
} }
table = append(table, val) table = append(table, val)
} }
// just strings // just strings
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
val := correct.NodeTest{ val := solutions.NodeTest{
Data: correct.ConvertIntToStringface(lib.MultRandWords()), Data: solutions.ConvertIntToStringface(lib.MultRandWords()),
} }
table = append(table, val) table = append(table, val)
} }
table = append(table, table = append(table,
correct.NodeTest{ solutions.NodeTest{
Data: []interface{}{"I", 1, "something", 2}, Data: []interface{}{"I", 1, "something", 2},
}, },
) )
@ -135,11 +135,11 @@ func main() {
for i := 0; i < len(arg.Data); i++ { for i := 0; i < len(arg.Data); i++ {
listPushBackTest8(link1, link2, arg.Data[i]) listPushBackTest8(link1, link2, arg.Data[i])
} }
correct.ListForEachIf(link2, addOneS, correct.IsPositive_node) solutions.ListForEachIf(link2, addOneS, solutions.IsPositive_node)
student.ListForEachIf(link1, addOne, student.IsPositive_node) student.ListForEachIf(link1, addOne, student.IsPositive_node)
comparFuncList8(link2, link1, student.IsPositive_node, addOne) comparFuncList8(link2, link1, student.IsPositive_node, addOne)
correct.ListForEachIf(link2, subtract1_sol, correct.IsPositive_node) solutions.ListForEachIf(link2, subtract1_sol, solutions.IsPositive_node)
student.ListForEachIf(link1, subtractOne, student.IsPositive_node) student.ListForEachIf(link1, subtractOne, student.IsPositive_node)
comparFuncList8(link2, link1, student.IsPositive_node, subtractOne) comparFuncList8(link2, link1, student.IsPositive_node, subtractOne)

16
test-go/tests/listlast_test/main.go

@ -6,13 +6,13 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
type ( type (
Node3 = student.NodeL Node3 = student.NodeL
List3 = correct.List List3 = solutions.List
NodeS3 = correct.NodeL NodeS3 = solutions.NodeL
ListS3 = student.List ListS3 = student.List
) )
@ -52,15 +52,15 @@ func listPushBackTest3(l *ListS3, l1 *List3, data interface{}) {
} }
} }
// last element of the correct.ListS // last element of the solutions.ListS
func main() { func main() {
link1 := &List3{} link1 := &List3{}
link2 := &ListS3{} link2 := &ListS3{}
table := []correct.NodeTest{} table := []solutions.NodeTest{}
table = correct.ElementsToTest(table) table = solutions.ElementsToTest(table)
table = append(table, table = append(table,
correct.NodeTest{ solutions.NodeTest{
Data: []interface{}{3, 2, 1}, Data: []interface{}{3, 2, 1},
}, },
) )
@ -68,7 +68,7 @@ func main() {
for i := 0; i < len(arg.Data); i++ { for i := 0; i < len(arg.Data); i++ {
listPushBackTest3(link2, link1, arg.Data[i]) listPushBackTest3(link2, link1, arg.Data[i])
} }
aux1 := correct.ListLast(link1) aux1 := solutions.ListLast(link1)
aux2 := student.ListLast(link2) aux2 := student.ListLast(link2)
if aux1 != aux2 { if aux1 != aux2 {

22
test-go/tests/listmerge_test/main.go

@ -6,13 +6,13 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
type ( type (
Node11 = student.NodeL Node11 = student.NodeL
List11 = correct.List List11 = solutions.List
NodeS11 = correct.NodeL NodeS11 = solutions.NodeL
ListS11 = student.List ListS11 = student.List
) )
@ -63,11 +63,11 @@ func comparFuncList11(l1 *List11, l2 *ListS11) {
for l1.Head != nil || l2.Head != nil { for l1.Head != nil || l2.Head != nil {
if (l1.Head == nil && l2.Head != nil) || (l1.Head != nil && l2.Head == nil) { if (l1.Head == nil && l2.Head != nil) || (l1.Head != nil && l2.Head == nil) {
lib.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) listToStringStu(l2), solutions.ListToString(l1.Head), l2.Head, l1.Head)
} }
if l1.Head.Data != l2.Head.Data { if l1.Head.Data != l2.Head.Data {
lib.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) listToStringStu(l2), solutions.ListToString(l1.Head), l2.Head.Data, l1.Head.Data)
} }
l1.Head = l1.Head.Next l1.Head = l1.Head.Next
l2.Head = l2.Head.Next l2.Head = l2.Head.Next
@ -93,22 +93,22 @@ func main() {
}) })
table = append(table, table = append(table,
nodeTest{ nodeTest{
data1: correct.ConvertIntToInterface(lib.MultRandInt()), data1: solutions.ConvertIntToInterface(lib.MultRandInt()),
data2: []interface{}{}, data2: []interface{}{},
}) })
// jut ints // jut ints
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
val := nodeTest{ val := nodeTest{
data1: correct.ConvertIntToInterface(lib.MultRandInt()), data1: solutions.ConvertIntToInterface(lib.MultRandInt()),
data2: correct.ConvertIntToInterface(lib.MultRandInt()), data2: solutions.ConvertIntToInterface(lib.MultRandInt()),
} }
table = append(table, val) table = append(table, val)
} }
// just strings // just strings
for i := 0; i < 2; i++ { for i := 0; i < 2; i++ {
val := nodeTest{ val := nodeTest{
data1: correct.ConvertIntToStringface(lib.MultRandWords()), data1: solutions.ConvertIntToStringface(lib.MultRandWords()),
data2: correct.ConvertIntToStringface(lib.MultRandWords()), data2: solutions.ConvertIntToStringface(lib.MultRandWords()),
} }
table = append(table, val) table = append(table, val)
} }
@ -126,7 +126,7 @@ func main() {
listPushBackTest11(link2Test, linkTest, arg.data2[i]) listPushBackTest11(link2Test, linkTest, arg.data2[i])
} }
correct.ListMerge(link1, linkTest) solutions.ListMerge(link1, linkTest)
student.ListMerge(link2, link2Test) student.ListMerge(link2, link2Test)
comparFuncList11(link1, link2) comparFuncList11(link1, link2)

16
test-go/tests/listpushback_test/main.go

@ -6,11 +6,11 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
type ( type (
ListS = correct.List ListS = solutions.List
List = student.List List = student.List
) )
@ -35,11 +35,11 @@ func comparFuncList(l *ListS, l1 *List, data []interface{}) {
for l.Head != nil || l1.Head != nil { for l.Head != nil || l1.Head != nil {
if (l.Head == nil && l1.Head != nil) || (l.Head != nil && l1.Head == nil) { if (l.Head == nil && l1.Head != nil) || (l.Head != nil && l1.Head == nil) {
lib.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) data, listToStringStu10(l1), solutions.ListToString(l.Head), l1.Head, l.Head)
} }
if l.Head.Data != l1.Head.Data { if l.Head.Data != l1.Head.Data {
lib.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) data, listToStringStu10(l1), solutions.ListToString(l.Head), l1.Head.Data, l.Head.Data)
} }
l.Head = l.Head.Next l.Head = l.Head.Next
l1.Head = l1.Head.Next l1.Head = l1.Head.Next
@ -50,17 +50,17 @@ func main() {
link1 := &ListS{} link1 := &ListS{}
link2 := &List{} link2 := &List{}
table := []correct.NodeTest{} table := []solutions.NodeTest{}
table = correct.ElementsToTest(table) table = solutions.ElementsToTest(table)
table = append(table, table = append(table,
correct.NodeTest{ solutions.NodeTest{
Data: []interface{}{"Hello", "man", "how are you"}, Data: []interface{}{"Hello", "man", "how are you"},
}, },
) )
for _, arg := range table { for _, arg := range table {
for _, item := range arg.Data { for _, item := range arg.Data {
student.ListPushBack(link2, item) student.ListPushBack(link2, item)
correct.ListPushBack(link1, item) solutions.ListPushBack(link1, item)
} }
comparFuncList(link1, link2, arg.Data) comparFuncList(link1, link2, arg.Data)
} }

16
test-go/tests/listpushfront_test/main.go

@ -6,11 +6,11 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
type ( type (
ListSa = correct.List ListSa = solutions.List
Lista = student.List Lista = student.List
) )
@ -35,11 +35,11 @@ func comparFuncList1(l *Lista, l1 *ListSa, data []interface{}) {
for l.Head != nil || l1.Head != nil { for l.Head != nil || l1.Head != nil {
if (l.Head == nil && l1.Head != nil) || (l.Head != nil && l1.Head == nil) { if (l.Head == nil && l1.Head != nil) || (l.Head != nil && l1.Head == nil) {
lib.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) data, listToStringStu11(l), solutions.ListToString(l1.Head), l.Head, l1.Head)
} }
if l.Head.Data != l1.Head.Data { if l.Head.Data != l1.Head.Data {
lib.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) data, listToStringStu11(l), solutions.ListToString(l1.Head), l.Head, l1.Head)
} }
l1.Head = l1.Head.Next l1.Head = l1.Head.Next
l.Head = l.Head.Next l.Head = l.Head.Next
@ -50,17 +50,17 @@ func comparFuncList1(l *Lista, l1 *ListSa, data []interface{}) {
func main() { func main() {
link1 := &Lista{} link1 := &Lista{}
link2 := &ListSa{} link2 := &ListSa{}
table := []correct.NodeTest{} table := []solutions.NodeTest{}
table = correct.ElementsToTest(table) table = solutions.ElementsToTest(table)
table = append(table, table = append(table,
correct.NodeTest{ solutions.NodeTest{
Data: []interface{}{"Hello", "man", "how are you"}, Data: []interface{}{"Hello", "man", "how are you"},
}, },
) )
for _, arg := range table { for _, arg := range table {
for _, item := range arg.Data { for _, item := range arg.Data {
student.ListPushFront(link1, item) student.ListPushFront(link1, item)
correct.ListPushFront(link2, item) solutions.ListPushFront(link2, item)
} }
comparFuncList1(link1, link2, arg.Data) comparFuncList1(link1, link2, arg.Data)
link1 = &Lista{} link1 = &Lista{}

20
test-go/tests/listremoveif_test/main.go

@ -6,13 +6,13 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
type ( type (
Node10 = student.NodeL Node10 = student.NodeL
List10 = correct.List List10 = solutions.List
NodeS10 = correct.NodeL NodeS10 = solutions.NodeL
ListS10 = student.List ListS10 = student.List
) )
@ -59,11 +59,11 @@ func comparFuncList10(l *List10, l1 *ListS10, data interface{}) {
for l.Head != nil || l1.Head != nil { for l.Head != nil || l1.Head != nil {
if (l.Head == nil && l1.Head != nil) || (l.Head != nil && l1.Head == nil) { if (l.Head == nil && l1.Head != nil) || (l.Head != nil && l1.Head == nil) {
lib.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) data, listToStringStu12(l1), solutions.ListToString(l.Head), l1.Head, l.Head)
} }
if l.Head.Data != l1.Head.Data { if l.Head.Data != l1.Head.Data {
lib.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) data, listToStringStu12(l1), solutions.ListToString(l.Head), l1.Head.Data, l.Head.Data)
} }
l.Head = l.Head.Next l.Head = l.Head.Next
l1.Head = l1.Head.Next l1.Head = l1.Head.Next
@ -75,12 +75,12 @@ func main() {
link1 := &List10{} link1 := &List10{}
link2 := &ListS10{} link2 := &ListS10{}
var index int var index int
table := []correct.NodeTest{} table := []solutions.NodeTest{}
table = correct.ElementsToTest(table) table = solutions.ElementsToTest(table)
table = append(table, table = append(table,
correct.NodeTest{ solutions.NodeTest{
Data: []interface{}{"hello", "hello1", "hello2", "hello3"}, Data: []interface{}{"hello", "hello1", "hello2", "hello3"},
}, },
) )
@ -95,11 +95,11 @@ func main() {
if link1.Head != nil && link2.Head != nil { if link1.Head != nil && link2.Head != nil {
cho := arg.Data[index] cho := arg.Data[index]
student.ListRemoveIf(link2, cho) student.ListRemoveIf(link2, cho)
correct.ListRemoveIf(link1, cho) solutions.ListRemoveIf(link1, cho)
comparFuncList10(link1, link2, cho) comparFuncList10(link1, link2, cho)
} else { } else {
student.ListRemoveIf(link2, 1) student.ListRemoveIf(link2, 1)
correct.ListRemoveIf(link1, 1) solutions.ListRemoveIf(link1, 1)
comparFuncList10(link1, link2, 1) comparFuncList10(link1, link2, 1)
} }

16
test-go/tests/listreverse_test/main.go

@ -6,13 +6,13 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
type ( type (
Node6 = student.NodeL Node6 = student.NodeL
List6 = correct.List List6 = solutions.List
NodeS6 = correct.NodeL NodeS6 = solutions.NodeL
ListS6 = student.List ListS6 = student.List
) )
@ -36,11 +36,11 @@ func comparFuncList6(l *List6, l1 *ListS6) {
for l.Head != nil || l1.Head != nil { for l.Head != nil || l1.Head != nil {
if (l.Head == nil && l1.Head != nil) || (l.Head != nil && l1.Head == nil) { if (l.Head == nil && l1.Head != nil) || (l.Head != nil && l1.Head == nil) {
lib.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) listToStringStu13(l1), solutions.ListToString(l.Head), l1.Head, l.Head)
} }
if l.Head.Data != l1.Head.Data { if l.Head.Data != l1.Head.Data {
lib.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) listToStringStu13(l1), solutions.ListToString(l.Head), l1.Head.Data, l.Head.Data)
} }
l.Head = l.Head.Next l.Head = l.Head.Next
l1.Head = l1.Head.Next l1.Head = l1.Head.Next
@ -73,16 +73,16 @@ func listPushBackTest6(l *ListS6, l1 *List6, data interface{}) {
func main() { func main() {
link1 := &List6{} link1 := &List6{}
link2 := &ListS6{} link2 := &ListS6{}
table := []correct.NodeTest{{ table := []solutions.NodeTest{{
Data: []interface{}{"I", 1, "something", 2}, Data: []interface{}{"I", 1, "something", 2},
}} }}
table = correct.ElementsToTest(table) table = solutions.ElementsToTest(table)
for _, arg := range table { for _, arg := range table {
for _, item := range arg.Data { for _, item := range arg.Data {
listPushBackTest6(link2, link1, item) listPushBackTest6(link2, link1, item)
} }
student.ListReverse(link2) student.ListReverse(link2)
correct.ListReverse(link1) solutions.ListReverse(link1)
comparFuncList6(link1, link2) comparFuncList6(link1, link2)
link1 = &List6{} link1 = &List6{}
link2 = &ListS6{} link2 = &ListS6{}

16
test-go/tests/listsize_test/main.go

@ -4,13 +4,13 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
type ( type (
Node2 = student.NodeL Node2 = student.NodeL
List2 = correct.List List2 = solutions.List
NodeS2 = correct.NodeL NodeS2 = solutions.NodeL
ListS2 = student.List ListS2 = student.List
) )
@ -41,10 +41,10 @@ func listPushBackTest2(l *ListS2, l1 *List2, data interface{}) {
func main() { func main() {
link := &List2{} link := &List2{}
link2 := &ListS2{} link2 := &ListS2{}
table := []correct.NodeTest{} table := []solutions.NodeTest{}
table = correct.ElementsToTest(table) table = solutions.ElementsToTest(table)
table = append(table, table = append(table,
correct.NodeTest{ solutions.NodeTest{
Data: []interface{}{"Hello", "man", "how are you"}, Data: []interface{}{"Hello", "man", "how are you"},
}, },
) )
@ -52,10 +52,10 @@ func main() {
for i := 0; i < len(arg.Data); i++ { for i := 0; i < len(arg.Data); i++ {
listPushBackTest2(link2, link, arg.Data[i]) listPushBackTest2(link2, link, arg.Data[i])
} }
aux := correct.ListSize(link) aux := solutions.ListSize(link)
aux2 := student.ListSize(link2) aux2 := student.ListSize(link2)
if aux != aux2 { if aux != aux2 {
lib.Fatalf("ListSize(%v) == %d instead of %d\n", correct.ListToString(link.Head), aux2, aux) lib.Fatalf("ListSize(%v) == %d instead of %d\n", solutions.ListToString(link.Head), aux2, aux)
} }
link = &List2{} link = &List2{}
link2 = &ListS2{} link2 = &ListS2{}

10
test-go/tests/listsort_test/main.go

@ -6,12 +6,12 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
type ( type (
NodeI12 = student.NodeI NodeI12 = student.NodeI
NodeIS12 = correct.NodeI NodeIS12 = solutions.NodeI
) )
func printListStudent(n *NodeI12) string { func printListStudent(n *NodeI12) string {
@ -54,11 +54,11 @@ func comparFuncNodeInt12(l1 *NodeI12, l2 *NodeIS12) {
for l1 != nil || l2 != nil { for l1 != nil || l2 != nil {
if (l1 == nil && l2 != nil) || (l1 != nil && l2 == nil) { if (l1 == nil && l2 != nil) || (l1 != nil && l2 == nil) {
lib.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) printListStudent(l1), solutions.PrintList(l2), l1, l2)
} }
if l1.Data != l2.Data { if l1.Data != l2.Data {
lib.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) printListStudent(l1), solutions.PrintList(l2), l1.Data, l2.Data)
} }
l1 = l1.Next l1 = l1.Next
l2 = l2.Next l2 = l2.Next
@ -85,7 +85,7 @@ func main() {
for i := 0; i < len(arg.data); i++ { for i := 0; i < len(arg.data); i++ {
nodePushBackListInt12(link1, link2, arg.data[i]) nodePushBackListInt12(link1, link2, arg.data[i])
} }
aux1 := correct.ListSort(link2) aux1 := solutions.ListSort(link2)
aux2 := student.ListSort(link1) aux2 := student.ListSort(link1)
comparFuncNodeInt12(aux2, aux1) comparFuncNodeInt12(aux2, aux1)

14
test-go/tests/sortedlistmerge_test/main.go

@ -6,12 +6,12 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
type ( type (
NodeI13 = student.NodeI NodeI13 = student.NodeI
NodeIS13 = correct.NodeI NodeIS13 = solutions.NodeI
) )
func printListStudent1(n *NodeI13) string { func printListStudent1(n *NodeI13) string {
@ -88,19 +88,19 @@ func main() {
link1 = student.ListSort(link1) link1 = student.ListSort(link1)
link2 = student.ListSort(link2) link2 = student.ListSort(link2)
linkTest1 = correct.ListSort(linkTest1) linkTest1 = solutions.ListSort(linkTest1)
linkTest2 = correct.ListSort(linkTest2) linkTest2 = solutions.ListSort(linkTest2)
aux1 := student.SortedListMerge(link1, link2) aux1 := student.SortedListMerge(link1, link2)
aux2 := correct.SortedListMerge(linkTest1, linkTest2) aux2 := solutions.SortedListMerge(linkTest1, linkTest2)
if aux1 == nil && aux2 == nil { if aux1 == nil && aux2 == nil {
} else if aux1 != nil && aux2 == nil { } else if aux1 != nil && aux2 == nil {
lib.Fatalf("\nstudent merged lists:%s\nmerged lists:%s\n\nSortListMerge() == %v instead of %v\n\n", lib.Fatalf("\nstudent merged lists:%s\nmerged lists:%s\n\nSortListMerge() == %v instead of %v\n\n",
printListStudent1(aux1), correct.PrintList(aux2), aux1, aux2) printListStudent1(aux1), solutions.PrintList(aux2), aux1, aux2)
} else if aux1.Data != aux2.Data { } else if aux1.Data != aux2.Data {
lib.Fatalf("\nstudent merged lists:%s\nmerged lists:%s\n\nSortListMerge() == %v instead of %v\n\n", lib.Fatalf("\nstudent merged lists:%s\nmerged lists:%s\n\nSortListMerge() == %v instead of %v\n\n",
printListStudent1(aux1), correct.PrintList(aux2), aux1, aux2) printListStudent1(aux1), solutions.PrintList(aux2), aux1, aux2)
} }
link1 = &NodeI13{} link1 = &NodeI13{}

12
test-go/tests/sortlistinsert_test/main.go

@ -6,12 +6,12 @@ import (
student "student" student "student"
"github.com/01-edu/public/test-go/lib" "github.com/01-edu/public/test-go/lib"
"github.com/01-edu/public/test-go/tests/correct" "github.com/01-edu/public/test-go/solutions"
) )
type ( type (
NodeI14 = student.NodeI NodeI14 = student.NodeI
NodeIS14 = correct.NodeI NodeIS14 = solutions.NodeI
) )
func listToStringStu3(n *NodeI14) string { func listToStringStu3(n *NodeI14) string {
@ -57,11 +57,11 @@ func comparFuncNodeInt14(l1 *NodeI14, l2 *NodeIS14, data []int) {
for l1 != nil || l2 != nil { for l1 != nil || l2 != nil {
if (l1 == nil && l2 != nil) || (l1 != nil && l2 == nil) { if (l1 == nil && l2 != nil) || (l1 != nil && l2 == nil) {
lib.Fatalf("\ndata used to insert: %d\nstudent list:%s\nlist:%s\n\nSortListInsert() == %v instead of %v\n\n", lib.Fatalf("\ndata used to insert: %d\nstudent list:%s\nlist:%s\n\nSortListInsert() == %v instead of %v\n\n",
data, listToStringStu3(l1), correct.PrintList(l2), l1, l2) data, listToStringStu3(l1), solutions.PrintList(l2), l1, l2)
} }
if l1.Data != l2.Data { if l1.Data != l2.Data {
lib.Fatalf("\ndata used to insert: %d\nstudent list:%s\nlist:%s\n\nSortListInsert() == %v instead of %v\n\n", lib.Fatalf("\ndata used to insert: %d\nstudent list:%s\nlist:%s\n\nSortListInsert() == %v instead of %v\n\n",
data, listToStringStu3(l1), correct.PrintList(l2), l1.Data, l2.Data) data, listToStringStu3(l1), solutions.PrintList(l2), l1.Data, l2.Data)
} }
l1 = l1.Next l1 = l1.Next
l2 = l2.Next l2 = l2.Next
@ -126,11 +126,11 @@ func main() {
link1 = nodepushback1(link1, item) link1 = nodepushback1(link1, item)
} }
link2 = correct.ListSort(link2) link2 = solutions.ListSort(link2)
link1 = sortStudentsList(link1) link1 = sortStudentsList(link1)
for _, item := range arg.data_ref { for _, item := range arg.data_ref {
link2 = correct.SortListInsert(link2, item) link2 = solutions.SortListInsert(link2, item)
link1 = student.SortListInsert(link1, item) link1 = student.SortListInsert(link1, item)
} }

Loading…
Cancel
Save