-
Notifications
You must be signed in to change notification settings - Fork 0
/
double_link_test.go
73 lines (57 loc) · 1.12 KB
/
double_link_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package algorithm
import (
"fmt"
"testing"
)
func TestDoubleLink_Add(t *testing.T) {
doubleLink := NewDoubleLink(1)
doubleLink.Add(2)
fmt.Println(doubleLink)
}
func TestDoubleLink_Scan(t *testing.T) {
doubleLink := NewDoubleLink(1)
doubleLink.Add(2)
doubleLink.Scan()
}
func TestDoubleLink_Reverse(t *testing.T) {
doubleLink := NewDoubleLink(1)
doubleLink.Add(2)
doubleLink.Reverse()
doubleLink.Scan()
}
func TestDoubleLink_Length(t *testing.T) {
doubleLink := NewDoubleLink(2)
doubleLink.Add(1)
fmt.Println(doubleLink.Length())
}
func TestDoubleLink_Append(t *testing.T) {
doubleLink := NewDoubleLink(1)
doubleLink.Append(2)
doubleLink.Scan()
}
func TestDoubleLink_Insert(t *testing.T) {
doubleLink := NewDoubleLink(1)
doubleLink.Append(3)
doubleLink.Insert(2, 2)
doubleLink.Scan()
}
func TestDoubleLink_Del(t *testing.T) {
doubleLink := NewDoubleLink(1)
doubleLink.Append(2)
doubleLink.Append(3)
doubleLink.Del(1)
doubleLink.Scan()
}
func TestHasCycle(t *testing.T) {
node1 := &ListNode{
1,
nil,
}
node2 := &ListNode{
2,
node1,
}
node1.Next = node2
head := node1
t.Log(hasCycle(head))
}