Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit99b3636

Browse files
committed
Add fuzzers
1 parente86a69b commit99b3636

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed

‎fuzz/.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
target
3+
libfuzzer

‎fuzz/Cargo.toml‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
[package]
3+
name ="unicode-segmentation-fuzz"
4+
version ="0.0.1"
5+
authors = ["Automatically generated"]
6+
7+
[dependencies.unicode-segmentation]
8+
path =".."
9+
10+
# Prevent this from interfering with workspaces
11+
[workspace]
12+
members = ["."]
13+
14+
[[bin]]
15+
name ="graphemes"
16+
path ="fuzzers/graphemes.rs"
17+
18+
[[bin]]
19+
name ="words"
20+
path ="fuzzers/words.rs"
21+
22+
[[bin]]
23+
name ="equality"
24+
path ="fuzzers/equality.rs"

‎fuzz/fuzzers/equality.rs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![no_main]
2+
3+
externcrate libfuzzer_sys;
4+
externcrate unicode_segmentation;
5+
use std::str;
6+
use unicode_segmentation::UnicodeSegmentation;
7+
#[export_name="rust_fuzzer_test_input"]
8+
pubexternfngo(data:&[u8]){
9+
ifletOk(s) = str::from_utf8(data){
10+
let result =UnicodeSegmentation::graphemes(s,true).flat_map(|s| s.chars()).collect::<String>();
11+
assert_eq!(s, result);
12+
let result = s.split_word_bounds().flat_map(|s| s.chars()).collect::<String>();
13+
assert_eq!(s, result);
14+
15+
}
16+
}

‎fuzz/fuzzers/graphemes.rs‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![no_main]
2+
3+
4+
externcrate libfuzzer_sys;
5+
6+
7+
externcrate unicode_segmentation;
8+
9+
use unicode_segmentation::UnicodeSegmentation;
10+
use std::str;
11+
12+
13+
#[export_name="rust_fuzzer_test_input"]
14+
pubexternfngo(data:&[u8]){
15+
ifletOk(s) = str::from_utf8(data){
16+
let g =UnicodeSegmentation::graphemes(s,true).collect::<Vec<_>>();
17+
assert!(UnicodeSegmentation::graphemes(s,true).rev().eq(g.iter().rev().cloned()));
18+
}
19+
}

‎fuzz/fuzzers/words.rs‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![no_main]
2+
3+
4+
externcrate libfuzzer_sys;
5+
6+
7+
externcrate unicode_segmentation;
8+
9+
use unicode_segmentation::UnicodeSegmentation;
10+
use std::str;
11+
12+
13+
#[export_name="rust_fuzzer_test_input"]
14+
pubexternfngo(data:&[u8]){
15+
ifletOk(s) = str::from_utf8(data){
16+
let g = s.split_word_bounds().collect::<Vec<_>>();
17+
assert!(s.split_word_bounds().rev().eq(g.iter().rev().cloned()));
18+
}
19+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp