| 1 |
// Copyright 2023-2025 The NATS Authors |
| 2 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 |
// you may not use this file except in compliance with the License. |
| 4 |
// You may obtain a copy of the License at |
| 5 |
// |
| 6 |
// http://www.apache.org/licenses/LICENSE-2.0 |
| 7 |
// |
| 8 |
// Unless required by applicable law or agreed to in writing, software |
| 9 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 10 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 |
// See the License for the specific language governing permissions and |
| 12 |
// limitations under the License. |
| 13 |
|
| 14 |
package stree |
| 15 |
|
| 16 |
import ( |
| 17 |
"testing" |
| 18 |
|
| 19 |
"github.com/nats-io/nats-server/v2/internal/antithesis" |
| 20 |
) |
| 21 |
|
| 22 |
func require_True(t testing.TB, b bool) { |
| 23 |
t.Helper() |
| 24 |
if !b { |
| 25 |
antithesis.AssertUnreachable(t, "Failed require_True check", nil) |
| 26 |
t.Fatalf("require true, but got false") |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
func require_False(t testing.TB, b bool) { |
| 31 |
t.Helper() |
| 32 |
if b { |
| 33 |
antithesis.AssertUnreachable(t, "Failed require_False check", nil) |
| 34 |
t.Fatalf("require false, but got true") |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
func require_NoError(t testing.TB, err error) { |
| 39 |
t.Helper() |
| 40 |
if err != nil { |
| 41 |
antithesis.AssertUnreachable(t, "Failed require_NoError check", map[string]any{ |
| 42 |
"error": err.Error(), |
| 43 |
}) |
| 44 |
t.Fatalf("require no error, but got: %v", err) |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
func require_Equal[T comparable](t testing.TB, a, b T) { |
| 49 |
t.Helper() |
| 50 |
if a != b { |
| 51 |
antithesis.AssertUnreachable(t, "Failed require_Equal check", nil) |
| 52 |
t.Fatalf("require %T equal, but got: %v != %v", a, a, b) |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
func require_Len(t testing.TB, a, b int) { |
| 57 |
t.Helper() |
| 58 |
if a != b { |
| 59 |
antithesis.AssertUnreachable(t, "Failed require_Len check", nil) |
| 60 |
t.Fatalf("require len, but got: %v != %v", a, b) |
| 61 |
} |
| 62 |
} |