From dbda9014990af524a48348c42cd1e44d757e79f4 Mon Sep 17 00:00:00 2001 From: Julian Daube Date: Thu, 4 Jul 2019 22:09:56 +0200 Subject: [PATCH] add tests --- tests/__main__.py | 56 ++++++++++++++++++++++++++++++++++++++ tests/test_aref.gds | Bin 0 -> 318 bytes tests/test_coords.gds | Bin 0 -> 170 bytes tests/test_path.gds | Bin 0 -> 168 bytes tests/test_sref.gds | Bin 0 -> 400 bytes tests/test_sref_depth.gds | Bin 0 -> 622 bytes tests/test_text.gds | Bin 0 -> 244 bytes 7 files changed, 56 insertions(+) create mode 100644 tests/__main__.py create mode 100644 tests/test_aref.gds create mode 100644 tests/test_coords.gds create mode 100644 tests/test_path.gds create mode 100644 tests/test_sref.gds create mode 100644 tests/test_sref_depth.gds create mode 100644 tests/test_text.gds diff --git a/tests/__main__.py b/tests/__main__.py new file mode 100644 index 0000000..d9a7ffd --- /dev/null +++ b/tests/__main__.py @@ -0,0 +1,56 @@ +import sys +import os + +import math +import progress.bar +import glob + +# allow import from parent directory +sys.path.append(os.path.dirname(sys.path[0])) + +import gds + +global bar + +def callback(parser): + global bar + + bar.max = parser.total + bar.index = parser.current + bar.update() + +for arg in glob.glob("{}/tests/*.gds".format(sys.path[0])): + f = open(arg, "rb") + try: + bar = progress.bar.IncrementalBar("parsing file") + lib = gds.parse_file(f, progress_func=callback) + print() + + print("file version: {}".format(lib.version)) + print("last access: {}".format(lib.last_access.isoformat())) + print("last modification: {}".format(lib.last_mod.isoformat())) + print("m/unit : {}".format(lib.meters_per_unit)) + print("unit/dbunit : {}".format(lib.units_per_dbunit)) + + print("library name : {}".format(lib.name)) + print("contains a total of {} structure(s)".format(len(lib.structures))) + + for name in lib.structures.keys(): + #print(name, end = " ") + print("- {}".format(name)) + for elem in lib.structures[name].elements: + if isinstance(elem, gds.Boundary): + for coord in elem.points: + coord = (coord[0] * lib.units_per_dbunit , coord[1] * lib.units_per_dbunit) + + print("linking structure references") + lib.link_all_refs(callback) + + except gds.ParserError as e: + print("parser error: {}".format(e)) + except KeyboardInterrupt: + continue + finally: + f.close() + +print("all done") diff --git a/tests/test_aref.gds b/tests/test_aref.gds new file mode 100644 index 0000000000000000000000000000000000000000..3caa67c14e5ecfa28b631197b6e7bbad917d2d98 GIT binary patch literal 318 zcmaKmJxT*n6otR{=Dj-u&V(2PicV>7At-6YfmE@z5F4?G?Z7xLLN{O$1Up@VE67IN zfK|Z8ct(lX=)1goF8Al0gW>%drSs`4DUO0oc7NCOytUKo_TsXcUcoSlN7e1&$^7YU zG=AB8oSmOi#=o!4tb&k%6<++-^T4>DC>Q$g%jL&DxC7xmB)PDL*l4Dmcq7~b|EwML z++uY{SQl@~zv`J;Q`aqFP5Oh*iETSE@%XDy$~HVhMcMgt6M31#!`(N! L3C!$AHv~Qb*1j>f literal 0 HcmV?d00001 diff --git a/tests/test_coords.gds b/tests/test_coords.gds new file mode 100644 index 0000000000000000000000000000000000000000..f4021aacc5c8f582ea9f0d768ebb4ab6bd65fa88 GIT binary patch literal 170 zcmZQzV_;&6V31*CVt>rQ&cMXL!=T5YiOgo;U}E#}bYfr-VP>^+>@@d2w)}&o%MSeo zv!g;7WLWX&V`D4I&o5zM;b353<7HxCWMJcCVqjp<5n%rR|HcOxW?)bkK*lg}5Y50M M$iTqD4#X@B09_|2D*ylh literal 0 HcmV?d00001 diff --git a/tests/test_path.gds b/tests/test_path.gds new file mode 100644 index 0000000000000000000000000000000000000000..d2373407c9448ee47d728afba88f88b3a5e60765 GIT binary patch literal 168 zcmZQzV_;&6V31*CVt>rQ&cMtd$RNSMh0JE)U}E#}bYfr-VP>^+>@@d2w)}&o%MSeo zv!g;7WLWX&V`D4I&o5zM;bdT7<7HxCWMJcCVgRxgK_mx1GXn$j3kDeh=KufyNB~8E Xfc*l9gz&j{Ft7+RFtD%#F$)6#-W?ds literal 0 HcmV?d00001 diff --git a/tests/test_sref.gds b/tests/test_sref.gds new file mode 100644 index 0000000000000000000000000000000000000000..6fb5db10f0b3222139bddb4929fd14a52eec2073 GIT binary patch literal 400 zcmZQzV_;&6V31*CVt>rQ&cMVV!XU~ZfXrs#U}E#}bYfr-VP>^+>@@d2w)}&o%MSeo zv!g;7WLRhgPDx8CPGexrQ&cMvT%b>!bhRkN*U}E#}bYfr-VP>^+>@@d2w)}&o%MSeo zv!g;7WLRhgPDx8CPGexf&Vty1L$3hTtw47>E&#JV7{Gej3>g^M_3`ReKrQ#vsSQ#bCg|ip*x^+>@@d2w)}&o%MSeo zv!g;7WLWX&V`D4I&o5zM;bCB4<7HxCWMC6xVgRzm85uYjcm$aL|NlRmfq|KgfkTol j#5FjCfklu3uj)4p42<)LRsC-b0|QeLs%mzi`78_o#&aT1 literal 0 HcmV?d00001