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]
+ ]