@@ -405,6 +405,84 @@ describe('Test createUniversalHex()', () => {
405
405
*/
406
406
} ) ;
407
407
408
+ describe ( 'Test isUniversalHex()' , ( ) => {
409
+ it ( 'Detects a Universal Intel Hex.' , ( ) => {
410
+ const normalHex =
411
+ ':020000040000FA\n' +
412
+ ':0400000A9900C0DEBB\n' +
413
+ ':1000000000400020218E01005D8E01005F8E010006\n' +
414
+ ':1000100000000000000000000000000000000000E0\n' +
415
+ ':10002000000000000000000000000000618E0100E0\n' +
416
+ ':100030000000000000000000638E0100658E0100DA\n' +
417
+ ':10004000678E01005D3D000065950100678E01002F\n' +
418
+ ':10005000678E010000000000218F0100678E010003\n' +
419
+ ':1000600069E80000D59A0100D9930100678E01006C\n' +
420
+ ':10007000678E0100678E0100678E0100678E0100A8\n' +
421
+ ':10008000678E0100678E0100678E0100678E010098\n' +
422
+ ':10009000678E01000D8A0100D98A0100A5E90000E0\n' +
423
+ ':0C00000BFFFFFFFFFFFFFFFFFFFFFFFFF5\n' +
424
+ ':00000001FF\n' ;
425
+
426
+ const result = uh . isUniversalHex ( normalHex ) ;
427
+
428
+ expect ( result ) . toBeTruthy ( ) ;
429
+ } ) ;
430
+
431
+ it ( 'Detects a Universal Intel Hex with Windows line endings.' , ( ) => {
432
+ const normalHex =
433
+ ':020000040000FA\r\n' +
434
+ ':0400000A9900C0DEBB\r\n' +
435
+ ':1000000000400020218E01005D8E01005F8E010006\r\n' +
436
+ ':1000100000000000000000000000000000000000E0\r\n' +
437
+ ':10002000000000000000000000000000618E0100E0\r\n' +
438
+ ':100030000000000000000000638E0100658E0100DA\r\n' +
439
+ ':10004000678E01005D3D000065950100678E01002F\r\n' +
440
+ ':10005000678E010000000000218F0100678E010003\r\n' +
441
+ ':1000600069E80000D59A0100D9930100678E01006C\r\n' +
442
+ ':10007000678E0100678E0100678E0100678E0100A8\r\n' +
443
+ ':10008000678E0100678E0100678E0100678E010098\r\n' +
444
+ ':10009000678E01000D8A0100D98A0100A5E90000E0\r\n' +
445
+ ':0C00000BFFFFFFFFFFFFFFFFFFFFFFFFF5\r\n' +
446
+ ':00000001FF\r\n' ;
447
+
448
+ const result = uh . isUniversalHex ( normalHex ) ;
449
+
450
+ expect ( result ) . toBeTruthy ( ) ;
451
+ } ) ;
452
+
453
+ it ( 'Detects an empty string as false' , ( ) => {
454
+ expect ( uh . isUniversalHex ( '' ) ) . toBeFalsy ( ) ;
455
+ } ) ;
456
+
457
+ it ( 'Detects a normal Intel Hex as false.' , ( ) => {
458
+ const normalHex =
459
+ ':020000040000FA\n' +
460
+ ':10558000002EEDD1E9E70020EAE7C0464302F0B57E\n' +
461
+ ':1055900042005D0AC30F4802440A4800120E000E82\n' +
462
+ ':00000001FF\n' ;
463
+
464
+ const result = uh . isUniversalHex ( normalHex ) ;
465
+
466
+ expect ( result ) . toBeFalsy ( ) ;
467
+ } ) ;
468
+
469
+ it ( 'Detects a random string as false.' , ( ) => {
470
+ const normalHex = 'This is just a random string' ;
471
+
472
+ const result = uh . isUniversalHex ( normalHex ) ;
473
+
474
+ expect ( result ) . toBeFalsy ( ) ;
475
+ } ) ;
476
+
477
+ it ( 'Returns false when failing to find the second record.' , ( ) => {
478
+ const normalHex = ':02000004\nThis is just a random string, nor a record.' ;
479
+
480
+ const result = uh . isUniversalHex ( normalHex ) ;
481
+
482
+ expect ( result ) . toBeFalsy ( ) ;
483
+ } ) ;
484
+ } ) ;
485
+
408
486
describe ( 'Separate a Universal Hex' , ( ) => {
409
487
it ( 'Throws an error on empty input' , ( ) => {
410
488
expect ( ( ) => {
0 commit comments