diff options
author | Arturs Artamonovs <arturs.artamonovs@protonmail.com> | 2025-02-03 22:31:45 +0000 |
---|---|---|
committer | Arturs Artamonovs <arturs.artamonovs@protonmail.com> | 2025-02-03 22:31:45 +0000 |
commit | 972a6d3e4d3b684fbadeb5cd046a8634ec24eb8c (patch) | |
tree | e96c4ce2d649558cc0b7b452d7a64fbe980b65c0 /PrySDR_Tests | |
parent | 1e096e55ca30dc80c3faa8d1ea36de13bc90cc6a (diff) | |
download | PrySDR-main.tar.gz PrySDR-main.zip |
iqconvert: converts from u8 to f32 without issuesmain
Diffstat (limited to 'PrySDR_Tests')
-rw-r--r-- | PrySDR_Tests/PrySDR_Tests.swift | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/PrySDR_Tests/PrySDR_Tests.swift b/PrySDR_Tests/PrySDR_Tests.swift new file mode 100644 index 0000000..70b9828 --- /dev/null +++ b/PrySDR_Tests/PrySDR_Tests.swift @@ -0,0 +1,79 @@ +// +// 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) + } + */ +} |