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.7 KiB
79 lines
1.7 KiB
5 years ago
|
package main
|
||
5 years ago
|
|
||
|
import (
|
||
5 years ago
|
"../lib"
|
||
|
"./correct"
|
||
|
"./student"
|
||
5 years ago
|
)
|
||
|
|
||
|
type Node9 = student.NodeL
|
||
5 years ago
|
type List9 = correct.List
|
||
|
type NodeS9 = correct.NodeL
|
||
5 years ago
|
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{}
|
||
|
|
||
5 years ago
|
table := []correct.NodeTest{}
|
||
|
table = correct.ElementsToTest(table)
|
||
5 years ago
|
table = append(table,
|
||
5 years ago
|
correct.NodeTest{
|
||
5 years ago
|
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)
|
||
5 years ago
|
aux2 := correct.ListFind(link1, arg.Data[(len(arg.Data)-1)/2], correct.CompStr)
|
||
5 years ago
|
|
||
5 years ago
|
if aux1 != nil || aux2 != nil {
|
||
|
if *aux1 != *aux2 {
|
||
5 years ago
|
lib.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)
|
||
5 years ago
|
aux2 := correct.ListFind(link1, "lksdf", correct.CompStr)
|
||
5 years ago
|
if aux1 != nil && aux2 != nil {
|
||
|
if *aux1 != *aux2 {
|
||
5 years ago
|
lib.Fatalf("ListFind(ref: lksdf) == %s instead of %s\n", *aux1, *aux2)
|
||
5 years ago
|
}
|
||
|
}
|
||
|
}
|