File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
swift/ql/test/library-tests/dataflow/flowsources Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ // --- stubs ---
3
+
4
+ struct URL {
5
+ init ? ( string: String ) { }
6
+ }
7
+
8
+ class NSObject {
9
+ }
10
+
11
+ class NSString : NSObject {
12
+ init ( string aString: String ) { }
13
+
14
+ convenience init ? ( contentsOfFile path: String ) { self . init ( string: " " ) }
15
+ convenience init ( contentsOfFile path: String , encoding enc: UInt ) throws { self . init ( string: " " ) }
16
+ convenience init ( contentsOfFile path: String , usedEncoding enc: UnsafeMutablePointer < UInt > ? ) throws { self . init ( string: " " ) }
17
+ convenience init ? ( contentsOf url: URL ) { self . init ( string: " " ) }
18
+ convenience init ( contentsOf url: URL , encoding enc: UInt ) throws { self . init ( string: " " ) }
19
+ convenience init ( contentsOf url: URL , usedEncoding enc: UnsafeMutablePointer < UInt > ? ) throws { self . init ( string: " " ) }
20
+
21
+ class func string( withContentsOfFile path: String ) -> Any ? { return nil }
22
+ class func string( withContentsOf url: URL ) -> Any ? { return nil }
23
+ }
24
+
25
+ // --- tests ---
26
+
27
+ func testNSStrings( ) {
28
+ do
29
+ {
30
+ let path = " file.txt "
31
+ let string1 = try NSString ( contentsOfFile: path) // SOURCE
32
+ let string2 = try NSString ( contentsOfFile: path, encoding: 0 ) // SOURCE
33
+ let string3 = try NSString ( contentsOfFile: path, usedEncoding: nil ) // SOURCE
34
+ let string4 = NSString . string ( withContentsOfFile: path) // SOURCE
35
+
36
+ let url = URL ( string: " http://example.com/ " ) !
37
+ let string5 = try NSString ( contentsOf: url) // SOURCE
38
+ let string6 = try NSString ( contentsOf: url, encoding: 0 ) // SOURCE
39
+ let string7 = try NSString ( contentsOf: url, usedEncoding: nil ) // SOURCE
40
+ let string8 = NSString . string ( withContentsOf: url) // SOURCE
41
+ } catch {
42
+ // ...
43
+ }
44
+ }
You can’t perform that action at this time.
0 commit comments