mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2026-04-24 00:00:05 +08:00
Early exit if settings is nil and use short format for nil checking
This commit is contained in:
@@ -75,15 +75,9 @@ class OpenVPNConfigurationTests: XCTestCase {
|
|||||||
|
|
||||||
configuration.settings = [:]
|
configuration.settings = [:]
|
||||||
XCTAssert(configuration.settings == nil, "Empty settings should return nil")
|
XCTAssert(configuration.settings == nil, "Empty settings should return nil")
|
||||||
}
|
|
||||||
|
|
||||||
func testCreateConfiguration() {
|
|
||||||
let configuration = OpenVPNConfiguration()
|
|
||||||
|
|
||||||
let some = configuration.fileContent
|
configuration.settings = nil
|
||||||
|
XCTAssert(configuration.settings == nil, "Empty settings should return nil")
|
||||||
let test = "Some String".data(using: .utf8)
|
|
||||||
configuration.fileContent = test
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ using namespace openvpn;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFileContent:(NSData *)fileContent {
|
- (void)setFileContent:(NSData *)fileContent {
|
||||||
_config.content = fileContent != nil ? std::string((const char *)fileContent.bytes) : "";
|
_config.content = fileContent ? std::string((const char *)fileContent.bytes) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDictionary<NSString *,NSString *> *)settings {
|
- (NSDictionary<NSString *,NSString *> *)settings {
|
||||||
@@ -55,6 +55,10 @@ using namespace openvpn;
|
|||||||
- (void)setSettings:(NSDictionary<NSString *,NSString *> *)settings {
|
- (void)setSettings:(NSDictionary<NSString *,NSString *> *)settings {
|
||||||
_config.contentList.clear();
|
_config.contentList.clear();
|
||||||
|
|
||||||
|
if (!settings) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
[settings enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, NSString * _Nonnull obj, BOOL * _Nonnull stop) {
|
[settings enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, NSString * _Nonnull obj, BOOL * _Nonnull stop) {
|
||||||
ClientAPI::KeyValue param = ClientAPI::KeyValue(std::string([key UTF8String]), std::string([obj UTF8String]));
|
ClientAPI::KeyValue param = ClientAPI::KeyValue(std::string([key UTF8String]), std::string([obj UTF8String]));
|
||||||
_config.contentList.push_back(param);
|
_config.contentList.push_back(param);
|
||||||
|
|||||||
Reference in New Issue
Block a user