mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-04 18:40:47 +00:00
Test with bad path that won't raise exception
This commit is contained in:
parent
0e2c77acf1
commit
b3f95f99e6
1 changed files with 20 additions and 17 deletions
|
@ -4,27 +4,30 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
NSError *error;
|
||||
NSString *path;
|
||||
NSData *data;
|
||||
START_SET("NSData file/url loading")
|
||||
|
||||
START_SET("NSData file/url loading")
|
||||
NSError *error;
|
||||
NSString *path;
|
||||
NSData *data;
|
||||
|
||||
// Try loading from a nonexistent path to trigger error
|
||||
path = @"/tmp/nonexistent_file.txt";
|
||||
data = [NSData dataWithContentsOfFile: path options:0 error:&error];
|
||||
PASS(data == nil && error != nil, "+dataWithContentsOfFile:options:error: sets error on failure");
|
||||
// Try loading from a nonexistent path to trigger error
|
||||
path = @"/tmp/nonexistent_file.txt";
|
||||
data = [NSData dataWithContentsOfFile: path options: 0 error: &error];
|
||||
PASS(data == nil && error != nil,
|
||||
"+dataWithContentsOfFile:options:error: sets error on failure")
|
||||
|
||||
data = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:path]
|
||||
options:0
|
||||
error:&error];
|
||||
PASS(data == nil && error != nil, "+dataWithContentsOfURL:options:error: sets error on failure");
|
||||
data = [NSData dataWithContentsOfURL: [NSURL fileURLWithPath: path]
|
||||
options: 0
|
||||
error: &error];
|
||||
PASS(data == nil && error != nil,
|
||||
"+dataWithContentsOfURL:options:error: sets error on failure")
|
||||
|
||||
// Try loading with invalid utf-8 path
|
||||
data = [NSData dataWithContentsOfFile: @"\xC3\x28" options:0 error:&error];
|
||||
PASS(data == nil && error != nil, "+dataWithContentsOfURL:options:error: sets error when path is invalid");
|
||||
// Try loading with bad path
|
||||
data = [NSData dataWithContentsOfFile: nil options: 0 error: &error];
|
||||
PASS(data == nil && error != nil,
|
||||
"+dataWithContentsOfURL:options:error: sets error when path is invalid")
|
||||
|
||||
END_SET("NSData file/url loading")
|
||||
END_SET("NSData file/url loading")
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue