Cleanup formatting
Wew, that's a lot of stuff. But I thought it makes sense after the
sysrepo migration.
Change-Id: If363d2ce1b11106113a9f0c37a3bcd59a940bd0b
diff --git a/src/ast_handlers.cpp b/src/ast_handlers.cpp
index b77964b..6fde52c 100644
--- a/src/ast_handlers.cpp
+++ b/src/ast_handlers.cpp
@@ -26,5 +26,5 @@
boost::optional<std::string> optModuleToOptString(const boost::optional<module_> module)
{
- return module.flat_map([] (const auto& module) { return boost::optional<std::string>(module.m_name); });
+ return module.flat_map([](const auto& module) { return boost::optional<std::string>(module.m_name); });
}
diff --git a/src/ast_handlers.hpp b/src/ast_handlers.hpp
index c4658e4..686af85 100644
--- a/src/ast_handlers.hpp
+++ b/src/ast_handlers.hpp
@@ -57,7 +57,7 @@
if (schema.listHasKey(dataPathToSchemaPath(parserContext.m_tmpListPath), ast)) {
parserContext.m_tmpListKeyLeafPath.m_location = dataPathToSchemaPath(parserContext.m_tmpListPath);
- parserContext.m_tmpListKeyLeafPath.m_node = { optModuleToOptString(parserContext.m_tmpListPath.m_nodes.back().m_prefix), ast };
+ parserContext.m_tmpListKeyLeafPath.m_node = {optModuleToOptString(parserContext.m_tmpListPath.m_nodes.back().m_prefix), ast};
} else {
auto listName = std::get<list_>(parserContext.m_tmpListPath.m_nodes.back().m_suffix).m_name;
parserContext.m_errorMsg = listName + " is not indexed by \"" + ast + "\".";
@@ -333,12 +333,12 @@
decltype(listInstances) filteredInstances;
//This filters out instances, which don't correspond to the partial instance we have.
- const auto partialFitsComplete = [&parserContext] (const auto& complete) {
+ const auto partialFitsComplete = [&parserContext](const auto& complete) {
const auto& partial = parserContext.m_tmpListKeys;
- return std::all_of(partial.begin(), partial.end(), [&complete] (const auto& oneKV) {
- const auto& [k, v] = oneKV;
- return complete.at(k) == v;
- });
+ return std::all_of(partial.begin(), partial.end(), [&complete](const auto& oneKV) {
+ const auto& [k, v] = oneKV;
+ return complete.at(k) == v;
+ });
};
std::copy_if(listInstances.begin(), listInstances.end(), std::inserter(filteredInstances, filteredInstances.end()), partialFitsComplete);
@@ -370,7 +370,7 @@
};
template <typename T>
-std::string commandNamesVisitor (boost::type<T>)
+std::string commandNamesVisitor(boost::type<T>)
{
return T::name;
}
diff --git a/src/ast_path.cpp b/src/ast_path.cpp
index b9f7ae4..7ab9b18 100644
--- a/src/ast_path.cpp
+++ b/src/ast_path.cpp
@@ -63,7 +63,6 @@
: m_prefix(module)
, m_suffix(node)
{
-
}
schemaNode_::schemaNode_(decltype(m_suffix) node)
diff --git a/src/cli.cpp b/src/cli.cpp
index f89c8d6..4f4328a 100644
--- a/src/cli.cpp
+++ b/src/cli.cpp
@@ -60,8 +60,8 @@
-v enable verbose mode
-p <port> port number [default: 830]
)";
-#include "netconf_access.hpp"
#include "cli-netconf.hpp"
+#include "netconf_access.hpp"
#define PROGRAM_NAME "netconf-access"
#else
#error "Unknown CLI backend"
@@ -86,7 +86,7 @@
} else if (ds.asString() == "running") {
datastoreType = Datastore::Running;
} else {
- std::cerr << PROGRAM_NAME << ": unknown datastore: " << ds.asString() << "\n";
+ std::cerr << PROGRAM_NAME << ": unknown datastore: " << ds.asString() << "\n";
return 1;
}
}
@@ -129,7 +129,6 @@
std::cerr << ex.what() << "\n";
return 1;
}
-
}
}
if (const auto& dataFiles = args["-i"]) {
@@ -175,10 +174,10 @@
Replxx lineEditor;
- lineEditor.bind_key(Replxx::KEY::meta(Replxx::KEY::BACKSPACE), [&lineEditor] (const auto& code) {
+ lineEditor.bind_key(Replxx::KEY::meta(Replxx::KEY::BACKSPACE), [&lineEditor](const auto& code) {
return lineEditor.invoke(Replxx::ACTION::KILL_TO_BEGINING_OF_WORD, code);
});
- lineEditor.bind_key(Replxx::KEY::control('W'), [&lineEditor] (const auto& code) {
+ lineEditor.bind_key(Replxx::KEY::control('W'), [&lineEditor](const auto& code) {
return lineEditor.invoke(Replxx::ACTION::KILL_TO_WHITESPACE_ON_LEFT, code);
});
diff --git a/src/datastore_access.hpp b/src/datastore_access.hpp
index da9c33f..057c96a 100644
--- a/src/datastore_access.hpp
+++ b/src/datastore_access.hpp
@@ -12,9 +12,9 @@
#include <memory>
#include <optional>
#include <string>
-#include "yang_operations.hpp"
#include "ast_values.hpp"
#include "list_instance.hpp"
+#include "yang_operations.hpp"
/*! \class DatastoreAccess
* \brief Abstract class for accessing a datastore
diff --git a/src/grammars.hpp b/src/grammars.hpp
index 161a515..7e5b49d 100644
--- a/src/grammars.hpp
+++ b/src/grammars.hpp
@@ -112,7 +112,7 @@
{
auto& parserContext = x3::get<parser_context_tag>(ctx);
auto iterBeforeDestination = begin;
- auto save_iter = x3::no_skip[x3::eps[([&iterBeforeDestination](auto& ctx) {iterBeforeDestination = _where(ctx).begin();})]];
+ auto save_iter = x3::no_skip[x3::eps[([&iterBeforeDestination](auto& ctx) { iterBeforeDestination = _where(ctx).begin(); })]];
auto grammar = datastoreSuggestions > copy_source > space_separator > datastoreSuggestions > save_iter > copy_destination;
try {
diff --git a/src/interpreter.cpp b/src/interpreter.cpp
index a39167e..97836bf 100644
--- a/src/interpreter.cpp
+++ b/src/interpreter.cpp
@@ -115,7 +115,7 @@
auto toPrint = m_datastore.schema()->availableNodes(toCanonicalPath(ls.m_path), recursion);
for (const auto& it : toPrint) {
- std::cout << (it.first ? *it.first + ":" : "" ) + it.second << std::endl;
+ std::cout << (it.first ? *it.first + ":" : "") + it.second << std::endl;
}
}
@@ -134,8 +134,7 @@
case yang::NodeTypes::PresenceContainer:
ss << "presence container";
break;
- case yang::NodeTypes::Leaf:
- {
+ case yang::NodeTypes::Leaf: {
auto leafType = m_datastore.schema()->leafType(path);
auto typedefName = m_datastore.schema()->leafTypeName(path);
std::string baseTypeStr;
diff --git a/src/interpreter.hpp b/src/interpreter.hpp
index 54a8d05..c59e3d2 100644
--- a/src/interpreter.hpp
+++ b/src/interpreter.hpp
@@ -9,8 +9,8 @@
#pragma once
#include <boost/variant/static_visitor.hpp>
-#include "proxy_datastore.hpp"
#include "parser.hpp"
+#include "proxy_datastore.hpp"
struct Interpreter : boost::static_visitor<void> {
diff --git a/src/leaf_data.hpp b/src/leaf_data.hpp
index 964c154..7bab723 100644
--- a/src/leaf_data.hpp
+++ b/src/leaf_data.hpp
@@ -140,7 +140,7 @@
bool operator()(const yang::IdentityRef& type) const
{
createSetSuggestions(type);
- auto checkValidIdentity = [this, type] (auto& ctx) {
+ auto checkValidIdentity = [this, type](auto& ctx) {
identityRef_ pair{boost::get<identityRef_>(_attr(ctx))};
if (!pair.m_prefix) {
pair.m_prefix = module_{parserContext.currentSchemaPath().m_nodes.front().m_prefix.get().m_name};
diff --git a/src/libyang_utils.cpp b/src/libyang_utils.cpp
index f1af868..1f0c372 100644
--- a/src/libyang_utils.cpp
+++ b/src/libyang_utils.cpp
@@ -6,7 +6,7 @@
leaf_data_ leafValueFromNode(libyang::S_Data_Node_Leaf_List node)
{
- std::function<leaf_data_(libyang::S_Data_Node_Leaf_List)> impl = [&impl] (libyang::S_Data_Node_Leaf_List node) -> leaf_data_ {
+ std::function<leaf_data_(libyang::S_Data_Node_Leaf_List)> impl = [&impl](libyang::S_Data_Node_Leaf_List node) -> leaf_data_ {
// value_type() is what's ACTUALLY stored inside `node`
// Leafrefs sometimes don't hold a reference to another, but they have the actual pointed-to value.
switch (node->value_type()) {
@@ -28,8 +28,7 @@
return node->value()->int32();
case LY_TYPE_INT64:
return node->value()->int64();
- case LY_TYPE_DEC64:
- {
+ case LY_TYPE_DEC64: {
auto v = node->value()->dec64();
return v.value * std::pow(10, -v.digits);
}
@@ -43,24 +42,22 @@
return identityRef_{node->value()->ident()->module()->name(), node->value()->ident()->name()};
case LY_TYPE_EMPTY:
return empty_{};
- case LY_TYPE_LEAFREF:
- {
+ case LY_TYPE_LEAFREF: {
auto refsTo = node->value()->leafref();
assert(refsTo);
return impl(std::make_shared<libyang::Data_Node_Leaf_List>(node->value()->leafref()));
}
- case LY_TYPE_BITS:
- {
+ case LY_TYPE_BITS: {
auto bits = node->value()->bit();
std::vector<libyang::S_Type_Bit> filterNull;
- std::copy_if(bits.begin(), bits.end(), std::back_inserter(filterNull), [] (auto bit) { return bit; });
+ std::copy_if(bits.begin(), bits.end(), std::back_inserter(filterNull), [](auto bit) { return bit; });
bits_ res;
- std::transform(filterNull.begin(), filterNull.end(), std::inserter(res.m_bits, res.m_bits.end()), [] (const auto& bit) { return bit->name(); });
+ std::transform(filterNull.begin(), filterNull.end(), std::inserter(res.m_bits, res.m_bits.end()), [](const auto& bit) { return bit->name(); });
return bits_{res};
}
default:
return std::string{"(can't print)"};
- }
+ }
};
return impl(node);
}
@@ -68,7 +65,7 @@
namespace {
void impl_lyNodesToTree(DatastoreAccess::Tree& res, const std::vector<std::shared_ptr<libyang::Data_Node>> items, std::optional<std::string> ignoredXPathPrefix)
{
- auto stripXPathPrefix = [&ignoredXPathPrefix] (auto path) {
+ auto stripXPathPrefix = [&ignoredXPathPrefix](auto path) {
return ignoredXPathPrefix && path.find(*ignoredXPathPrefix) != std::string::npos ? path.substr(ignoredXPathPrefix->size()) : path;
};
diff --git a/src/netconf-client.cpp b/src/netconf-client.cpp
index 42e9edc..fde9561 100644
--- a/src/netconf-client.cpp
+++ b/src/netconf-client.cpp
@@ -13,8 +13,8 @@
#include <nc_client.h>
}
#include <sstream>
-#include "netconf-client.hpp"
#include "UniqueResource.hpp"
+#include "netconf-client.hpp"
namespace libnetconf {
@@ -67,7 +67,7 @@
nc_reply_free(reinterpret_cast<nc_reply*>(reply));
}
-char *ssh_auth_interactive_cb(const char *auth_name, const char *instruction, const char *prompt, int echo, void *priv)
+char* ssh_auth_interactive_cb(const char* auth_name, const char* instruction, const char* prompt, int echo, void* priv)
{
const auto cb = static_cast<const client::KbdInteractiveCb*>(priv);
auto res = (*cb)(auth_name, instruction, prompt, echo);
@@ -162,7 +162,6 @@
default:
throw std::runtime_error{"Unhandled reply type"};
}
-
}
unique_ptr_for<struct nc_reply_data> do_rpc_data(client::Session* session, unique_ptr_for<struct nc_rpc>&& rpc)
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index 2c64cd4..1e56659 100644
--- a/src/netconf_access.cpp
+++ b/src/netconf_access.cpp
@@ -233,7 +233,7 @@
// I take the first child here, because the first element (the parent of the child()) will be the list
for (const auto& keyLeaf : instance->child()->tree_for()) {
auto leafData = std::make_shared<libyang::Data_Node_Leaf_List>(keyLeaf);
- instanceRes.insert({ leafData->schema()->name(), leafValueFromNode(leafData)});
+ instanceRes.insert({leafData->schema()->name(), leafValueFromNode(leafData)});
}
res.emplace_back(instanceRes);
}
diff --git a/src/path_parser.hpp b/src/path_parser.hpp
index 3abbce3..d03f670 100644
--- a/src/path_parser.hpp
+++ b/src/path_parser.hpp
@@ -266,7 +266,7 @@
using attribute_type = ModeToAttribute<PARSER_MODE>;
std::function<bool(const Schema&, const std::string& path)> m_filterFunction;
- PathParser(const std::function<bool(const Schema&, const std::string& path)>& filterFunction = [] (const auto&, const auto&) {return true;})
+ PathParser(const std::function<bool(const Schema&, const std::string& path)>& filterFunction = [](const auto&, const auto&) { return true; })
: m_filterFunction(filterFunction)
{
}
@@ -393,7 +393,7 @@
auto const trailingSlash_def =
x3::omit['/'] >> x3::attr(TrailingSlash::Present);
-auto const filterConfigFalse = [] (const Schema& schema, const std::string& path) {
+auto const filterConfigFalse = [](const Schema& schema, const std::string& path) {
return schema.isConfig(path);
};
@@ -441,7 +441,7 @@
}
if (attr.m_nodes.empty()
- || (!std::holds_alternative<rpcNode_>(attr.m_nodes.back().m_suffix) && !std::holds_alternative<actionNode_>(attr.m_nodes.back().m_suffix))) {
+ || (!std::holds_alternative<rpcNode_>(attr.m_nodes.back().m_suffix) && !std::holds_alternative<actionNode_>(attr.m_nodes.back().m_suffix))) {
auto& parserContext = x3::get<parser_context_tag>(ctx);
parserContext.m_errorMsg = "This is not a path to an RPC/action.";
return false;
@@ -453,7 +453,7 @@
auto const rpcActionPath = as<dataPath_>[RpcActionPath()];
-auto const noRpcOrAction = [] (const Schema& schema, const std::string& path) {
+auto const noRpcOrAction = [](const Schema& schema, const std::string& path) {
auto nodeType = schema.nodeType(path);
return nodeType != yang::NodeTypes::Rpc && nodeType != yang::NodeTypes::Action;
};
diff --git a/src/proxy_datastore.cpp b/src/proxy_datastore.cpp
index 393edef..113a923 100644
--- a/src/proxy_datastore.cpp
+++ b/src/proxy_datastore.cpp
@@ -60,9 +60,8 @@
}
namespace {
-struct getInputPath
-{
- template<typename InputType>
+struct getInputPath {
+ template <typename InputType>
auto operator()(const InputType& input)
{
return input.m_path;
diff --git a/src/proxy_datastore.hpp b/src/proxy_datastore.hpp
index ab69193..e7650cd 100644
--- a/src/proxy_datastore.hpp
+++ b/src/proxy_datastore.hpp
@@ -35,6 +35,7 @@
void cancel();
[[nodiscard]] std::shared_ptr<Schema> schema() const;
+
private:
/** @brief Picks a datastore based on the requested path.
*
diff --git a/src/python_netconf.cpp b/src/python_netconf.cpp
index 19c096f..7a0e4d3 100644
--- a/src/python_netconf.cpp
+++ b/src/python_netconf.cpp
@@ -8,8 +8,8 @@
#include <pybind11/functional.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
-#include "netconf_access.hpp"
#include "netconf-client.hpp"
+#include "netconf_access.hpp"
using namespace std::literals;
using namespace pybind11::literals;
diff --git a/src/static_schema.cpp b/src/static_schema.cpp
index af1004a..a75f471 100644
--- a/src/static_schema.cpp
+++ b/src/static_schema.cpp
@@ -167,9 +167,9 @@
return res;
}
- auto getTopLevelModule = [] (const auto& path) -> boost::optional<std::string> {
+ auto getTopLevelModule = [](const auto& path) -> boost::optional<std::string> {
if (!path.m_nodes.empty()) {
- return path.m_nodes.begin()->m_prefix.flat_map([] (const auto& module) {return boost::optional<std::string>(module.m_name);});
+ return path.m_nodes.begin()->m_prefix.flat_map([](const auto& module) { return boost::optional<std::string>(module.m_name); });
}
return boost::none;
@@ -213,7 +213,6 @@
yang::NodeTypes operator()(const yang::leaf&)
{
return yang::NodeTypes::Leaf;
-
}
yang::NodeTypes operator()(const yang::leaflist&)
{
diff --git a/src/sysrepo_access.cpp b/src/sysrepo_access.cpp
index f6e8d1d..7c21cad 100644
--- a/src/sysrepo_access.cpp
+++ b/src/sysrepo_access.cpp
@@ -9,8 +9,8 @@
#include <experimental/iterator>
#include <libyang/Tree_Data.hpp>
#include <libyang/Tree_Schema.hpp>
-#include <sysrepo-cpp/Session.hpp>
#include <sstream>
+#include <sysrepo-cpp/Session.hpp>
#include "libyang_utils.hpp"
#include "sysrepo_access.hpp"
#include "utils.hpp"
@@ -44,8 +44,7 @@
return std::string(value->data()->get_string());
case SR_ENUM_T:
return enum_{std::string(value->data()->get_enum())};
- case SR_IDENTITYREF_T:
- {
+ case SR_IDENTITYREF_T: {
auto pair = splitModuleNode(value->data()->get_identityref());
return identityRef_{*pair.first, pair.second};
}
@@ -61,8 +60,7 @@
return special_{SpecialValue::PresenceContainer};
case SR_LIST_T:
return special_{SpecialValue::List};
- case SR_BITS_T:
- {
+ case SR_BITS_T: {
bits_ res;
std::istringstream ss(value->data()->get_bits());
while (!ss.eof()) {
@@ -71,7 +69,6 @@
res.m_bits.push_back(bit);
}
return res;
-
}
default: // TODO: implement all types
return value->val_to_string();
@@ -333,7 +330,7 @@
}
// TODO: merge this with executeAction
-DatastoreAccess::Tree SysrepoAccess::executeRpc(const std::string &path, const Tree &input)
+DatastoreAccess::Tree SysrepoAccess::executeRpc(const std::string& path, const Tree& input)
{
auto srInput = toSrVals(path, input);
auto output = m_session->rpc_send(path.c_str(), srInput);
@@ -384,7 +381,7 @@
decltype(lists) instances;
auto wantedTree = *(m_schema->dataNodeFromPath(path)->find_path(path.c_str())->data().begin());
- std::copy_if(lists.begin(), lists.end(), std::inserter(instances, instances.end()), [this, pathToCheck=wantedTree->schema()->path()](const auto& item) {
+ std::copy_if(lists.begin(), lists.end(), std::inserter(instances, instances.end()), [this, pathToCheck = wantedTree->schema()->path()](const auto& item) {
// This filters out non-instances.
if (item.second.type() != typeid(special_) || boost::get<special_>(item.second).m_value != SpecialValue::List) {
return false;
diff --git a/src/sysrepo_access.hpp b/src/sysrepo_access.hpp
index e43b733..d0ad869 100644
--- a/src/sysrepo_access.hpp
+++ b/src/sysrepo_access.hpp
@@ -43,6 +43,7 @@
void copyConfig(const Datastore source, const Datastore destination) override;
[[nodiscard]] std::string dump(const DataFormat format) const override;
+
private:
std::vector<ListInstance> listInstances(const std::string& path) override;
[[noreturn]] void reportErrors() const;
diff --git a/src/yang_access.hpp b/src/yang_access.hpp
index ab948cf..62c43d6 100644
--- a/src/yang_access.hpp
+++ b/src/yang_access.hpp
@@ -53,8 +53,8 @@
void impl_removeNode(const std::string& path);
void validate();
- std::unique_ptr<ly_ctx, void(*)(ly_ctx*)> m_ctx;
- std::unique_ptr<lyd_node, void(*)(lyd_node*)> m_datastore;
+ std::unique_ptr<ly_ctx, void (*)(ly_ctx*)> m_ctx;
+ std::unique_ptr<lyd_node, void (*)(lyd_node*)> m_datastore;
std::shared_ptr<YangSchema> m_schema;
const int m_validation_mode;
};
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index 8793dd4..7f27711 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -198,7 +198,7 @@
auto leaf = std::make_shared<NodeType>(node);
auto leafUnits = leaf->units();
std::function<yang::TypeInfo(std::shared_ptr<libyang::Type>)> resolveType;
- resolveType = [this, &resolveType, leaf, leafUnits] (std::shared_ptr<libyang::Type> type) -> yang::TypeInfo {
+ resolveType = [this, &resolveType, leaf, leafUnits](std::shared_ptr<libyang::Type> type) -> yang::TypeInfo {
yang::LeafDataType resType;
switch (type->base()) {
case LY_TYPE_STRING:
@@ -249,24 +249,22 @@
case LY_TYPE_LEAFREF:
resType.emplace<yang::LeafRef>(::leafrefPath(type), std::make_unique<yang::TypeInfo>(leafType(::leafrefPath(type))));
break;
- case LY_TYPE_BITS:
- {
- auto resBits = yang::Bits{};
- for (const auto& bit : type->info()->bits()->bit()) {
- resBits.m_allowedValues.emplace(bit->name());
- }
- resType.emplace<yang::Bits>(std::move(resBits));
- break;
+ case LY_TYPE_BITS: {
+ auto resBits = yang::Bits{};
+ for (const auto& bit : type->info()->bits()->bit()) {
+ resBits.m_allowedValues.emplace(bit->name());
}
- case LY_TYPE_UNION:
- {
- auto resUnion = yang::Union{};
- for (auto unionType : type->info()->uni()->types()) {
- resUnion.m_unionTypes.emplace_back(resolveType(unionType));
- }
- resType.emplace<yang::Union>(std::move(resUnion));
- break;
+ resType.emplace<yang::Bits>(std::move(resBits));
+ break;
+ }
+ case LY_TYPE_UNION: {
+ auto resUnion = yang::Union{};
+ for (auto unionType : type->info()->uni()->types()) {
+ resUnion.m_unionTypes.emplace_back(resolveType(unionType));
}
+ resType.emplace<yang::Union>(std::move(resUnion));
+ break;
+ }
default:
using namespace std::string_literals;
throw UnsupportedYangTypeException("the type of "s + leaf->name() + " is not supported: " + std::to_string(leaf->type()->base()));
diff --git a/src/yang_schema.hpp b/src/yang_schema.hpp
index 3d1dc81..632f538 100644
--- a/src/yang_schema.hpp
+++ b/src/yang_schema.hpp
@@ -70,6 +70,7 @@
std::shared_ptr<libyang::Module> getYangModule(const std::string& name);
[[nodiscard]] std::string dataPathToSchemaPath(const std::string& path);
+
private:
friend class YangAccess;
template <typename NodeType>
diff --git a/tests/cd.cpp b/tests/cd.cpp
index 174ffd0..dc0b319 100644
--- a/tests/cd.cpp
+++ b/tests/cd.cpp
@@ -105,7 +105,7 @@
SECTION("example:list[number=1]")
{
input = "cd example:list[number=1]";
- auto keys = ListInstance {
+ auto keys = ListInstance{
{"number", int32_t{1}}};
expected.m_path.m_nodes.emplace_back(module_{"example"}, listElement_("list", keys));
}
@@ -113,7 +113,7 @@
SECTION("example:list[number=1]/contInList")
{
input = "cd example:list[number=1]/contInList";
- auto keys = ListInstance {
+ auto keys = ListInstance{
{"number", int32_t{1}}};
expected.m_path.m_nodes.emplace_back(module_{"example"}, listElement_("list", keys));
expected.m_path.m_nodes.emplace_back(container_("contInList"));
@@ -122,7 +122,7 @@
SECTION("example:twoKeyList[number=4][name='abcd']")
{
input = "cd example:twoKeyList[number=4][name='abcd']";
- auto keys = ListInstance {
+ auto keys = ListInstance{
{"number", int32_t{4}},
{"name", std::string{"abcd"}}};
expected.m_path.m_nodes.emplace_back(module_{"example"}, listElement_("twoKeyList", keys));
@@ -131,7 +131,7 @@
SECTION("enum key type")
{
input = "cd example:ports[name=A]";
- auto keys = ListInstance {
+ auto keys = ListInstance{
{"name", enum_{"A"}}};
expected.m_path.m_nodes.emplace_back(module_{"example"}, listElement_("ports", keys));
}
diff --git a/tests/command_completion.cpp b/tests/command_completion.cpp
index 2fedb78..c92bad0 100644
--- a/tests/command_completion.cpp
+++ b/tests/command_completion.cpp
@@ -23,10 +23,12 @@
{
expectedCompletions = {"cd", "copy", "create", "delete", "set", "commit", "get", "ls", "discard", "help", "describe", "move", "dump", "prepare", "exec", "cancel"};
expectedContextLength = 0;
- SECTION("no space") {
+ SECTION("no space")
+ {
input = "";
}
- SECTION("space") {
+ SECTION("space")
+ {
input = " ";
}
}
diff --git a/tests/data_query.cpp b/tests/data_query.cpp
index 4aa597e..eb8e838 100644
--- a/tests/data_query.cpp
+++ b/tests/data_query.cpp
@@ -5,9 +5,9 @@
*
*/
+#include "trompeloeil_doctest.hpp"
#include <experimental/iterator>
#include <sysrepo-cpp/Session.hpp>
-#include "trompeloeil_doctest.hpp"
#ifdef sysrepo_BACKEND
#include "sysrepo_access.hpp"
@@ -205,7 +205,6 @@
{{"type", enum_{"laptop"}}},
{{"type", enum_{"server"}}},
};
-
}
SECTION("cyril computers")
@@ -237,7 +236,6 @@
{{"id", int32_t{1}}},
{{"id", int32_t{2}}},
};
-
}
datastore.commitChanges();
diff --git a/tests/datastore_access.cpp b/tests/datastore_access.cpp
index 613f661..43d6038 100644
--- a/tests/datastore_access.cpp
+++ b/tests/datastore_access.cpp
@@ -8,8 +8,8 @@
#include "trompeloeil_doctest.hpp"
#include <sysrepo-cpp/Session.hpp>
-#include "yang_schema.hpp"
#include "proxy_datastore.hpp"
+#include "yang_schema.hpp"
#ifdef sysrepo_BACKEND
#include "sysrepo_access.hpp"
@@ -219,7 +219,7 @@
SECTION("set a non-existing leaf")
{
- catching<OnInvalidSchemaPathCreate>([&]{
+ catching<OnInvalidSchemaPathCreate>([&] {
datastore.setLeaf("/example-schema:non-existing", "what"s);
});
}
@@ -251,7 +251,7 @@
SECTION("deleting non-existing list keys")
{
- catching<OnKeyNotFound>([&]{
+ catching<OnKeyNotFound>([&] {
datastore.deleteItem("/example-schema:person[name='non existing']");
datastore.commitChanges();
});
@@ -259,11 +259,11 @@
SECTION("accessing non-existing schema nodes as a list")
{
- catching<OnInvalidSchemaPathCreate>([&]{
+ catching<OnInvalidSchemaPathCreate>([&] {
datastore.createItem("/example-schema:non-existing-list[xxx='blah']");
datastore.commitChanges();
});
- catching<OnInvalidSchemaPathDelete>([&]{
+ catching<OnInvalidSchemaPathDelete>([&] {
datastore.deleteItem("/example-schema:non-existing-list[xxx='non existing']");
datastore.commitChanges();
});
@@ -402,7 +402,7 @@
SECTION("creating a non-existing schema node as a container")
{
- catching<OnInvalidSchemaPathCreate>([&]{
+ catching<OnInvalidSchemaPathCreate>([&] {
datastore.createItem("/example-schema:non-existing-presence-container");
datastore.commitChanges();
});
@@ -410,7 +410,7 @@
SECTION("deleting a non-existing schema node as a container or leaf")
{
- catching<OnInvalidSchemaPathDelete>([&]{
+ catching<OnInvalidSchemaPathDelete>([&] {
datastore.deleteItem("/example-schema:non-existing-presence-container");
datastore.commitChanges();
});
@@ -444,7 +444,7 @@
datastore.setLeaf("/example-schema:leafDecimal", 123.4);
REQUIRE_CALL(mock, write("/example-schema:leafDecimal", std::nullopt, "123.4"s));
datastore.commitChanges();
- DatastoreAccess::Tree expected {
+ DatastoreAccess::Tree expected{
{"/example-schema:leafDecimal", 123.4},
};
REQUIRE(datastore.getItems("/example-schema:leafDecimal") == expected);
@@ -455,17 +455,18 @@
datastore.setLeaf("/example-schema:unionIntString", int32_t{10});
REQUIRE_CALL(mock, write("/example-schema:unionIntString", std::nullopt, "10"s));
datastore.commitChanges();
- DatastoreAccess::Tree expected {
+ DatastoreAccess::Tree expected{
{"/example-schema:unionIntString", int32_t{10}},
};
REQUIRE(datastore.getItems("/example-schema:unionIntString") == expected);
}
- SECTION("identityref") {
+ SECTION("identityref")
+ {
datastore.setLeaf("/example-schema:beast", identityRef_{"example-schema", "Mammal"});
REQUIRE_CALL(mock, write("/example-schema:beast", std::nullopt, "example-schema:Mammal"s));
datastore.commitChanges();
- DatastoreAccess::Tree expected {
+ DatastoreAccess::Tree expected{
{"/example-schema:beast", identityRef_{"example-schema", "Mammal"}},
};
REQUIRE(datastore.getItems("/example-schema:beast") == expected);
@@ -484,7 +485,7 @@
datastore.setLeaf("/example-schema:blob", binary_{"cHduegByIQ=="s});
REQUIRE_CALL(mock, write("/example-schema:blob", std::nullopt, "cHduegByIQ=="s));
datastore.commitChanges();
- DatastoreAccess::Tree expected {
+ DatastoreAccess::Tree expected{
{"/example-schema:blob", binary_{"cHduegByIQ=="s}},
};
REQUIRE(datastore.getItems("/example-schema:blob") == expected);
@@ -495,7 +496,7 @@
datastore.setLeaf("/example-schema:dummy", empty_{});
REQUIRE_CALL(mock, write("/example-schema:dummy", std::nullopt, ""s));
datastore.commitChanges();
- DatastoreAccess::Tree expected {
+ DatastoreAccess::Tree expected{
{"/example-schema:dummy", empty_{}},
};
REQUIRE(datastore.getItems("/example-schema:dummy") == expected);
@@ -506,7 +507,7 @@
datastore.setLeaf("/example-schema:flags", bits_{{"sign", "carry"}});
REQUIRE_CALL(mock, write("/example-schema:flags", std::nullopt, "carry sign"s));
datastore.commitChanges();
- DatastoreAccess::Tree expected {
+ DatastoreAccess::Tree expected{
{"/example-schema:flags", bits_{{"carry", "sign"}}},
};
REQUIRE(datastore.getItems("/example-schema:flags") == expected);
@@ -577,7 +578,7 @@
SECTION("deleting a non-existing leaf-list")
{
- catching<OnKeyNotFound>([&]{
+ catching<OnKeyNotFound>([&] {
datastore.deleteItem("/example-schema:addresses[.='non-existing']");
datastore.commitChanges();
});
@@ -585,12 +586,12 @@
SECTION("accessing a non-existing schema node as a leaf-list")
{
- catching<OnInvalidSchemaPathCreate>([&]{
+ catching<OnInvalidSchemaPathCreate>([&] {
datastore.createItem("/example-schema:non-existing[.='non-existing']");
datastore.commitChanges();
});
- catching<OnInvalidSchemaPathDelete>([&]{
+ catching<OnInvalidSchemaPathDelete>([&] {
datastore.deleteItem("/example-schema:non-existing[.='non-existing']");
datastore.commitChanges();
});
@@ -698,7 +699,7 @@
SECTION("moving non-existing schema nodes")
{
- catching<OnInvalidSchemaPathMove>([&]{
+ catching<OnInvalidSchemaPathMove>([&] {
datastore.moveItem("/example-schema:non-existing", yang::move::Absolute::Begin);
datastore.commitChanges();
});
@@ -904,7 +905,8 @@
}
};
-TEST_CASE("rpc/action") {
+TEST_CASE("rpc/action")
+{
trompeloeil::sequence seq1;
#ifdef sysrepo_BACKEND
@@ -946,12 +948,14 @@
std::string rpc;
DatastoreAccess::Tree input, output;
- SECTION("noop") {
+ SECTION("noop")
+ {
rpc = "/example-schema:noop";
proxyDatastore.initiateRpc(rpc);
}
- SECTION("small nuke") {
+ SECTION("small nuke")
+ {
rpc = "/example-schema:launch-nukes";
input = {
{"description", "dummy"s},
@@ -962,7 +966,8 @@
// no data are returned
}
- SECTION("small nuke") {
+ SECTION("small nuke")
+ {
rpc = "/example-schema:launch-nukes";
input = {
{"description", "dummy"s},
@@ -977,7 +982,8 @@
};
}
- SECTION("with lists") {
+ SECTION("with lists")
+ {
rpc = "/example-schema:launch-nukes";
input = {
{"payload/kilotons", uint64_t{6}},
@@ -997,7 +1003,8 @@
};
}
- SECTION("with leafref") {
+ SECTION("with leafref")
+ {
datastore->createItem("/example-schema:person[name='Colton']");
datastore->commitChanges();
@@ -1009,13 +1016,13 @@
proxyDatastore.setLeaf("/example-schema:fire/example-schema:whom", "Colton"s);
}
- catching<OnExec>([&] {REQUIRE(datastore->executeRpc(rpc, input) == output);});
- catching<OnExec>([&] {REQUIRE(proxyDatastore.execute() == output);});
+ catching<OnExec>([&] { REQUIRE(datastore->executeRpc(rpc, input) == output); });
+ catching<OnExec>([&] { REQUIRE(proxyDatastore.execute() == output); });
}
SECTION("non-existing RPC")
{
- catching<OnInvalidRpcPath>([&] {datastore->executeRpc("/example-schema:non-existing", DatastoreAccess::Tree{});});
+ catching<OnInvalidRpcPath>([&] { datastore->executeRpc("/example-schema:non-existing", DatastoreAccess::Tree{}); });
}
}
@@ -1033,11 +1040,12 @@
};
datastore->createItem("/example-schema:ports[name='A']");
datastore->commitChanges();
- SECTION("shutdown") {
+ SECTION("shutdown")
+ {
path = "/example-schema:ports[name='A']/shutdown";
}
- catching<OnExec>([&] {REQUIRE(datastore->executeAction(path, input) == output);});
+ catching<OnExec>([&] { REQUIRE(datastore->executeAction(path, input) == output); });
}
waitForCompletionAndBitMore(seq1);
diff --git a/tests/datastoreaccess_mock.hpp b/tests/datastoreaccess_mock.hpp
index b8ec1b0..751cdad 100644
--- a/tests/datastoreaccess_mock.hpp
+++ b/tests/datastoreaccess_mock.hpp
@@ -5,9 +5,9 @@
*
*/
+#include "trompeloeil_doctest.hpp"
#include <map>
#include "datastore_access.hpp"
-#include "trompeloeil_doctest.hpp"
#include "utils.hpp"
namespace trompeloeil {
@@ -38,5 +38,3 @@
IMPLEMENT_MOCK2(copyConfig);
IMPLEMENT_CONST_MOCK1(dump);
};
-
-
diff --git a/tests/interpreter.cpp b/tests/interpreter.cpp
index 966855d..d57ad64 100644
--- a/tests/interpreter.cpp
+++ b/tests/interpreter.cpp
@@ -6,11 +6,11 @@
*
*/
-#include <experimental/iterator>
#include "trompeloeil_doctest.hpp"
+#include <experimental/iterator>
#include "ast_commands.hpp"
-#include "interpreter.hpp"
#include "datastoreaccess_mock.hpp"
+#include "interpreter.hpp"
#include "parser.hpp"
#include "pretty_printers.hpp"
#include "static_schema.hpp"
@@ -236,7 +236,6 @@
scope = Scope::Relative;
inputPath = dataPath_{scope, {dataNode_{nodeup_{}}, dataNode_{{"mod"}, leaf_{"myLeaf"}}}};
}
-
}
}
diff --git a/tests/keyvalue_completion.cpp b/tests/keyvalue_completion.cpp
index 7b28ea8..0b1aea3 100644
--- a/tests/keyvalue_completion.cpp
+++ b/tests/keyvalue_completion.cpp
@@ -5,9 +5,9 @@
*
*/
+#include "trompeloeil_doctest.hpp"
#include <experimental/iterator>
#include <iostream>
-#include "trompeloeil_doctest.hpp"
#include "ast_commands.hpp"
#include "datastoreaccess_mock.hpp"
#include "parser.hpp"
@@ -74,12 +74,12 @@
SECTION("number")
{
input += "number=";
- expected = { "1", "7", "10", "100" };
+ expected = {"1", "7", "10", "100"};
}
SECTION("name")
{
input += "name=";
- expected = { "'Petr'", "'Honza'"};
+ expected = {"'Petr'", "'Honza'"};
}
queryExpectations.emplace_back(NAMED_REQUIRE_CALL(*mockDatastore, listInstances("/example:twoKeyList")).RETURN(queryReturn));
}
@@ -90,12 +90,12 @@
SECTION("Petr")
{
input += "'Petr'";
- expected = { "1", "7", "10"};
+ expected = {"1", "7", "10"};
}
SECTION("Honza")
{
input += "'Honza'";
- expected = { "10", "100" };
+ expected = {"10", "100"};
}
input += "][number=";
queryExpectations.emplace_back(NAMED_REQUIRE_CALL(*mockDatastore, listInstances("/example:twoKeyList"))
@@ -109,22 +109,22 @@
SECTION("1")
{
input += "1";
- expected = { "'Petr'" };
+ expected = {"'Petr'"};
}
SECTION("7")
{
input += "7";
- expected = { "'Petr'" };
+ expected = {"'Petr'"};
}
SECTION("10")
{
input += "10";
- expected = { "'Honza'", "'Petr'" };
+ expected = {"'Honza'", "'Petr'"};
}
SECTION("100")
{
input += "100";
- expected = { "'Honza'" };
+ expected = {"'Honza'"};
}
input += "][name=";
queryExpectations.emplace_back(NAMED_REQUIRE_CALL(*mockDatastore, listInstances("/example:twoKeyList"))
@@ -152,7 +152,6 @@
queryExpectations.emplace_back(NAMED_ALLOW_CALL(*mockDatastore, listInstances("/example:twoKeyList"))
.RETURN(queryReturn));
}
-
}
REQUIRE(parser.completeCommand(input, errorStream).m_completions == expected);
diff --git a/tests/leaf_editing.cpp b/tests/leaf_editing.cpp
index 7b203f4..c1639b2 100644
--- a/tests/leaf_editing.cpp
+++ b/tests/leaf_editing.cpp
@@ -123,7 +123,7 @@
SECTION("set mod:list[number=1]/leafInList \"another_data\"")
{
input = "set mod:list[number=1]/leafInList \"another_data\"";
- auto keys = ListInstance {
+ auto keys = ListInstance{
{"number", int32_t{1}}};
expected.m_path.m_nodes.emplace_back(module_{"mod"}, listElement_("list", keys));
expected.m_path.m_nodes.emplace_back(leaf_("leafInList"));
@@ -464,22 +464,27 @@
{
input = "set mod:flags ";
decltype(bits_::m_bits) bits;
- SECTION("<nothing>") {
+ SECTION("<nothing>")
+ {
bits = {};
}
- SECTION("carry") {
+ SECTION("carry")
+ {
input += "carry";
bits = {"carry"};
}
- SECTION("sign") {
+ SECTION("sign")
+ {
input += "sign";
bits = {"sign"};
}
- SECTION("carry sign") {
+ SECTION("carry sign")
+ {
input += "carry sign";
bits = {"carry", "sign"};
}
- SECTION("sign carry") {
+ SECTION("sign carry")
+ {
input += "sign carry";
bits = {"sign", "carry"};
}
@@ -585,11 +590,17 @@
SECTION("wrong base64 strings")
{
SECTION("invalid character")
+ {
input = "set mod:leafBinary dbahj-";
+ }
SECTION("equal sign in the middle")
+ {
input = "set mod:leafBinary db=ahj";
+ }
SECTION("enclosing in quotes")
+ {
input = "set mod:leafBinary 'dbahj'";
+ }
}
SECTION("non-existing identity")
diff --git a/tests/list_manipulation.cpp b/tests/list_manipulation.cpp
index e9dd466..5316384 100644
--- a/tests/list_manipulation.cpp
+++ b/tests/list_manipulation.cpp
@@ -37,7 +37,7 @@
SECTION("mod:list[number=3]")
{
input = "mod:list[number=3]";
- auto keys = ListInstance {
+ auto keys = ListInstance{
{"number", int32_t{3}}};
expectedPath.m_nodes.emplace_back(module_{"mod"}, listElement_("list", keys));
}
@@ -45,10 +45,10 @@
SECTION("mod:company[department=other:engineering]/inventory[id=1337]")
{
input = "mod:company[department=other:engineering]/inventory[id=1337]";
- auto keys = ListInstance {
+ auto keys = ListInstance{
{"department", identityRef_{"other", "engineering"}}};
expectedPath.m_nodes.emplace_back(module_{"mod"}, listElement_("company", keys));
- keys = ListInstance {
+ keys = ListInstance{
{"id", int32_t{1337}}};
expectedPath.m_nodes.emplace_back(listElement_("inventory", keys));
}
@@ -128,7 +128,7 @@
{
input = "move mod:addresses['1.2.3.4'] after '0.0.0.0'";
expected.m_source.m_nodes.emplace_back(module_{"mod"}, leafListElement_{"addresses", "1.2.3.4"s});
- expected.m_destination = yang::move::Relative {
+ expected.m_destination = yang::move::Relative{
yang::move::Relative::Position::After,
{{".", "0.0.0.0"s}}
};
@@ -138,7 +138,7 @@
{
input = "move mod:addresses['1.2.3.4'] before '0.0.0.0'";
expected.m_source.m_nodes.emplace_back(module_{"mod"}, leafListElement_{"addresses", "1.2.3.4"s});
- expected.m_destination = yang::move::Relative {
+ expected.m_destination = yang::move::Relative{
yang::move::Relative::Position::Before,
{{".", "0.0.0.0"s}}
};
@@ -150,7 +150,7 @@
auto keys = std::map<std::string, leaf_data_>{
{"number", int32_t{12}}};
expected.m_source.m_nodes.emplace_back(module_{"mod"}, listElement_("list", keys));
- expected.m_destination = yang::move::Relative {
+ expected.m_destination = yang::move::Relative{
yang::move::Relative::Position::Before,
ListInstance{{"number", int32_t{15}}}
};
diff --git a/tests/ls.cpp b/tests/ls.cpp
index 58d4add..e008557 100644
--- a/tests/ls.cpp
+++ b/tests/ls.cpp
@@ -43,7 +43,9 @@
SECTION("no arguments")
{
SECTION("ls")
+ {
input = "ls";
+ }
SECTION("ls --recursive")
{
@@ -62,7 +64,7 @@
SECTION("ls /example:a")
{
- SECTION("cwd: /") {}
+ SECTION("cwd: /") { }
SECTION("cwd: /example:a") { parser.changeNode(dataPath_{Scope::Relative, {dataNode_(module_{"example"}, container_{"a"})}}); }
input = "ls /example:a";
@@ -71,7 +73,7 @@
SECTION("ls /")
{
- SECTION("cwd: /") {}
+ SECTION("cwd: /") { }
SECTION("cwd: /example:a") { parser.changeNode(dataPath_{Scope::Relative, {dataNode_(module_{"example"}, container_{"a"})}}); }
input = "ls /";
expected.m_path = dataPath_{Scope::Absolute, {}};
@@ -105,7 +107,7 @@
SECTION("ls /example:a/a2")
{
- SECTION("cwd: /") {}
+ SECTION("cwd: /") { }
SECTION("cwd: /example:a") { parser.changeNode(dataPath_{Scope::Relative, {dataNode_(module_{"example"}, container_{"a"})}}); }
input = "ls /example:a/a2";
expected.m_path = dataPath_{Scope::Absolute, {dataNode_(module_{"example"}, container_{"a"}),
@@ -128,7 +130,7 @@
SECTION("ls /example:a/example:a2")
{
- SECTION("cwd: /") {}
+ SECTION("cwd: /") { }
SECTION("cwd: /example:a") { parser.changeNode(dataPath_{Scope::Relative, {dataNode_(module_{"example"}, container_{"a"})}}); }
input = "ls /example:a/example:a2";
@@ -138,7 +140,7 @@
SECTION("ls --recursive /example:a")
{
- SECTION("cwd: /") {}
+ SECTION("cwd: /") { }
SECTION("cwd: /example:a") { parser.changeNode(dataPath_{Scope::Relative, {dataNode_(module_{"example"}, container_{"a"})}}); }
input = "ls --recursive /example:a";
@@ -154,7 +156,7 @@
SECTION("ls /example:list")
{
- SECTION("cwd: /") {}
+ SECTION("cwd: /") { }
SECTION("cwd: /example:a") { parser.changeNode(dataPath_{Scope::Relative, {dataNode_(module_{"example"}, container_{"a"})}}); }
input = "ls /example:list";
expected.m_path = dataPath_{Scope::Absolute, {dataNode_(module_{"example"}, list_{"list"})}};
@@ -178,7 +180,7 @@
SECTION("ls example:list[number=342]/contInList")
{
input = "ls example:list[number=342]/contInList";
- auto keys = ListInstance {
+ auto keys = ListInstance{
{"number", int32_t{342}}};
expected.m_path = dataPath_{Scope::Relative, {dataNode_(module_{"example"}, listElement_{"list", keys}),
dataNode_(container_{"contInList"})}};
@@ -201,7 +203,7 @@
SECTION("ls example:list[number=343]/..")
{
input = "ls example:list[number=343]/..";
- auto keys = ListInstance {
+ auto keys = ListInstance{
{"number", int32_t{343}}};
expected.m_path = dataPath_{Scope::Relative, {dataNode_(module_{"example"}, listElement_{"list", keys}), dataNode_{nodeup_{}}}};
}
@@ -229,44 +231,44 @@
SECTION("invalid path")
{
SECTION("ls example:nonexistent")
- input = "ls example:nonexistent";
+ input = "ls example:nonexistent";
SECTION("ls /example:nonexistent")
- input = "ls /example:nonexistent";
+ input = "ls /example:nonexistent";
SECTION("ls /exa")
{
- SECTION("cwd: /") {}
+ SECTION("cwd: /") { }
SECTION("cwd: /example:a") { parser.changeNode(dataPath_{Scope::Relative, {dataNode_(module_{"example"}, container_{"a"})}}); }
input = "ls /exa";
}
SECTION("ls /bad:nonexistent")
- input = "ls /bad:nonexistent";
+ input = "ls /bad:nonexistent";
SECTION("ls example:a/nonexistent")
- input = "ls example:a/nonexistent";
+ input = "ls example:a/nonexistent";
SECTION("ls /example:a/nonexistent")
- input = "ls /example:a/nonexistent";
+ input = "ls /example:a/nonexistent";
}
SECTION("whitespace before path")
{
SECTION("ls --recursive/")
- input = "ls --recursive/";
+ input = "ls --recursive/";
SECTION("ls/")
- input = "ls/";
+ input = "ls/";
SECTION("ls --recursive/example:a")
- input = "ls --recursive/example:a";
+ input = "ls --recursive/example:a";
SECTION("ls/example:a")
- input = "ls/example:a";
+ input = "ls/example:a";
SECTION("lssecond:a")
- input = "lssecond:a";
+ input = "lssecond:a";
}
REQUIRE_THROWS_AS(parser.parseCommand(input, errorStream), InvalidCommandException);
diff --git a/tests/mock/sysrepo_subscription.cpp b/tests/mock/sysrepo_subscription.cpp
index 03be075..5c5fd27 100644
--- a/tests/mock/sysrepo_subscription.cpp
+++ b/tests/mock/sysrepo_subscription.cpp
@@ -22,11 +22,11 @@
}
int operator()(
- sysrepo::S_Session sess,
- [[maybe_unused]] const char *module_name,
- [[maybe_unused]] const char *xpath,
- [[maybe_unused]] sr_event_t event,
- [[maybe_unused]] uint32_t request_id)
+ sysrepo::S_Session sess,
+ [[maybe_unused]] const char* module_name,
+ [[maybe_unused]] const char* xpath,
+ [[maybe_unused]] sr_event_t event,
+ [[maybe_unused]] uint32_t request_id)
{
using namespace std::string_literals;
if (event == SR_EV_CHANGE) {
@@ -64,7 +64,7 @@
if (rec) {
cb = MyCallback{moduleName, rec};
} else {
- cb = [] (auto, auto, auto, auto, auto) { return SR_ERR_OK; };
+ cb = [](auto, auto, auto, auto, auto) { return SR_ERR_OK; };
}
m_subscription->module_change_subscribe(moduleName.c_str(), cb);
@@ -72,7 +72,7 @@
struct leafDataToSysrepoVal {
- leafDataToSysrepoVal (sysrepo::S_Val v, const std::string& xpath)
+ leafDataToSysrepoVal(sysrepo::S_Val v, const std::string& xpath)
: v(v)
, xpath(xpath)
{
@@ -108,7 +108,6 @@
std::stringstream ss;
std::copy(what.m_bits.begin(), what.m_bits.end(), std::experimental::make_ostream_joiner(ss, " "));
v->set(xpath.c_str(), ss.str().c_str());
-
}
template <typename Type>
@@ -133,35 +132,36 @@
{
}
int operator()(
- [[maybe_unused]] sysrepo::S_Session sess,
- [[maybe_unused]] const char *module_name,
- const char* path,
- [[maybe_unused]] const char* request_xpath,
- [[maybe_unused]] uint32_t request_id,
- libyang::S_Data_Node& parent)
+ [[maybe_unused]] sysrepo::S_Session sess,
+ [[maybe_unused]] const char* module_name,
+ const char* path,
+ [[maybe_unused]] const char* request_xpath,
+ [[maybe_unused]] uint32_t request_id,
+ libyang::S_Data_Node& parent)
{
auto data = m_dataSupplier.get_data(path);
libyang::S_Data_Node res;
for (const auto& [p, v] : data) {
if (!res) {
res = std::make_shared<libyang::Data_Node>(
- sess->get_context(),
- p.c_str(),
- v.type() == typeid(empty_) ? nullptr : leafDataToString(v).c_str(),
- LYD_ANYDATA_CONSTSTRING,
- 0);
+ sess->get_context(),
+ p.c_str(),
+ v.type() == typeid(empty_) ? nullptr : leafDataToString(v).c_str(),
+ LYD_ANYDATA_CONSTSTRING,
+ 0);
} else {
res->new_path(
- sess->get_context(),
- p.c_str(),
- v.type() == typeid(empty_) ? nullptr : leafDataToString(v).c_str(),
- LYD_ANYDATA_CONSTSTRING,
- 0);
+ sess->get_context(),
+ p.c_str(),
+ v.type() == typeid(empty_) ? nullptr : leafDataToString(v).c_str(),
+ LYD_ANYDATA_CONSTSTRING,
+ 0);
}
}
parent = res;
return SR_ERR_OK;
}
+
private:
const DataSupplier& m_dataSupplier;
};
diff --git a/tests/mock/sysrepo_subscription.hpp b/tests/mock/sysrepo_subscription.hpp
index 06ac405..c3f1f69 100644
--- a/tests/mock/sysrepo_subscription.hpp
+++ b/tests/mock/sysrepo_subscription.hpp
@@ -8,8 +8,8 @@
#pragma once
-#include <optional>
#include <memory>
+#include <optional>
#include "datastore_access.hpp"
namespace sysrepo {
@@ -47,6 +47,7 @@
class OperationalDataSubscription {
public:
OperationalDataSubscription(const std::string& moduleName, const std::string& path, const DataSupplier& dataSupplier);
+
private:
std::shared_ptr<sysrepo::Connection> m_connection;
std::shared_ptr<sysrepo::Session> m_session;
diff --git a/tests/mock/sysrepo_subscription_python.cpp b/tests/mock/sysrepo_subscription_python.cpp
index 55c6289..cde24d1 100644
--- a/tests/mock/sysrepo_subscription_python.cpp
+++ b/tests/mock/sysrepo_subscription_python.cpp
@@ -10,9 +10,10 @@
using namespace pybind11::literals;
-PYBIND11_MODULE(sysrepo_subscription_py, m) {
+PYBIND11_MODULE(sysrepo_subscription_py, m)
+{
m.doc() = "SysrepoSubscription Python interface";
pybind11::class_<SysrepoSubscription>(m, "SysrepoSubscription")
- .def(pybind11::init<const std::string&>(), "moduleName"_a);
+ .def(pybind11::init<const std::string&>(), "moduleName"_a);
}
diff --git a/tests/presence_containers.cpp b/tests/presence_containers.cpp
index e009c41..337ad48 100644
--- a/tests/presence_containers.cpp
+++ b/tests/presence_containers.cpp
@@ -53,7 +53,7 @@
SECTION("mod:list[quote='lol']/contInList")
{
input = "mod:list[quote='lol']/contInList";
- auto keys = ListInstance {
+ auto keys = ListInstance{
{"quote", std::string{"lol"}}};
expectedPath.m_nodes = {{{module_{"mod"}}, listElement_("list", keys)}, {container_("contInList")}};
}
@@ -61,7 +61,7 @@
SECTION("mod:list[quote='double\"quote']/contInList")
{
input = "mod:list[quote='double\"quote']/contInList";
- auto keys = ListInstance {
+ auto keys = ListInstance{
{"quote", std::string{"double\"quote"}}};
expectedPath.m_nodes = {{{module_{"mod"}}, listElement_("list", keys)}, {container_("contInList")}};
}
@@ -69,7 +69,7 @@
SECTION("mod:list[quote=\"single'quote\"]/contInList")
{
input = "mod:list[quote=\"single'quote\"]/contInList";
- auto keys = ListInstance {
+ auto keys = ListInstance{
{"quote", std::string{"single'quote"}}};
expectedPath.m_nodes = {{{module_{"mod"}}, listElement_("list", keys)}, {container_("contInList")}};
}
diff --git a/tests/pretty_printers.hpp b/tests/pretty_printers.hpp
index d3d67d3..1c7154b 100644
--- a/tests/pretty_printers.hpp
+++ b/tests/pretty_printers.hpp
@@ -12,16 +12,17 @@
namespace std {
std::ostream& operator<<(std::ostream& s, const leaf_data_& value)
{
- s << "leaf_data_<"<< boost::core::demangle(value.type().name()) << ">{" << leafDataToString(value) << "}" << std::endl;
+ s << "leaf_data_<" << boost::core::demangle(value.type().name()) << ">{" << leafDataToString(value) << "}" << std::endl;
return s;
}
std::ostream& operator<<(std::ostream& s, const Completions& completion)
{
- s << std::endl << "Completions {" << std::endl << " m_completions: ";
- std::transform(completion.m_completions.begin(), completion.m_completions.end(),
- std::experimental::make_ostream_joiner(s, ", "),
- [] (auto it) { return '"' + it + '"'; });
- s << std::endl << " m_contextLength: " << completion.m_contextLength << std::endl;
+ s << std::endl
+ << "Completions {" << std::endl
+ << " m_completions: ";
+ std::transform(completion.m_completions.begin(), completion.m_completions.end(), std::experimental::make_ostream_joiner(s, ", "), [](auto it) { return '"' + it + '"'; });
+ s << std::endl
+ << " m_contextLength: " << completion.m_contextLength << std::endl;
s << "}" << std::endl;
return s;
}
@@ -80,12 +81,12 @@
s << "}";
}
if (std::holds_alternative<yang::LeafRef>(type)) {
- s << "{" << std::get<yang::LeafRef>(type).m_targetXPath << "," << std::get<yang::LeafRef>(type).m_targetType->m_type << "}";
+ s << "{" << std::get<yang::LeafRef>(type).m_targetXPath << "," << std::get<yang::LeafRef>(type).m_targetType->m_type << "}";
}
if (std::holds_alternative<yang::Union>(type)) {
s << "{" << std::endl;
auto types = std::get<yang::Union>(type).m_unionTypes;
- std::transform(types.begin(), types.end(), std::experimental::make_ostream_joiner(s, ",\n"), [] (const auto& type) {
+ std::transform(types.begin(), types.end(), std::experimental::make_ostream_joiner(s, ",\n"), [](const auto& type) {
return type.m_type;
});
}
@@ -115,7 +116,8 @@
std::ostream& operator<<(std::ostream& s, const std::set<std::string> set)
{
- s << std::endl << "{";
+ s << std::endl
+ << "{";
std::copy(set.begin(), set.end(), std::experimental::make_ostream_joiner(s, ", "));
s << "}" << std::endl;
return s;
@@ -123,17 +125,21 @@
std::ostream& operator<<(std::ostream& s, const std::vector<ListInstance> set)
{
- s << std::endl << "{" << std::endl;
+ s << std::endl
+ << "{" << std::endl;
std::transform(set.begin(), set.end(), std::experimental::make_ostream_joiner(s, ", \n"), [](const auto& map) {
std::ostringstream ss;
- ss << " {" << std::endl << " ";
- std::transform(map.begin(), map.end(), std::experimental::make_ostream_joiner(ss, ", \n "), [](const auto& keyValue){
+ ss << " {" << std::endl
+ << " ";
+ std::transform(map.begin(), map.end(), std::experimental::make_ostream_joiner(ss, ", \n "), [](const auto& keyValue) {
return "{" + keyValue.first + "{" + boost::core::demangle(keyValue.second.type().name()) + "}" + ", " + leafDataToString(keyValue.second) + "}";
});
- ss << std::endl << " }";
+ ss << std::endl
+ << " }";
return ss.str();
});
- s << std::endl << "}" << std::endl;
+ s << std::endl
+ << "}" << std::endl;
return s;
}
}
diff --git a/tests/utils.cpp b/tests/utils.cpp
index fb85210..4b336b7 100644
--- a/tests/utils.cpp
+++ b/tests/utils.cpp
@@ -27,55 +27,65 @@
REQUIRE((filterByPrefix(set, "co") == std::set<Completion>{{"copak"}, {"coze"}}));
}
- SECTION("joinPaths") {
+ SECTION("joinPaths")
+ {
std::string prefix, suffix, result;
- SECTION("regular") {
+ SECTION("regular")
+ {
prefix = "/example:a";
suffix = "leaf";
result = "/example:a/leaf";
}
- SECTION("no prefix - absolute path") {
+ SECTION("no prefix - absolute path")
+ {
suffix = "/example:a/leaf";
result = "/example:a/leaf";
}
- SECTION("no prefix - relative path") {
+ SECTION("no prefix - relative path")
+ {
suffix = "example:a/leaf";
result = "example:a/leaf";
}
- SECTION("no suffix") {
+ SECTION("no suffix")
+ {
prefix = "/example:a/leaf";
result = "/example:a/leaf";
}
- SECTION("at root") {
+ SECTION("at root")
+ {
prefix = "/";
suffix = "example:a";
result = "/example:a";
}
- SECTION("trailing slash") {
+ SECTION("trailing slash")
+ {
prefix = "/example:a";
suffix = "/";
result = "/example:a/";
}
- SECTION("prefix ends with slash") {
+ SECTION("prefix ends with slash")
+ {
prefix = "/example:a/";
suffix = "leaf";
result = "/example:a/leaf";
}
- SECTION("suffix starts with slash") {
+ SECTION("suffix starts with slash")
+ {
prefix = "/example:a";
suffix = "/leaf";
result = "/example:a/leaf";
}
- SECTION("slashes all the way to eleven") {
+ SECTION("slashes all the way to eleven")
+ {
prefix = "/example:a/";
suffix = "/leaf";
result = "/example:a/leaf";
@@ -100,9 +110,7 @@
}
REQUIRE(leafDataTypeToString(type) == expected);
-
}
-
}
const auto schema = R"(
@@ -264,79 +272,98 @@
ctx->parse_module_mem(schema, LYS_IN_YANG);
auto dataNode = ctx->parse_data_mem(data, LYD_JSON, LYD_OPT_DATA_NO_YANGLIB | LYD_OPT_NOEXTDEPS | LYD_OPT_STRICT);
- SECTION("leafValueFromNode") {
+ SECTION("leafValueFromNode")
+ {
std::string path;
leaf_data_ expectedLeafData;
- SECTION("test-schema:int8") {
+ SECTION("test-schema:int8")
+ {
path = "test-schema:int8";
expectedLeafData = int8_t{8};
}
- SECTION("test-schema:int16") {
+ SECTION("test-schema:int16")
+ {
path = "test-schema:int16";
expectedLeafData = int16_t{300};
}
- SECTION("test-schema:int32") {
+ SECTION("test-schema:int32")
+ {
path = "test-schema:int32";
expectedLeafData = int32_t{-300};
}
- SECTION("test-schema:int64") {
+ SECTION("test-schema:int64")
+ {
path = "test-schema:int64";
expectedLeafData = int64_t{-999999999999999};
}
- SECTION("test-schema:uint8") {
+ SECTION("test-schema:uint8")
+ {
path = "test-schema:uint8";
expectedLeafData = uint8_t{8};
}
- SECTION("test-schema:uint16") {
+ SECTION("test-schema:uint16")
+ {
path = "test-schema:uint16";
expectedLeafData = uint16_t{300};
}
- SECTION("test-schema:uint32") {
+ SECTION("test-schema:uint32")
+ {
path = "test-schema:uint32";
expectedLeafData = uint32_t{300};
}
- SECTION("test-schema:uint64") {
+ SECTION("test-schema:uint64")
+ {
path = "test-schema:uint64";
expectedLeafData = uint64_t{999999999999999};
}
- SECTION("test-schema:boolean") {
+ SECTION("test-schema:boolean")
+ {
path = "test-schema:boolean";
expectedLeafData = true;
}
- SECTION("test-schema:string") {
+ SECTION("test-schema:string")
+ {
path = "test-schema:string";
expectedLeafData = std::string{"AHOJ"};
}
- SECTION("test-schema:enum") {
+ SECTION("test-schema:enum")
+ {
path = "test-schema:enum";
expectedLeafData = enum_{"A"};
}
- SECTION("test-schema:identityRef") {
+ SECTION("test-schema:identityRef")
+ {
path = "test-schema:identityRef";
expectedLeafData = identityRef_{"test-schema", "apple"};
}
- SECTION("test-schema:binary") {
+ SECTION("test-schema:binary")
+ {
path = "test-schema:binary";
expectedLeafData = binary_{"QUhPSgo="};
}
- SECTION("test-schema:empty") {
+ SECTION("test-schema:empty")
+ {
path = "test-schema:empty";
expectedLeafData = empty_{};
}
- SECTION("test-schema:bits") {
+ SECTION("test-schema:bits")
+ {
path = "test-schema:bits";
expectedLeafData = bits_{{"a", "AHOJ"}};
}
- SECTION("test-schema:dec64") {
+ SECTION("test-schema:dec64")
+ {
path = "test-schema:dec64";
expectedLeafData = 43242.43260;
}
- SECTION("test-schema:leafRefPresent") {
+ SECTION("test-schema:leafRefPresent")
+ {
path = "test-schema:leafRefPresent";
expectedLeafData = std::string{"Xaver"};
}
- SECTION("test-schema:leafRefNonPresent") {
+ SECTION("test-schema:leafRefNonPresent")
+ {
path = "test-schema:leafRefNonPresent";
expectedLeafData = std::string{"Lucas"};
}
@@ -345,11 +372,11 @@
REQUIRE(leaf->number() == 1);
auto firstLeaf = std::make_shared<libyang::Data_Node_Leaf_List>(leaf->data().front());
REQUIRE(leafValueFromNode(firstLeaf) == expectedLeafData);
-
}
- SECTION("lyNodesToTree") {
- DatastoreAccess::Tree expected {
+ SECTION("lyNodesToTree")
+ {
+ DatastoreAccess::Tree expected{
{"/test-schema:int8", int8_t{8}},
{"/test-schema:int16", int16_t{300}},
{"/test-schema:int32", int32_t{-300}},
diff --git a/tests/yang.cpp b/tests/yang.cpp
index 93e5925..1ec6507 100644
--- a/tests/yang.cpp
+++ b/tests/yang.cpp
@@ -6,10 +6,10 @@
*
*/
+#include "trompeloeil_doctest.hpp"
#include <experimental/iterator>
#include "leaf_data_helpers.hpp"
#include "pretty_printers.hpp"
-#include "trompeloeil_doctest.hpp"
#include "yang_schema.hpp"
const char* second_schema = R"(