Skip to content

Commit

Permalink
Version 0.1.3
Browse files Browse the repository at this point in the history
Support 900 mil DIP-64 and 1300 mil DIP-60 DCJ11 packages
  • Loading branch information
tgtakaoka committed Apr 29, 2024
1 parent b3995f9 commit 0b66a3d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dip"
version = "0.1.2"
version = "0.1.3"
authors = ["Tadashi G. Takaoka <tadashi.g.takaoka@gmail.com>"]
edition = "2018"
description = "Dual Inline Package visualizer with ASCII art"
Expand All @@ -9,7 +9,7 @@ repository = "https://github.com/tgtakaoka/dip.git"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "2.*.*" }
structopt = { version = "0.3", default-features = false }
toml = "0.5"
unicode-segmentation = "1.7.1"
clap = "*"
structopt = "*"
toml = "*"
unicode-segmentation = "*"
28 changes: 20 additions & 8 deletions src/dip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pub enum DipWidth {
MIL300,
MIL500,
MIL600,
MIL900,
MIL1300,
}

#[derive(Debug, PartialEq)]
Expand Down Expand Up @@ -232,6 +234,8 @@ impl Dip {
DipWidth::MIL300 => 5,
DipWidth::MIL500 => 7,
DipWidth::MIL600 => 9,
DipWidth::MIL900 => 15,
DipWidth::MIL1300 => 23,
}
}

Expand Down Expand Up @@ -371,6 +375,8 @@ impl Dip {
DipWidth::MIL300 => 4,
DipWidth::MIL500 => 5,
DipWidth::MIL600 => 6,
DipWidth::MIL900 => 8,
DipWidth::MIL1300 => 13,
}
}

Expand Down Expand Up @@ -549,8 +555,8 @@ impl FromStr for Dip {
Some(v) => match v.as_integer() {
None => return Err("dip package must be number".to_string()),
Some(n) if n <= 0 => return Err(format!("dip package {} must be positive", n)),
Some(n) if n >= 50 => {
return Err(format!("dip package {} must be less than 50", n))
Some(n) if n >= 80 => {
return Err(format!("dip package {} must be less than 80", n))
}
Some(n) if n % 2 != 0 => return Err(format!("dip package {} must be even", n)),
Some(n) => usize::try_from(n).ok().unwrap(),
Expand All @@ -564,7 +570,9 @@ impl FromStr for Dip {
Some(w) if w == 300 => DipWidth::MIL300,
Some(w) if w == 500 => DipWidth::MIL500,
Some(w) if w == 600 => DipWidth::MIL600,
Some(w) => return Err(format!("width {} must be 300 or 600 mil", w)),
Some(w) if w == 900 => DipWidth::MIL900,
Some(w) if w == 1300 => DipWidth::MIL1300,
Some(w) => return Err(format!("unknown DIP width {}", w)),
},
};

Expand Down Expand Up @@ -686,8 +694,8 @@ fn test_decode_error() {
Some("dip package -2 must be positive".to_string())
);
assert_eq!(
Dip::from_str("name = \"SN7400\"\ndip = 50").err(),
Some("dip package 50 must be less than 50".to_string())
Dip::from_str("name = \"SN7400\"\ndip = 80").err(),
Some("dip package 80 must be less than 80".to_string())
);
assert_eq!(
Dip::from_str("name = \"SN7400\"\ndip = 7").err(),
Expand All @@ -702,8 +710,12 @@ fn test_decode_error() {
Some("width must be number in mil".to_string())
);
assert_eq!(
Dip::from_str("name = \"SN7400\"\ndip = 8\nwidth = 400").err(),
Some("width 400 must be 300 or 600 mil".to_string())
Dip::from_str("name = \"SN7400\"\ndip = 8\nwidth = 200").err(),
Some("unknown DIP width 200".to_string())
);
assert_eq!(
Dip::from_str("name = \"SN7400\"\ndip = 8\nwidth = 350").err(),
Some("unknown DIP width 350".to_string())
);
assert_eq!(
Dip::from_str(
Expand Down Expand Up @@ -752,7 +764,7 @@ fn test_decode_error() {
"#
)
.err(),
Some("duplicate key: `1` at line 1 column 1".to_string())
Some("TOML parse error at line 6, column 13\n |\n6 | 1 = \"pin2\"\n | ^\nduplicate key `1` in document root\n".to_string())
);
assert_eq!(
Dip::from_str(
Expand Down

0 comments on commit 0b66a3d

Please sign in to comment.