mirror of
https://github.com/GyulyVGC/sniffnet.git
synced 2025-12-23 22:29:01 -05:00
fix old tests
This commit is contained in:
@@ -221,8 +221,9 @@ mod tests {
|
||||
|
||||
use crate::chart::manage_chart_data::{ChartSeries, get_max, get_min};
|
||||
use crate::networking::types::data_info::DataInfo;
|
||||
use crate::networking::types::data_representation::DataRepr;
|
||||
use crate::utils::types::timestamp::Timestamp;
|
||||
use crate::{ChartType, InfoTraffic, Language, StyleType, TrafficChart};
|
||||
use crate::{InfoTraffic, Language, StyleType, TrafficChart};
|
||||
|
||||
fn spline_from_vec(vec: Vec<(i32, i32)>) -> Spline<f32, f32> {
|
||||
Spline::from_vec(
|
||||
@@ -318,7 +319,7 @@ fn test_chart_data_updates() {
|
||||
min_packets: -1000.0,
|
||||
max_packets: 21000.0,
|
||||
language: Language::default(),
|
||||
data_repr: ChartType::Packets,
|
||||
data_repr: DataRepr::Packets,
|
||||
style: StyleType::default(),
|
||||
thumbnail: false,
|
||||
is_live_capture: true,
|
||||
|
||||
@@ -407,7 +407,7 @@ fn test_spline_samples() {
|
||||
let eps = 0.001;
|
||||
|
||||
let pts = spline.len() * 10;
|
||||
let samples = sample_spline(&spline);
|
||||
let samples = sample_spline(&spline, 1.0);
|
||||
assert_eq!(samples.len(), pts);
|
||||
|
||||
let delta = samples[1].0 - samples[0].0;
|
||||
|
||||
@@ -628,6 +628,7 @@ fn button_clear_filter<'a>(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::gui::pages::inspect_page::title_report_col_display;
|
||||
use crate::networking::types::data_representation::DataRepr;
|
||||
use crate::report::types::report_col::ReportCol;
|
||||
use crate::translations::types::language::Language;
|
||||
|
||||
@@ -636,78 +637,81 @@ fn test_table_titles_display_and_tooltip_values_for_each_language() {
|
||||
// check glyph len when adding new language...
|
||||
assert_eq!(Language::ALL.len(), 22);
|
||||
for report_col in ReportCol::ALL {
|
||||
for language in Language::ALL {
|
||||
let (title, title_small, tooltip_val) =
|
||||
title_report_col_display(&report_col, language);
|
||||
let title_chars = title.chars().collect::<Vec<char>>();
|
||||
let title_small_chars = title_small.chars().collect::<Vec<char>>();
|
||||
let max_chars = report_col.get_max_chars(Some(language));
|
||||
if tooltip_val.is_empty() {
|
||||
// all is entirely displayed
|
||||
assert!(title_chars.len() + title_small_chars.len() <= max_chars);
|
||||
assert_eq!(title, report_col.get_title(language));
|
||||
assert_eq!(title_small, report_col.get_title_direction_info(language));
|
||||
} else {
|
||||
// tooltip is the full concatenation
|
||||
assert_eq!(
|
||||
tooltip_val,
|
||||
[
|
||||
report_col.get_title(language),
|
||||
report_col.get_title_direction_info(language)
|
||||
]
|
||||
.concat()
|
||||
);
|
||||
if report_col.get_title_direction_info(language).len() == 0 {
|
||||
// displayed values have max len -1 (they include "…" that counts for 2 units)
|
||||
assert_eq!(title_chars.len() + title_small_chars.len(), max_chars - 1);
|
||||
for data_repr in DataRepr::ALL {
|
||||
for language in Language::ALL {
|
||||
let (title, title_small, tooltip_val) =
|
||||
title_report_col_display(&report_col, data_repr, language);
|
||||
let title_chars = title.chars().collect::<Vec<char>>();
|
||||
let title_small_chars = title_small.chars().collect::<Vec<char>>();
|
||||
let max_chars = report_col.get_max_chars(Some(language));
|
||||
if tooltip_val.is_empty() {
|
||||
// all is entirely displayed
|
||||
assert!(title_chars.len() + title_small_chars.len() <= max_chars);
|
||||
assert_eq!(title, report_col.get_title(language, data_repr));
|
||||
assert_eq!(title_small, report_col.get_title_direction_info(language));
|
||||
} else {
|
||||
match title_chars.len() {
|
||||
x if x == max_chars - 4 || x == max_chars - 3 => {
|
||||
assert_eq!(title_small_chars.len(), 1)
|
||||
}
|
||||
_ => assert_eq!(
|
||||
title_chars.len() + title_small_chars.len(),
|
||||
max_chars - 1
|
||||
),
|
||||
}
|
||||
}
|
||||
if title != report_col.get_title(language) {
|
||||
// first title part is not full, so second one is suspensions
|
||||
assert_eq!(title_small, "…");
|
||||
// check len wrt max
|
||||
assert!(title_chars.len() >= max_chars - 4);
|
||||
// first title part is max - 2 chars of full self
|
||||
// tooltip is the full concatenation
|
||||
assert_eq!(
|
||||
title,
|
||||
report_col
|
||||
.get_title(language)
|
||||
.chars()
|
||||
.collect::<Vec<char>>()[..max_chars - 2]
|
||||
.iter()
|
||||
.collect::<String>()
|
||||
tooltip_val,
|
||||
[
|
||||
report_col.get_title(language, data_repr),
|
||||
report_col.get_title_direction_info(language)
|
||||
]
|
||||
.concat()
|
||||
);
|
||||
} else {
|
||||
// first part is untouched
|
||||
// second title part is max - title.len - 2 chars of full self, plus suspensions
|
||||
let mut second_part = [
|
||||
&report_col
|
||||
.get_title_direction_info(language)
|
||||
.chars()
|
||||
.collect::<Vec<char>>()[..max_chars - 2 - title_chars.len()]
|
||||
.iter()
|
||||
.collect::<String>(),
|
||||
"…",
|
||||
]
|
||||
.concat();
|
||||
if second_part == String::from(" (…") || second_part == String::from(" …")
|
||||
{
|
||||
second_part = String::from("…");
|
||||
if report_col.get_title_direction_info(language).len() == 0 {
|
||||
// displayed values have max len -1 (they include "…" that counts for 2 units)
|
||||
assert_eq!(title_chars.len() + title_small_chars.len(), max_chars - 1);
|
||||
} else {
|
||||
match title_chars.len() {
|
||||
x if x == max_chars - 4 || x == max_chars - 3 => {
|
||||
assert_eq!(title_small_chars.len(), 1)
|
||||
}
|
||||
_ => assert_eq!(
|
||||
title_chars.len() + title_small_chars.len(),
|
||||
max_chars - 1
|
||||
),
|
||||
}
|
||||
}
|
||||
if title != report_col.get_title(language, data_repr) {
|
||||
// first title part is not full, so second one is suspensions
|
||||
assert_eq!(title_small, "…");
|
||||
// check len wrt max
|
||||
assert!(title_chars.len() >= max_chars - 4);
|
||||
// first title part is max - 2 chars of full self
|
||||
assert_eq!(
|
||||
title,
|
||||
report_col
|
||||
.get_title(language, data_repr)
|
||||
.chars()
|
||||
.collect::<Vec<char>>()[..max_chars - 2]
|
||||
.iter()
|
||||
.collect::<String>()
|
||||
);
|
||||
} else {
|
||||
// first part is untouched
|
||||
// second title part is max - title.len - 2 chars of full self, plus suspensions
|
||||
let mut second_part = [
|
||||
&report_col
|
||||
.get_title_direction_info(language)
|
||||
.chars()
|
||||
.collect::<Vec<char>>()[..max_chars - 2 - title_chars.len()]
|
||||
.iter()
|
||||
.collect::<String>(),
|
||||
"…",
|
||||
]
|
||||
.concat();
|
||||
if second_part == String::from(" (…")
|
||||
|| second_part == String::from(" …")
|
||||
{
|
||||
second_part = String::from("…");
|
||||
}
|
||||
assert_eq!(title_small, second_part);
|
||||
// second part never terminates with "(…"
|
||||
assert!(!title_small.ends_with("(…"));
|
||||
// second part never terminates with " …"
|
||||
assert!(!title_small.ends_with(" …"));
|
||||
}
|
||||
assert_eq!(title_small, second_part);
|
||||
// second part never terminates with "(…"
|
||||
assert!(!title_small.ends_with("(…"));
|
||||
// second part never terminates with " …"
|
||||
assert!(!title_small.ends_with(" …"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -869,17 +869,22 @@ fn sort_arrows<'a>(
|
||||
mod tests {
|
||||
use crate::gui::pages::overview_page::{MIN_BARS_LENGTH, get_bars_length};
|
||||
use crate::networking::types::data_info::DataInfo;
|
||||
use crate::networking::types::data_representation::DataRepr;
|
||||
|
||||
#[test]
|
||||
fn test_get_bars_length_simple() {
|
||||
let first_entry = DataInfo::new_for_tests(50, 50, 150, 50);
|
||||
let data_info = DataInfo::new_for_tests(25, 55, 165, 30);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Packets, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Packets, &first_entry, &data_info),
|
||||
(25, 55)
|
||||
);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Bytes, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Bytes, &first_entry, &data_info),
|
||||
(83, 15)
|
||||
);
|
||||
assert_eq!(
|
||||
get_bars_length(DataRepr::Bits, &first_entry, &data_info),
|
||||
(83, 15)
|
||||
);
|
||||
}
|
||||
@@ -889,21 +894,21 @@ fn test_get_bars_length_normalize_small_values() {
|
||||
let first_entry = DataInfo::new_for_tests(50, 50, 150, 50);
|
||||
let mut data_info = DataInfo::new_for_tests(2, 1, 1, 0);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Packets, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Packets, &first_entry, &data_info),
|
||||
(MIN_BARS_LENGTH as u16 / 2, MIN_BARS_LENGTH as u16 / 2)
|
||||
);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Bytes, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Bytes, &first_entry, &data_info),
|
||||
(MIN_BARS_LENGTH as u16, 0)
|
||||
);
|
||||
|
||||
data_info = DataInfo::new_for_tests(0, 3, 0, 2);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Packets, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Packets, &first_entry, &data_info),
|
||||
(0, MIN_BARS_LENGTH as u16)
|
||||
);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Bytes, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Bytes, &first_entry, &data_info),
|
||||
(0, MIN_BARS_LENGTH as u16)
|
||||
);
|
||||
}
|
||||
@@ -914,31 +919,31 @@ fn test_get_bars_length_normalize_very_small_values() {
|
||||
DataInfo::new_for_tests(u128::MAX / 2, u128::MAX / 2, u128::MAX / 2, u128::MAX / 2);
|
||||
let mut data_info = DataInfo::new_for_tests(1, 1, 1, 1);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Packets, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Packets, &first_entry, &data_info),
|
||||
(MIN_BARS_LENGTH as u16 / 2, MIN_BARS_LENGTH as u16 / 2)
|
||||
);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Bytes, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Bytes, &first_entry, &data_info),
|
||||
(MIN_BARS_LENGTH as u16 / 2, MIN_BARS_LENGTH as u16 / 2)
|
||||
);
|
||||
|
||||
data_info = DataInfo::new_for_tests(0, 1, 0, 1);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Packets, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Packets, &first_entry, &data_info),
|
||||
(0, MIN_BARS_LENGTH as u16)
|
||||
);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Bytes, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Bytes, &first_entry, &data_info),
|
||||
(0, MIN_BARS_LENGTH as u16)
|
||||
);
|
||||
|
||||
data_info = DataInfo::new_for_tests(1, 0, 1, 0);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Packets, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Packets, &first_entry, &data_info),
|
||||
(MIN_BARS_LENGTH as u16, 0)
|
||||
);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Bytes, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Bytes, &first_entry, &data_info),
|
||||
(MIN_BARS_LENGTH as u16, 0)
|
||||
);
|
||||
}
|
||||
@@ -949,93 +954,93 @@ fn test_get_bars_length_complex() {
|
||||
|
||||
let mut data_info = DataInfo::new_for_tests(0, 9, 0, 10);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Packets, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Packets, &first_entry, &data_info),
|
||||
(0, 16)
|
||||
);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Bytes, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Bytes, &first_entry, &data_info),
|
||||
(0, 71)
|
||||
);
|
||||
data_info = DataInfo::new_for_tests(9, 0, 13, 0);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Packets, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Packets, &first_entry, &data_info),
|
||||
(16, 0)
|
||||
);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Bytes, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Bytes, &first_entry, &data_info),
|
||||
(93, 0)
|
||||
);
|
||||
|
||||
data_info = DataInfo::new_for_tests(4, 5, 6, 7);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Packets, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Packets, &first_entry, &data_info),
|
||||
(7, 9)
|
||||
);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Bytes, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Bytes, &first_entry, &data_info),
|
||||
(43, 50)
|
||||
);
|
||||
data_info = DataInfo::new_for_tests(5, 4, 7, 6);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Packets, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Packets, &first_entry, &data_info),
|
||||
(9, 7)
|
||||
);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Bytes, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Bytes, &first_entry, &data_info),
|
||||
(50, 43)
|
||||
);
|
||||
|
||||
data_info = DataInfo::new_for_tests(1, 8, 1, 12);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Packets, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Packets, &first_entry, &data_info),
|
||||
(MIN_BARS_LENGTH as u16 / 2, 14)
|
||||
);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Bytes, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Bytes, &first_entry, &data_info),
|
||||
(7, 86)
|
||||
);
|
||||
data_info = DataInfo::new_for_tests(8, 1, 12, 1);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Packets, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Packets, &first_entry, &data_info),
|
||||
(14, MIN_BARS_LENGTH as u16 / 2)
|
||||
);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Bytes, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Bytes, &first_entry, &data_info),
|
||||
(86, 7)
|
||||
);
|
||||
|
||||
data_info = DataInfo::new_for_tests(6, 1, 10, 1);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Packets, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Packets, &first_entry, &data_info),
|
||||
(11, MIN_BARS_LENGTH as u16 / 2)
|
||||
);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Bytes, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Bytes, &first_entry, &data_info),
|
||||
(71, 7)
|
||||
);
|
||||
data_info = DataInfo::new_for_tests(1, 6, 1, 9);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Packets, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Packets, &first_entry, &data_info),
|
||||
(MIN_BARS_LENGTH as u16 / 2, 11,)
|
||||
);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Bytes, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Bytes, &first_entry, &data_info),
|
||||
(7, 64)
|
||||
);
|
||||
|
||||
data_info = DataInfo::new_for_tests(1, 6, 5, 5);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Bytes, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Bytes, &first_entry, &data_info),
|
||||
(36, 36)
|
||||
);
|
||||
|
||||
data_info = DataInfo::new_for_tests(0, 0, 0, 0);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Packets, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Packets, &first_entry, &data_info),
|
||||
(0, 0)
|
||||
);
|
||||
assert_eq!(
|
||||
get_bars_length(ChartType::Bytes, &first_entry, &data_info),
|
||||
get_bars_length(DataRepr::Bytes, &first_entry, &data_info),
|
||||
(0, 0)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1114,6 +1114,7 @@ mod tests {
|
||||
use crate::gui::types::message::Message;
|
||||
use crate::gui::types::timing_events::TimingEvents;
|
||||
use crate::networking::types::data_info::DataInfo;
|
||||
use crate::networking::types::data_representation::DataRepr;
|
||||
use crate::networking::types::host::Host;
|
||||
use crate::networking::types::traffic_direction::TrafficDirection;
|
||||
use crate::notifications::types::logged_notification::{
|
||||
@@ -1123,11 +1124,10 @@ mod tests {
|
||||
DataNotification, FavoriteNotification, Notification, Notifications,
|
||||
};
|
||||
use crate::notifications::types::sound::Sound;
|
||||
use crate::report::types::report_col::ReportCol;
|
||||
use crate::report::types::sort_type::SortType;
|
||||
use crate::{
|
||||
ByteMultiple, ChartType, ConfigDevice, ConfigSettings, ConfigWindow, Configs, IpVersion,
|
||||
Language, Protocol, ReportSortType, RunningPage, Sniffer, StyleType,
|
||||
ByteMultiple, ConfigDevice, ConfigSettings, ConfigWindow, Configs, IpVersion, Language,
|
||||
Protocol, ReportSortType, RunningPage, Sniffer, StyleType,
|
||||
};
|
||||
|
||||
// helpful to clean up files generated from tests
|
||||
@@ -1201,13 +1201,15 @@ fn test_correctly_update_protocol() {
|
||||
fn test_correctly_update_chart_kind() {
|
||||
let mut sniffer = Sniffer::new(Configs::default());
|
||||
|
||||
assert_eq!(sniffer.traffic_chart.data_repr, ChartType::Bytes);
|
||||
sniffer.update(Message::DataReprSelection(ChartType::Packets));
|
||||
assert_eq!(sniffer.traffic_chart.data_repr, ChartType::Packets);
|
||||
sniffer.update(Message::DataReprSelection(ChartType::Packets));
|
||||
assert_eq!(sniffer.traffic_chart.data_repr, ChartType::Packets);
|
||||
sniffer.update(Message::DataReprSelection(ChartType::Bytes));
|
||||
assert_eq!(sniffer.traffic_chart.data_repr, ChartType::Bytes);
|
||||
assert_eq!(sniffer.traffic_chart.data_repr, DataRepr::Bytes);
|
||||
sniffer.update(Message::DataReprSelection(DataRepr::Packets));
|
||||
assert_eq!(sniffer.traffic_chart.data_repr, DataRepr::Packets);
|
||||
sniffer.update(Message::DataReprSelection(DataRepr::Packets));
|
||||
assert_eq!(sniffer.traffic_chart.data_repr, DataRepr::Packets);
|
||||
sniffer.update(Message::DataReprSelection(DataRepr::Bytes));
|
||||
assert_eq!(sniffer.traffic_chart.data_repr, DataRepr::Bytes);
|
||||
sniffer.update(Message::DataReprSelection(DataRepr::Bits));
|
||||
assert_eq!(sniffer.traffic_chart.data_repr, DataRepr::Bits);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1216,53 +1218,31 @@ fn test_correctly_update_report_sort_kind() {
|
||||
let mut sniffer = Sniffer::new(Configs::default());
|
||||
|
||||
let sort = ReportSortType {
|
||||
byte_sort: SortType::Neutral,
|
||||
packet_sort: SortType::Neutral,
|
||||
data_sort: SortType::Neutral,
|
||||
};
|
||||
|
||||
assert_eq!(sniffer.report_sort_type, sort);
|
||||
sniffer.update(Message::ReportSortSelection(
|
||||
sort.next_sort(&ReportCol::Bytes),
|
||||
));
|
||||
sniffer.update(Message::ReportSortSelection(sort.next_sort()));
|
||||
assert_eq!(
|
||||
sniffer.report_sort_type,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Descending,
|
||||
packet_sort: SortType::Neutral
|
||||
data_sort: SortType::Descending,
|
||||
}
|
||||
);
|
||||
sniffer.update(Message::ReportSortSelection(sort.next_sort().next_sort()));
|
||||
assert_eq!(
|
||||
sniffer.report_sort_type,
|
||||
ReportSortType {
|
||||
data_sort: SortType::Ascending,
|
||||
}
|
||||
);
|
||||
sniffer.update(Message::ReportSortSelection(
|
||||
sort.next_sort(&ReportCol::Bytes)
|
||||
.next_sort(&ReportCol::Bytes),
|
||||
sort.next_sort().next_sort().next_sort(),
|
||||
));
|
||||
assert_eq!(
|
||||
sniffer.report_sort_type,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Ascending,
|
||||
packet_sort: SortType::Neutral
|
||||
}
|
||||
);
|
||||
sniffer.update(Message::ReportSortSelection(
|
||||
sort.next_sort(&ReportCol::Bytes)
|
||||
.next_sort(&ReportCol::Packets),
|
||||
));
|
||||
assert_eq!(
|
||||
sniffer.report_sort_type,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Neutral,
|
||||
packet_sort: SortType::Descending
|
||||
}
|
||||
);
|
||||
sniffer.update(Message::ReportSortSelection(
|
||||
sort.next_sort(&ReportCol::Bytes)
|
||||
.next_sort(&ReportCol::Bytes)
|
||||
.next_sort(&ReportCol::Bytes),
|
||||
));
|
||||
assert_eq!(
|
||||
sniffer.report_sort_type,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Neutral,
|
||||
packet_sort: SortType::Neutral
|
||||
data_sort: SortType::Neutral,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1663,7 +1643,7 @@ fn expire_notifications_timeout(sniffer: &mut Sniffer) {
|
||||
let mut sniffer = Sniffer::new(Configs::default());
|
||||
|
||||
let bytes_notification_init = DataNotification {
|
||||
data_repr: ChartType::Bytes,
|
||||
data_repr: DataRepr::Bytes,
|
||||
threshold: None,
|
||||
byte_multiple: ByteMultiple::KB,
|
||||
sound: Sound::Pop,
|
||||
@@ -1671,7 +1651,7 @@ fn expire_notifications_timeout(sniffer: &mut Sniffer) {
|
||||
};
|
||||
|
||||
let bytes_notification_toggled_on = DataNotification {
|
||||
data_repr: ChartType::Bytes,
|
||||
data_repr: DataRepr::Bytes,
|
||||
threshold: Some(800_000),
|
||||
byte_multiple: ByteMultiple::GB,
|
||||
sound: Sound::Pop,
|
||||
@@ -1679,7 +1659,7 @@ fn expire_notifications_timeout(sniffer: &mut Sniffer) {
|
||||
};
|
||||
|
||||
let bytes_notification_adjusted_threshold_sound_off = DataNotification {
|
||||
data_repr: ChartType::Bytes,
|
||||
data_repr: DataRepr::Bytes,
|
||||
threshold: Some(3),
|
||||
byte_multiple: ByteMultiple::KB,
|
||||
sound: Sound::None,
|
||||
@@ -1687,7 +1667,7 @@ fn expire_notifications_timeout(sniffer: &mut Sniffer) {
|
||||
};
|
||||
|
||||
let bytes_notification_sound_off_only = DataNotification {
|
||||
data_repr: ChartType::Bytes,
|
||||
data_repr: DataRepr::Bytes,
|
||||
threshold: Some(800_000),
|
||||
byte_multiple: ByteMultiple::GB,
|
||||
sound: Sound::None,
|
||||
@@ -1807,7 +1787,7 @@ fn test_clear_all_notifications() {
|
||||
VecDeque::from([LoggedNotification::DataThresholdExceeded(
|
||||
DataThresholdExceeded {
|
||||
id: 1,
|
||||
data_repr: ChartType::Packets,
|
||||
data_repr: DataRepr::Packets,
|
||||
threshold: 0,
|
||||
data_info: DataInfo::default(),
|
||||
timestamp: "".to_string(),
|
||||
|
||||
@@ -172,12 +172,78 @@ fn test_interpret_unknown_suffix_correctly() {
|
||||
|
||||
#[test]
|
||||
fn test_byte_multiple_display() {
|
||||
assert_eq!(format!("{}", ByteMultiple::B), "B");
|
||||
assert_eq!(format!("{}", ByteMultiple::KB), "KB");
|
||||
assert_eq!(format!("{}", ByteMultiple::MB), "MB");
|
||||
assert_eq!(format!("{}", ByteMultiple::GB), "GB");
|
||||
assert_eq!(format!("{}", ByteMultiple::TB), "TB");
|
||||
assert_eq!(format!("{}", ByteMultiple::PB), "PB");
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::B.pretty_print(DataRepr::Packets)),
|
||||
""
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::B.pretty_print(DataRepr::Bytes)),
|
||||
"B"
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::B.pretty_print(DataRepr::Bits)),
|
||||
"b"
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::KB.pretty_print(DataRepr::Packets)),
|
||||
""
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::KB.pretty_print(DataRepr::Bytes)),
|
||||
"KB"
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::KB.pretty_print(DataRepr::Bits)),
|
||||
"Kb"
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::MB.pretty_print(DataRepr::Packets)),
|
||||
""
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::MB.pretty_print(DataRepr::Bytes)),
|
||||
"MB"
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::MB.pretty_print(DataRepr::Bits)),
|
||||
"Mb"
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::GB.pretty_print(DataRepr::Packets)),
|
||||
""
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::GB.pretty_print(DataRepr::Bytes)),
|
||||
"GB"
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::GB.pretty_print(DataRepr::Bits)),
|
||||
"Gb"
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::TB.pretty_print(DataRepr::Packets)),
|
||||
""
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::TB.pretty_print(DataRepr::Bytes)),
|
||||
"TB"
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::TB.pretty_print(DataRepr::Bits)),
|
||||
"Tb"
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::PB.pretty_print(DataRepr::Packets)),
|
||||
""
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::PB.pretty_print(DataRepr::Bytes)),
|
||||
"PB"
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", ByteMultiple::PB.pretty_print(DataRepr::Bits)),
|
||||
"Pb"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -202,67 +268,256 @@ fn test_byte_multiple_multiplier() {
|
||||
|
||||
#[test]
|
||||
fn test_byte_multiple_formatted_string() {
|
||||
assert_eq!(ByteMultiple::formatted_string(u128::MIN), "0 B");
|
||||
assert_eq!(ByteMultiple::formatted_string(1), "1 B");
|
||||
assert_eq!(ByteMultiple::formatted_string(82), "82 B");
|
||||
assert_eq!(ByteMultiple::formatted_string(999), "999 B");
|
||||
assert_eq!(ByteMultiple::formatted_string(1_000), "1.0 KB");
|
||||
assert_eq!(ByteMultiple::formatted_string(1_090), "1.1 KB");
|
||||
assert_eq!(ByteMultiple::formatted_string(1_990), "2.0 KB");
|
||||
assert_eq!(ByteMultiple::formatted_string(9_090), "9.1 KB");
|
||||
assert_eq!(ByteMultiple::formatted_string(9_950), "9.9 KB");
|
||||
assert_eq!(ByteMultiple::formatted_string(9_951), "10 KB");
|
||||
assert_eq!(ByteMultiple::formatted_string(71_324), "71 KB");
|
||||
assert_eq!(ByteMultiple::formatted_string(821_789), "822 KB");
|
||||
assert_eq!(ByteMultiple::formatted_string(999_499), "999 KB");
|
||||
assert_eq!(ByteMultiple::formatted_string(999_999), "999 KB");
|
||||
assert_eq!(ByteMultiple::formatted_string(1_000_000), "1.0 MB");
|
||||
assert_eq!(ByteMultiple::formatted_string(3_790_000), "3.8 MB");
|
||||
assert_eq!(ByteMultiple::formatted_string(9_950_000), "9.9 MB");
|
||||
assert_eq!(ByteMultiple::formatted_string(9_951_000), "10 MB");
|
||||
assert_eq!(ByteMultiple::formatted_string(49_499_000), "49 MB");
|
||||
assert_eq!(ByteMultiple::formatted_string(49_500_000), "50 MB");
|
||||
assert_eq!(ByteMultiple::formatted_string(670_900_000), "671 MB");
|
||||
assert_eq!(ByteMultiple::formatted_string(998_199_999), "998 MB");
|
||||
assert_eq!(ByteMultiple::formatted_string(999_999_999), "999 MB");
|
||||
assert_eq!(ByteMultiple::formatted_string(1_000_000_000), "1.0 GB");
|
||||
assert_eq!(ByteMultiple::formatted_string(7_770_000_000), "7.8 GB");
|
||||
assert_eq!(ByteMultiple::formatted_string(9_950_000_000), "9.9 GB");
|
||||
assert_eq!(ByteMultiple::formatted_string(9_951_000_000), "10 GB");
|
||||
assert_eq!(ByteMultiple::formatted_string(19_951_000_000), "20 GB");
|
||||
assert_eq!(ByteMultiple::formatted_string(399_951_000_000), "400 GB");
|
||||
assert_eq!(ByteMultiple::formatted_string(999_999_999_999), "999 GB");
|
||||
assert_eq!(ByteMultiple::formatted_string(1_000_000_000_000), "1.0 TB");
|
||||
assert_eq!(ByteMultiple::formatted_string(9_950_000_000_000), "9.9 TB");
|
||||
assert_eq!(ByteMultiple::formatted_string(9_951_000_000_000), "10 TB");
|
||||
assert_eq!(DataRepr::Packets.formatted_string(u128::MIN), "0");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(u128::MIN), "0 B");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(u128::MIN), "0 b");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(1), "1");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(1), "1 B");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(1), "1 b");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(82), "82");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(82), "82 B");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(82), "82 b");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(999), "999");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(999), "999 B");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(999), "999 b");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(1_000), "1000");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(1_000), "1.0 KB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(1_000), "1.0 Kb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(1_090), "1090");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(1_090), "1.1 KB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(1_090), "1.1 Kb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(1_990), "1990");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(1_990), "2.0 KB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(1_990), "2.0 Kb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(9_090), "9090");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(9_090), "9.1 KB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(9_090), "9.1 Kb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(9_950), "9950");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(9_950), "9.9 KB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(9_950), "9.9 Kb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(9_951), "9951");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(9_951), "10 KB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(9_951), "10 Kb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(71_324), "71324");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(71_324), "71 KB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(71_324), "71 Kb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(821_789), "821789");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(821_789), "822 KB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(821_789), "822 Kb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(999_499), "999499");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(999_499), "999 KB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(999_499), "999 Kb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(999_999), "999999");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(999_999), "999 KB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(999_999), "999 Kb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(1_000_000), "1000000");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(1_000_000), "1.0 MB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(1_000_000), "1.0 Mb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(3_790_000), "3790000");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(3_790_000), "3.8 MB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(3_790_000), "3.8 Mb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(9_950_000), "9950000");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(9_950_000), "9.9 MB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(9_950_000), "9.9 Mb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(9_951_000), "9951000");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(9_951_000), "10 MB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(9_951_000), "10 Mb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(49_499_000), "49499000");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(49_499_000), "49 MB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(49_499_000), "49 Mb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(49_500_000), "49500000");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(49_500_000), "50 MB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(49_500_000), "50 Mb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(670_900_000), "670900000");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(670_900_000), "671 MB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(670_900_000), "671 Mb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(998_199_999), "998199999");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(998_199_999), "998 MB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(998_199_999), "998 Mb");
|
||||
|
||||
assert_eq!(DataRepr::Packets.formatted_string(999_999_999), "999999999");
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(999_999_999), "999 MB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(999_999_999), "999 Mb");
|
||||
|
||||
assert_eq!(
|
||||
ByteMultiple::formatted_string(999_950_000_000_000),
|
||||
DataRepr::Packets.formatted_string(1_000_000_000),
|
||||
"1000000000"
|
||||
);
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(1_000_000_000), "1.0 GB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(1_000_000_000), "1.0 Gb");
|
||||
|
||||
assert_eq!(
|
||||
DataRepr::Packets.formatted_string(7_770_000_000),
|
||||
"7770000000"
|
||||
);
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(7_770_000_000), "7.8 GB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(7_770_000_000), "7.8 Gb");
|
||||
|
||||
assert_eq!(
|
||||
DataRepr::Packets.formatted_string(9_950_000_000),
|
||||
"9950000000"
|
||||
);
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(9_950_000_000), "9.9 GB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(9_950_000_000), "9.9 Gb");
|
||||
|
||||
assert_eq!(
|
||||
DataRepr::Packets.formatted_string(9_951_000_000),
|
||||
"9951000000"
|
||||
);
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(9_951_000_000), "10 GB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(9_951_000_000), "10 Gb");
|
||||
|
||||
assert_eq!(
|
||||
DataRepr::Packets.formatted_string(19_951_000_000),
|
||||
"19951000000"
|
||||
);
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(19_951_000_000), "20 GB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(19_951_000_000), "20 Gb");
|
||||
|
||||
assert_eq!(
|
||||
DataRepr::Packets.formatted_string(399_951_000_000),
|
||||
"399951000000"
|
||||
);
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(399_951_000_000), "400 GB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(399_951_000_000), "400 Gb");
|
||||
|
||||
assert_eq!(
|
||||
DataRepr::Packets.formatted_string(999_999_999_999),
|
||||
"999999999999"
|
||||
);
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(999_999_999_999), "999 GB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(999_999_999_999), "999 Gb");
|
||||
|
||||
assert_eq!(
|
||||
DataRepr::Packets.formatted_string(1_000_000_000_000),
|
||||
"1000000000000"
|
||||
);
|
||||
assert_eq!(
|
||||
DataRepr::Bytes.formatted_string(1_000_000_000_000),
|
||||
"1.0 TB"
|
||||
);
|
||||
assert_eq!(DataRepr::Bits.formatted_string(1_000_000_000_000), "1.0 Tb");
|
||||
|
||||
assert_eq!(
|
||||
DataRepr::Packets.formatted_string(9_950_000_000_000),
|
||||
"9950000000000"
|
||||
);
|
||||
assert_eq!(
|
||||
DataRepr::Bytes.formatted_string(9_950_000_000_000),
|
||||
"9.9 TB"
|
||||
);
|
||||
assert_eq!(DataRepr::Bits.formatted_string(9_950_000_000_000), "9.9 Tb");
|
||||
|
||||
assert_eq!(
|
||||
DataRepr::Packets.formatted_string(9_951_000_000_000),
|
||||
"9951000000000"
|
||||
);
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(9_951_000_000_000), "10 TB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(9_951_000_000_000), "10 Tb");
|
||||
|
||||
assert_eq!(
|
||||
DataRepr::Packets.formatted_string(999_950_000_000_000),
|
||||
"999950000000000"
|
||||
);
|
||||
assert_eq!(
|
||||
DataRepr::Bytes.formatted_string(999_950_000_000_000),
|
||||
"999 TB"
|
||||
);
|
||||
assert_eq!(
|
||||
ByteMultiple::formatted_string(999_999_999_999_999),
|
||||
DataRepr::Bits.formatted_string(999_950_000_000_000),
|
||||
"999 Tb"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
DataRepr::Packets.formatted_string(999_999_999_999_999),
|
||||
"999999999999999"
|
||||
);
|
||||
assert_eq!(
|
||||
DataRepr::Bytes.formatted_string(999_999_999_999_999),
|
||||
"999 TB"
|
||||
);
|
||||
assert_eq!(
|
||||
ByteMultiple::formatted_string(1_000_000_000_000_000),
|
||||
DataRepr::Bits.formatted_string(999_999_999_999_999),
|
||||
"999 Tb"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
DataRepr::Packets.formatted_string(1_000_000_000_000_000),
|
||||
"1000000000000000"
|
||||
);
|
||||
assert_eq!(
|
||||
DataRepr::Bytes.formatted_string(1_000_000_000_000_000),
|
||||
"1.0 PB"
|
||||
);
|
||||
assert_eq!(
|
||||
ByteMultiple::formatted_string(1_000_000_000_000_000_0),
|
||||
DataRepr::Bits.formatted_string(1_000_000_000_000_000),
|
||||
"1.0 Pb"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
DataRepr::Packets.formatted_string(1_000_000_000_000_000_0),
|
||||
"10000000000000000"
|
||||
);
|
||||
assert_eq!(
|
||||
DataRepr::Bytes.formatted_string(1_000_000_000_000_000_0),
|
||||
"10 PB"
|
||||
);
|
||||
assert_eq!(
|
||||
ByteMultiple::formatted_string(999_999_999_000_000_000),
|
||||
DataRepr::Bits.formatted_string(1_000_000_000_000_000_0),
|
||||
"10 Pb"
|
||||
);
|
||||
assert_eq!(
|
||||
DataRepr::Packets.formatted_string(999_999_999_000_000_000),
|
||||
"999999999000000000"
|
||||
);
|
||||
assert_eq!(
|
||||
DataRepr::Bytes.formatted_string(999_999_999_000_000_000),
|
||||
"1000 PB"
|
||||
);
|
||||
assert_eq!(
|
||||
ByteMultiple::formatted_string(1_000_000_000_000_000_000_000),
|
||||
"1000000 PB"
|
||||
DataRepr::Bits.formatted_string(999_999_999_000_000_000),
|
||||
"1000 Pb"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
DataRepr::Packets.formatted_string(u128::MAX / 2),
|
||||
"170141183460469231731687303715884105727"
|
||||
);
|
||||
assert_eq!(
|
||||
ByteMultiple::formatted_string(u128::MAX / 2),
|
||||
DataRepr::Bytes.formatted_string(u128::MAX / 2),
|
||||
"170141184077655307190272 PB"
|
||||
);
|
||||
assert_eq!(ByteMultiple::formatted_string(u128::MAX), "inf PB");
|
||||
assert_eq!(
|
||||
DataRepr::Bits.formatted_string(u128::MAX / 2),
|
||||
"170141184077655307190272 Pb"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
DataRepr::Packets.formatted_string(u128::MAX),
|
||||
"340282366920938463463374607431768211455"
|
||||
);
|
||||
assert_eq!(DataRepr::Bytes.formatted_string(u128::MAX), "inf PB");
|
||||
assert_eq!(DataRepr::Bits.formatted_string(u128::MAX), "inf Pb");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ pub fn button_type(self) -> ButtonType {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::report::types::report_col::ReportCol;
|
||||
use crate::report::types::report_sort_type::ReportSortType;
|
||||
use crate::report::types::sort_type::SortType;
|
||||
|
||||
@@ -40,116 +39,39 @@ fn test_next_report_sort() {
|
||||
assert_eq!(
|
||||
sort,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Neutral,
|
||||
packet_sort: SortType::Neutral
|
||||
data_sort: SortType::Neutral,
|
||||
}
|
||||
);
|
||||
|
||||
sort = sort.next_sort(&ReportCol::Packets);
|
||||
sort = sort.next_sort();
|
||||
assert_eq!(
|
||||
sort,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Neutral,
|
||||
packet_sort: SortType::Descending
|
||||
data_sort: SortType::Descending,
|
||||
}
|
||||
);
|
||||
|
||||
sort = sort.next_sort(&ReportCol::Packets);
|
||||
sort = sort.next_sort();
|
||||
assert_eq!(
|
||||
sort,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Neutral,
|
||||
packet_sort: SortType::Ascending
|
||||
data_sort: SortType::Ascending,
|
||||
}
|
||||
);
|
||||
|
||||
sort = sort.next_sort(&ReportCol::Packets);
|
||||
sort = sort.next_sort();
|
||||
assert_eq!(
|
||||
sort,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Neutral,
|
||||
packet_sort: SortType::Neutral
|
||||
data_sort: SortType::Neutral,
|
||||
}
|
||||
);
|
||||
|
||||
sort = sort.next_sort(&ReportCol::Packets);
|
||||
sort = sort.next_sort();
|
||||
assert_eq!(
|
||||
sort,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Neutral,
|
||||
packet_sort: SortType::Descending
|
||||
}
|
||||
);
|
||||
|
||||
sort = sort.next_sort(&ReportCol::Bytes);
|
||||
assert_eq!(
|
||||
sort,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Descending,
|
||||
packet_sort: SortType::Neutral
|
||||
}
|
||||
);
|
||||
|
||||
sort = sort.next_sort(&ReportCol::Packets);
|
||||
assert_eq!(
|
||||
sort,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Neutral,
|
||||
packet_sort: SortType::Descending
|
||||
}
|
||||
);
|
||||
|
||||
sort = sort.next_sort(&ReportCol::Bytes);
|
||||
assert_eq!(
|
||||
sort,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Descending,
|
||||
packet_sort: SortType::Neutral
|
||||
}
|
||||
);
|
||||
|
||||
sort = sort.next_sort(&ReportCol::Bytes);
|
||||
assert_eq!(
|
||||
sort,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Ascending,
|
||||
packet_sort: SortType::Neutral
|
||||
}
|
||||
);
|
||||
|
||||
sort = sort.next_sort(&ReportCol::Packets);
|
||||
assert_eq!(
|
||||
sort,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Neutral,
|
||||
packet_sort: SortType::Descending
|
||||
}
|
||||
);
|
||||
|
||||
sort = sort.next_sort(&ReportCol::Bytes);
|
||||
assert_eq!(
|
||||
sort,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Descending,
|
||||
packet_sort: SortType::Neutral
|
||||
}
|
||||
);
|
||||
|
||||
sort = sort.next_sort(&ReportCol::Bytes);
|
||||
assert_eq!(
|
||||
sort,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Ascending,
|
||||
packet_sort: SortType::Neutral
|
||||
}
|
||||
);
|
||||
|
||||
sort = sort.next_sort(&ReportCol::Bytes);
|
||||
assert_eq!(
|
||||
sort,
|
||||
ReportSortType {
|
||||
byte_sort: SortType::Neutral,
|
||||
packet_sort: SortType::Neutral
|
||||
data_sort: SortType::Descending,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user