Compare commits
No commits in common. "bdeefdb3b6e0670d8ba5881b2c2348dc7abead50" and "9852ef687d35da51fc0bf78ccdcae6b3ff0b4c3b" have entirely different histories.
bdeefdb3b6
...
9852ef687d
@ -1,2 +1,2 @@
|
|||||||
[alias]
|
[alias]
|
||||||
coverage = "tarpaulin --out Html --skip-clean --output-dir coverage --exclude-files src/bin/* --exclude-files tests/*"
|
coverage = "tarpaulin --out Html --skip-clean --output-dir coverage"
|
||||||
|
|||||||
@ -1,18 +1,13 @@
|
|||||||
|
#![feature(trusted_random_access)]
|
||||||
|
|
||||||
|
use std::iter::TrustedRandomAccessNoCoerce;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use trevors_utilities::data_to_text::DataToText;
|
use trevors_utilities::data_to_text::DataToText;
|
||||||
use trevors_utilities::duration_to_string::duration_to_string::{duration_to_string, SECONDS_IN_DAY, SECONDS_IN_HOUR, SECONDS_IN_MINUTE};
|
use trevors_utilities::duration_to_string::duration_to_string::{duration_to_string, SECONDS_IN_DAY, SECONDS_IN_HOUR, SECONDS_IN_MINUTE};
|
||||||
use trevors_utilities::format_with_commas::format_with_commas;
|
use trevors_utilities::format_with_commas::format_with_commas;
|
||||||
|
|
||||||
fn demo_header(title: &str, width: Option<u8>) {
|
|
||||||
let width = width.unwrap_or(80) as usize;
|
|
||||||
let num_leading = (width - title.len() - 4) / 2;
|
|
||||||
println!("{}{}", "-".repeat(width), "");
|
|
||||||
println!("|{}{} {}|", " ".repeat(num_leading), title, " ".repeat(num_leading));
|
|
||||||
println!("{}{}", "-".repeat(width), "");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn duration_to_string_demo() {
|
fn duration_to_string_demo() {
|
||||||
demo_header("Duration to String", None);
|
println!("**This is the duration_to_string demo**");
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
let options = vec![
|
let options = vec![
|
||||||
@ -33,14 +28,16 @@ fn duration_to_string_demo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn data_to_text_demo() {
|
fn data_to_text_demo() {
|
||||||
demo_header("Data To Text", None);
|
println!("**Data To Text**");
|
||||||
let options: Vec<Vec<u8>> = vec![
|
let options: Vec<Vec<u8>> = vec![
|
||||||
(0..=255).collect(),
|
(0..=255).collect(),
|
||||||
(0..128).collect(),
|
(0..128).collect(),
|
||||||
(0x20..=0x7f).collect()
|
(0x20..=0x7f).collect()
|
||||||
];
|
];
|
||||||
|
|
||||||
for option in options { let data = DataToText::data_to_text(option.as_slice());
|
for option in options {
|
||||||
|
let sizeof = option.iter().size();
|
||||||
|
let data = DataToText::data_to_text(option.as_slice());
|
||||||
println!("{}", data);
|
println!("{}", data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,7 @@ impl DataToText {
|
|||||||
let ascii_char = if byte.is_ascii_graphic() {
|
let ascii_char = if byte.is_ascii_graphic() {
|
||||||
*byte as char
|
*byte as char
|
||||||
} else {
|
} else {
|
||||||
' '
|
'.'
|
||||||
};
|
};
|
||||||
ascii_line.push(ascii_char);
|
ascii_line.push(ascii_char);
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,3 @@ pub fn bool_to_string(b: bool) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bool_array_to_string(b: &[bool]) -> String {
|
|
||||||
b.iter().map(|b| bool_to_string(*b)).collect::<Vec<String>>().join("")
|
|
||||||
}
|
|
||||||
@ -33,7 +33,7 @@ fn data_to_text() {
|
|||||||
0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
|
0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
|
||||||
0x20, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x20,
|
0x20, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x20,
|
||||||
];
|
];
|
||||||
let expected_data: &str = "0x66 0x67 0x68 0x69 0x6a 0x6b 0x6c 0x6d 0x6e 0x6f 0x70 0x71 0x72 0x73 0x74 0x20 fghijklmnopqrst \n0x76 0x77 0x78 0x79 0x7a 0x7b 0x7c 0x7d 0x7e 0x7f 0x20 vwxyz{|}~ \n";
|
let expected_data: &str = "0x66 0x67 0x68 0x69 0x6a 0x6b 0x6c 0x6d 0x6e 0x6f 0x70 0x71 0x72 0x73 0x74 0x20 fghijklmnopqrst \n0x76 0x77 0x78 0x79 0x7a 0x7b 0x7c 0x7d 0x7e 0x7f 0x20 vwxyz{|}~..\n";
|
||||||
|
|
||||||
let actual_data = DataToText::data_to_text(data_to_display);
|
let actual_data = DataToText::data_to_text(data_to_display);
|
||||||
assert_eq!(actual_data, expected_data);
|
assert_eq!(actual_data, expected_data);
|
||||||
@ -64,10 +64,3 @@ fn data_to_text_window_all() {
|
|||||||
let expected = read_display("quickbrownfox");
|
let expected = read_display("quickbrownfox");
|
||||||
assert_eq!(formatted, expected);
|
assert_eq!(formatted, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_window_past_end_of_data() {
|
|
||||||
let bin_data = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06];
|
|
||||||
let formatted = DataToText::data_to_text_window(&bin_data, 10, 10);
|
|
||||||
assert_eq!(formatted, "");
|
|
||||||
}
|
|
||||||
|
|||||||
@ -2,4 +2,3 @@ mod data_to_text;
|
|||||||
mod number_system_conversion;
|
mod number_system_conversion;
|
||||||
mod test_compression;
|
mod test_compression;
|
||||||
mod format_with_commas;
|
mod format_with_commas;
|
||||||
mod primitive_formatting;
|
|
||||||
|
|||||||
@ -1,7 +0,0 @@
|
|||||||
use trevors_utilities::primitive_formatting;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_primitive_bool() {
|
|
||||||
assert_eq!("1".to_string(), primitive_formatting::bool_to_string(true));
|
|
||||||
assert_eq!("0".to_string(), primitive_formatting::bool_to_string(false));
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user