Skip to content

Commit

Permalink
chore(blp): assert on mip level counts in set image tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fallenoak committed Dec 16, 2023
1 parent 207ccd4 commit f2cbdf8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/lib/blp/Blp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class Blp {
return this.#height;
}

get mipLevelCount() {
return this.#images.length;
}

load(source: IoSource) {
const stream = openStream(source);
const header = blpIo.header.read(stream);
Expand Down
12 changes: 8 additions & 4 deletions src/spec/blp/Blp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,10 @@ describe('Blp', () => {
dstBlp.setImage(srcImage, BLP_COLOR_FORMAT.COLOR_RAW, false);
const dstImage = dstBlp.getImage(0);

expect(dstBlp.colorFormat).toBe(BLP_COLOR_FORMAT.COLOR_RAW);
expect(dstBlp.width).toBe(256);
expect(dstBlp.height).toBe(256);
expect(dstBlp.colorFormat).toBe(BLP_COLOR_FORMAT.COLOR_RAW);
expect(dstBlp.mipLevelCount).toBe(1);

expect(dstImage.width).toBe(256);
expect(dstImage.height).toBe(256);
Expand All @@ -490,9 +491,10 @@ describe('Blp', () => {
dstBlp.setImage(srcImage, BLP_COLOR_FORMAT.COLOR_RAW, true);
const dstImage = dstBlp.getImage(1);

expect(dstBlp.colorFormat).toBe(BLP_COLOR_FORMAT.COLOR_RAW);
expect(dstBlp.width).toBe(256);
expect(dstBlp.height).toBe(256);
expect(dstBlp.colorFormat).toBe(BLP_COLOR_FORMAT.COLOR_RAW);
expect(dstBlp.mipLevelCount).toBe(9);

expect(dstImage.width).toBe(128);
expect(dstImage.height).toBe(128);
Expand All @@ -508,9 +510,10 @@ describe('Blp', () => {
dstBlp.setImage(srcImage, BLP_COLOR_FORMAT.COLOR_RAW, false);
const dstImage = dstBlp.getImage(0);

expect(dstBlp.colorFormat).toBe(BLP_COLOR_FORMAT.COLOR_RAW);
expect(dstBlp.width).toBe(256);
expect(dstBlp.height).toBe(256);
expect(dstBlp.colorFormat).toBe(BLP_COLOR_FORMAT.COLOR_RAW);
expect(dstBlp.mipLevelCount).toBe(1);

expect(dstImage.width).toBe(256);
expect(dstImage.height).toBe(256);
Expand All @@ -526,9 +529,10 @@ describe('Blp', () => {
dstBlp.setImage(srcImage, BLP_COLOR_FORMAT.COLOR_RAW, true);
const dstImage = dstBlp.getImage(1);

expect(dstBlp.colorFormat).toBe(BLP_COLOR_FORMAT.COLOR_RAW);
expect(dstBlp.width).toBe(256);
expect(dstBlp.height).toBe(256);
expect(dstBlp.colorFormat).toBe(BLP_COLOR_FORMAT.COLOR_RAW);
expect(dstBlp.mipLevelCount).toBe(9);

expect(dstImage.width).toBe(128);
expect(dstImage.height).toBe(128);
Expand Down

0 comments on commit f2cbdf8

Please sign in to comment.