-
Notifications
You must be signed in to change notification settings - Fork 60
/
serialization_test.go
35 lines (30 loc) · 805 Bytes
/
serialization_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
package linkedlist
import (
"testing"
)
/*
TestSerializeAndUnserializeLinkedList tests solution(s) with the following signature and problem description:
func Serialize(node *Node) string
func Unserialize(stringRepresentation string) *Node
Write a function that turns a linked list into a string representation, and then a function that turns that
string representation to an actual linked list.
*/
func TestSerializeAndUnserializeLinkedList(t *testing.T) {
tests := []string{
"",
"1",
"1->2",
"1->2->3->4->2->1",
}
for i, test := range tests {
got := Serialize(Unserialize(test))
if got != test {
t.Fatalf("Failed test case #%d. Want %#v got %#v", i, test, got)
}
}
}
func TestATOI(t *testing.T) {
if got := atoi("A"); got != -1 {
t.Fatalf("want %d, got %d", -1, got)
}
}