testos_test.go 567 B

123456789101112131415161718192021222324252627
  1. // Copyright (C) 2019 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package model
  7. // fatal is the required common interface between *testing.B and *testing.T
  8. type fatal interface {
  9. Fatal(...interface{})
  10. Helper()
  11. }
  12. func must(f fatal, err error) {
  13. f.Helper()
  14. if err != nil {
  15. f.Fatal(err)
  16. }
  17. }
  18. func mustV[T any](v T, err error) T {
  19. if err != nil {
  20. panic(err)
  21. }
  22. return v
  23. }