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/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"(