summaryrefslogtreecommitdiff
path: root/PrySDR_Tests/PrySDR_Tests.swift
diff options
context:
space:
mode:
Diffstat (limited to 'PrySDR_Tests/PrySDR_Tests.swift')
-rw-r--r--PrySDR_Tests/PrySDR_Tests.swift79
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)
+ }
+ */
+}