summaryrefslogtreecommitdiff
path: root/tests/test.int.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test.int.js')
-rw-r--r--tests/test.int.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test.int.js b/tests/test.int.js
new file mode 100644
index 0000000..954fd27
--- /dev/null
+++ b/tests/test.int.js
@@ -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);
+ });
+});