mirror of
https://github.com/espressif/openthread.git
synced 2026-08-17 07:59:51 +00:00
[string] adding ot::String<size> class (#2764)
This commit adds a new template class `ot::String<size>` which implements a fixed-length character string. This class is then used as return value of `ToString()` methods from different classes. This simplifies the `ToString()` implementation and its use. This commit also adds a unit test for `String`.
This commit is contained in:
committed by
Jonathan Hui
parent
90b160ccfa
commit
4b918f85f0
@@ -83,14 +83,7 @@ void VerifyRawRssValue(int8_t aAverage, uint16_t aRawValue)
|
||||
// This function prints the values in the passed in link info instance. It is invoked as the final step in test-case.
|
||||
void PrintOutcome(LinkQualityInfo &aLinkInfo)
|
||||
{
|
||||
char stringBuf[LinkQualityInfo::kInfoStringSize];
|
||||
|
||||
VerifyOrQuit(aLinkInfo.ToInfoString(stringBuf, sizeof(stringBuf)) != NULL, "ToInfoString() returned NULL");
|
||||
|
||||
printf("%s", stringBuf);
|
||||
|
||||
// This test-case succeeded.
|
||||
printf(" -> PASS\n");
|
||||
printf("%s -> PASS \n", aLinkInfo.ToInfoString().AsCString());
|
||||
}
|
||||
|
||||
void TestLinkQualityData(RssTestData aRssData)
|
||||
@@ -139,16 +132,10 @@ void VerifyRawRssValue(RssAverager &aRssAverager)
|
||||
}
|
||||
}
|
||||
|
||||
// This function prints the values in the passed in link info instance. It is invoked as the final step in test-case.
|
||||
// This function prints the values in the passed link info instance. It is invoked as the final step in test-case.
|
||||
void PrintOutcome(RssAverager &aRssAverager)
|
||||
{
|
||||
char stringBuf[RssAverager::kStringSize];
|
||||
|
||||
VerifyOrQuit(aRssAverager.ToString(stringBuf, sizeof(stringBuf)) != NULL, "ToString() returned NULL");
|
||||
printf("%s", stringBuf);
|
||||
|
||||
// This test-case succeeded.
|
||||
printf(" -> PASS\n");
|
||||
printf("%s -> PASS\n", aRssAverager.ToString().AsCString());
|
||||
}
|
||||
|
||||
int8_t GetRandomRss(void)
|
||||
|
||||
Reference in New Issue
Block a user