Repository Public
1import Foundation2import Testing3import SheetCore4import SheetUI5import FunctionsNumeric6@testable import FeatureAudit78@MainActor enum Fixture {9 static let registered: Bool = { NumericFunctions.register(); return true }()1011 static func session(_ sheets: [String] = ["Sheet1"]) -> WorkbookSession {12 _ = registered13 return WorkbookSession(workbook: Workbook(sheetNames: sheets), locale: Locale(identifier: "en_US"))14 }1516 /// Types rows of text starting at A1 of a sheet.17 static func fill(_ s: WorkbookSession, sheet: Int = 0, at origin: String = "A1", _ rows: [[String]]) {18 let o = CellRef(a1: origin)!19 let parser = s.parser20 s.perform("fill") { e in21 for (r, row) in rows.enumerated() { for (c, text) in row.enumerated() where !text.isEmpty {22 try? e.setInput(sheet: sheet, row: o.row + r, col: o.col + c, text, parser: parser)23 } }24 }25 }2627 /// Region, Units, Price, Revenue: 6 data rows with one exact duplicate (rows 3 and 6) and one blank.28 static func sales() -> WorkbookSession {29 let s = session(["Sales", "Other"])30 fill(s, [31 ["Region", "Units", "Price", "Revenue"],32 ["North", "10", "2.5", "=B2*C2"],33 ["South", "20", "3", "=B3*C3"],34 ["East", "5", "4", "=B4*C4"],35 ["West", "", "1.5", "=B5*C5"],36 ["South", "20", "3", "=B6*C6"],37 ["North", "40", "2", "=B7*C7"],38 ])39 return s40 }4142 static func value(_ s: WorkbookSession, _ a1: String, sheet: Int = 0) -> Value {43 let c = CellRef(a1: a1)!44 return s.workbook.sheets[sheet].value(c.row, c.col)45 }46 static func rg(_ a1: String) -> RangeRef { RangeRef(a1: a1)! }47}48