Add util for unsigned and signed int. conversion

Will be used in later commit in extended clipboard handling.
This commit is contained in:
Niko Lehto
2020-01-28 17:00:04 +01:00
committed by Lauri Kasanen
parent fdeefcfab4
commit 286694869b
2 changed files with 31 additions and 0 deletions

16
kasmweb/tests/test.int.js Normal file
View File

@@ -0,0 +1,16 @@
/* eslint-disable no-console */
const expect = chai.expect;
import { toUnsigned32bit, toSigned32bit } from '../core/util/int.js';
describe('Integer casting', function () {
it('should cast unsigned to signed', function () {
let expected = 4294967286;
expect(toUnsigned32bit(-10)).to.equal(expected);
});
it('should cast signed to unsigned', function () {
let expected = -10;
expect(toSigned32bit(4294967286)).to.equal(expected);
});
});