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 zcmZQzV_;&6V31*CVt>rQ&cMjP%OK96g3M;%V`3{wEiQ>qEJ{sdU=U$uwR7w=_dd4# zgQd$3{ROk5LKtLNaqDJdV{>F+VBuh3VB=+CU}Rw9V`5-na1mf;U|`^7U|{(9|NlQ@ z1_nm6|Ns9@XJBCF`Tzf4J_7@55d#AQGXn!_DFXw81Oo%p3I+zoA_fM=Z!mofEP@OS zEbI(;ZRcQPE6UF=VPN5AU|rQ&cMXL!=T5YiOgo;U}E#}bYfr-VP>^+>@@d2w)}&o%MSeo zv!g;7WLWX&V`D4I&o5zM;b353<7HxCWMJcCVqjp<5n%rR|HcOxW?)bkK*lg}5Y50M O$iTqD&cMLJ!TrQ&cMtd$RNSMh0JE)U}E#}bYfr-VP>^+>@@d2w)}&o%MSeo zv!g;7WLWX&V`D4I&o5zM;bdT7<7HxCWMJcCVqjokQv{J5{LBmt%r6*Z1epK-|0BTw Z2J9C=6ok*cgMmemfq{jcfq{jE0RY||7|Z|w 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;7WLRhgPDx8CPGexAinS?qTIm2##WS{U&6q`MZDcSAUjz-7#LWyAa>x;D*$yXj|{8h0x;Wy0j!tJ zkb!|+AFo~{KRbZ6g2Do1FYjgs2DYsbz1$280z#-^NOY+E|Nk|Qfr0HlIt?+Ioq>Uc Gg#iE{9AS9? literal 0 HcmV?d00001 diff --git a/tests/test_text.gds b/tests/test_text.gds new file mode 100644 index 0000000000000000000000000000000000000000..4f85f90bb4cf2e6c0ebc7ac40a19352e8e315852 GIT binary patch literal 244 zcmZQzV_;&6V31*CVt>rQ#vsSQ#bCg|ip*x^+>@@d2w)}&o%MSeo zv!g;7WLWX&V`D4I&o5zM;bCB4<7HxCWMC6xVqjok6K7=LVBis8{{R2~Yz78qHU