mirror of
https://github.com/espressif/openthread.git
synced 2026-08-02 17:17:45 +00:00
[error] add 'ot::Error' and 'kError{Name}' for use by core modules (#6237)
This commit adds a new core header files `common/error.hpp` which
defines `ot::Error` (mirroring `otError`) and `kError{Name}` constants
(mirroring the public `OT_ERROR_{NAME}` definitions). The new (C++
style) definitions are used by core modules. This commit also moves
`otThreadErrorToString()` (from `logging.hpp` to `error.hpp`) and
renames it to `ErrorToString()` which is used as the internal (to
core) function to covert an `Error` to a string.
This commit is contained in:
@@ -295,7 +295,7 @@ void TestChildTable(void)
|
||||
uint16_t testNumAllowedChildren = 2;
|
||||
|
||||
ChildTable *table;
|
||||
otError error;
|
||||
Error error;
|
||||
|
||||
sInstance = testInitInstance();
|
||||
VerifyOrQuit(sInstance != nullptr, "Null instance");
|
||||
@@ -364,17 +364,17 @@ void TestChildTable(void)
|
||||
printf("Test Get/SetMaxChildrenAllowed");
|
||||
|
||||
error = table->SetMaxChildrenAllowed(kMaxChildren - 1);
|
||||
VerifyOrQuit(error == OT_ERROR_INVALID_STATE, "SetMaxChildrenAllowed() should fail when table is not empty");
|
||||
VerifyOrQuit(error == kErrorInvalidState, "SetMaxChildrenAllowed() should fail when table is not empty");
|
||||
|
||||
table->Clear();
|
||||
error = table->SetMaxChildrenAllowed(kMaxChildren + 1);
|
||||
VerifyOrQuit(error == OT_ERROR_INVALID_ARGS, "SetMaxChildrenAllowed() did not fail with an invalid arg");
|
||||
VerifyOrQuit(error == kErrorInvalidArgs, "SetMaxChildrenAllowed() did not fail with an invalid arg");
|
||||
|
||||
error = table->SetMaxChildrenAllowed(0);
|
||||
VerifyOrQuit(error == OT_ERROR_INVALID_ARGS, "SetMaxChildrenAllowed() did not fail with an invalid arg");
|
||||
VerifyOrQuit(error == kErrorInvalidArgs, "SetMaxChildrenAllowed() did not fail with an invalid arg");
|
||||
|
||||
error = table->SetMaxChildrenAllowed(testNumAllowedChildren);
|
||||
VerifyOrQuit(error == OT_ERROR_NONE, "SetMaxChildrenAllowed() failed");
|
||||
VerifyOrQuit(error == kErrorNone, "SetMaxChildrenAllowed() failed");
|
||||
VerifyOrQuit(table->GetMaxChildrenAllowed() == testNumAllowedChildren, "GetMaxChildrenAllowed() failed");
|
||||
|
||||
for (uint16_t num = 0; num < testNumAllowedChildren; num++)
|
||||
|
||||
Reference in New Issue
Block a user