@@ -117,135 +117,41 @@ class WiFiWidthTest {
117117 // setup
118118 val expected = 35
119119 // execute & validate
120- assertThat(calculateCenter80(Int . MIN_VALUE , expected, Int . MIN_VALUE )).isEqualTo(expected)
120+ assertThat(calculateCenter80(0 , expected, 0 )).isEqualTo(expected)
121121 assertThat(calculateCenter80(0 , expected, Int .MIN_VALUE )).isEqualTo(expected)
122- assertThat(calculateCenter80(Int .MAX_VALUE , expected, Int .MIN_VALUE )).isEqualTo(expected)
122+ assertThat(calculateCenter80(0 , expected, Int .MAX_VALUE )).isEqualTo(expected)
123+ assertThat(calculateCenter80(Int .MIN_VALUE , expected, 0 )).isEqualTo(expected)
124+ assertThat(calculateCenter80(Int .MAX_VALUE , expected, 0 )).isEqualTo(expected)
125+ assertThat(calculateCenter80(Int .MIN_VALUE , expected, Int .MIN_VALUE )).isEqualTo(expected)
126+ assertThat(calculateCenter80(Int .MAX_VALUE , expected, Int .MAX_VALUE )).isEqualTo(expected)
123127 }
124128
125129 @Test
126130 fun calculateCenter160 () {
127131 // setup
128- val frequencyRange = listOf (
129- 50 to (5250 to (5170 to 5329 )),
130- 82 to (5410 to (5330 to 5489 )),
131- 114 to (5650 to (5490 to 5730 )),
132- 163 to (5815 to (5735 to 5895 )),
133- 15 to (6025 to (5945 to 6104 )),
134- 47 to (6185 to (6105 to 6264 )),
135- 79 to (6345 to (6265 to 6424 )),
136- 111 to (6505 to (6425 to 6584 )),
137- 143 to (6665 to (6585 to 6744 )),
138- 175 to (6825 to (6745 to 6904 )),
139- 207 to (6985 to (6905 to 7065 ))
140- )
141- val frequencyCenter = frequencyRange.map { it.first to it.second.first }
142- val frequencyOutOfRange = listOf (5169 , 5731 , 5732 , 5733 , 5734 , 5896 , 5944 , 7066 )
132+ val expected = 35
143133 // execute & validate
144- calculateCenterUsingCenter1(frequencyCenter, calculateCenter160)
145- calculateCenterUsingCenter0(frequencyCenter, calculateCenter160)
146- calculateCenterUsingPrimary(frequencyCenter, calculateCenter160)
147- calculateCenterUsingRange(frequencyRange, calculateCenter160, frequencyCenter.map { it.second })
148- calculateCenterUsingOutOfRange(frequencyOutOfRange, calculateCenter160)
134+ assertThat(calculateCenter160(0 , 0 , expected)).isEqualTo(expected)
135+ assertThat(calculateCenter160(0 , Int .MIN_VALUE , expected)).isEqualTo(expected)
136+ assertThat(calculateCenter160(0 , Int .MAX_VALUE , expected)).isEqualTo(expected)
137+ assertThat(calculateCenter160(Int .MIN_VALUE , 0 , expected)).isEqualTo(expected)
138+ assertThat(calculateCenter160(Int .MAX_VALUE , 0 , expected)).isEqualTo(expected)
139+ assertThat(calculateCenter160(Int .MIN_VALUE , Int .MIN_VALUE , expected)).isEqualTo(expected)
140+ assertThat(calculateCenter160(Int .MAX_VALUE , Int .MAX_VALUE , expected)).isEqualTo(expected)
149141 }
150142
151143 @Test
152144 fun calculateCenter320 () {
153145 // setup
154- val frequencyRange = listOf (
155- 31 to (6100 to (5945 to 6264 )),
156- 95 to (6430 to (6265 to 6584 )),
157- 159 to (6750 to (6585 to 6904 )),
158- 191 to (6910 to (6905 to 7065 ))
159- )
160- val frequencyCenter = listOf (31 to 6100 , 63 to 6270 , 95 to 6430 , 127 to 6590 , 159 to 6750 , 191 to 6910 )
161- val frequencyOutOfRange = listOf (5944 , 7066 )
146+ val expected = 35
162147 // execute & validate
163- calculateCenterUsingCenter1(frequencyCenter, calculateCenter320)
164- calculateCenterUsingCenter0(frequencyCenter, calculateCenter320)
165- calculateCenterUsingPrimary(frequencyCenter, calculateCenter320)
166- calculateCenterUsingRange(frequencyRange, calculateCenter320, frequencyCenter.map { it.second })
167- calculateCenterUsingOutOfRange(frequencyOutOfRange, calculateCenter320)
148+ assertThat(calculateCenter320(0 , 0 , expected)).isEqualTo(expected)
149+ assertThat(calculateCenter320(0 , Int .MIN_VALUE , expected)).isEqualTo(expected)
150+ assertThat(calculateCenter320(0 , Int .MAX_VALUE , expected)).isEqualTo(expected)
151+ assertThat(calculateCenter320(Int .MIN_VALUE , 0 , expected)).isEqualTo(expected)
152+ assertThat(calculateCenter320(Int .MAX_VALUE , 0 , expected)).isEqualTo(expected)
153+ assertThat(calculateCenter320(Int .MIN_VALUE , Int .MIN_VALUE , expected)).isEqualTo(expected)
154+ assertThat(calculateCenter320(Int .MAX_VALUE , Int .MAX_VALUE , expected)).isEqualTo(expected)
168155 }
169156
170- /* *
171- * parameters:
172- * frequencyCenter: list of channel and frequency center
173- * calculateCenter: function to calculate center
174- */
175- private fun calculateCenterUsingCenter1 (frequencyCenter : List <Pair <Int , Int >>, calculateCenter : CalculateCenter ) {
176- frequencyCenter.forEach { (channel, expected) ->
177- // execute
178- val actualCenter1 = calculateCenter(0 , 0 , expected)
179- // validate
180- assertThat(actualCenter1).describedAs(" channel: $channel | frequency: $expected " ).isEqualTo(expected)
181- }
182- }
183-
184- /* *
185- * parameters:
186- * frequencyCenter: list of channel and frequency center
187- * calculateCenter: function to calculate center
188- */
189- private fun calculateCenterUsingCenter0 (frequencyCenter : List <Pair <Int , Int >>, calculateCenter : CalculateCenter ) {
190- frequencyCenter.forEach { (channel, expected) ->
191- // execute
192- val actualCenter0 = calculateCenter(0 , expected, 0 )
193- // validate
194- assertThat(actualCenter0).describedAs(" channel: $channel | frequency: $expected " ).isEqualTo(expected)
195- }
196- }
197-
198- /* *
199- * parameters:
200- * frequencyCenter: list of channel and frequency center
201- * calculateCenter: function to calculate center
202- */
203- private fun calculateCenterUsingPrimary (frequencyCenter : List <Pair <Int , Int >>, calculateCenter : CalculateCenter ) {
204- frequencyCenter.forEach { (channel, expected) ->
205- // execute
206- val actualPrimary = calculateCenter(expected, 0 , 0 )
207- // validate
208- assertThat(actualPrimary).describedAs(" channel: $channel | frequency: $expected " ).isEqualTo(expected)
209- }
210- }
211-
212- /* *
213- * parameters:
214- * frequencyRange: list of channel, frequency center, frequency range
215- * calculateCenter: function to calculate center
216- * frequencyCenter: list of frequency center
217- */
218- private fun calculateCenterUsingRange (
219- frequencyRange : List <Pair <Int , Pair <Int , Pair <Int , Int >>>>,
220- calculateCenter : CalculateCenter ,
221- frequencyCenter : List <Int >
222- ) {
223- frequencyRange.forEach { (channel, frequencyAndRange) ->
224- val (expected, range) = frequencyAndRange
225- (range.first.. range.second)
226- .filter { it !in frequencyCenter }
227- .forEach {
228- // execute
229- val actualPrimary = calculateCenter(it, 0 , 0 )
230- // validate
231- assertThat(actualPrimary).describedAs(" channel: $channel | frequency: $it " ).isEqualTo(expected)
232- }
233- }
234- }
235-
236- /* *
237- * parameters:
238- * outOfRangeFrequencies: list of out of range frequencies
239- * calculateCenter: function to calculate center
240- */
241- private fun calculateCenterUsingOutOfRange (outOfRangeFrequencies : List <Int >, calculateCenter : CalculateCenter ) {
242- outOfRangeFrequencies.forEach { frequency ->
243- // setup
244- val expected = 111
245- // execute
246- val actualPrimary = calculateCenter(frequency, 0 , expected)
247- // validate
248- assertThat(actualPrimary).describedAs(" frequency: $frequency " ).isEqualTo(expected)
249- }
250- }
251157}
0 commit comments