forked from mapbox/mapbox-gl-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix corner case with dash-array 0-length collapsing (mapbox#9385)
A dash array with values [0,0] results in a full collapse of values since it does not represent any dashes, fix the behavior with early return and add some more unit test coverage for other corner cases
- Loading branch information
1 parent
63ea338
commit 9d3b0a3
Showing
2 changed files
with
57 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import {test} from '../../util/test'; | ||
import LineAtlas from '../../../src/render/line_atlas'; | ||
|
||
test('LineAtlas', (t) => { | ||
const lineAtlas = new LineAtlas(64, 64); | ||
t.test('round [0, 0]', (t) => { | ||
const entry = lineAtlas.addDash([0, 0], true); | ||
t.equal(entry.width, 0); | ||
t.end(); | ||
}); | ||
t.test('round [1, 0]', (t) => { | ||
const entry = lineAtlas.addDash([1, 0], true); | ||
t.equal(entry.width, 1); | ||
t.end(); | ||
}); | ||
t.test('round [0, 1]', (t) => { | ||
const entry = lineAtlas.addDash([0, 1], true); | ||
t.equal(entry.width, 1); | ||
t.end(); | ||
}); | ||
t.test('odd round [1, 2, 1]', (t) => { | ||
const entry = lineAtlas.addDash([1, 2, 1], true); | ||
t.equal(entry.width, 4); | ||
t.end(); | ||
}); | ||
|
||
t.test('regular [0, 0]', (t) => { | ||
const entry = lineAtlas.addDash([0, 0], false); | ||
t.equal(entry.width, 0); | ||
t.end(); | ||
}); | ||
t.test('regular [1, 0]', (t) => { | ||
const entry = lineAtlas.addDash([1, 0], false); | ||
t.equal(entry.width, 1); | ||
t.end(); | ||
}); | ||
t.test('regular [0, 1]', (t) => { | ||
const entry = lineAtlas.addDash([0, 1], false); | ||
t.equal(entry.width, 1); | ||
t.end(); | ||
}); | ||
t.test('odd regular [1, 2, 1]', (t) => { | ||
const entry = lineAtlas.addDash([1, 2, 1], false); | ||
t.equal(entry.width, 4); | ||
t.end(); | ||
}); | ||
t.end(); | ||
}); |