Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bindings/nodejs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(dead_code)]

extern crate napi_derive;

mod cep;
Expand Down
12 changes: 5 additions & 7 deletions core/src/cep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ mod tests {

#[test]
fn is_valid_accepts_valid_formatted() {
assert!(is_valid(&cep_sp().to_string()));
assert!(is_valid(&cep_rj().to_string()));
assert!(is_valid(cep_sp().as_ref()));
assert!(is_valid(cep_rj().as_ref()));
}

#[test]
Expand Down Expand Up @@ -349,8 +349,8 @@ mod tests {

#[test]
fn strict_accepts_valid_formatted() {
assert!(is_valid_strict(&cep_sp().to_string()).is_ok());
assert!(is_valid_strict(&cep_rj().to_string()).is_ok());
assert!(is_valid_strict(cep_sp().as_ref()).is_ok());
assert!(is_valid_strict(cep_rj().as_ref()).is_ok());
}

#[test]
Expand Down Expand Up @@ -543,9 +543,7 @@ mod tests {
assert_eq!(
cep.state(),
Some(state),
"CEP {} should map to {:?}",
cep,
state
"CEP {cep} should map to {state:?}"
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/cnpj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ mod tests {
let result = is_valid("00623904000173");
// It's valid only if check digits match - let's compute
if let Some((d1, d2)) = compute_check_digits("006239040001") {
let cnpj_str = alloc::format!("006239040001{}{}", d1, d2);
let cnpj_str = alloc::format!("006239040001{d1}{d2}");
assert!(is_valid(&cnpj_str));
let cnpj: Cnpj = cnpj_str.parse().unwrap();
assert!(cnpj.as_str().starts_with("00"));
Expand Down
19 changes: 8 additions & 11 deletions core/src/municipio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27984,9 +27984,7 @@ mod tests {
assert!(
(a.state as u8) < (b.state as u8)
|| ((a.state as u8) == (b.state as u8) && a.name <= b.name),
"{} should come before {}",
a,
b
"{a} should come before {b}"
);
}
}
Expand All @@ -27995,7 +27993,7 @@ mod tests {
fn each_state_has_municipalities() {
for &state in &crate::uf::ALL {
let munis = Municipio::by_state(state);
assert!(!munis.is_empty(), "{:?} has no municipalities", state);
assert!(!munis.is_empty(), "{state:?} has no municipalities");
}
}

Expand All @@ -28004,8 +28002,7 @@ mod tests {
for &code in &CAPITAL_CODES {
assert!(
Municipio::from_ibge_code(code).is_some(),
"Capital code {} not found",
code
"Capital code {code} not found"
);
}
}
Expand All @@ -28021,15 +28018,15 @@ mod tests {

#[test]
fn from_ibge_code_sao_paulo() {
let sp = Municipio::from_ibge_code(3550308).unwrap();
let sp = Municipio::from_ibge_code(3_550_308).unwrap();
assert_eq!(sp.name, "São Paulo");
assert_eq!(sp.state, State::SP);
}

#[test]
fn from_ibge_code_returns_none() {
assert!(Municipio::from_ibge_code(0).is_none());
assert!(Municipio::from_ibge_code(9999999).is_none());
assert!(Municipio::from_ibge_code(9_999_999).is_none());
}

#[test]
Expand All @@ -28050,18 +28047,18 @@ mod tests {

#[test]
fn is_capital_correct() {
let sp = Municipio::from_ibge_code(3550308).unwrap();
let sp = Municipio::from_ibge_code(3_550_308).unwrap();
assert!(sp.is_capital());

// Campinas is not a capital
let campinas = Municipio::from_ibge_code(3509502).unwrap();
let campinas = Municipio::from_ibge_code(3_509_502).unwrap();
assert!(!campinas.is_capital());
}

#[test]
fn display_format() {
use alloc::string::ToString;
let sp = Municipio::from_ibge_code(3550308).unwrap();
let sp = Municipio::from_ibge_code(3_550_308).unwrap();
assert_eq!(sp.to_string(), "São Paulo/SP");
}

Expand Down
8 changes: 4 additions & 4 deletions core/tests/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use std::collections::HashMap;
use stdbr_core::{cep, cnpj, cpf, municipio, uf};

fn golden() -> Value {
let path = std::env::var("GOLDEN_JSON")
.unwrap_or_else(|_| "tests/parity/golden.json".to_string());
let json = std::fs::read_to_string(&path)
.unwrap_or_else(|e| panic!("failed to read {path}: {e}"));
let path =
std::env::var("GOLDEN_JSON").unwrap_or_else(|_| "tests/parity/golden.json".to_string());
let json =
std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("failed to read {path}: {e}"));
serde_json::from_str(&json).expect("failed to parse golden.json")
}

Expand Down
Loading