~cypheon/kicad2spice

8943c6229c677f2576248325bb2e409fd720ad27 — Johann Rudloff 5 years ago f18e5ec
Add tests.
3 files changed, 19 insertions(+), 0 deletions(-)

M eeschema2netlist.opam
A test/dune
A test/tokenize.ml
M eeschema2netlist.opam => eeschema2netlist.opam +1 -0
@@ 9,6 9,7 @@ synopsis: "Generate netlists from Kicad schema files"
depends: [
  "dune" {build}
  "menhir" {build}
  "alcotest" {build}
  "batteries" { >= "2.9" }
  "ppx_deriving" { build & >= "4.3" }
  "ppx_compare" { build & >= "0.12" }

A test/dune => test/dune +4 -0
@@ 0,0 1,4 @@
(test
  (name tokenize)
  (libraries eeschema alcotest)
  )

A test/tokenize.ml => test/tokenize.ml +14 -0
@@ 0,0 1,14 @@
open Eeschema

let test () = List.iter (fun (expected_tokens, line) -> Alcotest.(check (list string)) "simple tokenization" expected_tokens (Lex_tokenize.tokenize line)) [
    ["L";"power:GND";"#PWR02"], "L power:GND #PWR02";
    ["F";"0";"#PWR02";"H";"2050";"1400";"50";"0001";"C";"CNN"], "F 0 \"#PWR02\" H 2050 1400 50  0001 C CNN";
    ["F";"0";"#PWR02 with  spaces ";"H";"2050";"1400";"50";"0001";"C";"CNN"], "F 0 \"#PWR02 with  spaces \" H 2050 1400 50  0001 C CNN";
    ["F";"2";"";"H";"2050";"1650";"50";"0001";"C";"CNN"], "F 2 \"\" H 2050 1650 50  0001 C CNN";
    ["1";"2050";"1650"], "	1    2050 1650";
  ]

let () =
  Alcotest.run "tokenize" [
    "all", ["simple tokenizations", `Quick, test]
  ]