TestParseIntValueTruncation tests float truncation scenarios
(t *testing.T)
| 74 | |
| 75 | // TestParseIntValueTruncation tests float truncation scenarios |
| 76 | func TestParseIntValueTruncation(t *testing.T) { |
| 77 | tests := []struct { |
| 78 | name string |
| 79 | value float64 |
| 80 | expected int |
| 81 | shouldTruncate bool |
| 82 | }{ |
| 83 | { |
| 84 | name: "clean conversion - no truncation", |
| 85 | value: 60.0, |
| 86 | expected: 60, |
| 87 | shouldTruncate: false, |
| 88 | }, |
| 89 | { |
| 90 | name: "truncation required - 60.5", |
| 91 | value: 60.5, |
| 92 | expected: 60, |
| 93 | shouldTruncate: true, |
| 94 | }, |
| 95 | { |
| 96 | name: "truncation required - 60.7", |
| 97 | value: 60.7, |
| 98 | expected: 60, |
| 99 | shouldTruncate: true, |
| 100 | }, |
| 101 | { |
| 102 | name: "clean conversion - 100.0", |
| 103 | value: 100.0, |
| 104 | expected: 100, |
| 105 | shouldTruncate: false, |
| 106 | }, |
| 107 | { |
| 108 | name: "truncation required - 123.99", |
| 109 | value: 123.99, |
| 110 | expected: 123, |
| 111 | shouldTruncate: true, |
| 112 | }, |
| 113 | { |
| 114 | name: "truncation required - negative with fraction", |
| 115 | value: -5.5, |
| 116 | expected: -5, |
| 117 | shouldTruncate: true, |
| 118 | }, |
| 119 | { |
| 120 | name: "clean conversion - negative integer", |
| 121 | value: -10.0, |
| 122 | expected: -10, |
| 123 | shouldTruncate: false, |
| 124 | }, |
| 125 | { |
| 126 | name: "truncation required - small fraction", |
| 127 | value: 1.1, |
| 128 | expected: 1, |
| 129 | shouldTruncate: true, |
| 130 | }, |
| 131 | } |
| 132 | |
| 133 | for _, tt := range tests { |
nothing calls this directly
no test coverage detected