use spreadsheet_ods_cellref::{CellRange, CellRef, ColRange, RowRange}; #[test] fn test_cellref() { let c = CellRef::new(); assert_eq!(c.to_formula(), "[.A1]"); let c = CellRef::remote("table2", 17, 44); assert_eq!(c.to_formula(), "[table2.AS18]"); let c = CellRef::remote("table 2", 17, 44); assert_eq!(c.to_formula(), "['table 2'.AS18]"); let c = CellRef::local(33, 5); assert_eq!(c.to_formula(), "[.F34]"); assert_eq!(c.absolute().to_formula(), "[.$F$34]"); let c = CellRef::local(33, 5); assert_eq!(c.absolute_row().to_formula(), "[.F$34]"); let c = CellRef::local(33, 5); assert_eq!(c.absolute_col().to_formula(), "[.$F34]"); let c = CellRef::try_from(".B2").unwrap(); assert_eq!(c.to_string(), ".B2"); } #[test] fn test_cell_range() { let c = CellRange::new(); assert_eq!(c.to_string(), ".A1:.A1"); let c = CellRange::local(4, 2, 8, 2); assert_eq!(c.to_string(), ".C5:.C9"); let c = CellRange::remote("table2", 4, 2, 8, 2); assert_eq!(c.to_string(), "table2.C5:.C9"); let c = CellRange::origin_span(1, 1, (1, 1)); assert_eq!(c.to_string(), ".B2:.B2"); let c = CellRange::try_from(".AK47:.BB333").unwrap(); assert_eq!(c.to_string(), ".AK47:.BB333"); } #[test] fn test_col_range() { let c = ColRange::new(2, 4); assert_eq!(c.to_string(), ".C:.E"); let c = ColRange::try_from(".$C:.$E").unwrap(); assert_eq!(c.to_string(), ".$C:.$E"); } #[test] fn test_row_range() { let c = RowRange::new(2, 4); assert_eq!(c.to_string(), ".3:.5"); let c = RowRange::try_from(".277:.348").unwrap(); assert_eq!(c.to_string(), ".277:.348"); }