forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull request project-chip#336: Feature/UIC-2597
Merge in WMN_TOOLS/matter from feature/UIC-2597 to silabs Squashed commit of the following: commit e15376f4885bc0887c097c4fb90fecbd9e64d7f6 Author: Anders Esbensen <Anders.Esbensen@silabs.com> Date: Fri Dec 2 11:37:15 2022 +0100 Fixed more Unit test. commit 1c0ed441673cbf6f27142f0f9ccfb836a6407a64 Author: Anders Esbensen <Anders.Esbensen@silabs.com> Date: Thu Dec 1 11:52:45 2022 +0100 Fixed GCC build error. commit f3e2048380ffba618f89fe0afb37ba5603f1d8ef Author: Anders Esbensen <Anders.Esbensen@silabs.com> Date: Thu Dec 1 09:52:24 2022 +0100 Removed foo_test ... and 16 more commits
- Loading branch information
1 parent
b349fb2
commit 45ce4cd
Showing
40 changed files
with
17,370 additions
and
41,587 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
silabs_examples/unify-matter-bridge/linux/src/tests/TestHelpers.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
#include <nlunit-test.h> | ||
#include <sl_log.h> | ||
#include <nlohmann/json.hpp> | ||
#include <sstream> | ||
namespace unify::matter_bridge::test { | ||
|
||
|
||
/** Assert two Strings containing JSON code are equal (ignoring whitespaces and order of JSON entries)*/ | ||
#define NL_TEST_ASSERT_EQUAL_JSON(_suite, _expected, _actual) {\ | ||
try {\ | ||
auto _expected_json = nlohmann::json::parse(_expected);\ | ||
auto _actual_json = nlohmann::json::parse(_actual);\ | ||
if (_expected_json != _actual_json) {\ | ||
sl_log_error("ASSERTION FAILED", "\nExpected: %s\nActual: %s\nDiff: %s", _expected_json.dump().c_str(), _actual_json.dump().c_str(), nlohmann::json::diff(_expected_json, _actual_json).dump().c_str());\ | ||
NL_TEST_ASSERT(_suite, _expected == _actual);\ | ||
}\ | ||
} catch (const nlohmann::detail::exception &_ex) {\ | ||
sl_log_error("JSON PARSE FAILED", "%s", _ex.what());\ | ||
NL_TEST_ASSERT(_suite, false);\ | ||
}\ | ||
} | ||
|
||
/** Assert two of any type are equal. Should work for all non-custom types*/ | ||
#define NL_TEST_ASSERT_EQUAL(_suite, _expected, _actual) {\ | ||
if (_expected != _actual) {\ | ||
std::ostringstream _dbg_out;\ | ||
_dbg_out << "Expected: " << _expected << std::endl << "Actual: " << _actual;\ | ||
sl_log_error("ASSERTION FAILED", "\n%s", _dbg_out.str().c_str());\ | ||
NL_TEST_ASSERT(_suite, _expected == _actual);\ | ||
}\ | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.