1// Copyright 2014 Marc-Antoine Ruel. All rights reserved. 2// Use of this source code is governed under the Apache License, Version 2.0 3// that can be found in the LICENSE file. 4 5package ut 6 7import ( 8 "fmt" 9 "testing" 10) 11 12// WARNING: Any code change to this file will trigger a test failure of 13// TestDecorateMax or TestDecorate. Make sure to update the expectation 14// accordingly. Sorry for the inconvenience. 15 16// TODO(maruel): It's wrong to hard code the containing path name. 17const file = "ut/decorate_test.go" 18 19func a() string { 20 return b() 21} 22 23func b() string { 24 return c() 25} 26 27func c() string { 28 return d() 29} 30 31func d() string { 32 return Decorate("Foo") 33} 34 35func TestDecorateMax(t *testing.T) { 36 t.Parallel() 37 // This test is line number dependent. a() is not listed, only b(), c() and 38 // d(). 39 base := 24 40 expected := fmt.Sprintf("%s:%d: %s:%d: %s:%d: Foo", file, base, file, base+4, file, base+8) 41 AssertEqual(t, expected, a()) 42} 43 44func TestDecorate(t *testing.T) { 45 t.Parallel() 46 // This test is line number dependent. 47 a := Decorate("Foo") 48 expected := fmt.Sprintf("%s:47: Foo", file) 49 AssertEqual(t, expected, a) 50} 51