Fix tests.

This commit is contained in:
Dario Nieuwenhuis
2023-05-29 19:46:28 +02:00
parent cc23129456
commit 46961cfdf7
10 changed files with 24 additions and 26 deletions

View File

@ -163,7 +163,7 @@ pub(super) fn get_sector(address: u32, regions: &[&FlashRegion]) -> FlashSector
bank_offset = 0;
}
if address < region.end() {
if address >= region.base && address < region.end() {
let index_in_region = (address - region.base) / region.erase_size;
return FlashSector {
bank: region.bank,

View File

@ -209,39 +209,39 @@ mod tests {
#[test]
fn test_compute_dead_time_value() {
struct test_run {
struct TestRun {
value: u16,
ckd: Ckd,
bits: u8,
}
let fn_results = [
test_run {
TestRun {
value: 1,
ckd: Ckd::DIV1,
bits: 1,
},
test_run {
TestRun {
value: 125,
ckd: Ckd::DIV1,
bits: 125,
},
test_run {
TestRun {
value: 245,
ckd: Ckd::DIV1,
bits: 64 + 245 / 2,
},
test_run {
TestRun {
value: 255,
ckd: Ckd::DIV2,
bits: 127,
},
test_run {
TestRun {
value: 400,
ckd: Ckd::DIV1,
bits: 32 + (400u16 / 8) as u8,
},
test_run {
TestRun {
value: 600,
ckd: Ckd::DIV4,
bits: 64 + (600u16 / 8) as u8,