11/*
2- * Copyright 2012-2021 the original author or authors.
2+ * Copyright 2012-2022 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2828 * Tests for {@link DurationStyle}.
2929 *
3030 * @author Phillip Webb
31+ * @author Valentine Wu
3132 */
3233class DurationStyleTests {
3334
@@ -39,6 +40,7 @@ void detectAndParseWhenValueIsNullShouldThrowException() {
3940
4041 @ Test
4142 void detectAndParseWhenIso8601ShouldReturnDuration () {
43+ assertThat (DurationStyle .detectAndParse ("pt20.345s" )).isEqualTo (Duration .parse ("pt20.345s" ));
4244 assertThat (DurationStyle .detectAndParse ("PT20.345S" )).isEqualTo (Duration .parse ("PT20.345S" ));
4345 assertThat (DurationStyle .detectAndParse ("PT15M" )).isEqualTo (Duration .parse ("PT15M" ));
4446 assertThat (DurationStyle .detectAndParse ("+PT15M" )).isEqualTo (Duration .parse ("PT15M" ));
@@ -143,6 +145,7 @@ void detectWhenSimpleShouldReturnSimple() {
143145
144146 @ Test
145147 void detectWhenIso8601ShouldReturnIso8601 () {
148+ assertThat (DurationStyle .detect ("pt20.345s" )).isEqualTo (DurationStyle .ISO8601 );
146149 assertThat (DurationStyle .detect ("PT20.345S" )).isEqualTo (DurationStyle .ISO8601 );
147150 assertThat (DurationStyle .detect ("PT15M" )).isEqualTo (DurationStyle .ISO8601 );
148151 assertThat (DurationStyle .detect ("+PT15M" )).isEqualTo (DurationStyle .ISO8601 );
@@ -161,6 +164,7 @@ void detectWhenUnknownShouldThrowException() {
161164
162165 @ Test
163166 void parseIso8601ShouldParse () {
167+ assertThat (DurationStyle .ISO8601 .parse ("pt20.345s" )).isEqualTo (Duration .parse ("pt20.345s" ));
164168 assertThat (DurationStyle .ISO8601 .parse ("PT20.345S" )).isEqualTo (Duration .parse ("PT20.345S" ));
165169 assertThat (DurationStyle .ISO8601 .parse ("PT15M" )).isEqualTo (Duration .parse ("PT15M" ));
166170 assertThat (DurationStyle .ISO8601 .parse ("+PT15M" )).isEqualTo (Duration .parse ("PT15M" ));
@@ -173,6 +177,7 @@ void parseIso8601ShouldParse() {
173177
174178 @ Test
175179 void parseIso8601WithUnitShouldIgnoreUnit () {
180+ assertThat (DurationStyle .ISO8601 .parse ("pt20.345s" , ChronoUnit .SECONDS )).isEqualTo (Duration .parse ("pt20.345s" ));
176181 assertThat (DurationStyle .ISO8601 .parse ("PT20.345S" , ChronoUnit .SECONDS )).isEqualTo (Duration .parse ("PT20.345S" ));
177182 assertThat (DurationStyle .ISO8601 .parse ("PT15M" , ChronoUnit .SECONDS )).isEqualTo (Duration .parse ("PT15M" ));
178183 assertThat (DurationStyle .ISO8601 .parse ("+PT15M" , ChronoUnit .SECONDS )).isEqualTo (Duration .parse ("PT15M" ));
0 commit comments