[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:
Abtin Keshavarzian
2018-06-11 09:10:52 -07:00
committed by Jonathan Hui
parent 90b160ccfa
commit 4b918f85f0
29 changed files with 631 additions and 313 deletions
+3 -16
View File
@@ -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)