* Simple get/set tests
(readFunc: string, writeFunc: string)
| 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 |