From 9ced2215fdd484d647a486b8e1c385b0dc013225 Mon Sep 17 00:00:00 2001 From: brdandu Date: Fri, 9 May 2025 13:49:22 -0400 Subject: [PATCH] Generating correctly for string type attributes which have numbers only as their default values when using helper-endpointconfig.js Github: ZAP#1504 --- src-electron/util/types.js | 2 +- test/gen-matter-3-1.test.js | 3 +++ test/resource/multiple-device-types-per-endpoint.zap | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src-electron/util/types.js b/src-electron/util/types.js index 4f7cbf90e7..7a372ad115 100644 --- a/src-electron/util/types.js +++ b/src-electron/util/types.js @@ -169,7 +169,7 @@ function longTypeDefaultValue(size, type, value) { let v = '' if (value == null || value.length == 0) { v = '0x00, '.repeat(size) - } else if (isNaN(value)) { + } else if (isString(type)) { // String Value if (isOneBytePrefixedString(type)) { v = bin.stringToOneByteLengthPrefixCBytes(value, size).content diff --git a/test/gen-matter-3-1.test.js b/test/gen-matter-3-1.test.js index 90d53e3f9a..a1bb19855b 100644 --- a/test/gen-matter-3-1.test.js +++ b/test/gen-matter-3-1.test.js @@ -368,6 +368,9 @@ test( expect(endpointType1.deviceTypeRef[1]).toEqual( endpointType2.deviceTypeRef[0] ) + + // Testing number values for string type attributes under GENERATED_DEFAULTS(helper-endpointconfig.js) + expect(ept).toMatch(/\/\* 17 - Description, \*\/\\\n.*2, '7', '7',/) }, testUtil.timeout.long() ) diff --git a/test/resource/multiple-device-types-per-endpoint.zap b/test/resource/multiple-device-types-per-endpoint.zap index 4c8fd8ccd5..2735d065bb 100644 --- a/test/resource/multiple-device-types-per-endpoint.zap +++ b/test/resource/multiple-device-types-per-endpoint.zap @@ -6971,7 +6971,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "B2", + "defaultValue": "77", "reportable": 1, "minInterval": 0, "maxInterval": 65344,