File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,4 +23,28 @@ final class EditableColorValueTests: XCTestCase {
2323 // 0...720 is twice the reference span.
2424 XCTAssertEqual ( dragUnitsPerPixel ( for: 0 ... 720 ) , 2.0 )
2525 }
26+
27+ func test_stableDecimalPlaces_noDot_defaultsToTwo( ) {
28+ XCTAssertEqual ( ColorComponentField . stableDecimalPlaces ( for: " 5 " ) , 2 )
29+ }
30+
31+ func test_stableDecimalPlaces_trailingDotNoDigits_clampsUpToTwo( ) {
32+ XCTAssertEqual ( ColorComponentField . stableDecimalPlaces ( for: " 5. " ) , 2 )
33+ }
34+
35+ func test_stableDecimalPlaces_oneDecimal_clampsUpToTwo( ) {
36+ XCTAssertEqual ( ColorComponentField . stableDecimalPlaces ( for: " 5.1 " ) , 2 )
37+ }
38+
39+ func test_stableDecimalPlaces_twoDecimals_keepsTwo( ) {
40+ XCTAssertEqual ( ColorComponentField . stableDecimalPlaces ( for: " 5.12 " ) , 2 )
41+ }
42+
43+ func test_stableDecimalPlaces_fourDecimals_keepsFour( ) {
44+ XCTAssertEqual ( ColorComponentField . stableDecimalPlaces ( for: " 5.1234 " ) , 4 )
45+ }
46+
47+ func test_stableDecimalPlaces_moreThanFourDecimals_clampsDownToFour( ) {
48+ XCTAssertEqual ( ColorComponentField . stableDecimalPlaces ( for: " 5.123456 " ) , 4 )
49+ }
2650}
You can’t perform that action at this time.
0 commit comments