summaryrefslogtreecommitdiff
path: root/PrySDR_Tests/PrySDR_Tests.swift
blob: 70b9828d630072845665da4a83f0556075b961aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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)
    }
     */
}