Skip to content

Commit

Permalink
Add GDS to JSON/ YAML/ TOML Conversion CLI. Discover #33 re TOML.
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-fritchman committed Dec 15, 2022
1 parent 61f0446 commit 3f3e5f8
Show file tree
Hide file tree
Showing 8 changed files with 2,986 additions and 8 deletions.
35 changes: 30 additions & 5 deletions gds21/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use chrono::NaiveDate;
// Local Imports
use crate::data::*;
use crate::read::*;
use layout21utils::SerializationFormat::{Json, Yaml, Toml};

/// Specified creation date for test cases
fn test_dates() -> GdsDateTimes {
Expand Down Expand Up @@ -177,19 +178,44 @@ fn record_too_long() -> GdsResult<()> {
}
}

#[test]
fn empty_lib() -> GdsResult<()> {
// Test round-tripping an empty library
/// Create an empty library with known dates
fn empty_lib() -> GdsLibrary {
// Create an empty library
let mut lib = GdsLibrary::new("empty");

// Set its dates to some known value, so we can check it round-trips
lib.dates = test_dates();
// And return it for other test
lib
}
#[test]
fn empty_lib_roundtrip() -> GdsResult<()> {
// Create an empty, testable library
let lib = empty_lib();

// OK now the actual test
roundtrip(&lib)?;
check(&lib, &resource("empty.gds.json"));
Ok(())
}
#[test]
fn empty_lib_to_json() -> GdsResult<()> {
let lib = empty_lib();
Json.save(&lib, &resource("empty.gds.json")).expect("save failed");
Ok(())
}
#[test]
fn empty_lib_to_yaml() -> GdsResult<()> {
let lib = empty_lib();
Yaml.save(&lib, &resource("empty.gds.yaml")).expect("save failed");
Ok(())
}
#[test]
#[ignore] // https://github.com/dan-fritchman/Layout21/issues/33
fn empty_lib_to_toml() -> GdsResult<()> {
let lib = empty_lib();
Toml.save(&lib, &resource("empty.gds.toml")).expect("save failed");
Ok(())
}

#[test]
fn test_invalid_dates() -> GdsResult<()> {
Expand All @@ -207,7 +233,6 @@ fn test_invalid_dates() -> GdsResult<()> {

/// Compare `lib` to "golden" data loaded from JSON at path `golden`.
fn check(lib: &GdsLibrary, fname: &impl AsRef<Path>) {
use layout21utils::SerializationFormat::Json;
// Uncomment this bit to over-write the golden data
// Json.save(lib, fname).unwrap();

Expand Down
8 changes: 7 additions & 1 deletion layout21converters/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ version = "0.2.1"
workspace = "../"
exclude = ["resources",]

# Converts GDS files to protocol buffer descriptions, using Layout21, and Gds21.
[[bin]]
name = "gds2proto"
path = "src/gds2proto.rs"
Expand All @@ -22,13 +23,18 @@ path = "src/proto2gds.rs"
test = true
bench = false

# Converts GDS files to protocol buffer descriptions, using Layout21, and Gds21.
[[bin]]
name = "lef2yaml"
path = "src/lef2yaml.rs"
test = true
bench = false

[[bin]]
name = "gds2ser"
path = "src/gds2ser.rs"
test = true
bench = false

[dependencies]
gds21 = {path = "../gds21"}
lef21 = {path = "../lef21"}
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit 3f3e5f8

Please sign in to comment.