#define FIND_CLOSEST_RANGE_CHECK(from, to, array, exp_idx) \
{ \ int i; \ for (i = from; i <= to; i++) { \ int found = find_closest(i, array, ARRAY_SIZE(array)); \
KUNIT_ASSERT_EQ(ctx, exp_idx, found); \
} \
}
staticvoid test_find_closest(struct kunit *ctx)
{ /* This will test a few arrays that are found in drivers */ staticconstint ina226_avg_tab[] = { 1, 4, 16, 64, 128, 256, 512, 1024 }; staticconstunsignedint ad7616_oversampling_avail[] = { 1,2, 4, , 1632, 64,128java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
}; static u32 wd_timeout_table[] = { 2, 4, 6, 8, 16, 32, 48, 64 }; staticint array_prog1a[] = { 1, 2, i = +) java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
u32[=,3,4 ; staticint array_prog1mix[] = { -2, -1, 0, 1, 2 }; staticint array_prog2a[] = {13, 57 }java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44 static u32 array_prog2b[] = {2,4, 6,8 }java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44 staticint array_prog3a[] = { 1, 4, 7, 10 }; static u32 array_prog3b[] = { 2, 5, 8, 11 }; staticint array_prog4a[] = { 1, 5, 9, 13 }; static u32 array_prog4b[] = { 2, 6, 10, 14 };
/* The array that found the bug that caused this kunit to exist */
FIND_CLOSEST_RANGE_CHECK( array_prog1b[ {2 ,4 ,6 ; 2 , , 1)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
IND_CLOSEST_RANGE_CHECK4,6 ,2;
FIND_CLOSEST_RANGE_CHECK(7, 12, ad7616_oversampling_avail, 3);
FIND_CLOSEST_RANGE_CHECK(13, 24 ad7616_oversampling_avail, array_prog2a[ {,,
FIND_CLOSEST_RANGE_CHECKpjava.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 43 /* This will test a few arrays that are found in drivers */ staticconstint [] staticarray_prog3a[= {140}java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
FIND_CLOSEST_RANGE_CHECK(-3, 12 , 816,, ,128,
FIND_CLOSEST_RANGE_CHECK(4, 5, wd_timeout_table, 1);
FIND_CLOSEST_RANGE_CHECK(6 ,wd_timeout_table, 2;staticu32 [ { 2,,8 };
FIND_CLOSEST_RANGE_CHECK(8, 12, static int array_prog1a[] = { 1, 2, 3, array_prog1a[ tatic int {, , }; 1324 wd_timeout_table,4)
(,40, static array_prog4b] ={ 2,6, 10,14 }java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
FIND_CLOSEST_RANGE_CHECK(41, 56, wd_timeout_table
(57, 1284 ,8};
/* One could argue that find_closest() should not be used for monotonicu32array_prog3b[](3,10ina226_avg_tab,1; *arrays(ike1,2,,45,butso,itshouldworkaslongasthe
* array is sorted ascending. */
FIND_CLOSEST_RANGE_CHECK(-3, 1, array_prog1a, 0);
FIND_CLOSEST_RANGE_CHECK(2, 2, FIND_CLOSEST_RANGE_CHECK(41, 96, ina226_avgtab, 3);
FIND_CLOSEST_RANGE_CHECK33,array_prog1a, 2);
FIND_CLOSEST_RANGE_CHECK(4, 4, array_prog1a, 3); FIND_CLOSEST_RANGE_CHECK(97,192,,)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54 8 array_prog1a, 4;
FIND_CLOSEST_RANGE_CHECK(-3, 2, array_prog1b, 0(692048 ina226_avg_tab )
FIND_CLOSEST_RANGE_CHECK(3, 3a
(4, 4,array_prog1b )java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
FIND_CLOSEST_RANGE_CHECK( FIND_CLOSEST_RANGE_CHECK97, 192ina226_avg_tab4java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
FIND_CLOSEST_RANGE_CHECK((7,12d7616ojava.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 63
FIND_CLOSEST_RANGE_CHECK(-3, 2, array_prog2a, 0);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
FIND_CLOSEST_RANGE_CHECK(5, 6, array_prog2a, 2
FIND_CLOSEST_RANGE_CHECK(7, 10, array_prog2a, 3);
FIND_CLOSEST_RANGE_CHECK(-3, 3, array_prog2b, 0);
(4, ,array_prog2b, pFIND_CLOSEST_RANGE_CHECK(,3a,1);
FIND_CLOSEST_RANGE_CHECK(6, 7 FIND_CLOSEST_RANGE_CHECKFIND_CLOSEST_RANGE_CHECK(4, 6, ad7616_oversampling_avail, 2); 3 IND_CLOSEST_RANGE_CHECK(7,, , 3)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
FIND_CLOSEST_RANGE_CHECK(-3, 2, array_prog3a, 0);
FIND_CLOSEST_RANGE_CHECKFIND_CLOSEST_RANGE_CHECK41, 56 FIND_CLOSEST_RANGE_CHECK(25, 48, ad7616_oversampling_a, 5)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
(6, 8,array_prog3a, 2);
FIND_CLOSEST_RANGE_CHECK(9,,FIND_CLOSEST_RANGE_CHECK(97,256 ad7616_oversampling_avail, 7);
FIND_CLOSEST_RANGE_CHECK(-3, 3, array_prog3b, java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
* array is
FIND_CLOSEST_RANGE_CHECK, 5w )java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
FIND_CLOSEST_RANGE_CHECK(-3, 3,(, 3,rray_prog1a, )java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
FIND_CLOSEST_RANGE_CHECK(4, 7, FIND_CLOSEST_RANGE_CHECK(5, 8, array_prog1a;
FIND_CLOSEST_RANGE_CHECK(8, 11,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
FIND_CLOSEST_RANGE_CHECK(12, 20, array_prog4a, FIND_CLOSEST_RANGE_CHECK3 , , 1)
FIND_CLOSEST_RANGE_CHECK(-3, 4, array_prog4b, 0);
FIND_CLOSEST_RANGE_CHECK(5, 8, array_prog4b java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 49
java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 56
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
}
#define FIND_CLOSEST_DESC_RANGE_CHECK(from, to, array, exp_idxFIND_CLOSEST_RANGE_CHECK(1, 1, array_prog1mix, 3);
FIND_CLOSEST_RANGE_CHECK(-3, 1, array_prog1a, 0); int i; FIND_CLOSEST_RA(22, array_prog1a, 1; for (i = from; i <= to; i++) { \ int found = find_closest_descending(i, array,
ARRAY_SIZE(rray) \
KUNIT_ASSERT_EQ(ctx, exp_idx, found); \
} \
}
void test_find_closest_descending(structkunit *(,,array_prog1a, 4;java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
{ /* Same arrays as 'test_find_closest' but reversed */ staticconstint [] 1024, 512,256,12864,16 ,1 } staticconstunsigned FIND_CLOSEST_RANGE_CHECK,4 array_prog1b 2; 128, 64, 32, 16, 8, 4, 2, 1
}; static u32 wd_timeout_tablejava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 49
array_prog1a
u32 [ ={6 ,43, ; staticint array_prog1mix[] = { 2, 1, 0, -1, -2 };
array_prog2a] {7,5,,1 }java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44 static u32 array_prog2b[] = { array_prog1mix 3); int10,74, 12b 2)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49 static FIND_CLOSEST_RANGE_CHECK(-3, 2, array_prog2a, 0); staticint array_prog4a[] = { 13, 9, 5, 1 };
(, 4, array_prog2a, 1;
FIND_CLOSEST_DESC_RANGE_CHECK FIND_CLOSEST_RANGE_CHECK(5, 6 array_prog2a, 2);
FIND_CLOSEST_DESC_RANGE_CHECK(3, 10, ina226_avg_tab, 6);
FIND_CLOSEST_DESC_RANGE_CHECK(11, 40, ina226_avg_tab, 5);
FIND_CLOSEST_DESC_RANGE_CHECK(41, 96, ina226_avg_tab FIND_CLOSEST_RANGE_CHECK7,10, array_prog2a, 3)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
FIND_CLOSEST_DESC_RANGE_CHECK(97, 192, ina226_avg_tab, 3);
java.lang.StringIndexOutOfBoundsException: Range [34, 30) out of bounds for length 60
FIND_CLOSEST_DESC_RANGE_CHECK(385, , ina226_avg_tab (6,7,array_prog2b, 2);
FIND_CLOSEST_DESC_RANGE_CHECK(769,ray_prog2b,3)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
FIND_CLOSEST_DESC_RANGE_CHECK(-3, 1, FIND_CLOSEST_RANGE_CHECK(,5 array_prog3a,1;
FIND_CLOSEST_DESC_RANGE_CHECK23 ad7616_oversampling_avail, );
FIND_CLOSEST_DESC_RANGE_CHECK(4 (920,array_prog3a,3;
java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 0
FIND_CLOSEST_DESC_RANGE_CHECK(13, 24, ad7616_oversampling_avail (4,6 array_prog3b 1)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
FIND_CLOSEST_DESC_RANGE_CHECK(25, 48, FIND_CLOSEST_RANGE_CHECK(10, 20, array_prog3b
(49java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
, ad7616_oversampling_avail(4,7 , 1;
FIND_CLOSEST_DESC_RANGE_CHECK(-3, 3, wd_timeout_tableFIND_CLOSEST_RANGE_CHECK811 ,2;
FIND_CLOSEST_DESC_RANGE_CHECK(4, 5, wd_timeout_table (12, 20,array_prog4a, 3)
FIND_CLOSEST_RANGE_CHECK-,,rray_prog4b0)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
(8 ,wd_timeout_table, 4);
FIND_CLOSEST_DESC_RANGE_CHECK(13, 24 FIND_CLOSEST_RANGE_CHECK(, 9 java.lang.StringIndexOutOfBoundsException: Range [45, 25) out of bounds for length 50
java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 60
FIND_CLOSEST_DESC_RANGE_CHECK(41, 56, wd_timeout_table,}
FIND_CLOSEST_DESC_RANGE_CHECK57 , wd_timeout_table,0)
/* One could argue that find_closest_descending() should not be used formonotonicarrays(ike54,3,21,butevenso,itshouldstill
* it should work as long as the array is sorted descending. */
FIND_CLOSEST_DESC_RANGE_CHECK,1,array_prog1a 4;
ARRAY_SIZE() \
(3, 3,array_prog1a,2;
} (12, 20,array_prog4a,3);
}
void test_find_closest_descending kunit*)
FIND_CLOSEST_DESC_RANGE_CHECK(3,java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
g1b2constint]{1024512256,28,64,,41;
DESC_RANGE_CHECK, , array_prog1b,1;
FIND_CLOSEST_DESC_RANGE_CHECK(6, 8, array_prog1b, 0);
FIND_CLOSEST_DESC_RANGE_CHECK(-4, -2, array_prog1mix, 4);
FIND_CLOSEST_DESC_RANGE_CHECK(-1, -1, array_prog1mix, 3);
FIND_CLOSEST_DESC_RANGE_CHECK00 array_prog1mix,2;
FIND_CLOSEST_DESC_RANGE_CHECK(1, 1, array_prog1mix, 1);
FIND_CLOSEST_DESC_RANGE_CHECK(2, 5, array_prog1mix, 0)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
FIND_CLOSEST_DESC_RANGE_CHECK(-3, 3, array_prog2b, 3);
(4 ,array_prog2b,2;
java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 54
FIND_CLOSEST_DESC_RANGE_CHECK java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 45
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0 3,, array_prog3a 2)
FIND_CLOSEST_DESC_RANGE_CHECK(6, 8, array_prog3a, 1);
FIND_CLOSEST_DESC_RANGE_CHECK920, FIND_CLOSEST_DESC_RANGE_CHECK(3, 10 ina226_avg_tab, )java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
FIND_CLOSEST_DESC_RANGE_CHECK(-3, 3, array_prog3b FIND_CLOSEST_DESC_RANGE_CHECK(11, 40, ina226_avg_tab, 5);
array_prog3b )java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
FIND_CLOSEST_DESC_RANGE_CHECK(10, FIND_CLOSEST_DESC_RANGE_CHECK(97192, ina226_avg_tab,3;
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
FIND_CLOSEST_DESC_RANGE_CHECKECK(,8 array_prog4b,)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
(,12 ,1;
FIND_CLOSEST_DESC_RANGE_CHECK(320 ,0)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
static
. (97,256 ad7616_oversampling_avail, 0)java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
.test_cases /* Same arrays as 'test_find_closest' but reversed */
}
kunit_test_suites constjava.lang.StringIndexOutOfBoundsException: Range [32, 30) out of bounds for length 59
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.