blob: ebe23b9e119d5f1990e61d66f02972dd2687c04f (
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
|
//
// TestDataConverters.swift
// PrySDR
//
// Created by Jacky Jack on 04/02/2025.
//
import Foundation
import Testing
import Numerics
struct IQTypeConvertes_Tests {
@Test func cnvU8dataToInt16() async throws {
let d1 = Data([0,0])
let r1 = [Int16](asInt16(d1))
#expect(r1[0] == 0)
let d2 = Data([0,1])
let r2 = [Int16](asInt16(d2))
#expect(r2[0] == 1)
let d3 = Data([255,255])
let r3 = [Int16](asInt16(d3))
#expect(r3[0] == -1)
let d4 = Data([128,0])
let r4 = [Int16](asInt16(d4))
#expect(r4[0] == -32768)
}
@Test func cnvU8dataToUInt16() async throws {
let d1 = Data([0,0])
let r1 = [UInt16](asUInt16(d1))
#expect(r1[0] == 0)
let d2 = Data([0,1])
let r2 = [UInt16](asUInt16(d2))
#expect(r2[0] == 1)
let d3 = Data([255,255])
let r3 = [UInt16](asUInt16(d3))
#expect(r3[0] == 65535)
let d4 = Data([128,0])
let r4 = [UInt16](asUInt16(d4))
#expect(r4[0] == 32768)
}
@Test func cnvU8dataToSC16Q11() async throws {
let d1 = Data([0,0])
let r1 = [Int16](asSC16Q11(d1))
#expect(r1[0] == 0)
let d2 = Data([0,1])
let r2 = [Int16](asSC16Q11(d2))
#expect(r2[0] == 1)
let d4 = Data([0x07,0xff])
let r4 = [Int16](asSC16Q11(d4))
#expect(r4[0] == 2047)
let d3 = Data([0x0f,0xff])
let r3 = [Int16](asSC16Q11(d3))
#expect(r3[0] == -2048)
}
@Test func testSpeed() async throws {
//measure(label:"Start") {
// print("Hello")
//}
}
}
|