// Copyright 2015 The Servo Project Developers. // Copyright 2017 The UNIC Project Developers. // // See the COPYRIGHT file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Based on *General Scope* of *Bidirectional Character Types* table. //! //! Reference: #[macro_use] extern crate matches; #[macro_use] extern crate unic_char_range; use unic_ucd::bidi::BidiClass as BC; use unic_ucd::category::GeneralCategory as GC; #[test] #[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))] fn test_from_bidi_class() { for cp in chars!(..) { match BC::of(cp) { // == Strong == // BC::LeftToRight => { // TODO: Impl using Script property, etc } // BC::RightToLeft => { // TODO: Impl using Script property, etc } // BC::ArabicLetter => { // TODO: Impl using Script property, etc } // == Weak == // BC::EuropeanNumber => { assert!(GC::of(cp).is_number()); } // BC::EuropeanSeparator => { assert!(matches!(GC::of(cp), GC::MathSymbol | GC::DashPunctuation)); } // BC::EuropeanTerminator => { assert!( GC::of(cp).is_symbol() || matches!(GC::of(cp), GC::Unassigned | GC::OtherPunctuation) ); } // BC::ArabicNumber => { assert!(matches!( GC::of(cp), GC::Format | GC::OtherNumber | GC::OtherPunctuation | GC::DecimalNumber )); } // BC::CommonSeparator => { assert!(matches!( GC::of(cp), GC::OtherPunctuation | GC::SpaceSeparator | GC::MathSymbol )); } // Every NSM must be a GC=Mark // // BC::NonspacingMark => { assert!(GC::of(cp).is_mark()); } // BC::BoundaryNeutral => { assert!(GC::of(cp).is_other()); } // == Neutral == // BC::ParagraphSeparator => { assert!(matches!(GC::of(cp), GC::Control | GC::ParagraphSeparator)); } // BC::SegmentSeparator => { assert!(matches!(GC::of(cp), GC::Control)); } // BC::WhiteSpace => { assert!(matches!( GC::of(cp), GC::Control | GC::SpaceSeparator | GC::LineSeparator )); } // BC::OtherNeutral => { assert!(!matches!( GC::of(cp), GC::UppercaseLetter | GC::LowercaseLetter | GC::TitlecaseLetter | GC::OtherLetter | GC::NonspacingMark | GC::SpacingMark | GC::EnclosingMark | GC::DecimalNumber | GC::SpaceSeparator | GC::LineSeparator | GC::ParagraphSeparator )); } // == Explicit Formatting == BC::LeftToRightEmbedding | BC::LeftToRightIsolate | BC::LeftToRightOverride | BC::RightToLeftEmbedding | BC::RightToLeftIsolate | BC::RightToLeftOverride | BC::FirstStrongIsolate | BC::PopDirectionalFormat | BC::PopDirectionalIsolate => { assert_eq!(GC::of(cp), GC::Format); } } } } #[test] fn test_from_general_category() { for cp in chars!(..) { if !GC::of(cp).is_mark() { // Every GC!=Mark must not be an NSM // // assert_ne!(BC::of(cp), BC::NonspacingMark); } } }