mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2026-02-22 00:00:06 +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 = [:]
|
||||
XCTAssert(configuration.settings == nil, "Empty settings should return nil")
|
||||
}
|
||||
|
||||
func testCreateConfiguration() {
|
||||
let configuration = OpenVPNConfiguration()
|
||||
|
||||
let some = configuration.fileContent
|
||||
|
||||
let test = "Some String".data(using: .utf8)
|
||||
configuration.fileContent = test
|
||||
configuration.settings = nil
|
||||
XCTAssert(configuration.settings == nil, "Empty settings should return nil")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ using namespace openvpn;
|
||||
}
|
||||
|
||||
- (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 {
|
||||
@@ -55,6 +55,10 @@ using namespace openvpn;
|
||||
- (void)setSettings:(NSDictionary<NSString *,NSString *> *)settings {
|
||||
_config.contentList.clear();
|
||||
|
||||
if (!settings) {
|
||||
return;
|
||||
}
|
||||
|
||||
[settings enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, NSString * _Nonnull obj, BOOL * _Nonnull stop) {
|
||||
ClientAPI::KeyValue param = ClientAPI::KeyValue(std::string([key UTF8String]), std::string([obj UTF8String]));
|
||||
_config.contentList.push_back(param);
|
||||
|
||||
Reference in New Issue
Block a user