99 mhaiSelection ,
1010 mmxuSelection ,
1111 ptocSelection ,
12- lln0Selection
12+ lln0Selection ,
13+ ptrcSelection
1314} from "./insertSelectedLNodeType.testdata.js" ;
1415
1516import {
@@ -22,6 +23,31 @@ import {
2223import { insertSelectedLNodeType } from "./insertSelectedLNodeType.js" ;
2324import { CdcChildren , DaDescription , LNodeDescription , nsdToJson } from "./nsdToJson.js" ;
2425
26+
27+ function cyrb64 ( str : string ) : string {
28+ /* eslint-disable no-bitwise */
29+ let h1 = 0xdeadbeef ;
30+ let h2 = 0x41c6ce57 ;
31+ /* eslint-disable-next-line no-plusplus */
32+ for ( let i = 0 , ch ; i < str . length ; i ++ ) {
33+ ch = str . charCodeAt ( i ) ;
34+ h1 = Math . imul ( h1 ^ ch , 2654435761 ) ;
35+ h2 = Math . imul ( h2 ^ ch , 1597334677 ) ;
36+ }
37+ h1 =
38+ Math . imul ( h1 ^ ( h1 >>> 16 ) , 2246822507 ) ^
39+ Math . imul ( h2 ^ ( h2 >>> 13 ) , 3266489909 ) ;
40+ h2 =
41+ Math . imul ( h2 ^ ( h2 >>> 16 ) , 2246822507 ) ^
42+ Math . imul ( h1 ^ ( h1 >>> 13 ) , 3266489909 ) ;
43+ return (
44+ ( h2 >>> 0 ) . toString ( 16 ) . padStart ( 8 , "0" ) +
45+ ( h1 >>> 0 ) . toString ( 16 ) . padStart ( 8 , "0" )
46+ ) ;
47+ /* eslint-enable no-bitwise */
48+ }
49+
50+
2551const incompleteMmxu = findElement ( missingMmxuTypes ) as XMLDocument ;
2652const imcompleteLtrk = findElement ( incompleteLtrkTypes ) as XMLDocument ;
2753const incompleteAtcc = findElement ( incompleteAtccTypes ) as XMLDocument ;
@@ -239,5 +265,15 @@ describe("insertLNodeTypeSelection", () => {
239265
240266 expect ( edits . length ) . to . equal ( 5 ) ;
241267 expect ( ( edits [ 3 ] . node as Element ) . querySelector ( 'DA[name="dataNs"] > Val' ) ?. textContent ) . to . equal ( "TestNameSpace-1-d-1234567890" ) ;
268+ } ) ;
269+
270+ it ( 'set user defined LNodeType.id' , ( ) => {
271+ const id = cyrb64 ( "TestFile" ) ;
272+ const edits = insertSelectedLNodeType ( missingDataTypes , ptrcSelection , { class : "PTRC" , id } ) ;
273+
274+ expect ( edits . length ) . to . equal ( 4 ) ;
275+ expect ( ( edits [ 1 ] . node as Element ) . getAttribute ( "id" ) ) . to . equal ( "96ba6481aba181d8" ) ;
276+ expect ( ( edits [ 2 ] . node as Element ) . getAttribute ( "id" ) ) . to . equal ( "Beh$oscd$_c6ed035c8137b35a" ) ;
277+ expect ( ( edits [ 3 ] . node as Element ) . getAttribute ( "id" ) ) . to . equal ( "stVal$oscd$_48ba16345b8e7f5b" ) ;
242278 } )
243279} ) ;
0 commit comments