4
4
5
5
import XCTest
6
6
7
+ @testable import shared_preferences_foundation
8
+
7
9
#if os(iOS)
8
- import Flutter
10
+ import Flutter
9
11
#elseif os(macOS)
10
- import FlutterMacOS
12
+ import FlutterMacOS
11
13
#endif
12
14
13
- @testable import shared_preferences_foundation
14
-
15
15
class RunnerTests : XCTestCase {
16
16
let prefixes : [ String ] = [ " aPrefix " , " " ]
17
17
@@ -30,7 +30,7 @@ class RunnerTests: XCTestCase {
30
30
XCTAssertEqual ( storedValues [ " \( aPrefix) aDouble " ] as! Double , 3.14 , accuracy: 0.0001 )
31
31
XCTAssertEqual ( storedValues [ " \( aPrefix) anInt " ] as? Int , 42 )
32
32
XCTAssertEqual ( storedValues [ " \( aPrefix) aString " ] as? String , " hello world " )
33
- XCTAssertEqual ( storedValues [ " \( aPrefix) aStringList " ] as? Array < String > , [ " hello " , " world " ] )
33
+ XCTAssertEqual ( storedValues [ " \( aPrefix) aStringList " ] as? [ String ] , [ " hello " , " world " ] )
34
34
}
35
35
}
36
36
@@ -70,40 +70,40 @@ class RunnerTests: XCTestCase {
70
70
XCTAssertNil ( finalValues [ testKey] as Any ? )
71
71
}
72
72
}
73
-
74
- func testClearWithNoAllowlist( ) throws {
75
- for aPrefix in prefixes {
76
- let plugin = SharedPreferencesPlugin ( )
77
- let testKey = " \( aPrefix) foo "
78
- plugin. setValue ( key: testKey, value: 42 )
79
-
80
- // Make sure there is something to clear, so the test can't pass due to a set failure.
81
- let preRemovalValues = plugin. getAll ( prefix: aPrefix, allowList: nil )
82
- XCTAssertEqual ( preRemovalValues [ testKey] as? Int , 42 )
83
-
84
- // Then verify that clearing works.
85
- plugin. clear ( prefix: aPrefix, allowList: nil )
86
-
87
- let finalValues = plugin. getAll ( prefix: aPrefix, allowList: nil )
88
- XCTAssertNil ( finalValues [ testKey] as Any ? )
89
- }
73
+
74
+ func testClearWithNoAllowlist( ) throws {
75
+ for aPrefix in prefixes {
76
+ let plugin = SharedPreferencesPlugin ( )
77
+ let testKey = " \( aPrefix) foo "
78
+ plugin. setValue ( key: testKey, value: 42 )
79
+
80
+ // Make sure there is something to clear, so the test can't pass due to a set failure.
81
+ let preRemovalValues = plugin. getAll ( prefix: aPrefix, allowList: nil )
82
+ XCTAssertEqual ( preRemovalValues [ testKey] as? Int , 42 )
83
+
84
+ // Then verify that clearing works.
85
+ plugin. clear ( prefix: aPrefix, allowList: nil )
86
+
87
+ let finalValues = plugin. getAll ( prefix: aPrefix, allowList: nil )
88
+ XCTAssertNil ( finalValues [ testKey] as Any ? )
90
89
}
91
-
92
- func testClearWithAllowlist ( ) throws {
93
- for aPrefix in prefixes {
94
- let plugin = SharedPreferencesPlugin ( )
95
- let testKey = " \( aPrefix ) foo "
96
- plugin . setValue ( key : testKey, value : 42 )
97
-
98
- // Make sure there is something to clear, so the test can't pass due to a set failure.
99
- let preRemovalValues = plugin . getAll ( prefix : aPrefix , allowList : nil )
100
- XCTAssertEqual ( preRemovalValues [ testKey ] as? Int , 42 )
101
-
102
- plugin . clear ( prefix : aPrefix , allowList : [ " \( aPrefix ) notfoo " ] )
103
-
104
- let finalValues = plugin . getAll ( prefix : aPrefix , allowList : nil )
105
- XCTAssertEqual ( finalValues [ testKey ] as? Int , 42 )
106
- }
90
+ }
91
+
92
+ func testClearWithAllowlist ( ) throws {
93
+ for aPrefix in prefixes {
94
+ let plugin = SharedPreferencesPlugin ( )
95
+ let testKey = " \( aPrefix ) foo "
96
+ plugin . setValue ( key : testKey , value : 42 )
97
+
98
+ // Make sure there is something to clear, so the test can't pass due to a set failure.
99
+ let preRemovalValues = plugin . getAll ( prefix : aPrefix , allowList : nil )
100
+ XCTAssertEqual ( preRemovalValues [ testKey ] as? Int , 42 )
101
+
102
+ plugin . clear ( prefix : aPrefix , allowList : [ " \( aPrefix ) notfoo " ] )
103
+
104
+ let finalValues = plugin . getAll ( prefix : aPrefix , allowList : nil )
105
+ XCTAssertEqual ( finalValues [ testKey ] as? Int , 42 )
107
106
}
108
-
107
+ }
108
+
109
109
}
0 commit comments