mirror of
https://github.com/openharmony/third_party_rust_unicode-width.git
synced 2026-07-18 13:18:15 -04:00
rename to unicode-width ; add tests from libcoretests for char.width()
This commit is contained in:
+4
-4
@@ -1,12 +1,12 @@
|
||||
[package]
|
||||
|
||||
name = "unicode_width"
|
||||
name = "unicode-width"
|
||||
version = "0.0.1"
|
||||
authors = ["kwantam <kwantam@gmail.com>"]
|
||||
|
||||
homepage = "https://github.com/unicode-rs/unicode_width"
|
||||
repository = "https://github.com/unicode-rs/unicode_width"
|
||||
documentation = "https://unicode-rs.github.io/unicode_width/unicode_width"
|
||||
homepage = "https://github.com/unicode-rs/unicode-width"
|
||||
repository = "https://github.com/unicode-rs/unicode-width"
|
||||
documentation = "https://unicode-rs.github.io/unicode-width/unicode-width"
|
||||
license = "MIT/Apache-2.0"
|
||||
keywords = ["text", "width", "unicode"]
|
||||
readme = "README.md"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# unicode_width
|
||||
# unicode-width
|
||||
|
||||
Determine displayed width of `char` and `str` types according to
|
||||
[Unicode Standard Annex #11](http://www.unicode.org/reports/tr11/)
|
||||
rules.
|
||||
|
||||
[](https://travis-ci.org/unicode-rs/unicode_width)
|
||||
[](https://travis-ci.org/unicode-rs/unicode-width)
|
||||
|
||||
```rust
|
||||
extern crate unicode_width;
|
||||
@@ -21,4 +21,4 @@ fn main() {
|
||||
}
|
||||
```
|
||||
|
||||
[Documentation](http://unicode-rs.github.io/unicode_width/unicode_width/)
|
||||
[Documentation](http://unicode-rs.github.io/unicode-width/unicode-width/)
|
||||
|
||||
+31
-1
@@ -34,7 +34,7 @@
|
||||
//!
|
||||
//! ```toml
|
||||
//! [dependencies]
|
||||
//! unicode_width = "0.0.1"
|
||||
//! unicode-width = "0.0.1"
|
||||
//! ```
|
||||
|
||||
#![deny(missing_docs, unsafe_code)]
|
||||
@@ -144,4 +144,34 @@ mod tests {
|
||||
assert_eq!(UnicodeWidthChar::width('\u{2081}'), Some(1));
|
||||
assert_eq!('\u{2081}'.width_cjk(), Some(2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_char2() {
|
||||
use super::UnicodeWidthChar;
|
||||
use core::option::Option::{Some, None};
|
||||
|
||||
assert_eq!(UnicodeWidthChar::width('\x00'),Some(0));
|
||||
assert_eq!('\x00'.width_cjk(),Some(0));
|
||||
|
||||
assert_eq!(UnicodeWidthChar::width('\x0A'),None);
|
||||
assert_eq!('\x0A'.width_cjk(),None);
|
||||
|
||||
assert_eq!(UnicodeWidthChar::width('w'),Some(1));
|
||||
assert_eq!('w'.width_cjk(),Some(1));
|
||||
|
||||
assert_eq!(UnicodeWidthChar::width('h'),Some(2));
|
||||
assert_eq!('h'.width_cjk(),Some(2));
|
||||
|
||||
assert_eq!(UnicodeWidthChar::width('\u{AD}'),Some(1));
|
||||
assert_eq!('\u{AD}'.width_cjk(),Some(1));
|
||||
|
||||
assert_eq!(UnicodeWidthChar::width('\u{1160}'),Some(0));
|
||||
assert_eq!('\u{1160}'.width_cjk(),Some(0));
|
||||
|
||||
assert_eq!(UnicodeWidthChar::width('\u{a1}'),Some(1));
|
||||
assert_eq!('\u{a1}'.width_cjk(),Some(2));
|
||||
|
||||
assert_eq!(UnicodeWidthChar::width('\u{300}'),Some(0));
|
||||
assert_eq!('\u{300}'.width_cjk(),Some(0));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user