Exemple #1
0
import (
	"github.com/Vungle/vungo/vast"
	"github.com/Vungle/vungo/vast/vasttest"
	"testing"
	"time"
)

type durationTest struct {
	duration vast.Duration
	value    string
}

var durationTests = []durationTest{
	durationTest{
		vast.Duration(time.Hour),
		"01:00:00",
	},
	durationTest{
		vast.Duration(time.Minute * 33),
		"00:33:00",
	},
	durationTest{
		vast.Duration(time.Second * 45),
		"00:00:45",
	},
	durationTest{
		vast.Duration(time.Hour + time.Second*50),
		"01:00:50",
	},
	durationTest{
Exemple #2
0
func TestDurationValidateErrors(t *testing.T) {
	vasttest.VerifyVastElementErrorAsExpected(t, vast.Duration(-time.Hour), vast.Duration(-time.Hour).Validate(), vast.ErrDurationNegative)
	vasttest.VerifyVastElementErrorAsExpected(t, vast.Duration(0), vast.Duration(0).Validate(), vast.ErrDurationEqualZero)
	vasttest.VerifyVastElementErrorAsExpected(t, vast.Duration(time.Hour), vast.Duration(time.Hour).Validate(), nil)
}
Exemple #3
0
	"testing"
	"time"
)

type offsetTest struct {
	offset vast.Offset
	value  string
}

var offsetTests = []offsetTest{
	offsetTest{
		vast.Offset{},
		"00:00:00",
	},
	offsetTest{
		vast.Offset{Duration: vast.Duration(time.Hour)},
		"01:00:00",
	},
	offsetTest{
		vast.Offset{Duration: vast.Duration(time.Hour + (30 * time.Minute))},
		"01:30:00",
	},
	offsetTest{
		vast.Offset{Duration: vast.Duration(time.Second + (128 * time.Millisecond))},
		"00:00:01.128",
	},
	offsetTest{
		vast.Offset{Percent: 1},
		"1%",
	},
	offsetTest{