Skip to content

Commit

Permalink
🎨 cargo clippy & fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
phidiaLam committed Nov 19, 2024
1 parent 8845884 commit f4c89cf
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions libs/bitmap-convert/src/base70.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bnum::types::U256;

use crate::error::Error;

const BASE_70: &'static [u8] =
const BASE_70: &[u8] =
b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-~._()!*";
// 字符转下标
static CHAR_TO_INDEX: LazyLock<[u8; 127]> = LazyLock::new(|| {
Expand Down Expand Up @@ -71,30 +71,30 @@ impl BitmapBase70Conv for Bitmap<256> {
}
}


#[cfg(test)]
mod tests {
use super::*;
use bitmaps::Bitmap;

use super::*;

fn generate_sample_bitmap() -> Bitmap<256> {
let mut bitmap = Bitmap::<256>::new();
for i in 1..=40 {
bitmap.set(i, true); // 设置第i位为 true
bitmap.set(i, true); // 设置第i位为 true
}
return bitmap;
}

#[test]
fn test_to_base_70() {
let bitmap = generate_sample_bitmap();

// 将 bitmap 转换为 base70 字符串
let base70_string = bitmap.to_base_70().unwrap();

// 确保 base70 字符串不为空
assert!(!base70_string.is_empty());

// 额外验证:可以输出看看转换后的字符串是什么
println!("Base70 encoded string: {}", base70_string);

Expand All @@ -104,9 +104,10 @@ mod tests {
#[test]
fn test_from_base_70() {
let bitmap = generate_sample_bitmap();

let decoded_bitmap = BitmapBase70Conv::from_base_70("ugAUrMi".to_owned()).unwrap();

let decoded_bitmap =
BitmapBase70Conv::from_base_70("ugAUrMi".to_owned()).unwrap();

assert_eq!(bitmap, decoded_bitmap);
}
}
}

0 comments on commit f4c89cf

Please sign in to comment.