File: util_test.go

package info (click to toggle)
golang-github-shenwei356-util 0.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 228 kB
  • sloc: makefile: 2
file content (19 lines) | stat: -rw-r--r-- 478 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package byteutil

import "testing"

func TestSubSlice(t *testing.T) {
	s := []byte("0123456789")
	if true &&
		string(SubSlice(s, 0, 0)) == "0123456789" &&
		string(SubSlice(s, 0, 1)) == "0" &&
		string(SubSlice(s, 1, 2)) == "1" &&
		string(SubSlice(s, -2, -1)) == "8" &&
		string(SubSlice(s, len(s)-1, len(s))) == "9" &&
		string(SubSlice(s, -1, 0)) == "9" && // different from python
		string(SubSlice(s, 7, -1)) == "78" &&
		true {
	} else {
		t.Error("SubSlice error")
	}
}