Skip to content

Commit

Permalink
test: add a few example of formulas with suffixes
Browse files Browse the repository at this point in the history
That matches what the documentation says, but it can be surprising
that "32G" is still interpreted as the number of megabytes.
  • Loading branch information
keszybz committed Nov 20, 2024
1 parent 766bfb0 commit a6df332
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,30 @@ foo=0
);
}

#[test]
fn test_eval_size_expression_500() {
assert_eq!(
dev_with_zram_size_size(Some("500"), 5000),
500 * 1024 * 1024
);
}

#[test]
fn test_eval_size_expression_500k() {
assert_eq!(
dev_with_zram_size_size(Some("500k"), 5000),
500 * 1000 * 1024 * 1024
);
}

#[test]
fn test_eval_size_expression_32g() {
assert_eq!(
dev_with_zram_size_size(Some("32G"), 5000),
32 * 1000_000_000 * 1024 * 1024
);
}

#[test]
fn test_eval_size_expression_default() {
assert_eq!(dev_with_zram_size_size(None, 100), 50 * 1024 * 1024);
Expand Down

0 comments on commit a6df332

Please sign in to comment.