-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e069e26
commit b9b42f1
Showing
326 changed files
with
25,971 additions
and
1,045 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// | ||
// Use this file to import your target's public headers that you would like to expose to Swift. | ||
// | ||
|
60 changes: 60 additions & 0 deletions
60
...ckoTests/DataModels/BluetoothModels/SILBluetoothServiceCharacteristicPropertiesSpec.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// SILBluetoothServiceCharacteristicPropertiesSpec.swift | ||
// BlueGeckoTests | ||
// | ||
// Created by Grzegorz Janosz on 15/04/2021. | ||
// Copyright © 2021 SiliconLabs. All rights reserved. | ||
// | ||
|
||
@testable import BlueGecko | ||
|
||
import Foundation | ||
import Quick | ||
import Nimble | ||
import RealmSwift | ||
|
||
class SILBluetoothServiceCharacteristicPropertiesSpec: QuickSpec { | ||
|
||
override func spec() { | ||
context("SILBluetoothServiceCharacteristicProperties") { | ||
var propertyDict: NSDictionary! | ||
var properties: SILBluetoothServiceCharacteristicProperties! | ||
beforeEach { | ||
propertyDict = [ | ||
"Broadcast" : "Excluded", | ||
"Indicate" : "Excluded", | ||
"Notify" : "Mandatory", | ||
"Read" : "Excluded", | ||
"ReliableWrite" : "Excluded", | ||
"SignedWrite" : "Excluded", | ||
"WritableAuxiliaries" : "Excluded", | ||
"Write" : "Optional", | ||
"WriteWithoutResponse" : "Excluded", | ||
] | ||
properties = SILBluetoothServiceCharacteristicProperties(propertyDict: propertyDict) | ||
} | ||
|
||
describe("init") { | ||
it("should have set right properties") { | ||
expect(properties.propertyMap[.Broadcast]).to(equal(.Excluded)) | ||
expect(properties.propertyMap[.Indicate]).to(equal(.Excluded)) | ||
expect(properties.propertyMap[.Notify]).to(equal(.Mandatory)) | ||
expect(properties.propertyMap[.Read]).to(equal(.Excluded)) | ||
expect(properties.propertyMap[.ReliableWrite]).to(equal(.Excluded)) | ||
expect(properties.propertyMap[.SignedWrite]).to(equal(.Excluded)) | ||
expect(properties.propertyMap[.WritableAuxiliaries]).to(equal(.Excluded)) | ||
expect(properties.propertyMap[.Write]).to(equal(.Optional)) | ||
expect(properties.propertyMap[.WriteWithoutResponse]).to(equal(.Excluded)) | ||
} | ||
} | ||
|
||
describe("mandatoriesProperties") { | ||
it("should have set right properties") { | ||
expect(properties.mandatoryProperties.count).to(equal(2)) | ||
expect(properties.mandatoryProperties).to(contain(.Notify)) | ||
expect(properties.mandatoryProperties).to(contain(.Write)) | ||
} | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
BlueGeckoTests/DataModels/BluetoothModels/SILBluetoothServiceDescriptorPropertiesSpec.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// SILBluetoothServiceCharacteristicPropertiesSpec.swift | ||
// BlueGeckoTests | ||
// | ||
// Created by Grzegorz Janosz on 15/04/2021. | ||
// Copyright © 2021 SiliconLabs. All rights reserved. | ||
// | ||
|
||
@testable import BlueGecko | ||
|
||
import Foundation | ||
import Quick | ||
import Nimble | ||
import RealmSwift | ||
|
||
class SILBluetoothServiceDescriptorPropertiesSpec: QuickSpec { | ||
|
||
override func spec() { | ||
context("SILBluetoothServiceDescriptorProperties") { | ||
var propertyDict: NSDictionary! | ||
var properties: SILBluetoothServiceDescriptorProperties! | ||
beforeEach { | ||
propertyDict = [ | ||
"Read" : "Excluded", | ||
"Write" : "Mandatory" | ||
] | ||
properties = SILBluetoothServiceDescriptorProperties(propertyDict: propertyDict) | ||
} | ||
|
||
describe("init") { | ||
it("should have set right properties") { | ||
expect(properties.propertyMap[.Read]).to(equal(.Excluded)) | ||
expect(properties.propertyMap[.Write]).to(equal(.Mandatory)) | ||
} | ||
} | ||
|
||
describe("mandatoriesProperties") { | ||
it("should have set right properties") { | ||
expect(properties.mandatoryProperties.count).to(equal(1)) | ||
expect(properties.mandatoryProperties).to(contain(.Write)) | ||
} | ||
} | ||
} | ||
} | ||
} |
334 changes: 334 additions & 0 deletions
334
BlueGeckoTests/DataModels/GattConfigurator/SILGattConfigurationModelSpec.swift
Large diffs are not rendered by default.
Oops, something went wrong.
95 changes: 95 additions & 0 deletions
95
BlueGeckoTests/DataModels/GattConfigurator/SILGattConfiguratorServiceHelperSpec.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// | ||
// SILGattConfiguratorServiceHelperSpec.swift | ||
// BlueGeckoTests | ||
// | ||
// Created by Grzegorz Janosz on 01/04/2021. | ||
// Copyright © 2021 SiliconLabs. All rights reserved. | ||
// | ||
|
||
@testable import BlueGecko | ||
|
||
import Foundation | ||
import Quick | ||
import Nimble | ||
import RealmSwift | ||
|
||
class SILGattConfiguratorServiceHelperSpec: QuickSpec { | ||
|
||
override func spec() { | ||
var repository: SILGattConfigurationRepository! | ||
|
||
beforeSuite { | ||
Realm.Configuration.defaultConfiguration.inMemoryIdentifier = self.name | ||
repository = SILGattConfigurationRepository() | ||
} | ||
|
||
beforeEach { | ||
let realm = try! Realm() | ||
try! realm.write { | ||
realm.deleteAll() | ||
} | ||
} | ||
|
||
context("SILGattConfiguratorServiceHelper") { | ||
describe("services") { | ||
it("should return the same number of services") { | ||
let configurationEntity = SILGattConfigurationEntity() | ||
let service1 = SILGattConfigurationServiceEntity() | ||
service1.cbuuidString = CBUUID(string: "71da3fd1-7e10-41c1-b16f-4430b506cde7").uuidString | ||
let service2 = SILGattConfigurationServiceEntity() | ||
service2.cbuuidString = CBUUID(string: "71da3fd1-7e10-41c1-b16f-4430b506cde8").uuidString | ||
let services = [service1, service2] | ||
for service in services { | ||
repository.add(service: service) | ||
configurationEntity.services.append(service) | ||
} | ||
let helper = SILGattConfiguratorServiceHelper(configuration: configurationEntity) | ||
let result = helper.services | ||
expect(result.count).to(equal(services.count)) | ||
} | ||
|
||
it("should set proper isPrimary for created services") { | ||
let configurationEntity = SILGattConfigurationEntity() | ||
let testService = SILGattConfigurationServiceEntity() | ||
testService.cbuuidString = CBUUID(string: "71da3fd1-7e10-41c1-b16f-4430b506cde7").uuidString | ||
testService.isPrimary = false | ||
repository.add(service: testService) | ||
configurationEntity.services.append(testService) | ||
let helper = SILGattConfiguratorServiceHelper(configuration: configurationEntity) | ||
let result = helper.services | ||
expect(result[0].isPrimary).to(beFalse()) | ||
} | ||
} | ||
describe("init") { | ||
it("should service have the same size in configuration") { | ||
let configurationEntity = SILGattConfigurationEntity() | ||
let service1 = SILGattConfigurationServiceEntity() | ||
service1.cbuuidString = CBUUID(string: "71da3fd1-7e10-41c1-b16f-4430b506cde7").uuidString | ||
let service2 = SILGattConfigurationServiceEntity() | ||
service2.cbuuidString = CBUUID(string: "71da3fd1-7e10-41c1-b16f-4430b506cde8").uuidString | ||
let services = [service1, service2] | ||
for service in services { | ||
repository.add(service: service) | ||
configurationEntity.services.append(service) | ||
} | ||
let helper = SILGattConfiguratorServiceHelper(configuration: configurationEntity) | ||
let result = helper.services | ||
expect(result.count).to(equal(services.count)) | ||
} | ||
|
||
it("should service have set proper isPrimary for created services") { | ||
let configurationEntity = SILGattConfigurationEntity() | ||
let testService = SILGattConfigurationServiceEntity() | ||
testService.cbuuidString = CBUUID(string: "71da3fd1-7e10-41c1-b16f-4430b506cde7").uuidString | ||
testService.isPrimary = false | ||
repository.add(service: testService) | ||
configurationEntity.services.append(testService) | ||
let helper = SILGattConfiguratorServiceHelper(configuration: configurationEntity) | ||
let result = helper.services | ||
expect(result[0].isPrimary).to(beFalse()) | ||
} | ||
} | ||
} | ||
|
||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
BlueGeckoTests/DataModels/IOP/SILTestResultComparableTest.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// | ||
// SILTestResultComparableTest.swift | ||
// BlueGeckoTests | ||
// | ||
// Created by Kamil Czajka on 23.4.2021. | ||
// Copyright © 2021 SiliconLabs. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Quick | ||
import Nimble | ||
@testable import BlueGecko | ||
|
||
class SILTestResultComparableTest: QuickSpec { | ||
private var testObject1: SILTestResult! | ||
private var testObject2: SILTestResult! | ||
|
||
private let testName = "Test" | ||
private let testStatus = SILTestStatus.none | ||
|
||
override func spec() { | ||
afterEach { | ||
self.testObject1 = nil | ||
self.testObject2 = nil | ||
} | ||
|
||
describe("<") { | ||
it("1 < 2 -> true") { | ||
self.testObject1 = SILTestResult(testID: "1", testName: self.testName, testStatus: self.testStatus) | ||
self.testObject2 = SILTestResult(testID: "2", testName: self.testName, testStatus: self.testStatus) | ||
|
||
expect(self.testObject1 < self.testObject2).to(equal(true)) | ||
} | ||
|
||
it("1 < 2.5 -> true") { | ||
self.testObject1 = SILTestResult(testID: "1", testName: self.testName, testStatus: self.testStatus) | ||
self.testObject2 = SILTestResult(testID: "2.5", testName: self.testName, testStatus: self.testStatus) | ||
|
||
expect(self.testObject1 < self.testObject2).to(equal(true)) | ||
} | ||
|
||
it("2.1 < 2.2 -> true") { | ||
self.testObject1 = SILTestResult(testID: "2.1", testName: self.testName, testStatus: self.testStatus) | ||
self.testObject2 = SILTestResult(testID: "2.2", testName: self.testName, testStatus: self.testStatus) | ||
|
||
expect(self.testObject1 < self.testObject2).to(equal(true)) | ||
} | ||
|
||
it("4.9 < 4.10 -> true") { | ||
self.testObject1 = SILTestResult(testID: "4.9", testName: self.testName, testStatus: self.testStatus) | ||
self.testObject2 = SILTestResult(testID: "4.10", testName: self.testName, testStatus: self.testStatus) | ||
|
||
expect(self.testObject1 < self.testObject2).to(equal(true)) | ||
} | ||
|
||
it("4.10 < 7 -> true") { | ||
self.testObject1 = SILTestResult(testID: "4.10", testName: self.testName, testStatus: self.testStatus) | ||
self.testObject2 = SILTestResult(testID: "7", testName: self.testName, testStatus: self.testStatus) | ||
|
||
expect(self.testObject1 < self.testObject2).to(equal(true)) | ||
} | ||
} | ||
|
||
describe("==") { | ||
it("1 == 1 -> true") { | ||
self.testObject1 = SILTestResult(testID: "1", testName: self.testName, testStatus: self.testStatus) | ||
self.testObject2 = SILTestResult(testID: "1", testName: self.testName, testStatus: self.testStatus) | ||
|
||
expect(self.testObject1 == self.testObject2).to(equal(true)) | ||
} | ||
|
||
it("2.1 == 2.1 -> true") { | ||
self.testObject1 = SILTestResult(testID: "2.1", testName: self.testName, testStatus: self.testStatus) | ||
self.testObject2 = SILTestResult(testID: "2.1", testName: self.testName, testStatus: self.testStatus) | ||
|
||
expect(self.testObject1 == self.testObject2).to(equal(true)) | ||
} | ||
|
||
it("4.10 == 4.10 -> true") { | ||
self.testObject1 = SILTestResult(testID: "4.10", testName: self.testName, testStatus: self.testStatus) | ||
self.testObject2 = SILTestResult(testID: "4.10", testName: self.testName, testStatus: self.testStatus) | ||
|
||
expect(self.testObject1 == self.testObject2).to(equal(true)) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// | ||
// SILTemperatureMeasurementSpec.m | ||
// BlueGeckoTests | ||
// | ||
// Created by Grzegorz Janosz on 24/02/2021. | ||
// Copyright © 2021 SiliconLabs. All rights reserved. | ||
// | ||
|
||
@import Quick; | ||
@import Nimble; | ||
#import <Foundation/Foundation.h> | ||
#import "SILTemperatureMeasurement.h" | ||
|
||
QuickSpecBegin(SILTemperatureMeasurementSpec) | ||
|
||
__block NSMutableData *inputData; | ||
__block SILTemperatureMeasurement *sut; | ||
beforeEach(^{ | ||
inputData = [NSMutableData data]; | ||
}); | ||
|
||
context(@"basic properties", ^{ | ||
beforeEach(^{ | ||
char bytes[6] = { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00 }; | ||
[inputData appendBytes:bytes length:6]; | ||
sut = [SILTemperatureMeasurement decodeTemperatureMeasurementWithData:inputData]; | ||
}); | ||
|
||
it(@"should not be nil", ^{ | ||
expect(sut).toNot(beNil()); | ||
}); | ||
|
||
it(@"should not be in Fahrenheit", ^{ | ||
expect(sut.isFahrenheit).to(beFalse()); | ||
}); | ||
|
||
it(@"should has measurement date", ^{ | ||
expect(sut.measurementDate).toNot(beNil()); | ||
}); | ||
}); | ||
|
||
context(@"temperature type", ^{ | ||
beforeEach(^{ | ||
char bytes[6] = { 0x04, 0x00, 0x00, 0x00, 0x00, 0x09 }; | ||
[inputData appendBytes:bytes length:6]; | ||
sut = [SILTemperatureMeasurement decodeTemperatureMeasurementWithData:inputData]; | ||
}); | ||
|
||
it(@"should be typanum for 0x09", ^{ | ||
expect(sut).toNot(beNil()); | ||
expect(@(sut.temperatureType)).to(equal(SILTemperatureTypeTypanum)); | ||
}); | ||
}); | ||
|
||
context(@"for positive number", ^{ | ||
beforeEach(^{ | ||
char bytes[6] = { 0x04, 0x1b, 0x0e, 0x00, 0xfe, 0x09 }; | ||
[inputData appendBytes:bytes length:6]; | ||
sut = [SILTemperatureMeasurement decodeTemperatureMeasurementWithData:inputData]; | ||
}); | ||
|
||
it(@"should has proper value with accuracy", ^{ | ||
expect(sut).toNot(beNil()); | ||
expect(sut.value).to(beCloseTo(36.11).within(0.1)); | ||
}); | ||
}); | ||
|
||
context(@"for negative number", ^{ | ||
it(@"should has proper value with accuracy - first number", ^{ | ||
char bytes[6] = { 0x04, 0x7b, 0xef, 0xff, 0xff, 0x09 }; | ||
[inputData appendBytes:bytes length:6]; | ||
sut = [SILTemperatureMeasurement decodeTemperatureMeasurementWithData:inputData]; | ||
expect(sut).toNot(beNil()); | ||
expect(sut.value).to(beCloseTo(-422.9).within(0.1)); | ||
}); | ||
|
||
it(@"should has proper value with accuracy - second number", ^{ | ||
char bytes[6] = { 0x04, 0x7b, 0xef, 0xff, 0xfd, 0x09 }; | ||
[inputData appendBytes:bytes length:6]; | ||
sut = [SILTemperatureMeasurement decodeTemperatureMeasurementWithData:inputData]; | ||
expect(sut).toNot(beNil()); | ||
expect(sut.value).to(beCloseTo(-4.229).within(0.0001)); | ||
}); | ||
}); | ||
|
||
QuickSpecEnd |
Oops, something went wrong.