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.
80 lines
1.7 KiB
80 lines
1.7 KiB
5 years ago
|
package main
|
||
5 years ago
|
|
||
|
import (
|
||
5 years ago
|
"github.com/01-edu/z01"
|
||
5 years ago
|
|
||
|
solution "./solutions"
|
||
|
student "./student"
|
||
|
)
|
||
|
|
||
|
type Node9 = student.NodeL
|
||
|
type List9 = solution.List
|
||
|
type NodeS9 = solution.NodeL
|
||
|
type ListS9 = student.List
|
||
|
|
||
5 years ago
|
func listPushBackTest9(l1 *ListS9, l2 *List9, data interface{}) {
|
||
5 years ago
|
n := &Node9{Data: data}
|
||
|
n1 := &NodeS9{Data: data}
|
||
5 years ago
|
if l1.Head == nil {
|
||
|
l1.Head = n
|
||
5 years ago
|
} else {
|
||
5 years ago
|
iterator := l1.Head
|
||
5 years ago
|
for iterator.Next != nil {
|
||
|
iterator = iterator.Next
|
||
|
}
|
||
|
iterator.Next = n
|
||
|
}
|
||
5 years ago
|
if l2.Head == nil {
|
||
|
l2.Head = n1
|
||
5 years ago
|
} else {
|
||
5 years ago
|
iterator1 := l2.Head
|
||
5 years ago
|
for iterator1.Next != nil {
|
||
|
iterator1 = iterator1.Next
|
||
|
}
|
||
|
iterator1.Next = n1
|
||
|
}
|
||
|
}
|
||
|
|
||
5 years ago
|
func main() {
|
||
|
link1 := &List9{}
|
||
5 years ago
|
link2 := &ListS9{}
|
||
|
|
||
|
table := []solution.NodeTest{}
|
||
|
table = solution.ElementsToTest(table)
|
||
|
table = append(table,
|
||
|
solution.NodeTest{
|
||
|
Data: []interface{}{"hello", "hello1", "hello2", "hello3"},
|
||
|
},
|
||
|
)
|
||
|
|
||
|
for _, arg := range table {
|
||
|
for i := 0; i < len(arg.Data); i++ {
|
||
5 years ago
|
listPushBackTest9(link2, link1, arg.Data[i])
|
||
5 years ago
|
}
|
||
|
if len(arg.Data) != 0 {
|
||
5 years ago
|
aux1 := student.ListFind(link2, arg.Data[(len(arg.Data)-1)/2], student.CompStr)
|
||
|
aux2 := solution.ListFind(link1, arg.Data[(len(arg.Data)-1)/2], solution.CompStr)
|
||
5 years ago
|
|
||
5 years ago
|
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)
|
||
5 years ago
|
}
|
||
|
}
|
||
|
}
|
||
5 years ago
|
link1 = &List9{}
|
||
5 years ago
|
link2 = &ListS9{}
|
||
|
}
|
||
|
|
||
|
for i := 0; i < len(table[0].Data); i++ {
|
||
5 years ago
|
listPushBackTest9(link2, link1, table[0].Data[i])
|
||
5 years ago
|
}
|
||
|
|
||
5 years ago
|
aux1 := student.ListFind(link2, "lksdf", student.CompStr)
|
||
|
aux2 := solution.ListFind(link1, "lksdf", solution.CompStr)
|
||
|
if aux1 != nil && aux2 != nil {
|
||
|
if *aux1 != *aux2 {
|
||
|
z01.Fatalf("ListFind(ref: lksdf) == %s instead of %s\n", *aux1, *aux2)
|
||
5 years ago
|
}
|
||
|
}
|
||
|
}
|