trace_test.go 683 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package trace
  5. import (
  6. "reflect"
  7. "testing"
  8. )
  9. type s struct{}
  10. func (s) String() string { return "lazy string" }
  11. // TestReset checks whether all the fields are zeroed after reset.
  12. func TestReset(t *testing.T) {
  13. tr := New("foo", "bar")
  14. tr.LazyLog(s{}, false)
  15. tr.LazyPrintf("%d", 1)
  16. tr.SetRecycler(func(_ interface{}) {})
  17. tr.SetTraceInfo(3, 4)
  18. tr.SetMaxEvents(100)
  19. tr.SetError()
  20. tr.Finish()
  21. tr.(*trace).reset()
  22. if !reflect.DeepEqual(tr, new(trace)) {
  23. t.Errorf("reset didn't clear all fields: %+v", tr)
  24. }
  25. }