-
Notifications
You must be signed in to change notification settings - Fork 0
/
gobuf_test.go
68 lines (59 loc) · 1.7 KB
/
gobuf_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
package gobuf
import (
"fmt"
)
func ExampleNewBuf() {
buf := NewBuf()
fmt.Printf("Bufer Size: %v\n", size)
fmt.Printf("Bufer Index: %v\n", buf.index)
fmt.Printf("Bufer Next Index: %v\n", buf.nextIndex)
fmt.Printf("Bufer Get Index: %v\n", buf.getIndex)
// Output:
// Bufer Size: 8192
// Bufer Index: 0
// Bufer Next Index: 1
// Bufer Get Index: 1
}
func ExampleBuf_Add() {
buf := NewBuf()
buf.Add(35)
fmt.Printf("Bufer[0] is %v\n", 35)
fmt.Printf("Bufer Index: %v\n", buf.index)
fmt.Printf("Bufer Next Index: %v\n", buf.nextIndex)
fmt.Printf("Bufer Get Index: %v\n", buf.getIndex)
// Output:
// Bufer[0] is 35
// Bufer Index: 1
// Bufer Next Index: 2
// Bufer Get Index: 1
}
func ExampleBuf_Get() {
buf := NewBuf()
buf.Add(35)
buf.Add(100)
fmt.Printf("Bufer Index: %v\n", buf.index)
fmt.Printf("Bufer Next Index: %v\n", buf.nextIndex)
fmt.Printf("Bufer Get Index: %v\n", buf.getIndex)
fmt.Printf("\nBufer Get yielded: %v\n", buf.Get())
fmt.Printf("Bufer Index: %v\n", buf.index)
fmt.Printf("Bufer Next Index: %v\n", buf.nextIndex)
fmt.Printf("Bufer Get Index: %v\n", buf.getIndex)
fmt.Printf("\nBufer Get yielded: %v\n", buf.Get())
fmt.Printf("Bufer Index: %v\n", buf.index)
fmt.Printf("Bufer Next Index: %v\n", buf.nextIndex)
fmt.Printf("Bufer Get Index: %v\n", buf.getIndex)
// Output:
// Bufer Index: 2
// Bufer Next Index: 3
// Bufer Get Index: 1
//
// Bufer Get yielded: 35
// Bufer Index: 2
// Bufer Next Index: 3
// Bufer Get Index: 2
//
// Bufer Get yielded: 100
// Bufer Index: 2
// Bufer Next Index: 3
// Bufer Get Index: 3
}