From 9024ddadf06dbbdb860b2910377ed2abcabea422 Mon Sep 17 00:00:00 2001 From: Etienne Rossignon Date: Sat, 15 Jul 2023 15:20:31 +0200 Subject: [PATCH] add more test for coerceInt64 --- .../test/test_coerce.js | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/node-opcua-basic-types/test/test_coerce.js b/packages/node-opcua-basic-types/test/test_coerce.js index 57bcbcf3e..3e830a2c6 100644 --- a/packages/node-opcua-basic-types/test/test_coerce.js +++ b/packages/node-opcua-basic-types/test/test_coerce.js @@ -40,17 +40,35 @@ describe("coerceInt32", () => { coerceInt32([0, 56]).should.eql(56); }); }); + +describe ("coerceInt64", ()=>{ + it("should coerce a positive Int32 to Int64", ()=>{ + coerceInt64(10).should.eql([0x0,0xA]); + }); + it("should coerce a negative Int32 to Int64", () => { + coerceInt64(-1).should.eql([0xFFFFFFFF, 0xFFFFFFFF]); + }); + it("should coerce a negative Int32 to Int64", () => { + coerceInt64(-2).should.eql([0xFFFFFFFF, 0xFFFFFFFE]); + }); + it("should coerce a negative Int32 to Int64", () => { + coerceInt64(-9).should.eql([0xFFFFFFFF, 0xFFFFFFF7]); + }); +}) describe("coerceUInt64", () => { - it("should coerce an Int32 into Int64", () => { + it("should coerce an Int32 into UInt64", () => { coerceUInt64(0xff1000).should.eql([0x0, 0xff1000]); }); - it("should coerce an long number into Int64", () => { + it("should coerce an long number into UInt64", () => { coerceUInt64(0x1020000000).should.eql([0x10, 0x20000000]); }); - it("should coerce an long number into Int64", () => { + + it("should coerce an long number into UInt64", () => { + coerceUInt64(0x100020000000).should.eql([0x1000, 0x20000000]); + }); + it("should coerce an long number into UInt64", () => { coerceUInt64(0x100020000000).should.eql([0x1000, 0x20000000]); }); - [ [1, [0x0, 0x1]], [-1, [0xffffffff, 0xffffffff]],