From a632edb99acaed94c5fe8248ad84b5c74d23d319 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 24 Apr 2024 12:56:05 +0000 Subject: [PATCH] Restyled by clang-format --- src/lib/dnssd/tests/TestTxtFields.cpp | 110 +++++++++++++------------- 1 file changed, 54 insertions(+), 56 deletions(-) diff --git a/src/lib/dnssd/tests/TestTxtFields.cpp b/src/lib/dnssd/tests/TestTxtFields.cpp index e2540859fe965a..ce206e34ae46aa 100644 --- a/src/lib/dnssd/tests/TestTxtFields.cpp +++ b/src/lib/dnssd/tests/TestTxtFields.cpp @@ -303,12 +303,10 @@ TEST(TestTxtFields, TestGetCommissionerPasscode) bool NodeDataIsEmpty(const CommissionNodeData & node) { - if (node.longDiscriminator != 0 || node.vendorId != 0 || node.productId != 0 || - node.commissioningMode != 0 || node.deviceType != 0 || node.rotatingIdLen != 0 || - node.pairingHint != 0 || node.mrpRetryIntervalIdle.HasValue() || - node.mrpRetryIntervalActive.HasValue() || node.mrpRetryActiveThreshold.HasValue() || - node.isICDOperatingAsLIT.HasValue() || node.supportsTcp || - node.supportsCommissionerGeneratedPasscode != 0) + if (node.longDiscriminator != 0 || node.vendorId != 0 || node.productId != 0 || node.commissioningMode != 0 || + node.deviceType != 0 || node.rotatingIdLen != 0 || node.pairingHint != 0 || node.mrpRetryIntervalIdle.HasValue() || + node.mrpRetryIntervalActive.HasValue() || node.mrpRetryActiveThreshold.HasValue() || node.isICDOperatingAsLIT.HasValue() || + node.supportsTcp || node.supportsCommissionerGeneratedPasscode != 0) { return false; } @@ -461,55 +459,55 @@ void DiscoveredTxtFieldSessionIdleInterval() strcpy(key, "SII"); strcpy(val, "1"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( nodeData.Get().GetMrpRetryIntervalIdle().HasValue()); - EXPECT_TRUE( nodeData.Get().GetMrpRetryIntervalIdle().Value() == 1_ms32); + EXPECT_TRUE(nodeData.Get().GetMrpRetryIntervalIdle().HasValue()); + EXPECT_TRUE(nodeData.Get().GetMrpRetryIntervalIdle().Value() == 1_ms32); // Maximum strcpy(key, "SII"); strcpy(val, "3600000"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( nodeData.Get().GetMrpRetryIntervalIdle().HasValue()); - EXPECT_TRUE( nodeData.Get().GetMrpRetryIntervalIdle().Value() == 3600000_ms32); + EXPECT_TRUE(nodeData.Get().GetMrpRetryIntervalIdle().HasValue()); + EXPECT_TRUE(nodeData.Get().GetMrpRetryIntervalIdle().Value() == 3600000_ms32); // Test no other fields were populated ResetRetryIntervalIdle(nodeData); - EXPECT_TRUE( NodeDataIsEmpty(nodeData.Get())); + EXPECT_TRUE(NodeDataIsEmpty(nodeData.Get())); // Invalid SII - negative value strcpy(key, "SII"); strcpy(val, "-1"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryIntervalIdle().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryIntervalIdle().HasValue()); // Invalid SII - greater than maximum strcpy(key, "SII"); strcpy(val, "3600001"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryIntervalIdle().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryIntervalIdle().HasValue()); // Invalid SII - much greater than maximum strcpy(key, "SII"); strcpy(val, "1095216660481"); // 0xFF00000001 == 1 (mod 2^32) FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryIntervalIdle().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryIntervalIdle().HasValue()); // Invalid SII - hexadecimal value strcpy(key, "SII"); strcpy(val, "0x20"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryIntervalIdle().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryIntervalIdle().HasValue()); // Invalid SII - leading zeros strcpy(key, "SII"); strcpy(val, "0700"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryIntervalIdle().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryIntervalIdle().HasValue()); // Invalid SII - text at the end strcpy(key, "SII"); strcpy(val, "123abc"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryIntervalIdle().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryIntervalIdle().HasValue()); } // Test SAI (formerly CRA) @@ -526,55 +524,55 @@ void DiscoveredTxtFieldSessionActiveInterval() strcpy(key, "SAI"); strcpy(val, "1"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( nodeData.Get().GetMrpRetryIntervalActive().HasValue()); - EXPECT_TRUE( nodeData.Get().GetMrpRetryIntervalActive().Value() == 1_ms32); + EXPECT_TRUE(nodeData.Get().GetMrpRetryIntervalActive().HasValue()); + EXPECT_TRUE(nodeData.Get().GetMrpRetryIntervalActive().Value() == 1_ms32); // Maximum strcpy(key, "SAI"); strcpy(val, "3600000"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( nodeData.Get().GetMrpRetryIntervalActive().HasValue()); - EXPECT_TRUE( nodeData.Get().GetMrpRetryIntervalActive().Value() == 3600000_ms32); + EXPECT_TRUE(nodeData.Get().GetMrpRetryIntervalActive().HasValue()); + EXPECT_TRUE(nodeData.Get().GetMrpRetryIntervalActive().Value() == 3600000_ms32); // Test no other fields were populated ResetRetryIntervalActive(nodeData); - EXPECT_TRUE( NodeDataIsEmpty(nodeData.Get())); + EXPECT_TRUE(NodeDataIsEmpty(nodeData.Get())); // Invalid SAI - negative value strcpy(key, "SAI"); strcpy(val, "-1"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryIntervalActive().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryIntervalActive().HasValue()); // Invalid SAI - greater than maximum strcpy(key, "SAI"); strcpy(val, "3600001"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryIntervalActive().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryIntervalActive().HasValue()); // Invalid SAI - much greater than maximum strcpy(key, "SAI"); strcpy(val, "1095216660481"); // 0xFF00000001 == 1 (mod 2^32) FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryIntervalActive().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryIntervalActive().HasValue()); // Invalid SAI - hexadecimal value strcpy(key, "SAI"); strcpy(val, "0x20"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryIntervalActive().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryIntervalActive().HasValue()); // Invalid SAI - leading zeros strcpy(key, "SAI"); strcpy(val, "0700"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryIntervalActive().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryIntervalActive().HasValue()); // Invalid SAI - text at the end strcpy(key, "SAI"); strcpy(val, "123abc"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryIntervalActive().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryIntervalActive().HasValue()); } // Test SAT (Session Active Threshold) @@ -591,55 +589,55 @@ void DiscoveredTxtFieldSessionActiveThreshold() strcpy(key, "SAT"); strcpy(val, "1"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( nodeData.Get().GetMrpRetryActiveThreshold().HasValue()); - EXPECT_TRUE( nodeData.Get().GetMrpRetryActiveThreshold().Value() == 1_ms16); + EXPECT_TRUE(nodeData.Get().GetMrpRetryActiveThreshold().HasValue()); + EXPECT_TRUE(nodeData.Get().GetMrpRetryActiveThreshold().Value() == 1_ms16); // Maximum strcpy(key, "SAT"); strcpy(val, "65535"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( nodeData.Get().GetMrpRetryActiveThreshold().HasValue()); - EXPECT_TRUE( nodeData.Get().GetMrpRetryActiveThreshold().Value() == 65535_ms16); + EXPECT_TRUE(nodeData.Get().GetMrpRetryActiveThreshold().HasValue()); + EXPECT_TRUE(nodeData.Get().GetMrpRetryActiveThreshold().Value() == 65535_ms16); // Test no other fields were populated ResetRetryActiveThreshold(nodeData); - EXPECT_TRUE( NodeDataIsEmpty(nodeData.Get())); + EXPECT_TRUE(NodeDataIsEmpty(nodeData.Get())); // Invalid SAI - negative value strcpy(key, "SAT"); strcpy(val, "-1"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryActiveThreshold().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryActiveThreshold().HasValue()); // Invalid SAI - greater than maximum strcpy(key, "SAT"); strcpy(val, "65536"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryActiveThreshold().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryActiveThreshold().HasValue()); // Invalid SAT - much greater than maximum strcpy(key, "SAT"); strcpy(val, "1095216660481"); // 0xFF00000001 == 1 (mod 2^32) FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryActiveThreshold().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryActiveThreshold().HasValue()); // Invalid SAT - hexadecimal value strcpy(key, "SAT"); strcpy(val, "0x20"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryActiveThreshold().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryActiveThreshold().HasValue()); // Invalid SAT - leading zeros strcpy(key, "SAT"); strcpy(val, "0700"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryActiveThreshold().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryActiveThreshold().HasValue()); // Invalid SAT - text at the end strcpy(key, "SAT"); strcpy(val, "123abc"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().GetMrpRetryActiveThreshold().HasValue()); + EXPECT_TRUE(!nodeData.Get().GetMrpRetryActiveThreshold().HasValue()); } // Test T (TCP support) @@ -656,23 +654,23 @@ void DiscoveredTxtFieldTcpSupport() strcpy(key, "T"); strcpy(val, "1"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( nodeData.Get().supportsTcp); + EXPECT_TRUE(nodeData.Get().supportsTcp); // Test no other fields were populated nodeData.Get().supportsTcp = false; - EXPECT_TRUE( NodeDataIsEmpty(nodeData.Get())); + EXPECT_TRUE(NodeDataIsEmpty(nodeData.Get())); // False strcpy(key, "T"); strcpy(val, "0"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( nodeData.Get().supportsTcp == false); + EXPECT_TRUE(nodeData.Get().supportsTcp == false); // Invalid value, stil false strcpy(key, "T"); strcpy(val, "asdf"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( nodeData.Get().supportsTcp == false); + EXPECT_TRUE(nodeData.Get().supportsTcp == false); } // Test ICD (ICD operation Mode) @@ -689,27 +687,27 @@ void DiscoveredTxtFieldICDoperatesAsLIT() strcpy(key, "ICD"); strcpy(val, "1"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( nodeData.Get().isICDOperatingAsLIT.HasValue()); - EXPECT_TRUE( nodeData.Get().isICDOperatingAsLIT.Value()); + EXPECT_TRUE(nodeData.Get().isICDOperatingAsLIT.HasValue()); + EXPECT_TRUE(nodeData.Get().isICDOperatingAsLIT.Value()); // Test no other fields were populated nodeData.Get().isICDOperatingAsLIT.ClearValue(); - EXPECT_TRUE( NodeDataIsEmpty(nodeData.Get())); + EXPECT_TRUE(NodeDataIsEmpty(nodeData.Get())); // ICD is operating as a SIT device strcpy(key, "ICD"); strcpy(val, "0"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( nodeData.Get().isICDOperatingAsLIT.HasValue()); - EXPECT_TRUE( nodeData.Get().isICDOperatingAsLIT.Value() == false); + EXPECT_TRUE(nodeData.Get().isICDOperatingAsLIT.HasValue()); + EXPECT_TRUE(nodeData.Get().isICDOperatingAsLIT.Value() == false); nodeData.Get().isICDOperatingAsLIT.ClearValue(); - EXPECT_TRUE( NodeDataIsEmpty(nodeData.Get())); + EXPECT_TRUE(NodeDataIsEmpty(nodeData.Get())); // Invalid value, No key set strcpy(key, "ICD"); strcpy(val, "asdf"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( nodeData.Get().isICDOperatingAsLIT.HasValue() == false); + EXPECT_TRUE(nodeData.Get().isICDOperatingAsLIT.HasValue() == false); } // Test IsDeviceTreatedAsSleepy() with CRI @@ -725,19 +723,19 @@ void DiscoveredTestIsDeviceSessionIdle() CommonResolutionData & resolutionData = nodeData.Get(); // No key/val set, so the device can't be sleepy - EXPECT_TRUE( !nodeData.Get().IsDeviceTreatedAsSleepy(&defaultMRPConfig)); + EXPECT_TRUE(!nodeData.Get().IsDeviceTreatedAsSleepy(&defaultMRPConfig)); // If the interval is the default value, the device is not sleepy strcpy(key, "SII"); sprintf(val, "%d", static_cast(CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL.count())); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().IsDeviceTreatedAsSleepy(&defaultMRPConfig)); + EXPECT_TRUE(!nodeData.Get().IsDeviceTreatedAsSleepy(&defaultMRPConfig)); // If the interval is greater than the default value, the device is sleepy sprintf(key, "SII"); sprintf(val, "%d", static_cast(CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL.count() + 1)); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( nodeData.Get().IsDeviceTreatedAsSleepy(&defaultMRPConfig)); + EXPECT_TRUE(nodeData.Get().IsDeviceTreatedAsSleepy(&defaultMRPConfig)); } // Test IsDeviceTreatedAsSleepy() with CRA @@ -753,19 +751,19 @@ void DiscoveredTestIsDeviceSessionActive() CommonResolutionData & resolutionData = nodeData.Get(); // No key/val set, so the device can't be sleepy - EXPECT_TRUE( !nodeData.Get().IsDeviceTreatedAsSleepy(&defaultMRPConfig)); + EXPECT_TRUE(!nodeData.Get().IsDeviceTreatedAsSleepy(&defaultMRPConfig)); // If the interval is the default value, the device is not sleepy sprintf(key, "SAI"); sprintf(val, "%d", static_cast(CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL.count())); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( !nodeData.Get().IsDeviceTreatedAsSleepy(&defaultMRPConfig)); + EXPECT_TRUE(!nodeData.Get().IsDeviceTreatedAsSleepy(&defaultMRPConfig)); // If the interval is greater than the default value, the device is sleepy strcpy(key, "SAI"); sprintf(val, "%d", static_cast(CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL.count() + 1)); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData); - EXPECT_TRUE( nodeData.Get().IsDeviceTreatedAsSleepy(&defaultMRPConfig)); + EXPECT_TRUE(nodeData.Get().IsDeviceTreatedAsSleepy(&defaultMRPConfig)); } // Test SAI (formally CRI)