// PolyBLEPHelperTests.swift // Lyrebird // // Copyright (c) 2026 Joshua Parmenter / realizedsound // SPDX-License-Identifier: MIT import Testing @testable @_spi(LyrebirdExtensions) import LyrebirdSynth // MARK: - polyBLEP / polyBLAMP unit tests @Suite("PolyBLEP helpers") struct PolyBLEPHelperTests { @Test("polyBLEP returns 0 far from discontinuity") func testPolyBLEPFarFromDiscontinuity() { // At t = 0.5, dt = 0.01: far from both edges #expect(polyBLEP(0.5, 0.01) == 0.0) } @Test("polyBLEP returns non-zero near rising edge") func testPolyBLEPNearRisingEdge() { // At t = 0.005, dt = 0.01: within dt of rising edge (t < dt) let correction: Double = polyBLEP(0.005, 0.01) #expect(correction != 0.0) } @Test("polyBLEP returns non-zero near falling edge") func testPolyBLEPNearFallingEdge() { // At t = 0.995, dt = 0.01: within dt of falling edge (t > 1 - dt) let correction: Double = polyBLEP(0.995, 0.01) #expect(correction != 0.0) } @Test("polyBLAMP returns 0 far from corner") func testPolyBLAMPFarFromCorner() { #expect(polyBLAMP(0.5, 0.01) == 0.0) } @Test("polyBLAMP returns non-zero near corner") func testPolyBLAMPNearCorner() { let correction: Double = polyBLAMP(0.005, 0.01) #expect(correction != 0.0) } }