[nexus] use indexed SetName() in test cases (#12814)

This commit simplifies node naming in various Nexus test cases by
using the indexed `SetName(prefix, index)` flavor.

This replaces manual string formatting using `snprintf` or
`ot::String` buffers with the built-in indexed naming support.
This commit is contained in:
Abtin Keshavarzian
2026-04-01 07:38:03 -07:00
committed by GitHub
parent d9fc6c15dc
commit ad0d0fcb5e
3 changed files with 5 additions and 11 deletions
+1 -5
View File
@@ -102,11 +102,7 @@ static void CreateNodes(Core &aNexus, Node *aNodes[], uint16_t aCount, const cha
for (uint16_t i = 0; i < aCount; i++)
{
aNodes[i] = &aNexus.CreateNode();
String<16> name;
name.Append("%s_%u", aNamePrefix, i + 1);
aNodes[i]->SetName(name.AsCString());
aNodes[i]->SetName(aNamePrefix, i + 1);
}
}
+3 -3
View File
@@ -99,12 +99,12 @@ void Test5_2_5(void)
Node &reed1 = nexus.CreateNode();
leader.SetName("LEADER");
for (uint16_t i = 0; i < kRouterCount; i++)
{
char name[16];
snprintf(name, sizeof(name), "ROUTER_%u", i + 1);
routers[i]->SetName(name);
routers[i]->SetName("ROUTER", i + 1);
}
br.SetName("BR");
med1.SetName("MED_1");
reed1.SetName("REED_1");
+1 -3
View File
@@ -101,9 +101,7 @@ void Test_5_2_6(void)
for (uint16_t i = 0; i < kInitialRouterCount - 2; i++)
{
routers[i] = &nexus.CreateNode();
char name[16];
snprintf(name, sizeof(name), "ROUTER_%u", i + 2);
routers[i]->SetName(name);
routers[i]->SetName("ROUTER", i + 2);
}
nexus.AdvanceTime(0);