mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.4 KiB
79 lines
1.4 KiB
5 years ago
|
package main
|
||
5 years ago
|
|
||
|
import (
|
||
|
"strconv"
|
||
5 years ago
|
|
||
5 years ago
|
"../lib"
|
||
|
"./correct"
|
||
|
"./student"
|
||
5 years ago
|
)
|
||
|
|
||
|
type Node3 = student.NodeL
|
||
5 years ago
|
type List3 = correct.List
|
||
|
type NodeS3 = correct.NodeL
|
||
5 years ago
|
type ListS3 = student.List
|
||
|
|
||
|
func listToStringStu9(l *ListS3) string {
|
||
|
var res string
|
||
|
it := l.Head
|
||
|
for it != nil {
|
||
|
switch it.Data.(type) {
|
||
|
case int:
|
||
|
res += strconv.Itoa(it.Data.(int)) + "-> "
|
||
|
case string:
|
||
|
res += it.Data.(string) + "-> "
|
||
|
}
|
||
|
it = it.Next
|
||
|
}
|
||
|
res += "<nil>"
|
||
|
return res
|
||
|
}
|
||
|
|
||
5 years ago
|
// inserts node on two lists
|
||
5 years ago
|
func listPushBackTest3(l *ListS3, l1 *List3, data interface{}) {
|
||
|
n := &Node3{Data: data}
|
||
|
n1 := &NodeS3{Data: data}
|
||
|
if l.Head == nil {
|
||
|
l.Head = n
|
||
|
l.Tail = n
|
||
|
} else {
|
||
|
l.Tail.Next = n
|
||
|
l.Tail = n
|
||
|
}
|
||
|
if l1.Head == nil {
|
||
|
l1.Head = n1
|
||
|
l1.Tail = n1
|
||
|
} else {
|
||
|
l1.Tail.Next = n1
|
||
|
l1.Tail = n1
|
||
|
}
|
||
|
}
|
||
|
|
||
5 years ago
|
// last element of the correct.ListS
|
||
5 years ago
|
func main() {
|
||
|
link1 := &List3{}
|
||
5 years ago
|
link2 := &ListS3{}
|
||
5 years ago
|
table := []correct.NodeTest{}
|
||
5 years ago
|
|
||
5 years ago
|
table = correct.ElementsToTest(table)
|
||
5 years ago
|
table = append(table,
|
||
5 years ago
|
correct.NodeTest{
|
||
5 years ago
|
Data: []interface{}{3, 2, 1},
|
||
|
},
|
||
|
)
|
||
|
for _, arg := range table {
|
||
|
for i := 0; i < len(arg.Data); i++ {
|
||
5 years ago
|
listPushBackTest3(link2, link1, arg.Data[i])
|
||
5 years ago
|
}
|
||
5 years ago
|
aux1 := correct.ListLast(link1)
|
||
5 years ago
|
aux2 := student.ListLast(link2)
|
||
5 years ago
|
|
||
5 years ago
|
if aux1 != aux2 {
|
||
5 years ago
|
lib.Fatalf("\nlist:%s\n\nListLast() == %v instead of %v\n\n",
|
||
5 years ago
|
listToStringStu9(link2), aux2, aux1)
|
||
5 years ago
|
}
|
||
5 years ago
|
link1 = &List3{}
|
||
5 years ago
|
link2 = &ListS3{}
|
||
|
}
|
||
|
}
|