-
-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b63718
commit e3264db
Showing
4 changed files
with
69 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/node-opcua-types/test/test_encode_decode_extObjects.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { BinaryStream } from "node-opcua-binary-stream"; | ||
import { ExtensionObject } from "node-opcua-extension-object"; | ||
import { DataType } from "node-opcua-variant"; | ||
import { PubSubConfigurationDataType, PubSubConnectionDataType, UABinaryFileDataType } from "../dist"; | ||
import "should"; | ||
|
||
describe("Testing encoding/decoding of complex ExtensionObjects", () => { | ||
it("should encode and decode a large extension object encodeExtensionObject/decodeExtensionObject", async () => { | ||
const value = new PubSubConfigurationDataType({ | ||
connections: [new PubSubConnectionDataType({})] | ||
}); | ||
const binaryFile = new UABinaryFileDataType({ | ||
body: { dataType: DataType.ExtensionObject, value } | ||
}); | ||
|
||
const stream = new BinaryStream(binaryFile.binaryStoreSize()); | ||
binaryFile.encode(stream); | ||
|
||
const reloaded = new UABinaryFileDataType(); | ||
stream.rewind(); | ||
|
||
reloaded.decode(stream); | ||
|
||
const a = binaryFile.toJSON(); | ||
const b = reloaded.toJSON(); | ||
|
||
a.should.eql(b); | ||
// console.log(a); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters