Start work on testing v0

This commit is contained in:
Austen Adler 2023-02-17 01:01:45 +00:00
parent d990e98de9
commit f70d8524bb
3 changed files with 25 additions and 6 deletions

View File

@ -1,4 +1,22 @@
use std::str::FromStr;
use this_algorithm::Address;
mod common;
#[test]
fn test_v0() {
t("grape orange apple 1000");
t("1000 apple orange grape");
t("\t\tgrape\n\t orange apple 1000 \t ");
t("\n1000 APPlE oRAnGE GrAPe\n");
ll(37.55512, -76.89212);
assert!(false);
}
fn ll(lat: f64, lon: f64) {
eprintln!("{lat}, {lon} =>\t{}", Address::from_lat_lon(lat, lon));
}
fn t(s: &str) {
eprintln!("{:?}", Address::from_str(s));
}
// #[test]
// fn test_address() {

View File

@ -35,10 +35,12 @@ fn main() {
}
fn write_words(mut file: impl Write, words: &[Word]) {
let len = words.len();
writeln!(
&mut file,
r#"/// Static array of `Word`
pub const WORDS: &[Word] = &["#
pub static WORDS: [Word; {len}] = ["#
)
.unwrap();
@ -57,8 +59,7 @@ fn write_word_map(mut file: impl Write, words: &[Word]) {
writeln!(
&mut file,
r#"/// Mapping from all caps `&str` to `&'static Word`
pub static WORD_MAP: phf::Map<&'static str, &'static Word> =
{};"#,
pub static WORD_MAP: phf::Map<&'static str, &'static Word> = {};"#,
word_map.build()
)
.unwrap();
@ -73,8 +74,8 @@ fn write_number_to_words(mut file: impl Write, words: &[Word]) {
writeln!(
&mut file,
// "pub const NUMBER_TO_WORDS: &[&[usize]] = &["
"pub const NUMBER_TO_WORDS: &[&[&'static Word]] = &["
// "pub static NUMBER_TO_WORDS: &[&[usize]] = &["
"pub static NUMBER_TO_WORDS: &[&[&'static Word]] = &["
)
.unwrap();

View File

@ -16,7 +16,7 @@ pub struct Word<'a> {
impl Display for Word<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self)
write!(f, "{}", self.word)
}
}