File: common.go

package info (click to toggle)
golang-github-etherlabsio-go-m3u8 1.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 348 kB
  • sloc: makefile: 3
file content (42 lines) | stat: -rw-r--r-- 975 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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package test

import (
	"strings"
	"testing"

	"github.com/etherlabsio/go-m3u8/m3u8"
	"github.com/stretchr/testify/assert"
)

func assertNotNilEqual(t *testing.T, expected interface{}, ptr interface{}) {
	assert.NotNil(t, ptr)
	switch ptr.(type) {
	case *string:
		s, ok := ptr.(*string)
		assert.True(t, ok)
		assert.Equal(t, expected, *s)
	case *float64:
		f, ok := ptr.(*float64)
		assert.True(t, ok)
		assert.Equal(t, expected, *f)
	case *int:
		i, ok := ptr.(*int)
		assert.True(t, ok)
		assert.Equal(t, expected, *i)
	case *bool:
		b, ok := ptr.(*bool)
		assert.True(t, ok)
		assert.Equal(t, expected, *b)
	default:
		t.Fatal("not supported assert type")
	}
}

func assertEqualWithoutNewLine(t *testing.T, expected string, actual string) {
	removedNewLine := strings.Replace(expected, "\n", "", -1)
	assert.Equal(t, removedNewLine, actual)
}

func assertToString(t *testing.T, expected string, item m3u8.Item) {
	assertEqualWithoutNewLine(t, expected, item.String())
}