remora-kit

RemoraKit, shared dive computer engine (Buhlmann ZHL-16C + GF) and SwiftUI components for Open Remora and Open Merou
git clone https://git.schurger.org/remora-kit.git
Log | Files | Refs | README | LICENSE

SampleDiveExportTests.swift (1606B)


      1 // SPDX-License-Identifier: GPL-2.0-only
      2 import Foundation
      3 import Testing
      4 @testable import RemoraDeco
      5 
      6 /// Builds a test dive in the shared-folder format (JSON + UDDF), to exercise the Sub Rascasse import.
      7 /// Runs only when SAMPLE_DIVE_DIR (output folder) is set. The profile is computed, but `source = remora` so it
      8 /// gets past the simulation filter: the site and notes say clearly that it is a test, to be deleted.
      9 @Suite("Sample dive")
     10 struct SampleDiveExportTests {
     11     static let dir = ProcessInfo.processInfo.environment["SAMPLE_DIVE_DIR"]
     12 
     13     @Test(.enabled(if: dir != nil))
     14     func writeSampleDive() throws {
     15         let start = ISO8601DateFormatter().date(from: "2026-11-13T15:00:00Z")!
     16         var dive = simulateDive(depth: 18, bottomMinutes: 25, start: start, logbook: Logbook())
     17         dive.site = "Open Rémora test"
     18         dive.notes = "Test dive generated by the Open Rémora engine to exercise the import (computed profile, not a real dive). Delete it."
     19         dive.number = 1
     20         #expect(dive.source == .remora)
     21 
     22         let encoder = JSONEncoder()
     23         encoder.dateEncodingStrategy = .iso8601
     24         encoder.outputFormatting = [.sortedKeys]
     25         let base = URL(fileURLWithPath: Self.dir!).appendingPathComponent(dive.id.uuidString)
     26         try encoder.encode(dive).write(to: base.appendingPathExtension("json"))
     27         try UDDF.export([dive]).write(to: base.appendingPathExtension("uddf"), atomically: true, encoding: .utf8)
     28         print("WROTE \(base.path).json and .uddf: \(dive.samples.count) samples, \(dive.maxDepth) m, \(Int(dive.duration / 60)) min")
     29     }
     30 }