Skip to content

Commit

Permalink
added test and update the lib doc to show the usecase of need_reshape
Browse files Browse the repository at this point in the history
  • Loading branch information
YouKnow-sys committed Oct 31, 2023
1 parent 39f0db1 commit a0a3106
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@
//! println!("{line}");
//! }
//! ```
//!
//! You can also check if a text need reshaping or not, this method can be
//! useful when you dont want a copy of original string in case of no reshape.
//! ```rust
//! use ar_reshaper::ArabicReshaper;
//!
//! let reshaper = ArabicReshaper::default();
//!
//! let text = "من به reshape نیاز دارم";
//! if reshaper.need_reshape(text) {
//! println!("{}", reshaper.reshape(text));
//! }
//! ```
//!
//! A rusty rewrite of [python-arabic-reshaper](https://github.com/mpcabd/python-arabic-reshaper)
//! You can check the original repository for more information.
Expand Down
16 changes: 16 additions & 0 deletions tests/basic_reshaping.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
use ar_reshaper::ArabicReshaper;

#[test]
fn need_reshape() {
let reshaper = ArabicReshaper::default();

let cases = [
("سلام", true),
("خوبی؟", true),
("Yeah, Im good", false),
("How about you?", false),
];

for (text, neeed_reshape) in cases {
assert_eq!(reshaper.need_reshape(text), neeed_reshape);
}
}

#[test]
fn default_reshaping() {
let reshaper = ArabicReshaper::default();
Expand Down

0 comments on commit a0a3106

Please sign in to comment.