github.com/grailbio/bigslice@v0.0.0-20230519005545-30c4c12152ad/name_test.go (about)

     1  // Copyright 2019 GRAIL, Inc. All rights reserved.
     2  // Use of this source code is governed by the Apache 2.0
     3  // license that can be found in the LICENSE file.
     4  
     5  package bigslice
     6  
     7  import (
     8  	"runtime"
     9  	"testing"
    10  )
    11  
    12  func sliceOperation(helper bool) Name {
    13  	return MakeName("test") // line 16
    14  }
    15  
    16  func callSliceOp(helper bool) Name {
    17  	if helper {
    18  		Helper()
    19  	}
    20  	return sliceOperation(helper) // line 20
    21  }
    22  
    23  // Note: this test is quite brittle as it relies on actual line numbers.
    24  func TestMakeName(t *testing.T) {
    25  	_, file, _, _ := runtime.Caller(0)
    26  
    27  	if got, want := callSliceOp(false), (Name{"test", file, 20, 0}); got != want {
    28  		t.Errorf("got %v, want %v", got, want)
    29  	}
    30  	if got, want := callSliceOp(true), (Name{"test", file, 30, 0}); got != want { // line 30
    31  		t.Errorf("got %v, want %v", got, want)
    32  	}
    33  }