Skip to content

Instantly share code, notes, and snippets.

@nphyx
Created September 14, 2015 06:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nphyx/5895d07fba9686ac357f to your computer and use it in GitHub Desktop.
Save nphyx/5895d07fba9686ac357f to your computer and use it in GitHub Desktop.
Unit test for unsigned 24-bit int accessors for Javascript DataViews.
describe("DataView", function() {
it("should implement Uint24 accessors", function() {
var i, n, buf, dv;
buf = new ArrayBuffer(3);
dv = new DataView(buf);
n = Math.pow(2, 24);
// this should give us decent coverage without trying every single number, which takes forever
for(i = 1; i < n; i += 111) {
dv.setUint24(0, i);
dv.getUint24(0).should.equal(i);
}
});
});
@nphyx
Copy link
Author

nphyx commented Sep 14, 2015

This is a unit test for https://gist.github.com/nphyx/5c19ef4cdb9774d87e0d
Test environment is Mocha+Chai.

For the record I have run this test for the full range of possible values, it just takes a long time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment