Skip to content

Commit efa0430

Browse files
committed
rename to unicode-width ; add tests from libcoretests for char.width()
1 parent 5a5364d commit efa0430

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22

3-
name = "unicode_width"
3+
name = "unicode-width"
44
version = "0.0.1"
55
authors = ["kwantam <kwantam@gmail.com>"]
66

7-
homepage = "https://github.com/unicode-rs/unicode_width"
8-
repository = "https://github.com/unicode-rs/unicode_width"
9-
documentation = "https://unicode-rs.github.io/unicode_width/unicode_width"
7+
homepage = "https://github.com/unicode-rs/unicode-width"
8+
repository = "https://github.com/unicode-rs/unicode-width"
9+
documentation = "https://unicode-rs.github.io/unicode-width/unicode-width"
1010
license = "MIT/Apache-2.0"
1111
keywords = ["text", "width", "unicode"]
1212
readme = "README.md"

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# unicode_width
1+
# unicode-width
22

33
Determine displayed width of `char` and `str` types according to
44
[Unicode Standard Annex #11](http://www.unicode.org/reports/tr11/)
55
rules.
66

7-
[![Build Status](https://travis-ci.org/unicode-rs/unicode_width.svg?branch=master)](https://travis-ci.org/unicode-rs/unicode_width)
7+
[![Build Status](https://travis-ci.org/unicode-rs/unicode-width.svg?branch=master)](https://travis-ci.org/unicode-rs/unicode-width)
88

99
```rust
1010
extern crate unicode_width;
@@ -21,4 +21,4 @@ fn main() {
2121
}
2222
```
2323

24-
[Documentation](http://unicode-rs.github.io/unicode_width/unicode_width/)
24+
[Documentation](http://unicode-rs.github.io/unicode-width/unicode-width/)

src/lib.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
//!
3535
//! ```toml
3636
//! [dependencies]
37-
//! unicode_width = "0.0.1"
37+
//! unicode-width = "0.0.1"
3838
//! ```
3939
4040
#![deny(missing_docs, unsafe_code)]
@@ -144,4 +144,34 @@ mod tests {
144144
assert_eq!(UnicodeWidthChar::width('\u{2081}'), Some(1));
145145
assert_eq!('\u{2081}'.width_cjk(), Some(2));
146146
}
147+
148+
#[test]
149+
fn test_char2() {
150+
use super::UnicodeWidthChar;
151+
use core::option::Option::{Some, None};
152+
153+
assert_eq!(UnicodeWidthChar::width('\x00'),Some(0));
154+
assert_eq!('\x00'.width_cjk(),Some(0));
155+
156+
assert_eq!(UnicodeWidthChar::width('\x0A'),None);
157+
assert_eq!('\x0A'.width_cjk(),None);
158+
159+
assert_eq!(UnicodeWidthChar::width('w'),Some(1));
160+
assert_eq!('w'.width_cjk(),Some(1));
161+
162+
assert_eq!(UnicodeWidthChar::width('h'),Some(2));
163+
assert_eq!('h'.width_cjk(),Some(2));
164+
165+
assert_eq!(UnicodeWidthChar::width('\u{AD}'),Some(1));
166+
assert_eq!('\u{AD}'.width_cjk(),Some(1));
167+
168+
assert_eq!(UnicodeWidthChar::width('\u{1160}'),Some(0));
169+
assert_eq!('\u{1160}'.width_cjk(),Some(0));
170+
171+
assert_eq!(UnicodeWidthChar::width('\u{a1}'),Some(1));
172+
assert_eq!('\u{a1}'.width_cjk(),Some(2));
173+
174+
assert_eq!(UnicodeWidthChar::width('\u{300}'),Some(0));
175+
assert_eq!('\u{300}'.width_cjk(),Some(0));
176+
}
147177
}

0 commit comments

Comments
 (0)