From 79b5f5a0ccfe38513e670d0e10e19260a6106382 Mon Sep 17 00:00:00 2001 From: Pascal Seitz Date: Tue, 1 Oct 2024 19:03:01 +0800 Subject: [PATCH] fix bench --- benches/bench.rs | 11 +++++------ src/utils/mod.rs | 16 ++++------------ tests/is_japanese.rs | 4 +--- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/benches/bench.rs b/benches/bench.rs index 84bde7d..b124923 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -4,17 +4,16 @@ extern crate test; #[cfg(test)] mod tests { - use test::Bencher; - use wana_kana::{to_kana, to_romaji, *}; + use wana_kana::*; #[bench] fn bench_kana_1(b: &mut test::Bencher) { - b.iter(|| to_kana::to_kana("aiueosashisusesonaninunenokakikukeko")) + b.iter(|| "aiueosashisusesonaninunenokakikukeko".to_kana()) } #[bench] fn bench_kana_2(b: &mut test::Bencher) { - b.iter(|| to_kana::to_kana("AIUEOSASHISUSESONANINUNENOKAKIKUKEKO")) + b.iter(|| "AIUEOSASHISUSESONANINUNENOKAKIKUKEKO".to_kana()) } #[bench] @@ -39,11 +38,11 @@ mod tests { #[bench] fn bench_hiragana_to_romaji(b: &mut test::Bencher) { - b.iter(|| to_romaji::to_romaji("あいうえおさしすせそなにぬねのかきくけこ")) + b.iter(|| "あいうえおさしすせそなにぬねのかきくけこ".to_romaji()) } #[bench] fn bench_katakana_to_romaji(b: &mut test::Bencher) { - b.iter(|| to_romaji::to_romaji("アイウエオサシスセソナニヌネノカキクケコ")) + b.iter(|| "アイウエオサシスセソナニヌネノカキクケコ".to_romaji()) } } diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 0b0ceef..a3326ef 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -59,12 +59,8 @@ mod tests { #[test] fn is_char_english_punctuation_test() { - assert!( - EN_PUNC.iter().cloned().all(is_char_english_punctuation) - ); - assert!( - !JA_PUNC.iter().cloned().all(is_char_english_punctuation) - ); + assert!(EN_PUNC.iter().cloned().all(is_char_english_punctuation)); + assert!(!JA_PUNC.iter().cloned().all(is_char_english_punctuation)); assert!(is_char_english_punctuation(' ')); assert!(!is_char_english_punctuation('a')); assert!(!is_char_english_punctuation('ふ')); @@ -84,12 +80,8 @@ mod tests { #[test] fn is_char_japanese_punctuation_test() { - assert!( - !EN_PUNC.iter().cloned().all(is_char_japanese_punctuation) - ); - assert!( - JA_PUNC.iter().cloned().all(is_char_japanese_punctuation) - ); + assert!(!EN_PUNC.iter().cloned().all(is_char_japanese_punctuation)); + assert!(JA_PUNC.iter().cloned().all(is_char_japanese_punctuation)); assert!(is_char_japanese_punctuation(' ')); assert!(!is_char_japanese_punctuation('?')); assert!(!is_char_japanese_punctuation('a')); diff --git a/tests/is_japanese.rs b/tests/is_japanese.rs index 974a19f..f876aed 100644 --- a/tests/is_japanese.rs +++ b/tests/is_japanese.rs @@ -42,9 +42,7 @@ mod tests { } #[test] fn kanji_with_zenkaku_punctuation_is_japanese() { - assert!( - "泣き虫。#!〜〈〉《》〔〕[]【】(){}〝〟".is_japanese() - ); + assert!("泣き虫。#!〜〈〉《》〔〕[]【】(){}〝〟".is_japanese()); } #[test] fn kanji_with_romaji_punctuation_is_not_japanese() {