]> git.proxmox.com Git - rustc.git/blame - vendor/unicode-security/src/tests.rs
New upstream version 1.45.0+dfsg1
[rustc.git] / vendor / unicode-security / src / tests.rs
CommitLineData
dfeec247
XL
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.
4//
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.
10
11#[test]
12fn test_general_security_profile_identifier_allowed() {
13 use crate::GeneralSecurityProfile;
14 assert_eq!(GeneralSecurityProfile::identifier_allowed('A'), true);
15 assert_eq!('A'.identifier_allowed(), true);
16 assert_eq!(GeneralSecurityProfile::identifier_allowed('0'), true);
17 assert_eq!('0'.identifier_allowed(), true);
18 assert_eq!(GeneralSecurityProfile::identifier_allowed('_'), true);
19 assert_eq!('_'.identifier_allowed(), true);
20 assert_eq!(GeneralSecurityProfile::identifier_allowed('\x00'), false);
21 assert_eq!('\x00'.identifier_allowed(), false);
22 // U+00B5 MICRO SIGN
23 assert_eq!(GeneralSecurityProfile::identifier_allowed('µ'), false);
24 assert_eq!('µ'.identifier_allowed(), false);
25 // U+2160 ROMAN NUMERAL ONE
26 assert_eq!(GeneralSecurityProfile::identifier_allowed('Ⅰ'), false);
27 assert_eq!('Ⅰ'.identifier_allowed(), false);
28}
29
30#[test]
31fn test_mixed_script() {
32 use crate::MixedScript;
33 assert_eq!("".is_single_script(), true);
34 assert_eq!("".resolve_script_set().is_empty(), false);
35 assert_eq!("".resolve_script_set().is_all(), true);
36 assert_eq!("A".is_single_script(), true);
37 assert_eq!("A".resolve_script_set().is_empty(), false);
38 assert_eq!("A".resolve_script_set().is_all(), false);
39 assert_eq!("A0".is_single_script(), true);
40 assert_eq!("A0".resolve_script_set().is_empty(), false);
41 assert_eq!("A0".resolve_script_set().is_all(), false);
42 assert_eq!("0.".is_single_script(), true);
43 assert_eq!("0.".resolve_script_set().is_empty(), false);
44 assert_eq!("0.".resolve_script_set().is_all(), true);
45 assert_eq!("福".is_single_script(), true);
46 assert_eq!("福".resolve_script_set().is_empty(), false);
47 assert_eq!("福".resolve_script_set().is_all(), false);
48 assert_eq!("冬の雪".is_single_script(), true);
49 assert_eq!("冬の雪".resolve_script_set().is_empty(), false);
50 assert_eq!("冬の雪".resolve_script_set().is_all(), false);
51 assert_eq!("幻ㄒㄧㄤ".is_single_script(), true);
52 assert_eq!("幻ㄒㄧㄤ".resolve_script_set().is_empty(), false);
53 assert_eq!("幻ㄒㄧㄤ".resolve_script_set().is_all(), false);
54 assert_eq!("日出은".is_single_script(), true);
55 assert_eq!("日出은".resolve_script_set().is_empty(), false);
56 assert_eq!("日出은".resolve_script_set().is_all(), false);
57 assert_eq!("夏の幻ㄒㄧㄤ".is_single_script(), false);
58 assert_eq!("夏の幻ㄒㄧㄤ".resolve_script_set().is_empty(), true);
59 assert_eq!("夏の幻ㄒㄧㄤ".resolve_script_set().is_all(), false);
60}
f9f354fc
XL
61
62#[test]
63fn test_confusable_detection() {
64 use crate::skeleton;
65 use std::string::String;
66 assert_eq!(&skeleton("").collect::<String>(), "");
67 assert_eq!(&skeleton("s").collect::<String>(), "s");
68 assert_eq!(&skeleton("sss").collect::<String>(), "sss");
69 assert_eq!(&skeleton("ﶛ").collect::<String>(), "نمى");
70 assert_eq!(&skeleton("ﶛﶛ").collect::<String>(), "نمىنمى");
71}