-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CFString conversion to/from Rust strings
- Loading branch information
Showing
10 changed files
with
384 additions
and
72 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#![cfg_attr(not(feature = "afl"), no_main)] | ||
use objc2_core_foundation::CFString; | ||
|
||
fn run(s: &str) { | ||
let obj = CFString::from_str(s); | ||
assert_eq!(obj.to_string(), s); | ||
} | ||
|
||
#[cfg(not(feature = "afl"))] | ||
libfuzzer_sys::fuzz_target!(|s: &str| run(s)); | ||
|
||
#[cfg(feature = "afl")] | ||
fn main() { | ||
afl::fuzz!(|s: &str| { | ||
run(s); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//! Test that a `'static` str used in `CFString` can't later be modified. | ||
use objc2_core_foundation::CFString; | ||
|
||
fn main() { | ||
// Create a `&'static mut str`. | ||
let s = String::from("xyz").leak(); | ||
|
||
// Construct a `CFString` from it. | ||
let cf = CFString::from_static_str(s); | ||
assert_eq!(cf.to_string(), "xyz"); | ||
|
||
// Modify the string. | ||
s.make_ascii_uppercase(); | ||
|
||
// This would be invalid, since CFString is expected to be immutable. | ||
assert_eq!(cf.to_string(), "XYZ"); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.