func TestToDuration(t *testing.T) {
	t.Parallel()

	d := duration.Duration{Years: 1}
	assert.Equal(t, d.ToDuration(), time.Hour*24*365)

	d = duration.Duration{Weeks: 1}
	assert.Equal(t, d.ToDuration(), time.Hour*24*7)

	d = duration.Duration{Days: 1}
	assert.Equal(t, d.ToDuration(), time.Hour*24)

	d = duration.Duration{Hours: 1}
	assert.Equal(t, d.ToDuration(), time.Hour)

	d = duration.Duration{Minutes: 1}
	assert.Equal(t, d.ToDuration(), time.Minute)

	d = duration.Duration{Seconds: 1}
	assert.Equal(t, d.ToDuration(), time.Second)
}
func TestString(t *testing.T) {
	t.Parallel()

	// test empty
	d := duration.Duration{}
	assert.Equal(t, d.String(), "P")

	// test only larger-than-day
	d = duration.Duration{Years: 1, Days: 2}
	assert.Equal(t, d.String(), "P1Y2D")

	// test only smaller-than-day
	d = duration.Duration{Hours: 1, Minutes: 2, Seconds: 3}
	assert.Equal(t, d.String(), "PT1H2M3S")

	// test full format
	d = duration.Duration{Years: 1, Days: 2, Hours: 3, Minutes: 4, Seconds: 5}
	assert.Equal(t, d.String(), "P1Y2DT3H4M5S")

	// test week format
	d = duration.Duration{Weeks: 1}
	assert.Equal(t, d.String(), "P1W")
}