diff options
Diffstat (limited to 'gerber/tests')
-rw-r--r-- | gerber/tests/resources/example_guess_by_content.g0 | 166 | ||||
-rw-r--r-- | gerber/tests/test_layers.py | 24 |
2 files changed, 189 insertions, 1 deletions
diff --git a/gerber/tests/resources/example_guess_by_content.g0 b/gerber/tests/resources/example_guess_by_content.g0 new file mode 100644 index 0000000..5b26afe --- /dev/null +++ b/gerber/tests/resources/example_guess_by_content.g0 @@ -0,0 +1,166 @@ +G04 ULTIpost, Date: Nov. 01, 2017 09:40 * +G04 Design file: C:\example_guess_by_content.g0 * +G04 Layer name: Bottom * +G04 Scale: 100 percent, Rotated: Yes, Reflected: No * +G75* +%MOIN*% +%OFA0B0*% +%FSLAX24Y24*% +%IPPOS*% +%LPD*% +%AMOC8* +5,1,8,0,0,1.08239X$1,22.5* +% +%ADD10R,0.0340X0.0880*% +%ADD11R,0.0671X0.0237*% +%ADD12R,0.4178X0.4332*% +%ADD13R,0.0930X0.0500*% +%ADD14R,0.0710X0.1655*% +%ADD15R,0.0671X0.0592*% +%ADD16R,0.0592X0.0671*% +%ADD17R,0.0710X0.1615*% +%ADD18R,0.1419X0.0828*% +%ADD19C,0.0634*% +%ADD20C,0.1360*% +%ADD21R,0.0474X0.0580*% +%ADD22C,0.0680*% +%ADD23R,0.0552X0.0552*% +%ADD24C,0.1340*% +%ADD25C,0.0476*% +D10* +X005000Y010604D03* +X005500Y010604D03* +X006000Y010604D03* +X006500Y010604D03* +X006500Y013024D03* +X006000Y013024D03* +X005500Y013024D03* +X005000Y013024D03* +D11* +X011423Y007128D03* +X011423Y006872D03* +X011423Y006616D03* +X011423Y006360D03* +X011423Y006104D03* +X011423Y005848D03* +X011423Y005592D03* +X011423Y005336D03* +X011423Y005080D03* +X011423Y004825D03* +X011423Y004569D03* +X011423Y004313D03* +X011423Y004057D03* +X011423Y003801D03* +X014277Y003801D03* +X014277Y004057D03* +X014277Y004313D03* +X014277Y004569D03* +X014277Y004825D03* +X014277Y005080D03* +X014277Y005336D03* +X014277Y005592D03* +X014277Y005848D03* +X014277Y006104D03* +X014277Y006360D03* +X014277Y006616D03* +X014277Y006872D03* +X014277Y007128D03* +D12* +X009350Y010114D03* +D13* +X012630Y010114D03* +X012630Y010784D03* +X012630Y011454D03* +X012630Y009444D03* +X012630Y008774D03* +D14* +X010000Y013467D03* +X010000Y016262D03* +D15* +X004150Y012988D03* +X004150Y012240D03* +X009900Y005688D03* +X009900Y004940D03* +X015000Y006240D03* +X015000Y006988D03* +D16* +X014676Y008364D03* +X015424Y008364D03* +X017526Y004514D03* +X018274Y004514D03* +X010674Y004064D03* +X009926Y004064D03* +X004174Y009564D03* +X003426Y009564D03* +X005376Y014564D03* +X006124Y014564D03* +D17* +X014250Y016088D03* +X014250Y012741D03* +D18* +X014250Y010982D03* +X014250Y009447D03* +D19* +X017200Y009464D03* +X018200Y009964D03* +X018200Y010964D03* +X017200Y010464D03* +X017200Y011464D03* +X018200Y011964D03* +D20* +X020700Y012714D03* +X020700Y008714D03* +D21* +X005004Y003814D03* +X005004Y004864D03* +X005004Y005864D03* +X005004Y006914D03* +X008696Y006914D03* +X008696Y005864D03* +X008696Y004864D03* +X008696Y003814D03* +D22* +X001800Y008564D02* +X001200Y008564D01* +X001200Y009564D02* +X001800Y009564D01* +X001800Y010564D02* +X001200Y010564D01* +X001200Y011564D02* +X001800Y011564D01* +X001800Y012564D02* +X001200Y012564D01* +X005350Y016664D02* +X005350Y017264D01* +X006350Y017264D02* +X006350Y016664D01* +X007350Y016664D02* +X007350Y017264D01* +X017350Y017114D02* +X017350Y016514D01* +X018350Y016514D02* +X018350Y017114D01* +D23* +X016613Y004514D03* +X015787Y004514D03* +D24* +X020800Y005064D03* +X020800Y016064D03* +X002300Y016064D03* +X002350Y005114D03* +D25* +X009250Y004064D03* +X012100Y005314D03* +X013500Y006864D03* +X015650Y006264D03* +X015200Y004514D03* +X013550Y008764D03* +X013350Y010114D03* +X013300Y011464D03* +X011650Y013164D03* +X010000Y015114D03* +X006500Y013714D03* +X004150Y011564D03* +X014250Y014964D03* +X015850Y009914D03* +M02* diff --git a/gerber/tests/test_layers.py b/gerber/tests/test_layers.py index 6cafecf..597c0d3 100644 --- a/gerber/tests/test_layers.py +++ b/gerber/tests/test_layers.py @@ -61,7 +61,8 @@ def test_guess_layer_class_regex(): Hint(layer='top', ext=[], name=[], - regex=r'(.*)(\scopper top|\stop copper)$' + regex=r'(.*)(\scopper top|\stop copper)$', + content=[] ), ] hints.extend(layer_hints) @@ -70,6 +71,27 @@ def test_guess_layer_class_regex(): assert_equal(layer_class, guess_layer_class(filename)) +def test_guess_layer_class_by_content(): + """ Test layer class by checking content + """ + + expected_layer_class = 'bottom' + filename = os.path.join(os.path.dirname(__file__), + 'resources/example_guess_by_content.g0') + + layer_hints = [ + Hint(layer='bottom', + ext=[], + name=[], + regex='', + content=['G04 Layer name: Bottom'] + ) + ] + hints.extend(layer_hints) + + assert_equal(expected_layer_class, guess_layer_class_by_content(filename)) + + def test_sort_layers(): """ Test layer ordering """ |