4242static BackoffAlgorithmContext_t retryParams ;
4343/* Return value of #BackoffAlgorithm_GetNextBackoff. */
4444static BackoffAlgorithmStatus_t BackoffAlgorithmStatus ;
45- static uint16_t nextBackoff ;
45+ static uint32_t nextBackoff ;
4646static uint32_t testRandomVal ;
4747
4848/* ============================ UNITY FIXTURES ============================ */
@@ -83,8 +83,8 @@ int suiteTearDown( int numFailures )
8383 */
8484static void verifyContextData ( BackoffAlgorithmContext_t * pContext ,
8585 uint32_t expectedAttemptsDone ,
86- uint16_t expectedNextJitterMax ,
87- uint16_t expectedMaxBackoff ,
86+ uint32_t expectedNextJitterMax ,
87+ uint32_t expectedMaxBackoff ,
8888 uint32_t expectedMaxAttempts )
8989{
9090 TEST_ASSERT_EQUAL ( expectedNextJitterMax , pContext -> nextJitterMax );
@@ -133,9 +133,9 @@ void test_BackoffAlgorithm_InitializeParams_Sets_Jitter_Correctly( void )
133133void test_BackoffAlgorithm_GetNextBackoff_Success_RandVal_Less_Than_Jitter_Max ( void )
134134{
135135 int iter = 1 ;
136- uint16_t expectedAttemptsDone = 0 ;
137- uint16_t expectedNextJitterMax = TEST_BACKOFF_BASE_VALUE ;
138- uint16_t expectedNextBackoff = 0 ;
136+ uint32_t expectedAttemptsDone = 0 ;
137+ uint32_t expectedNextJitterMax = TEST_BACKOFF_BASE_VALUE ;
138+ uint32_t expectedNextBackoff = 0 ;
139139
140140 for ( ; iter < 2 ; iter ++ )
141141 {
@@ -145,7 +145,7 @@ void test_BackoffAlgorithm_GetNextBackoff_Success_RandVal_Less_Than_Jitter_Max(
145145
146146 /* As the random value is less than the max jitter value, the expected
147147 * next backoff value should remain the same as the random value. */
148- expectedNextBackoff = testRandomVal ;
148+ expectedNextBackoff = ( testRandomVal % retryParams . nextJitterMax ) + 1U ;
149149
150150 /* The jitter max value should double with the above call for use in next call. */
151151 expectedNextJitterMax *= 2 ;
@@ -180,8 +180,8 @@ void test_BackoffAlgorithm_GetNextBackoff_Success_RandVal_Less_Than_Jitter_Max(
180180void test_BackoffAlgorithm_GetNextBackoff_Success_RandVal_More_Than_Jitter_Max ( void )
181181{
182182 int iter = 1 ;
183- uint16_t expectedAttemptsDone = 0 ;
184- uint16_t expectedNextJitterMax = TEST_BACKOFF_BASE_VALUE ;
183+ uint32_t expectedAttemptsDone = 0 ;
184+ uint32_t expectedNextJitterMax = TEST_BACKOFF_BASE_VALUE ;
185185
186186 for ( ; iter < 2 ; iter ++ )
187187 {
@@ -199,7 +199,7 @@ void test_BackoffAlgorithm_GetNextBackoff_Success_RandVal_More_Than_Jitter_Max(
199199 /* As the random value is greater than the jitter max value, the expected
200200 * next backoff value should be truncated to a value within the jitter window
201201 * for the retry attempt. */
202- uint16_t expectedNextBackoff = ( testRandomVal % ( retryParams .nextJitterMax + 1U ) ) ;
202+ uint32_t expectedNextBackoff = ( testRandomVal % retryParams .nextJitterMax ) + 1U ;
203203
204204 /* Call the BackoffAlgorithm_GetNextBackoff API a couple times. */
205205 TEST_ASSERT_EQUAL ( BackoffAlgorithmSuccess ,
@@ -258,7 +258,7 @@ void test_BackoffAlgorithm_GetNextBackoff_Returns_Cap_Backoff( void )
258258 * Thus, the BackoffAlgorithm_GetNextBackoff API should return the random value as
259259 * the next back-off value. */
260260 testRandomVal = retryParams .nextJitterMax ;
261- uint16_t expectedBackoffVal = testRandomVal ;
261+ uint16_t expectedBackoffVal = ( testRandomVal % retryParams . nextJitterMax ) + 1U ;
262262
263263 /* Call the BackoffAlgorithm_GetNextBackoff API. */
264264 TEST_ASSERT_EQUAL ( BackoffAlgorithmSuccess ,
@@ -278,7 +278,7 @@ void test_BackoffAlgorithm_GetNextBackoff_Returns_Cap_Backoff( void )
278278 /* Now, set the random value as the maximum back-off value to
279279 * expect that the next back-off value returned by the API is the maximum
280280 * back-off value.*/
281- testRandomVal = TEST_BACKOFF_MAX_VALUE ;
281+ testRandomVal = TEST_BACKOFF_MAX_VALUE - 1 ;
282282
283283 /* Call BackoffAlgorithm_GetNextBackoff API again to verify that it now returns the
284284 * cap value as the next back-off value. */
@@ -326,7 +326,7 @@ void test_BackoffAlgorithm_GetNextBackoff_NextJitterMax_Below_Cap_Backoff( void
326326 TEST_ASSERT_EQUAL ( BackoffAlgorithmSuccess ,
327327 BackoffAlgorithm_GetNextBackoff ( & retryParams , testRandomVal , & nextBackoff ) );
328328 /* Make sure that zero is returned as the next backoff value . */
329- TEST_ASSERT_EQUAL ( 0 , nextBackoff );
329+ TEST_ASSERT_EQUAL ( 1 , nextBackoff );
330330
331331 /* Verify that the context data for expected data after the API call. */
332332 verifyContextData ( & retryParams ,
0 commit comments