FIX: NOW shows now formatted output
This commit is contained in:
committed by
Nicolás Hatcher Andrés
parent
acf334074f
commit
dd78db3d2b
@@ -75,6 +75,7 @@ mod test_log;
|
||||
mod test_log10;
|
||||
mod test_mod_quotient;
|
||||
mod test_networkdays;
|
||||
mod test_now;
|
||||
mod test_percentage;
|
||||
mod test_set_functions_error_handling;
|
||||
mod test_sheet_names;
|
||||
|
||||
30
base/src/test/test_now.rs
Normal file
30
base/src/test/test_now.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
use crate::{mock_time, test::util::new_empty_model};
|
||||
|
||||
// 14:44 20 Mar 2023 Berlin
|
||||
const TIMESTAMP_2023: i64 = 1679319865208;
|
||||
|
||||
#[test]
|
||||
fn arguments() {
|
||||
let mut model = new_empty_model();
|
||||
|
||||
model._set("A1", "=NOW(1)");
|
||||
model.evaluate();
|
||||
|
||||
assert_eq!(
|
||||
model._get_text("A1"),
|
||||
"#ERROR!",
|
||||
"NOW should not accept arguments"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_date_time() {
|
||||
mock_time::set_mock_time(TIMESTAMP_2023);
|
||||
let mut model = new_empty_model();
|
||||
model._set("A1", "=NOW()");
|
||||
model.evaluate();
|
||||
let text = model._get_text("A1");
|
||||
assert_eq!(text, *"20/03/2023 13:44:25");
|
||||
}
|
||||
@@ -33,7 +33,8 @@ fn now_basic_utc() {
|
||||
model.evaluate();
|
||||
|
||||
assert_eq!(model._get_text("A1"), *"20/03/2023");
|
||||
assert_eq!(model._get_text("A2"), *"45005.572511574");
|
||||
// 45005.572511574
|
||||
assert_eq!(model._get_text("A2"), *"20/03/2023 13:44:25");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -46,5 +47,5 @@ fn now_basic_europe_berlin() {
|
||||
|
||||
assert_eq!(model._get_text("A1"), *"20/03/2023");
|
||||
// This is UTC + 1 hour: 45005.572511574 + 1/24
|
||||
assert_eq!(model._get_text("A2"), *"45005.614178241");
|
||||
assert_eq!(model._get_text("A2"), *"20/03/2023 14:44:25");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user