MCPcopy
hub / github.com/jvilk/BrowserFS / testFunction

Function testFunction

test/tests/general/buffer-test.ts:14–30  ·  view source on GitHub ↗

* Simple get/set tests

(readFunc: string, writeFunc: string)

Source from the content-addressed store, hash-verified

12 */
13
14 function testFunction(readFunc: string, writeFunc: string) {
15 return function(nums: number | number[]) {
16 let writeNum: number, expectNum: number;
17 if (Array.isArray(nums)) {
18 writeNum = nums[0];
19 expectNum = nums[1];
20 } else {
21 writeNum = expectNum = nums;
22 }
23 (<any>buff)[writeFunc](writeNum, 0, true);
24 if (!isNaN(expectNum)) {
25 assert.strictEqual(expectNum, (<any>buff)[readFunc](0));
26 } else {
27 assert(isNaN((<any>buff)[readFunc](0)));
28 }
29 };
30 }
31
32 var oneByteInts = [
33 0, 0x7F, [0xFF, -1], -1*0x7F, -1

Callers 1

buffer-test.tsFile · 0.85

Calls 1

assertFunction · 0.50

Tested by

no test coverage detected