-
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.
- Loading branch information
1 parent
3397ed7
commit 6096c72
Showing
5 changed files
with
154 additions
and
10 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
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,28 @@ | ||
const test = require("flug"); | ||
const { iterClip } = require("../src/xdim"); | ||
|
||
const range = ct => new Array(ct).fill(0).map((_, i) => i); | ||
|
||
test("iter clip with rect", ({ eq }) => { | ||
// band row column | ||
const pixelDepth = 4; | ||
const height = 768; | ||
const width = 1024; | ||
const data = range(pixelDepth).map(band => { | ||
return range(height).map(row => { | ||
return range(width).map(column => { | ||
return { b: band, r: row, c: column }; | ||
}); | ||
}); | ||
}); | ||
const iter = iterClip({ data, layout: "[band][row][column]", sizes: { band: 4, row: 768, column: 1024 }, rect: { band: [1, 3] } }); | ||
eq(iter.next().value, { b: 1, r: 0, c: 0 }); | ||
eq(iter.next().value, { b: 1, r: 0, c: 1 }); | ||
for (let i = 0; i < 1021; i++) iter.next(); | ||
eq(iter.next().value, { b: 1, r: 0, c: 1023 }); | ||
eq(iter.next().value, { b: 1, r: 1, c: 0 }); | ||
|
||
let last; | ||
for (last of iter); | ||
eq(last, { b: 3, r: 767, c: 1023 }); | ||
}); |
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,27 @@ | ||
const test = require("flug"); | ||
const { validateRect } = require("../src/xdim"); | ||
|
||
test("validating invalid rectangle", ({ eq }) => { | ||
const rect = { band: [0, 0], row: [6, 5], column: [1, 1] }; | ||
|
||
let threw = false; | ||
try { | ||
validateRect({ rect }); | ||
} catch (error) { | ||
threw = true; | ||
} | ||
eq(threw, true); | ||
}); | ||
|
||
test("validating valid rectangle", ({ eq }) => { | ||
const rect = { band: [0, 0], row: [6, 6], column: [1, 1] }; | ||
|
||
let threw = false; | ||
try { | ||
validateRect({ rect }); | ||
} catch (error) { | ||
console.error(error); | ||
threw = true; | ||
} | ||
eq(threw, false); | ||
}); |