1 // Copyright 2012-2015 The Rust Project Developers. 2 // Copyright 2017 The UNIC Project Developers. 3 // 4 // See the COPYRIGHT file at the top-level directory of this distribution. 5 // 6 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or 7 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 8 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 9 // option. This file may not be copied, modified, or distributed 10 // except according to those terms. 11 12 #[macro_use] 13 extern crate quickcheck; 14 15 use unic_segment::{Graphemes, WordBounds}; 16 17 // QuickCheck Graphemes 18 quickcheck! { 19 fn quickcheck_graphemes_new_join_vs_input(input: String) -> bool { 20 let graphemes = Graphemes::new(&input).collect::<String>(); 21 graphemes == input 22 } 23 24 fn quickcheck_graphemes_new_forward_vs_reverse(input: String) -> bool { 25 let graphemes1 = Graphemes::new(&input).collect::<Vec<_>>(); 26 let mut graphemes2 = Graphemes::new(&input).rev().collect::<Vec<_>>(); 27 graphemes2.reverse(); 28 graphemes1 == graphemes2 29 } 30 31 fn quickcheck_graphemes_new_legacy_join_vs_input(input: String) -> bool { 32 let graphemes = Graphemes::new_legacy(&input).collect::<String>(); 33 graphemes == input 34 } 35 36 fn quickcheck_graphemes_new_legacy_forward_vs_reverse(input: String) -> bool { 37 let graphemes1 = Graphemes::new_legacy(&input).collect::<Vec<_>>(); 38 let mut graphemes2 = Graphemes::new_legacy(&input).rev().collect::<Vec<_>>(); 39 graphemes2.reverse(); 40 graphemes1 == graphemes2 41 } 42 } 43 44 // QuickCheck Words 45 quickcheck! { 46 fn quickcheck_words_new_join_vs_input(input: String) -> bool { 47 let words = WordBounds::new(&input).collect::<String>(); 48 words == input 49 } 50 51 fn quickcheck_words_new_forward_vs_reverse(input: String) -> bool { 52 let words1 = WordBounds::new(&input).collect::<Vec<_>>(); 53 let mut words2 = WordBounds::new(&input).rev().collect::<Vec<_>>(); 54 words2.reverse(); 55 words1 == words2 56 } 57 } 58