This commit refactors various unit tests to use `constexpr` for
defining constants instead of anonymous `enum` types.
Using `constexpr` is the modern and preferred approach in C++, as it
provides explicit types for constants and improves code clarity and
type safety.
This commit moves the `instance` module to a newly added folder
`core/instance` (from `core/common`. Header file `extension.hpp`
and its example is also moved to the same folder.
This commit migrates unit tests to cmake.
* build unit tests with cmake
* add missing tests in cmake
* use ctest
* add platform udp stubs for test platform
* skip some static_assert with gcc-4
This commit updates `VerifyOrQuit()` and `SuccessOrQuit()` macros to
include the failed condition in the error message that is printed on
a failure (in addition to function name and line number where the
error happened). This commit also changes the second parameter
(`aMessage`) to in these macros to be optional.
This commit also updates unit tests to remove the second `aMessage`
string in cases where the failure can be inferred from the condition
itself.
This commit updates `test_utils.hpp/cpp` to include a common helper
function `DumpBuffer` to print the content of a buffer (as hex and char string)
to screen. It also removes unused helper functions and use of STL header
files and types.
This commit makes the following changes: It defines the public
`otInstance` as an empty opaque structure which is used by all public
C OpenThread APIs. It defines a new class `ot::Instance` (inheriting
from `otInstance) which is then used in core source files. The
functionality related to the instance is also moved/added into the
newly added `Instance` class (as class/static or member methods).
This commit adds support for encoding/decoding `uint64_t`/`int64_t`
to spinel as primitive types. `X` and `x` are used as format ASCII
character associated with `uint64_t` and `int64_t` respectively.
This commit also updates the `SpinelEncoder` and `SpinelDecoder`
to add methods related to 64-bit long integer. The related unit test
are also updated.
This commit adds a new class `SpinelEncoder` which provides a set of
methods/APIs to help in encoding/writing content using Spinel formating
(it is practically a C++ wrapper over Spinel C APIs). A unit test
`test_spinel_encoder` is also added in this commit.
This commit also updates the `NcpBase` implementation to adopt the new
`SpinelEncoder` class mainly in implementation of get, insert, and
remove handlers for different Spinel properties. The new class
provides the following advantages: (a) it simplifies the
implementation of handers, particularly get-handlers for properties
with a single type output; (b) it adds type-checking and type-safety
when frames are being created, e.g., if the Spinel format expects a
`SPINEL_DATATYPE_UINT8` but a `uint16_t` value is provided, the new
model will cause a compile-time error (few instances in code where the
types did not match are fixed in this commit).