Example program with default formatting
diff --git a/docs/src/ntext/numtext.rs.html b/docs/src/ntext/numtext.rs.html
index 7463c20..2124104 100644
--- a/docs/src/ntext/numtext.rs.html
+++ b/docs/src/ntext/numtext.rs.html
@@ -320,7 +320,7 @@
pub fn to_text_fmt(number: usize, fmt: &Formatting) -> String {
let mut numtext: String = String::new();
let mut last: Option<u8> = None;
- let tens_place_holders: [u8; 2] = [2, 5];
+ let tens_place_holders: [u8; 3] = [2, 5, 7];
let digits: Vec<u8> = number
.to_string()
.chars()
@@ -343,7 +343,7 @@
if let Some(last_digit) = last {
numtext.push_str(tens_place(last_digit, *digit, fmt).unwrap().as_str());
if place > 2 {
- if let Some(sep) = fmt.digit_seperator {
+ if let Some(sep) = fmt.place_seperator {
numtext.push_str(sep);
}
numtext.push_str(place_value(0, place, fmt).unwrap().as_str());
diff --git a/docs/src/ntext/test.rs.html b/docs/src/ntext/test.rs.html
index bfe02eb..e4ccf88 100644
--- a/docs/src/ntext/test.rs.html
+++ b/docs/src/ntext/test.rs.html
@@ -29,6 +29,21 @@
26
27
28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
#[cfg(test)]
mod tests {
@@ -57,6 +72,21 @@
);
assert_eq!(to_text(12, fmt), "twelve");
}
+ #[test]
+ fn numbers_formatting() {
+ use crate::to_text_fmt as to_text;
+ use crate::Formatting;
+ let fmt = &Formatting::default();
+ assert_eq!(to_text(1, fmt), "One");
+ assert_eq!(to_text(10, fmt), "Ten");
+ assert_eq!(to_text(100, fmt), "One Hundred");
+ assert_eq!(to_text(1000, fmt), "One Thousand");
+ assert_eq!(to_text(12315, fmt), "Twelve Thousand,Three Hundred,Fifteen");
+ assert_eq!(
+ to_text(1235245, fmt),
+ "Twelve Million,Thirty-Five Thousand,Two Hundred,Forty-Five"
+ );
+ }
}