Created
September 14, 2015 06:27
-
-
Save nphyx/5895d07fba9686ac357f to your computer and use it in GitHub Desktop.
Unit test for unsigned 24-bit int accessors for Javascript DataViews.
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
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); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.