-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
source_location_test.go
41 lines (33 loc) · 1.24 KB
/
source_location_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
// Copyright 2022 The zapcl Authors
// SPDX-License-Identifier: BSD-3-Clause
package zapcl
import (
"strings"
"testing"
)
func TestSourceLocation(t *testing.T) {
t.Parallel()
got := SourceLocation(Caller(0)).Interface.(*sourceLocation)
if gotFile, wantFile := got.File, "zapcl/source_location_test.go"; !strings.Contains(gotFile, wantFile) {
t.Errorf("except contains got %s in %s", gotFile, wantFile)
}
if gotLine, wantLine := got.Line, int64(14); gotLine != wantLine {
t.Errorf("except equal got %d in %d", gotLine, wantLine)
}
if gotFunc, wantFunc := got.Function, "zapcl.TestSourceLocation"; !strings.Contains(gotFunc, wantFunc) {
t.Errorf("except contains got %s in %s", gotFunc, wantFunc)
}
}
func TestNewSource(t *testing.T) {
t.Parallel()
got := newSource(Caller(0))
if gotFile, wantFile := got.File, "zapcl/source_location_test.go"; !strings.Contains(gotFile, wantFile) {
t.Fatalf("except contains got %s in %s", gotFile, wantFile)
}
if gotLine, wantLine := got.Line, int64(30); gotLine != wantLine {
t.Errorf("except equal got %d in %d", gotLine, wantLine)
}
if gotFunc, wantFunc := got.Function, "zapcl.TestNewSource"; !strings.Contains(gotFunc, wantFunc) {
t.Errorf("except contains got %s in %s", gotFunc, wantFunc)
}
}