pub mod codes;
pub mod ic;
pub mod random;
pub use codes::{get_loc_code, LOC_CODES, REGION_CODES, SIGN_CODES, VERIFY_CODES};
pub use ic::{compute_verify_code, IdentityCard};
pub use random::generate_identitycard;
#[cfg(test)]
mod tests {
use crate::{generate_identitycard, IdentityCard};
use std::str::FromStr;
#[test]
fn test_random() {
let ic = generate_identitycard("610102".to_string(), "19910201".to_string());
assert_eq!(ic.to_string().starts_with("610102"), true);
assert_eq!(ic.to_string().starts_with("61010219910201"), true);
assert_eq!(ic.verify_ic(), true);
}
#[test]
fn test_fromstr() {
let ic_number = "440222199602175492";
let ic = IdentityCard::from_str(ic_number).unwrap();
println!("{:#?}\n{}", ic, ic);
assert_eq!(ic.to_string(), ic_number.to_string());
assert_eq!(ic.verify_ic(), true);
}
#[test]
fn test_leap() {
let ic = generate_identitycard("西安市".to_string(), "202002".to_string());
println!("{:#?}", ic);
assert_eq!(ic.verify_ic(), true)
}
}