UPDATE: Dump of initial files
This commit is contained in:
BIN
xlsx/tests/basic_text.xlsx
Normal file
BIN
xlsx/tests/basic_text.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_test_no_export/tables.xlsx
Normal file
BIN
xlsx/tests/calc_test_no_export/tables.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/ABS.xlsx
Normal file
BIN
xlsx/tests/calc_tests/ABS.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/ATAN2_POWER.xlsx
Normal file
BIN
xlsx/tests/calc_tests/ATAN2_POWER.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/AVERAGE.xlsx
Normal file
BIN
xlsx/tests/calc_tests/AVERAGE.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/BESSEL.xlsx
Normal file
BIN
xlsx/tests/calc_tests/BESSEL.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/BITs.xlsx
Normal file
BIN
xlsx/tests/calc_tests/BITs.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/CHOOSE.xlsx
Normal file
BIN
xlsx/tests/calc_tests/CHOOSE.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/COMPLEXs.xlsx
Normal file
BIN
xlsx/tests/calc_tests/COMPLEXs.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/CONCAT.xlsx
Normal file
BIN
xlsx/tests/calc_tests/CONCAT.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/CONCATENATE.xlsx
Normal file
BIN
xlsx/tests/calc_tests/CONCATENATE.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/CONVERT.xlsx
Normal file
BIN
xlsx/tests/calc_tests/CONVERT.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/COUNT.xlsx
Normal file
BIN
xlsx/tests/calc_tests/COUNT.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/COUNTIF.xlsx
Normal file
BIN
xlsx/tests/calc_tests/COUNTIF.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/COUNTIFS.xlsx
Normal file
BIN
xlsx/tests/calc_tests/COUNTIFS.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/CUMPRINC_CUMIPMT.xlsx
Normal file
BIN
xlsx/tests/calc_tests/CUMPRINC_CUMIPMT.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/DATE_DAY_MONTH_YEAR.xlsx
Normal file
BIN
xlsx/tests/calc_tests/DATE_DAY_MONTH_YEAR.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/DB_DDB.xlsx
Normal file
BIN
xlsx/tests/calc_tests/DB_DDB.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/DOLLARs.xlsx
Normal file
BIN
xlsx/tests/calc_tests/DOLLARs.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/EOMONTH.xlsx
Normal file
BIN
xlsx/tests/calc_tests/EOMONTH.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/ERFs.xlsx
Normal file
BIN
xlsx/tests/calc_tests/ERFs.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/ERROR.TYPE.xlsx
Normal file
BIN
xlsx/tests/calc_tests/ERROR.TYPE.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/EXACT.xlsx
Normal file
BIN
xlsx/tests/calc_tests/EXACT.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/FIND_SEARCH.xlsx
Normal file
BIN
xlsx/tests/calc_tests/FIND_SEARCH.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/FV.xlsx
Normal file
BIN
xlsx/tests/calc_tests/FV.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/GESTEP_DELTA.xlsx
Normal file
BIN
xlsx/tests/calc_tests/GESTEP_DELTA.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/HVLOOKUP.xlsx
Normal file
BIN
xlsx/tests/calc_tests/HVLOOKUP.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/IFNA.xlsx
Normal file
BIN
xlsx/tests/calc_tests/IFNA.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/IFS.xlsx
Normal file
BIN
xlsx/tests/calc_tests/IFS.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/IPMT_PPMT.xlsx
Normal file
BIN
xlsx/tests/calc_tests/IPMT_PPMT.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/IRR.xlsx
Normal file
BIN
xlsx/tests/calc_tests/IRR.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/ISPMT.xlsx
Normal file
BIN
xlsx/tests/calc_tests/ISPMT.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/ISREF_ISFORMULA_ISODD_ISEVEN.xlsx
Normal file
BIN
xlsx/tests/calc_tests/ISREF_ISFORMULA_ISODD_ISEVEN.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/IS_INFORMATION.xlsx
Normal file
BIN
xlsx/tests/calc_tests/IS_INFORMATION.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/MATCH.xlsx
Normal file
BIN
xlsx/tests/calc_tests/MATCH.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/MIN_MAX.xlsx
Normal file
BIN
xlsx/tests/calc_tests/MIN_MAX.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/MIRR.xlsx
Normal file
BIN
xlsx/tests/calc_tests/MIRR.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/NOMINAL_EFFECT.xlsx
Normal file
BIN
xlsx/tests/calc_tests/NOMINAL_EFFECT.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/NPER.xlsx
Normal file
BIN
xlsx/tests/calc_tests/NPER.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/NPV.xlsx
Normal file
BIN
xlsx/tests/calc_tests/NPV.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/NUMBER_SYSTEMS.xlsx
Normal file
BIN
xlsx/tests/calc_tests/NUMBER_SYSTEMS.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/PDURATION.xlsx
Normal file
BIN
xlsx/tests/calc_tests/PDURATION.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/PMT.xlsx
Normal file
BIN
xlsx/tests/calc_tests/PMT.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/PRODUCT.xlsx
Normal file
BIN
xlsx/tests/calc_tests/PRODUCT.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/PV.xlsx
Normal file
BIN
xlsx/tests/calc_tests/PV.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/RATE.xlsx
Normal file
BIN
xlsx/tests/calc_tests/RATE.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/REPT.xlsx
Normal file
BIN
xlsx/tests/calc_tests/REPT.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/ROUND.xlsx
Normal file
BIN
xlsx/tests/calc_tests/ROUND.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/ROW_COLUM.xlsx
Normal file
BIN
xlsx/tests/calc_tests/ROW_COLUM.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/RRI.xlsx
Normal file
BIN
xlsx/tests/calc_tests/RRI.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/SLN_SYD.xlsx
Normal file
BIN
xlsx/tests/calc_tests/SLN_SYD.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/SQRT_SQRTPI.xlsx
Normal file
BIN
xlsx/tests/calc_tests/SQRT_SQRTPI.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/STRING_HANDLING.xlsx
Normal file
BIN
xlsx/tests/calc_tests/STRING_HANDLING.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/SUBSTITUTE.xlsx
Normal file
BIN
xlsx/tests/calc_tests/SUBSTITUTE.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/SUMIFS.xlsx
Normal file
BIN
xlsx/tests/calc_tests/SUMIFS.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/SUMIF_AVERAGE_IF.xlsx
Normal file
BIN
xlsx/tests/calc_tests/SUMIF_AVERAGE_IF.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/TBILLs.xlsx
Normal file
BIN
xlsx/tests/calc_tests/TBILLs.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/TEXT.xlsx
Normal file
BIN
xlsx/tests/calc_tests/TEXT.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/TEXTBEFORE_TEXTAFTER.xlsx
Normal file
BIN
xlsx/tests/calc_tests/TEXTBEFORE_TEXTAFTER.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/TEXTJOIN.xlsx
Normal file
BIN
xlsx/tests/calc_tests/TEXTJOIN.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/TYPE.xlsx
Normal file
BIN
xlsx/tests/calc_tests/TYPE.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/T_VALUE_VALUETOTEXT.xlsx
Normal file
BIN
xlsx/tests/calc_tests/T_VALUE_VALUETOTEXT.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/XIRR.xlsx
Normal file
BIN
xlsx/tests/calc_tests/XIRR.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/XLOOKUP.xlsx
Normal file
BIN
xlsx/tests/calc_tests/XLOOKUP.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/XNPV.xlsx
Normal file
BIN
xlsx/tests/calc_tests/XNPV.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/arithmetic.xlsx
Normal file
BIN
xlsx/tests/calc_tests/arithmetic.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/defined_names.xlsx
Normal file
BIN
xlsx/tests/calc_tests/defined_names.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/defined_names_for_unit_test.xlsx
Normal file
BIN
xlsx/tests/calc_tests/defined_names_for_unit_test.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/issue_341.xlsx
Normal file
BIN
xlsx/tests/calc_tests/issue_341.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/logical.xlsx
Normal file
BIN
xlsx/tests/calc_tests/logical.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/percentage.xlsx
Normal file
BIN
xlsx/tests/calc_tests/percentage.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/quotes.xlsx
Normal file
BIN
xlsx/tests/calc_tests/quotes.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/range_operator.xlsx
Normal file
BIN
xlsx/tests/calc_tests/range_operator.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/simple_functions.xlsx
Normal file
BIN
xlsx/tests/calc_tests/simple_functions.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/calc_tests/trigonometric_functions.xlsx
Normal file
BIN
xlsx/tests/calc_tests/trigonometric_functions.xlsx
Normal file
Binary file not shown.
2524
xlsx/tests/example.json
Normal file
2524
xlsx/tests/example.json
Normal file
File diff suppressed because it is too large
Load Diff
BIN
xlsx/tests/example.xlsx
Normal file
BIN
xlsx/tests/example.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/freeze.xlsx
Normal file
BIN
xlsx/tests/freeze.xlsx
Normal file
Binary file not shown.
BIN
xlsx/tests/split.xlsx
Normal file
BIN
xlsx/tests/split.xlsx
Normal file
Binary file not shown.
243
xlsx/tests/test.rs
Normal file
243
xlsx/tests/test.rs
Normal file
@@ -0,0 +1,243 @@
|
||||
use std::{env, fs, io};
|
||||
use uuid::Uuid;
|
||||
|
||||
use ironcalc::compare::{test_file, test_load_and_saving};
|
||||
use ironcalc::export::save_to_xlsx;
|
||||
use ironcalc::import::{load_from_excel, load_model_from_xlsx};
|
||||
use ironcalc_base::model::Model;
|
||||
use ironcalc_base::types::{HorizontalAlignment, VerticalAlignment, Workbook};
|
||||
|
||||
// This is a functional test.
|
||||
// We check that the output of example.xlsx is what we expect.
|
||||
#[test]
|
||||
fn test_example() {
|
||||
let model = load_from_excel("tests/example.xlsx", "en", "UTC").unwrap();
|
||||
assert_eq!(model.worksheets[0].frozen_rows, 0);
|
||||
assert_eq!(model.worksheets[0].frozen_columns, 0);
|
||||
let contents =
|
||||
fs::read_to_string("tests/example.json").expect("Something went wrong reading the file");
|
||||
let model2: Workbook = serde_json::from_str(&contents).unwrap();
|
||||
let s = serde_json::to_string(&model).unwrap();
|
||||
assert_eq!(model, model2, "{s}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_save_to_xlsx() {
|
||||
let mut model = load_model_from_xlsx("tests/example.xlsx", "en", "UTC").unwrap();
|
||||
model.evaluate();
|
||||
let temp_file_name = "temp_file_example.xlsx";
|
||||
// test can safe
|
||||
save_to_xlsx(&model, temp_file_name).unwrap();
|
||||
// test can open
|
||||
let model = load_model_from_xlsx(temp_file_name, "en", "UTC").unwrap();
|
||||
let metadata = &model.workbook.metadata;
|
||||
assert_eq!(metadata.application, "IronCalc Sheets");
|
||||
// FIXME: This will need to be updated once we fix versioning
|
||||
assert_eq!(metadata.app_version, "10.0000");
|
||||
// TODO: can we show it is the 'same' model?
|
||||
fs::remove_file(temp_file_name).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_freeze() {
|
||||
// freeze has 3 frozen columns and 2 frozen rows
|
||||
let model = load_from_excel("tests/freeze.xlsx", "en", "UTC").unwrap();
|
||||
assert_eq!(model.worksheets[0].frozen_rows, 2);
|
||||
assert_eq!(model.worksheets[0].frozen_columns, 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_split() {
|
||||
// We test that a workbook with split panes do not produce frozen rows and columns
|
||||
let model = load_from_excel("tests/split.xlsx", "en", "UTC").unwrap();
|
||||
assert_eq!(model.worksheets[0].frozen_rows, 0);
|
||||
assert_eq!(model.worksheets[0].frozen_columns, 0);
|
||||
}
|
||||
|
||||
fn test_model_has_correct_styles(model: &Model) {
|
||||
// A1 is bold
|
||||
let style_a1 = model.get_style_for_cell(0, 1, 1);
|
||||
assert!(style_a1.font.b);
|
||||
assert!(!style_a1.font.i);
|
||||
assert!(!style_a1.font.u);
|
||||
|
||||
// B1 is Italics
|
||||
let style_b1 = model.get_style_for_cell(0, 1, 2);
|
||||
assert!(style_b1.font.i);
|
||||
assert!(!style_b1.font.b);
|
||||
assert!(!style_b1.font.u);
|
||||
|
||||
// C1 Underlined
|
||||
let style_c1 = model.get_style_for_cell(0, 1, 3);
|
||||
assert!(style_c1.font.u);
|
||||
assert!(!style_c1.font.b);
|
||||
assert!(!style_c1.font.i);
|
||||
|
||||
// D1 Bold and Italics
|
||||
let style_d1 = model.get_style_for_cell(0, 1, 4);
|
||||
assert!(style_d1.font.b);
|
||||
assert!(style_d1.font.i);
|
||||
assert!(!style_d1.font.u);
|
||||
|
||||
// E1 Bold, italics and underlined
|
||||
let style_e1 = model.get_style_for_cell(0, 1, 5);
|
||||
assert!(style_e1.font.b);
|
||||
assert!(style_e1.font.i);
|
||||
assert!(style_e1.font.u);
|
||||
assert!(!style_e1.font.strike);
|
||||
|
||||
// F1 strikethrough
|
||||
let style_f1 = model.get_style_for_cell(0, 1, 6);
|
||||
assert!(style_f1.font.strike);
|
||||
|
||||
// G1 Double underlined just get simple underlined
|
||||
let style_g1 = model.get_style_for_cell(0, 1, 7);
|
||||
assert!(style_g1.font.u);
|
||||
|
||||
let height_row_3 = model.workbook.worksheet(0).unwrap().row_height(3).unwrap();
|
||||
assert_eq!(height_row_3, 136.0);
|
||||
|
||||
let height_row_5 = model.workbook.worksheet(0).unwrap().row_height(5).unwrap();
|
||||
assert_eq!(height_row_5, 62.0);
|
||||
|
||||
// Second sheet has alignment
|
||||
// Horizontal
|
||||
let alignment = model.get_style_for_cell(1, 2, 1).alignment;
|
||||
assert_eq!(alignment, None);
|
||||
|
||||
let alignment = model.get_style_for_cell(1, 3, 1).alignment.unwrap();
|
||||
assert_eq!(alignment.horizontal, HorizontalAlignment::Left);
|
||||
|
||||
let alignment = model.get_style_for_cell(1, 4, 1).alignment.unwrap();
|
||||
assert_eq!(alignment.horizontal, HorizontalAlignment::Distributed);
|
||||
|
||||
let alignment = model.get_style_for_cell(1, 5, 1).alignment.unwrap();
|
||||
assert_eq!(alignment.horizontal, HorizontalAlignment::Right);
|
||||
|
||||
let alignment = model.get_style_for_cell(1, 6, 1).alignment.unwrap();
|
||||
assert_eq!(alignment.horizontal, HorizontalAlignment::Center);
|
||||
|
||||
let alignment = model.get_style_for_cell(1, 7, 1).alignment.unwrap();
|
||||
assert_eq!(alignment.horizontal, HorizontalAlignment::Fill);
|
||||
|
||||
let alignment = model.get_style_for_cell(1, 8, 1).alignment.unwrap();
|
||||
assert_eq!(alignment.horizontal, HorizontalAlignment::Justify);
|
||||
|
||||
// Vertical
|
||||
let alignment = model.get_style_for_cell(1, 2, 2).alignment;
|
||||
assert_eq!(alignment, None);
|
||||
|
||||
let alignment = model.get_style_for_cell(1, 3, 2).alignment;
|
||||
assert_eq!(alignment, None);
|
||||
|
||||
let alignment = model.get_style_for_cell(1, 4, 2).alignment.unwrap();
|
||||
assert_eq!(alignment.vertical, VerticalAlignment::Top);
|
||||
|
||||
let alignment = model.get_style_for_cell(1, 5, 2).alignment.unwrap();
|
||||
assert_eq!(alignment.vertical, VerticalAlignment::Center);
|
||||
|
||||
let alignment = model.get_style_for_cell(1, 6, 2).alignment.unwrap();
|
||||
assert_eq!(alignment.vertical, VerticalAlignment::Justify);
|
||||
|
||||
let alignment = model.get_style_for_cell(1, 7, 2).alignment.unwrap();
|
||||
assert_eq!(alignment.vertical, VerticalAlignment::Distributed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simple_text() {
|
||||
let model = load_model_from_xlsx("tests/basic_text.xlsx", "en", "UTC").unwrap();
|
||||
|
||||
test_model_has_correct_styles(&model);
|
||||
|
||||
let temp_file_name = "temp_file_test_named_styles.xlsx";
|
||||
save_to_xlsx(&model, temp_file_name).unwrap();
|
||||
|
||||
let model = load_model_from_xlsx(temp_file_name, "en", "UTC").unwrap();
|
||||
fs::remove_file(temp_file_name).unwrap();
|
||||
test_model_has_correct_styles(&model);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_defined_names_casing() {
|
||||
let test_file_path = "tests/calc_tests/defined_names_for_unit_test.xlsx";
|
||||
let loaded_workbook = load_from_excel(test_file_path, "en", "UTC").unwrap();
|
||||
let mut model = Model::from_json(&serde_json::to_string(&loaded_workbook).unwrap()).unwrap();
|
||||
|
||||
let (row, column) = (2, 13); // B13
|
||||
let test_cases = [
|
||||
("=named1", "11"),
|
||||
("=NAMED1", "11"),
|
||||
("=NaMeD1", "11"),
|
||||
("=named2", "22"),
|
||||
("=NAMED2", "22"),
|
||||
("=NaMeD2", "22"),
|
||||
("=named3", "33"),
|
||||
("=NAMED3", "33"),
|
||||
("=NaMeD3", "33"),
|
||||
];
|
||||
for (formula, expected_value) in test_cases {
|
||||
model.set_user_input(0, row, column, formula.to_string());
|
||||
model.evaluate();
|
||||
assert_eq!(
|
||||
model.formatted_cell_value(0, row, column).unwrap(),
|
||||
expected_value
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_xlsx() {
|
||||
let mut entries = fs::read_dir("tests/calc_tests/")
|
||||
.unwrap()
|
||||
.map(|res| res.map(|e| e.path()))
|
||||
.collect::<Result<Vec<_>, io::Error>>()
|
||||
.unwrap();
|
||||
entries.sort();
|
||||
let temp_folder = env::temp_dir();
|
||||
let path = format!("{}", Uuid::new_v4());
|
||||
let dir = temp_folder.join(path);
|
||||
fs::create_dir(&dir).unwrap();
|
||||
for file_path in entries {
|
||||
let file_name_str = file_path.file_name().unwrap().to_str().unwrap();
|
||||
let file_path_str = file_path.to_str().unwrap();
|
||||
println!("Testing file: {}", file_path_str);
|
||||
if file_name_str.ends_with(".xlsx") && !file_name_str.starts_with('~') {
|
||||
if let Err(message) = test_file(file_path_str) {
|
||||
println!("{}", message);
|
||||
panic!("Model was evaluated inconsistently with XLSX data.")
|
||||
}
|
||||
assert!(test_load_and_saving(file_path_str, &dir).is_ok());
|
||||
} else {
|
||||
println!("skipping");
|
||||
}
|
||||
}
|
||||
fs::remove_dir_all(&dir).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_export() {
|
||||
let mut entries = fs::read_dir("tests/calc_test_no_export/")
|
||||
.unwrap()
|
||||
.map(|res| res.map(|e| e.path()))
|
||||
.collect::<Result<Vec<_>, io::Error>>()
|
||||
.unwrap();
|
||||
entries.sort();
|
||||
let temp_folder = env::temp_dir();
|
||||
let path = format!("{}", Uuid::new_v4());
|
||||
let dir = temp_folder.join(path);
|
||||
fs::create_dir(&dir).unwrap();
|
||||
for file_path in entries {
|
||||
let file_name_str = file_path.file_name().unwrap().to_str().unwrap();
|
||||
let file_path_str = file_path.to_str().unwrap();
|
||||
println!("Testing file: {}", file_path_str);
|
||||
if file_name_str.ends_with(".xlsx") && !file_name_str.starts_with('~') {
|
||||
if let Err(message) = test_file(file_path_str) {
|
||||
println!("{}", message);
|
||||
panic!("Model was evaluated inconsistently with XLSX data.")
|
||||
}
|
||||
} else {
|
||||
println!("skipping");
|
||||
}
|
||||
}
|
||||
fs::remove_dir_all(&dir).unwrap();
|
||||
}
|
||||
Reference in New Issue
Block a user