Commit Graph

15 Commits

Author SHA1 Message Date
Abtin Keshavarzian 9d95a19e52 [tests] use constexpr for constants in unit tests (#13145)
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.
2026-05-25 19:39:27 -07:00
Abtin Keshavarzian 1528c8831d [core] define core/instance folder for instance modules (#9561)
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.
2023-10-26 05:08:24 -07:00
Zhanglong Xia f64b7cc73c [test] add code spell check and correct wrong spelling (#9066) 2023-05-22 18:04:09 -07:00
Yakun Xu 0e667b8e03 [test] use cmake to run unit tests (#8724)
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
2023-02-09 10:19:01 -08:00
Jonathan Hui 9c467a23ae [clang-format] apply v14 changes (#8490) 2022-12-07 16:23:20 -08:00
Abtin Keshavarzian 57d072d352 [test] enhance {Verify/Success}OrQuit() and their use in unit test (#6764)
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.
2021-06-28 11:38:10 -07:00
Yakun Xu fb16fd44d7 [build] move hdlc to lib/hdlc (#4590)
This commit moves hdlc from src/ncp to src/lib/hdlc, src/spinel is also
moved to src/lib/spinel.
2020-02-27 08:49:01 -08:00
Yakun Xu 8546bceeab [build] move spinel into src/utils (#4558)
Move spinel from src/ncp into src/utils and remove dependency on
OpenThread's core configurations.
2020-02-19 11:45:35 -08:00
Abtin Keshavarzian eaf2e7b9f7 [unit-test] add a common function to dump buffer content (#4367)
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.
2019-12-11 09:16:48 -08:00
Abtin Keshavarzian f10c6c36fd [unit-test] remove (unnecessary) ENABLE_TEST_MAIN definition (#4367) 2019-12-11 09:16:48 -08:00
Jonathan Hui 9d585edc46 [types] move types into specific headers (#2946) 2018-08-08 11:19:41 -07:00
Jonathan Hui 69d98d4a53 [code-style] apply clang-format 2018-02-09 21:43:42 +00:00
Abtin Keshavarzian 02c876ef62 [instance] define ot::Instance class (#2307)
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).
2017-11-13 08:27:57 -08:00
Abtin Keshavarzian 1e6658b3ad [spinel] add support for 64-bit long signed/unsigned integer (#2309)
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.
2017-11-01 21:46:09 -07:00
Abtin Keshavarzian 192df6cf00 [ncp] adding SpinelEncoder class and updating NCP implementation (#2221)
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).
2017-09-27 23:04:53 -07:00