File: converter_test.go

package info (click to toggle)
golang-github-nfnt-resize 0.0~git20180221.83c6a99-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 164 kB
  • sloc: makefile: 2
file content (43 lines) | stat: -rw-r--r-- 621 bytes parent folder | download | duplicates (3)
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
34
35
36
37
38
39
40
41
42
43
package resize

import (
	"testing"
)

func Test_ClampUint8(t *testing.T) {
	var testData = []struct {
		in       int32
		expected uint8
	}{
		{0, 0},
		{255, 255},
		{128, 128},
		{-2, 0},
		{256, 255},
	}
	for _, test := range testData {
		actual := clampUint8(test.in)
		if actual != test.expected {
			t.Fail()
		}
	}
}

func Test_ClampUint16(t *testing.T) {
	var testData = []struct {
		in       int64
		expected uint16
	}{
		{0, 0},
		{65535, 65535},
		{128, 128},
		{-2, 0},
		{65536, 65535},
	}
	for _, test := range testData {
		actual := clampUint16(test.in)
		if actual != test.expected {
			t.Fail()
		}
	}
}