Skip to content

Commit

Permalink
add test on name_to_filename
Browse files Browse the repository at this point in the history
  • Loading branch information
Koyaani committed Jun 9, 2022
1 parent 1a97915 commit 9e92880
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion tests/test_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from py3dtiles.points.points_grid import Grid
from py3dtiles.points.node import Node
from py3dtiles.points.utils import compute_spacing
from py3dtiles.points.utils import compute_spacing, name_to_filename
from py3dtiles.points.distance import is_point_far_enough

# test point
Expand Down Expand Up @@ -73,3 +73,27 @@ def test_is_point_far_enough():

def test_is_point_far_enough_perf(benchmark):
benchmark(is_point_far_enough, sample_points, xyz, 0.25 ** 2)


def test_short_name_to_filename():
short_tile_name = ''.encode("ascii")
filename = name_to_filename('work/', short_tile_name)
assert filename == 'work/r'


def test_long_name_to_filename():
long_tile_name = '110542453782'.encode("ascii")
filename = name_to_filename('work/', long_tile_name)
assert filename == 'work/11054245/r3782'


def test_long_name_to_filename_with_extension():
long_tile_name = '110542453782'.encode("ascii")
filename = name_to_filename('work/', long_tile_name, suffix='.pnts')
assert filename == 'work/11054245/r3782.pnts'


def test_long_name_to_filename_with_short_split():
long_tile_name = '110542453782'.encode("ascii")
filename = name_to_filename('work/', long_tile_name, split_len=2)
assert filename == 'work/11/05/42/45/37/r82'

0 comments on commit 9e92880

Please sign in to comment.