PageRenderTime 40ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/src/pkg/testing/wrapper.go

http://github.com/tav/go
Go | 105 lines | 55 code | 20 blank | 30 comment | 0 complexity | 9acf435869606ef87a26938ef611a215 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. // Copyright 2009 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. // This file contains wrappers so t.Errorf etc. have documentation.
  5. // TODO: delete when godoc shows exported methods for unexported embedded fields.
  6. // TODO: need to change the argument to runtime.Caller in testing.go from 4 to 3 at that point.
  7. package testing
  8. // Fail marks the function as having failed but continues execution.
  9. func (b *B) Fail() {
  10. b.common.Fail()
  11. }
  12. // Failed returns whether the function has failed.
  13. func (b *B) Failed() bool {
  14. return b.common.Failed()
  15. }
  16. // FailNow marks the function as having failed and stops its execution.
  17. // Execution will continue at the next Test.
  18. func (b *B) FailNow() {
  19. b.common.FailNow()
  20. }
  21. // Log formats its arguments using default formatting, analogous to Println(),
  22. // and records the text in the error log.
  23. func (b *B) Log(args ...interface{}) {
  24. b.common.Log(args...)
  25. }
  26. // Logf formats its arguments according to the format, analogous to Printf(),
  27. // and records the text in the error log.
  28. func (b *B) Logf(format string, args ...interface{}) {
  29. b.common.Logf(format, args...)
  30. }
  31. // Error is equivalent to Log() followed by Fail().
  32. func (b *B) Error(args ...interface{}) {
  33. b.common.Error(args...)
  34. }
  35. // Errorf is equivalent to Logf() followed by Fail().
  36. func (b *B) Errorf(format string, args ...interface{}) {
  37. b.common.Errorf(format, args...)
  38. }
  39. // Fatal is equivalent to Log() followed by FailNow().
  40. func (b *B) Fatal(args ...interface{}) {
  41. b.common.Fatal(args...)
  42. }
  43. // Fatalf is equivalent to Logf() followed by FailNow().
  44. func (b *B) Fatalf(format string, args ...interface{}) {
  45. b.common.Fatalf(format, args...)
  46. }
  47. // Fail marks the function as having failed but continues execution.
  48. func (t *T) Fail() {
  49. t.common.Fail()
  50. }
  51. // Failed returns whether the function has failed.
  52. func (t *T) Failed() bool {
  53. return t.common.Failed()
  54. }
  55. // FailNow marks the function as having failed and stops its execution.
  56. // Execution will continue at the next Test.
  57. func (t *T) FailNow() {
  58. t.common.FailNow()
  59. }
  60. // Log formats its arguments using default formatting, analogous to Println(),
  61. // and records the text in the error log.
  62. func (t *T) Log(args ...interface{}) {
  63. t.common.Log(args...)
  64. }
  65. // Logf formats its arguments according to the format, analogous to Printf(),
  66. // and records the text in the error log.
  67. func (t *T) Logf(format string, args ...interface{}) {
  68. t.common.Logf(format, args...)
  69. }
  70. // Error is equivalent to Log() followed by Fail().
  71. func (t *T) Error(args ...interface{}) {
  72. t.common.Error(args...)
  73. }
  74. // Errorf is equivalent to Logf() followed by Fail().
  75. func (t *T) Errorf(format string, args ...interface{}) {
  76. t.common.Errorf(format, args...)
  77. }
  78. // Fatal is equivalent to Log() followed by FailNow().
  79. func (t *T) Fatal(args ...interface{}) {
  80. t.common.Fatal(args...)
  81. }
  82. // Fatalf is equivalent to Logf() followed by FailNow().
  83. func (t *T) Fatalf(format string, args ...interface{}) {
  84. t.common.Fatalf(format, args...)
  85. }