File: allocs.go

package info (click to toggle)
golang-github-pion-stun 0.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 868 kB
  • sloc: sh: 50; makefile: 40
file content (20 lines) | stat: -rw-r--r-- 462 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

// Package testutil contains helpers and utilities for writing tests
package testutil

import (
	"testing"
)

// ShouldNotAllocate fails if f allocates.
func ShouldNotAllocate(t *testing.T, f func()) {
	if Race {
		t.Skip("skip while running with -race")
		return
	}
	if a := testing.AllocsPerRun(10, f); a > 0 {
		t.Errorf("Allocations detected: %f", a)
	}
}