// // PrySDR_Tests.swift // PrySDR_Tests // // Created by Jacky Jack on 21/01/2025. // import Testing import Numerics struct IQConverter_Tests { @Test func convertU8arrayToFloat32_accel_size1() async throws { // Write your test here and use APIs like `#expect(...)` to check expected conditions. let arr1:[UInt8] = [0] let res1 = cnvU8toFloat32_accel(arr1) #expect(res1[0].truncate(places: 3) == -0.997) //#expect(res1[0].isApproximatelyEqual(to: -0.997, absoluteTolerance: 0.001)) let arr2:[UInt8] = [255] let res2 = cnvU8toFloat32_accel(arr2) #expect(res2[0].truncate(places: 3) == 0.996) let arr3:[UInt8] = [127] let res3 = cnvU8toFloat32_accel(arr3) #expect(res3[0].truncate(places: 3) == -0.004) let arr4:[UInt8] = [128] let res4 = cnvU8toFloat32_accel(arr4) #expect(res4[0].truncate(places: 3) == 0.003) } /* @Test func cnvU8arrayToFloat32_size16() async throws { // Write your test here and use APIs like `#expect(...)` to check expected conditions. #expect(false) } */ /* @Test func cnvU8arrayToFloat32_size1024() async throws { // Write your test here and use APIs like `#expect(...)` to check expected conditions. #expect(false) } */ @Test func cnvU8arrayToFloat32_naive_size1() async throws { // Write your test here and use APIs like `#expect(...)` to check expected conditions. let arr1:[UInt8] = [0] let res1 = cnvU8toFloat32(arr1) //minus truncates to "up" #expect(res1[0].truncate(places: 3) == -0.997) let arr2:[UInt8] = [255] let res2 = cnvU8toFloat32(arr2) #expect(res2[0].truncate(places: 3) == 0.996) let arr3:[UInt8] = [127] let res3 = cnvU8toFloat32(arr3) //minus truncates to "up" #expect(res3[0].truncate(places: 3) == -0.004) let arr4:[UInt8] = [128] let res4 = cnvU8toFloat32(arr4) #expect(res4[0].truncate(places: 3) == 0.003) } /* @Test func cnvU8arrayToFloat32_naive_size16() async throws { // Write your test here and use APIs like `#expect(...)` to check expected conditions. #expect(false) } */ /* @Test func cnvU8arrayToFloat32_naive_size1024() async throws { // Write your test here and use APIs like `#expect(...)` to check expected conditions. #expect(false) } */ }