From 13aac7627f1de072256c3c3a9ff83ccb006894f7 Mon Sep 17 00:00:00 2001 From: Jakub Andrysek Date: Thu, 19 Jun 2025 13:25:36 +0200 Subject: [PATCH] refactor(test): Format long strings in expect_exact calls for better readability --- tests/validation/nvs/nvs.ino | 18 ++++++++---------- tests/validation/nvs/test_nvs.py | 18 +++++++++++++++--- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/tests/validation/nvs/nvs.ino b/tests/validation/nvs/nvs.ino index 5196b0459e9..12c640c65b0 100644 --- a/tests/validation/nvs/nvs.ino +++ b/tests/validation/nvs/nvs.ino @@ -1,7 +1,6 @@ #include #include - struct TestData { uint8_t id; uint16_t value; @@ -78,16 +77,15 @@ void setup() { } Serial.printf("Values from Preferences: "); - Serial.printf("char: %c | uchar: %u | short: %d | ushort: %u | int: %ld | uint: %lu | ", - val_char, val_uchar, val_short, val_ushort, val_int, val_uint); - Serial.printf("long: %lld | ulong: %lu | long64: %lld | ulong64: %llu | ", - val_long, val_ulong, val_long64, val_ulong64); - Serial.printf("float: %.2f | double: %.2f | bool: %s | str: %s | strLen: %s | struct: {id:%u,val:%u}\n", - val_float, val_double, val_bool ? "true" : "false", val_string.c_str(), val_string_buf, test_data.id, test_data.value); - + Serial.printf("char: %c | uchar: %u | short: %d | ushort: %u | int: %ld | uint: %lu | ", val_char, val_uchar, val_short, val_ushort, val_int, val_uint); + Serial.printf("long: %lld | ulong: %lu | long64: %lld | ulong64: %llu | ", val_long, val_ulong, val_long64, val_ulong64); + Serial.printf( + "float: %.2f | double: %.2f | bool: %s | str: %s | strLen: %s | struct: {id:%u,val:%u}\n", val_float, val_double, val_bool ? "true" : "false", + val_string.c_str(), val_string_buf, test_data.id, test_data.value + ); // Increment the values - val_char += 1; // Increment char A -> B + val_char += 1; // Increment char A -> B val_uchar += 1; val_short += 1; val_ushort += 1; @@ -99,7 +97,7 @@ void setup() { val_ulong64 += 1; val_float += 1.1f; val_double += 1.1; - val_bool = !val_bool; // Toggle boolean value + val_bool = !val_bool; // Toggle boolean value // Increment string values using function incrementStringValues(val_string, val_string_buf, sizeof(val_string_buf)); diff --git a/tests/validation/nvs/test_nvs.py b/tests/validation/nvs/test_nvs.py index e336bf7d0eb..7f595b8e93d 100644 --- a/tests/validation/nvs/test_nvs.py +++ b/tests/validation/nvs/test_nvs.py @@ -5,10 +5,22 @@ def test_nvs(dut): LOGGER = logging.getLogger(__name__) LOGGER.info("Expecting default values from Preferences") - dut.expect_exact("Values from Preferences: char: A | uchar: 0 | short: 0 | ushort: 0 | int: 0 | uint: 0 | long: 0 | ulong: 0 | long64: 0 | ulong64: 0 | float: 0.00 | double: 0.00 | bool: false | str: str0 | strLen: strLen0 | struct: {id:1,val:100}") + dut.expect_exact( + "Values from Preferences: char: A | uchar: 0 | short: 0 | ushort: 0 | int: 0 | uint: 0 | long: 0 | ulong: 0 | " + "long64: 0 | ulong64: 0 | float: 0.00 | double: 0.00 | bool: false | str: str0 | strLen: strLen0 | " + "struct: {id:1,val:100}" + ) LOGGER.info("Expecting updated preferences for the first time") - dut.expect_exact("Values from Preferences: char: B | uchar: 1 | short: 1 | ushort: 1 | int: 1 | uint: 1 | long: 1 | ulong: 1 | long64: 1 | ulong64: 1 | float: 1.10 | double: 1.10 | bool: true | str: str1 | strLen: strLen1 | struct: {id:2,val:110}") + dut.expect_exact( + "Values from Preferences: char: B | uchar: 1 | short: 1 | ushort: 1 | int: 1 | uint: 1 | long: 1 | ulong: 1 | " + "long64: 1 | ulong64: 1 | float: 1.10 | double: 1.10 | bool: true | str: str1 | strLen: strLen1 | " + "struct: {id:2,val:110}" + ) LOGGER.info("Expecting updated preferences for the second time") - dut.expect_exact("Values from Preferences: char: C | uchar: 2 | short: 2 | ushort: 2 | int: 2 | uint: 2 | long: 2 | ulong: 2 | long64: 2 | ulong64: 2 | float: 2.20 | double: 2.20 | bool: false | str: str2 | strLen: strLen2 | struct: {id:3,val:120}") + dut.expect_exact( + "Values from Preferences: char: C | uchar: 2 | short: 2 | ushort: 2 | int: 2 | uint: 2 | long: 2 | ulong: 2 | " + "long64: 2 | ulong64: 2 | float: 2.20 | double: 2.20 | bool: false | str: str2 | strLen: strLen2 | " + "struct: {id:3,val:120}" + )