]>
git.proxmox.com Git - rustc.git/blob - vendor/unicode-xid-0.1.0/src/tests.rs
1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #[cfg(feature = "bench")]
13 #[cfg(feature = "bench")]
15 #[cfg(feature = "bench")]
16 use std
::prelude
::v1
::*;
18 use super::UnicodeXID
;
20 #[cfg(feature = "bench")]
22 fn cargo_is_xid_start(b
: &mut Bencher
) {
23 let string
= iter
::repeat('a'
).take(4096).collect
::<String
>();
25 b
.bytes
= string
.len() as u64;
27 string
.chars().all(UnicodeXID
::is_xid_start
)
31 #[cfg(feature = "bench")]
33 fn stdlib_is_xid_start(b
: &mut Bencher
) {
34 let string
= iter
::repeat('a'
).take(4096).collect
::<String
>();
36 b
.bytes
= string
.len() as u64;
38 string
.chars().all(char::is_xid_start
)
42 #[cfg(feature = "bench")]
44 fn cargo_xid_continue(b
: &mut Bencher
) {
45 let string
= iter
::repeat('a'
).take(4096).collect
::<String
>();
47 b
.bytes
= string
.len() as u64;
49 string
.chars().all(UnicodeXID
::is_xid_continue
)
53 #[cfg(feature = "bench")]
55 fn stdlib_xid_continue(b
: &mut Bencher
) {
56 let string
= iter
::repeat('a'
).take(4096).collect
::<String
>();
58 b
.bytes
= string
.len() as u64;
60 string
.chars().all(char::is_xid_continue
)
65 fn test_is_xid_start() {
68 '
\u{1000d}'
, '
\u{10026}'
,
72 assert
!(UnicodeXID
::is_xid_start(*ch
), "{}", ch
);
77 fn test_is_not_xid_start() {
81 ' '
, '
['
, '
<'
, '
{'
, '
('
,
82 '
\u{02c2}'
, '
\u{ffff}'
,
86 assert
!(!UnicodeXID
::is_xid_start(*ch
), "{}", ch
);
91 fn test_is_xid_continue() {
93 '
0'
, '
9'
, 'A'
, 'Z'
, 'a'
, 'z'
, '_'
,
94 '
\u{1000d}'
, '
\u{10026}'
,
98 assert
!(UnicodeXID
::is_xid_continue(*ch
), "{}", ch
);
103 fn test_is_not_xid_continue() {
106 ' '
, '
['
, '
<'
, '
{'
, '
('
,
107 '
\u{02c2}'
, '
\u{ffff}'
,
111 assert
!(!UnicodeXID
::is_xid_continue(ch
), "{}", ch
);