mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
[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:
committed by
GitHub
parent
d9fc6c15dc
commit
ad0d0fcb5e
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user