File: buffers_test.go

package info (click to toggle)
go-mmproxy 2.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 248 kB
  • sloc: makefile: 12; sh: 7
file content (33 lines) | stat: -rw-r--r-- 571 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2024 Konrad Zemek <konrad.zemek@gmail.com>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package tests

import (
	"testing"

	"github.com/kzemek/go-mmproxy/buffers"
)

func TestGetGetsAPutBuffer(t *testing.T) {
	buf1 := buffers.Get()
	buf2 := buffers.Get()

	for i := range buf1 {
		buf1[i] = 127
	}

	buffers.Put(buf1)

	buf3 := buffers.Get()

	for i := range buf3 {
		if buf3[i] != 127 {
			t.Errorf("Expected to retrieve previously stored buffer")
		}
	}

	buffers.Put(buf3)
	buffers.Put(buf2)
}