Skip to content

Commit

Permalink
Survex3D encoding and version tests
Browse files Browse the repository at this point in the history
  • Loading branch information
speleo3 committed Dec 16, 2023
1 parent 9e69f1f commit d221b9a
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# https://help.github.com/articles/dealing-with-line-endings/

* text=auto eol=lf
*.py text
*.svg text
*.th2 text

*.svx text
*.3d binary
2 changes: 1 addition & 1 deletion extensions/survex.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def __init__(self, filename=None, flags_leg_exclude=0):
self.flags_leg_exclude = flags_leg_exclude
if filename is None:
pass
elif isinstance(filename, basestring):
elif isinstance(filename, basestring) or hasattr(filename, "__fspath__"):
self.load(filename)
else:
# assume iterable with stations
Expand Down
Binary file added tests/data/3d/umlaut-latin1-v3.3d
Binary file not shown.
Binary file added tests/data/3d/umlaut-latin1-v4.3d
Binary file not shown.
Binary file added tests/data/3d/umlaut-latin1-v5.3d
Binary file not shown.
Binary file added tests/data/3d/umlaut-latin1-v6.3d
Binary file not shown.
Binary file added tests/data/3d/umlaut-latin1-v7.3d
Binary file not shown.
Binary file added tests/data/3d/umlaut-latin1-v8.3d
Binary file not shown.
Binary file added tests/data/3d/umlaut-utf8-v3.3d
Binary file not shown.
Binary file added tests/data/3d/umlaut-utf8-v4.3d
Binary file not shown.
Binary file added tests/data/3d/umlaut-utf8-v5.3d
Binary file not shown.
Binary file added tests/data/3d/umlaut-utf8-v6.3d
Binary file not shown.
Binary file added tests/data/3d/umlaut-utf8-v7.3d
Binary file not shown.
Binary file added tests/data/3d/umlaut-utf8-v8.3d
Binary file not shown.
9 changes: 9 additions & 0 deletions tests/data/make-3d.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
for enc in latin1 utf8; do
for v in 3 4 5 6 7 8; do
out="3d/umlaut-$enc-v$v.3d"
if [[ ! -f "$out" ]]; then
cavern -v $v -o "$out" umlaut-$enc.svx
fi
done
done
5 changes: 5 additions & 0 deletions tests/data/umlaut-latin1.svx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*title "H�hle mit Umlaut"

*data normal from to length clino compass
1 2 1.2 +0 000
2 3 3.4 +0 090
5 changes: 5 additions & 0 deletions tests/data/umlaut-utf8.svx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*title "Höhle mit Umlaut"

*data normal from to length clino compass
1 2 1.2 +0 000
2 3 3.4 +0 090
13 changes: 13 additions & 0 deletions tests/test_survex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import survex as m

from pathlib import Path

TESTS_DATA = Path(__file__).resolve().parent / "data"


def test_Survex3D_umlaut():
for path3d in (TESTS_DATA / "3d").glob("umlaut-*.3d"):
s = m.Survex3D(path3d)
assert s.length() == 460.0
assert list(s.sortedlabels()) == ["1", "2", "3"]
assert s.title == "Höhle mit Umlaut"

0 comments on commit d221b9a

Please sign in to comment.