File: log_test.go

package info (click to toggle)
golang-github-anacrolix-log 0.13.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 148 kB
  • sloc: makefile: 2
file content (44 lines) | stat: -rw-r--r-- 781 bytes parent folder | download
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
package log

import (
	"runtime"
	"strconv"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestLogBadString(t *testing.T) {
	Str("\xef\x00\xaa\x1ctest\x00test").AddValue("\x00").Log(Default)
}

type stringer struct {
	s string
}

func (me stringer) String() string {
	return strconv.Quote(me.s)
}

func TestValueStringNonLatin(t *testing.T) {
	const (
		u = "カワキヲアメク\n"
		q = `"カワキヲアメク\n"`
	)
	s := stringer{u}
	assert.Equal(t, q, s.String())
	m := Str("").AddValue(q)
	assert.True(t, m.HasValue(q))
}

func BenchmarkPcNames(b *testing.B) {
	b.ReportAllocs()
	var names []string
	for i := 0; i < b.N; i++ {
		var pc [1]uintptr
		runtime.Callers(1, pc[:])
		names = pcNames(pc[0], names[:0])
		//b.Log(names[0], names[1])
		//panic("hi")
	}
}