Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
puripuri2100 committed May 9, 2024
1 parent 797816a commit dff692b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion jplaw_data_types/src/law.rs
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ impl FromStr for LawIdType {
use LawIdType::*;
if s == "CONSTITUTION" {
Ok(Constitution)
} else if &s[0..1] == "AC" {
} else if &s[0..=1] == "AC" {
let rippou_type_s = &s[2..=8].parse::<usize>().map_err(|_| ())?;
let rippou_type = if *rippou_type_s == 0 {
RippouType::Kakuhou
Expand Down Expand Up @@ -1155,6 +1155,24 @@ fn check_from_str_law_id() {
assert_eq!(law_id.to_string(), s);
}

#[test]
fn check_from_str_law_id_2() {
let s = "345AC0000000089";
let law_id = LawId::from_str(s).unwrap();
assert_eq!(
law_id,
LawId {
era: Era::Showa,
year: 45,
law_id_type: LawIdType::Act {
rippou_type: RippouType::Kakuhou,
num: 89
}
}
);
assert_eq!(law_id.to_string(), s);
}

/// 法令のデータ
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub struct LawData {
Expand Down

0 comments on commit dff692b

Please sign in to comment.