56 lines
2.1 KiB
Swift
56 lines
2.1 KiB
Swift
//___FILEHEADER___
|
|
|
|
import Testing
|
|
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
|
|
|
// MARK: - ___FILEBASENAMEASIDENTIFIER___
|
|
|
|
/// Test suite for ___FILEBASENAMEASIDENTIFIER___'s subject Generator.
|
|
///
|
|
/// Add @Test methods for: parameter ranges, edge cases (zero / negative freq,
|
|
/// out-of-range mul/add, exhausted state, reset), block-size correctness,
|
|
/// channel-count claims (`outputChannelCount`), and any RT-safety invariants.
|
|
///
|
|
/// `makeTestEngine`, `makeSynthGraph`, and `advanceBlock` live in
|
|
/// `Tests/LyrebirdTests/TestHelpers.swift` and are intentionally module-internal
|
|
/// — this file only compiles when dropped under `Tests/LyrebirdTests/`.
|
|
@Suite("___FILEBASENAMEASIDENTIFIER___")
|
|
struct ___FILEBASENAMEASIDENTIFIER___ {
|
|
|
|
/// Subject under test produces finite output for a single block.
|
|
@Test func outputIsFinite() throws {
|
|
let engine = makeTestEngine(blockSize: 64)
|
|
try engine.start()
|
|
defer { engine.stop() }
|
|
|
|
// Replace OscSin.Audio with the Generator you are testing.
|
|
let gen = OscSin.Audio(freq: 440.0)
|
|
|
|
let g = makeSynthGraph(engine: engine)
|
|
let out = gen.calculatedSamples(graph: g, count: 64)
|
|
let samples = Array((out.first ?? []).prefix(64))
|
|
|
|
#expect(samples.count == 64)
|
|
#expect(samples.allSatisfy { $0.isFinite })
|
|
}
|
|
|
|
/// Subject under test advances state across blocks — output of block 2
|
|
/// differs from output of block 1 for a non-DC signal.
|
|
@Test func stateAdvancesAcrossBlocks() throws {
|
|
let engine = makeTestEngine(blockSize: 64)
|
|
try engine.start()
|
|
defer { engine.stop() }
|
|
|
|
let gen = OscSin.Audio(freq: 440.0)
|
|
|
|
let g1 = makeSynthGraph(engine: engine)
|
|
let block1 = Array((gen.calculatedSamples(graph: g1, count: 64).first ?? []).prefix(64))
|
|
advanceBlock(engine)
|
|
|
|
let g2 = makeSynthGraph(engine: engine)
|
|
let block2 = Array((gen.calculatedSamples(graph: g2, count: 64).first ?? []).prefix(64))
|
|
|
|
#expect(block1 != block2, "Generator should advance state between blocks")
|
|
}
|
|
}
|