mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
Merge branch 'developer' into mysocket
This commit is contained in:
@ -6,18 +6,17 @@
|
||||
|
||||
class CmdLineParser {
|
||||
public:
|
||||
void Parse(int argc, char *argv[]);
|
||||
void Parse(int argc, const char * const argv[]);
|
||||
void Parse(const std::string &s);
|
||||
void Print();
|
||||
|
||||
//getters
|
||||
int multi_id() const { return multi_id_; };
|
||||
int detector_id() const { return detector_id_; };
|
||||
int n_arguments() const { return arguments_.size(); }
|
||||
const std::string &command() const { return command_; }
|
||||
const std::string &executable() const { return executable_; }
|
||||
const std::vector<std::string> &arguments() const { return arguments_; };
|
||||
std::vector<char *> argv();
|
||||
std::vector<const char *> argv() const;
|
||||
|
||||
private:
|
||||
void DecodeIdAndPosition(const char *c);
|
||||
|
@ -2,9 +2,10 @@
|
||||
#define GITBRANCH "refgui"
|
||||
#define APIGOTTHARD 0x190108
|
||||
#define APIMOENCH 0x181108
|
||||
#define APIJUNGFRAU 0x190405
|
||||
#define APILIB 0x190405
|
||||
#define APIRECEIVER 0x190405
|
||||
#define APIGUI 0x190405
|
||||
#define APICTB 0x190514
|
||||
#define APIEIGER 0x190516
|
||||
#define APICTB 0x190516
|
||||
|
||||
#define APIJUNGFRAU 0x190517
|
||||
|
@ -5,10 +5,11 @@
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
//printing function for debugging
|
||||
|
||||
void CmdLineParser::Print() {
|
||||
std::cout << "\nCmdLineParser::Print()\n";
|
||||
std::cout << "\tmulti_id: " << multi_id_ << ", detector_id: " << detector_id_ << std::endl;
|
||||
std::cout << "\tmulti_id: " << multi_id_
|
||||
<< ", detector_id: " << detector_id_ << std::endl;
|
||||
std::cout << "\texecutable: " << executable_ << '\n';
|
||||
std::cout << "\tcommand: " << command_ << '\n';
|
||||
std::cout << "\tn_arguments: " << n_arguments() << '\n';
|
||||
@ -19,27 +20,22 @@ void CmdLineParser::Print() {
|
||||
std::cout << "\n\n";
|
||||
};
|
||||
|
||||
void CmdLineParser::Parse(int argc, char *argv[]) {
|
||||
//first element of argv is the command used to call the executable ->skipping
|
||||
//and if this is the only command skip all
|
||||
executable_ = argv[0];
|
||||
void CmdLineParser::Parse(int argc, const char * const argv[]) {
|
||||
executable_ = argv[0]; //first arg is calling binary
|
||||
if (argc > 1) {
|
||||
//second element is cmd string that needs to be decoded
|
||||
DecodeIdAndPosition(argv[1]);
|
||||
//The rest of the arguments goes into a vector for later processing
|
||||
for (int i = 2; i < argc; ++i) {
|
||||
arguments_.emplace_back(std::string(argv[i]));
|
||||
arguments_.emplace_back(argv[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void CmdLineParser::Parse(const std::string &s) {
|
||||
std::istringstream iss(s);
|
||||
auto it = std::istream_iterator<std::string>(iss);
|
||||
//read the first element and increment
|
||||
command_ = *it++;
|
||||
arguments_ = std::vector<std::string>(it, std::istream_iterator<std::string>());
|
||||
;
|
||||
arguments_ =
|
||||
std::vector<std::string>(it, std::istream_iterator<std::string>());
|
||||
DecodeIdAndPosition(command_.c_str());
|
||||
}
|
||||
|
||||
@ -51,19 +47,23 @@ void CmdLineParser::DecodeIdAndPosition(const char *c) {
|
||||
if (contains_id && contains_pos) {
|
||||
int r = sscanf(c, "%d-%d:%s", &multi_id_, &detector_id_, tmp);
|
||||
if (r != 3) {
|
||||
throw(std::invalid_argument("Cannot decode client or detector id from: \"" + std::string(c) + "\"\n"));
|
||||
throw(std::invalid_argument(
|
||||
"Cannot decode client or detector id from: \"" +
|
||||
std::string(c) + "\"\n"));
|
||||
}
|
||||
command_ = tmp;
|
||||
} else if (contains_id && !contains_pos) {
|
||||
int r = sscanf(c, "%d-%s", &multi_id_, tmp);
|
||||
if (r != 2) {
|
||||
throw(std::invalid_argument("Cannot decode client id from: \"" + std::string(c) + "\"\n"));
|
||||
throw(std::invalid_argument("Cannot decode client id from: \"" +
|
||||
std::string(c) + "\"\n"));
|
||||
}
|
||||
command_ = tmp;
|
||||
} else if (!contains_id && contains_pos) {
|
||||
int r = sscanf(c, "%d:%s", &detector_id_, tmp);
|
||||
if (r != 2) {
|
||||
throw(std::invalid_argument("Cannot decode detector id from: \"" + std::string(c) + "\"\n"));
|
||||
throw(std::invalid_argument("Cannot decode detector id from: \"" +
|
||||
std::string(c) + "\"\n"));
|
||||
}
|
||||
command_ = tmp;
|
||||
} else {
|
||||
@ -71,12 +71,11 @@ void CmdLineParser::DecodeIdAndPosition(const char *c) {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<char *> CmdLineParser::argv() {
|
||||
std::vector<char *> vec;
|
||||
if (command_.empty()!=true){
|
||||
std::vector<const char *> CmdLineParser::argv() const {
|
||||
std::vector<const char *> vec;
|
||||
if (command_.empty() != true) {
|
||||
vec.push_back(&command_.front());
|
||||
}
|
||||
|
||||
for (auto &arg : arguments_) {
|
||||
vec.push_back(&arg.front());
|
||||
}
|
||||
|
@ -24,9 +24,7 @@ IpAddr::IpAddr(const std::string &address) {
|
||||
inet_pton(AF_INET, address.c_str(), &addr_);
|
||||
}
|
||||
|
||||
IpAddr::IpAddr(const char *address) {
|
||||
inet_pton(AF_INET, address, &addr_);
|
||||
}
|
||||
IpAddr::IpAddr(const char *address) { inet_pton(AF_INET, address, &addr_); }
|
||||
|
||||
std::string IpAddr::str() const {
|
||||
char ipstring[INET_ADDRSTRLEN]{};
|
||||
@ -35,9 +33,9 @@ std::string IpAddr::str() const {
|
||||
}
|
||||
std::string IpAddr::hex() const {
|
||||
std::ostringstream ss;
|
||||
ss << std::hex << std::setfill('0');
|
||||
for (int i = 0; i != 4; ++i) {
|
||||
ss << std::hex << std::setfill('0') << std::setw(2)
|
||||
<< ((addr_ >> i * 8) & 0xFF);
|
||||
ss << std::setw(2) << ((addr_ >> i * 8) & 0xFF);
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
@ -60,18 +58,14 @@ std::string MacAddr::to_hex(const char delimiter) const {
|
||||
for (int i = 32; i >= 0; i -= 8) {
|
||||
if (delimiter)
|
||||
ss << delimiter;
|
||||
ss << ((addr_ >> i) & 0xFF);
|
||||
ss << std::setw(2) << ((addr_ >> i) & 0xFF);
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string MacAddr::str() const {
|
||||
return to_hex(':');
|
||||
}
|
||||
std::string MacAddr::str() const { return to_hex(':'); }
|
||||
|
||||
std::string MacAddr::hex() const {
|
||||
return to_hex();
|
||||
}
|
||||
std::string MacAddr::hex() const { return to_hex(); }
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const IpAddr &addr) {
|
||||
return out << addr.str();
|
||||
|
@ -2,18 +2,126 @@
|
||||
#include "catch.hpp"
|
||||
#include <exception>
|
||||
#include <string>
|
||||
//tests to add
|
||||
//help for all docs
|
||||
//command for all depreciated commands
|
||||
// tests to add
|
||||
// help for all docs
|
||||
// command for all depreciated commands
|
||||
|
||||
TEST_CASE("Parse with no arguments results in no command and default id") {
|
||||
//build up argc and argv
|
||||
//first argument is the command used to call the binary
|
||||
using vs = std::vector<std::string>;
|
||||
|
||||
SCENARIO("Construction", "[support]") {
|
||||
GIVEN("A default constructed CmdLineParser") {
|
||||
CmdLineParser p;
|
||||
THEN("The state of the object is valid") {
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.command().empty());
|
||||
REQUIRE(p.arguments().empty());
|
||||
REQUIRE(p.argv().empty());
|
||||
REQUIRE(p.argv().data() == nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SCENARIO("Parsing a string with the command line parser", "[support]") {
|
||||
GIVEN("A CmdLineParser") {
|
||||
CmdLineParser p;
|
||||
WHEN("Parsing an empty string") {
|
||||
std::string s;
|
||||
p.Parse(s);
|
||||
THEN("command and arguments are empty") {
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.command().empty());
|
||||
REQUIRE(p.arguments().empty());
|
||||
REQUIRE(p.argv().empty());
|
||||
}
|
||||
}
|
||||
WHEN("Parsing a string with a single command") {
|
||||
std::string s = "vrf";
|
||||
p.Parse(s);
|
||||
THEN("command is assigned and id's remain default") {
|
||||
REQUIRE(p.command() == "vrf");
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.arguments().empty());
|
||||
REQUIRE(p.argv().size() == 1);
|
||||
}
|
||||
}
|
||||
WHEN("Parsing a string with command and value") {
|
||||
std::string s = "vthreshold 1500";
|
||||
p.Parse(s);
|
||||
THEN("cmd and value are assigned and id's remain default") {
|
||||
REQUIRE(p.command() == "vthreshold");
|
||||
REQUIRE(p.arguments()[0] == "1500");
|
||||
REQUIRE(p.arguments().size() == 1);
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
}
|
||||
}
|
||||
WHEN("Parsing a string with detector id and command") {
|
||||
vs arg{"9:vcp", "53:vthreshold", "128:vtrim", "5:threshold"};
|
||||
std::vector<int> det_id{9, 53, 128, 5};
|
||||
vs res{"vcp", "vthreshold", "vtrim", "threshold"};
|
||||
|
||||
THEN("Values are correctly decoded") {
|
||||
for (size_t i = 0; i != arg.size(); ++i) {
|
||||
p.Parse(arg[i]);
|
||||
REQUIRE(p.detector_id() == det_id[i]);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.command() == res[i]);
|
||||
REQUIRE(p.arguments().empty());
|
||||
REQUIRE(p.argv().size() == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
WHEN("Parsing a string with multi_id detector id and command") {
|
||||
vs arg{"8-12:vrf", "0-52:vcmp", "19-10:vtrim", "31-127:threshold"};
|
||||
std::vector<int> det_id{12, 52, 10, 127};
|
||||
std::vector<int> multi_id{8, 0, 19, 31};
|
||||
vs res{"vrf", "vcmp", "vtrim", "threshold"};
|
||||
|
||||
THEN("Values are correctly decoded") {
|
||||
for (size_t i = 0; i != arg.size(); ++i) {
|
||||
p.Parse(arg[i]);
|
||||
REQUIRE(p.detector_id() == det_id[i]);
|
||||
REQUIRE(p.multi_id() == multi_id[i]);
|
||||
REQUIRE(p.command() == res[i]);
|
||||
REQUIRE(p.arguments().empty());
|
||||
REQUIRE(p.argv().size() == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("Parsing string with cmd and multiple arguments") {
|
||||
std::string s = "trimen 5000 6000 7000";
|
||||
p.Parse(s);
|
||||
THEN("cmd and args are correct") {
|
||||
REQUIRE(p.command() == "trimen");
|
||||
REQUIRE(p.arguments().size() == 3);
|
||||
REQUIRE(p.arguments()[0] == "5000");
|
||||
REQUIRE(p.arguments()[1] == "6000");
|
||||
REQUIRE(p.arguments()[2] == "7000");
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("Cliend id and or detector id cannot be decoded") {
|
||||
vs arg{"o:cmd", "-5:cmd", "aedpva:cmd",
|
||||
"5-svc:vrf", "asv-5:cmd", "savc-asa:cmd"};
|
||||
THEN("Parsing Throws") {
|
||||
for (size_t i = 0; i != arg.size(); ++i) {
|
||||
REQUIRE_THROWS(p.Parse(arg[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Parse with no arguments results in no command and default id",
|
||||
"[support]") {
|
||||
// build up argc and argv
|
||||
// first argument is the command used to call the binary
|
||||
int argc = 1;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
|
||||
const char* const argv[]{"call"};
|
||||
CmdLineParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
@ -23,25 +131,11 @@ TEST_CASE("Parse with no arguments results in no command and default id") {
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Parse empty string") {
|
||||
std::string s;
|
||||
CmdLineParser p;
|
||||
p.Parse(s);
|
||||
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.command().empty());
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Parse a command without client id and detector id results in default") {
|
||||
TEST_CASE(
|
||||
"Parse a command without client id and detector id results in default",
|
||||
"[support]") {
|
||||
int argc = 2;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
char a1[] = "vrf";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
argv[1] = static_cast<char *>(a1);
|
||||
|
||||
const char*const argv[]{"caller", "vrf"};
|
||||
CmdLineParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
@ -51,27 +145,10 @@ TEST_CASE("Parse a command without client id and detector id results in default"
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Parse a string without client id and detector id results in default") {
|
||||
std::string s = "vrf";
|
||||
CmdLineParser p;
|
||||
p.Parse(s);
|
||||
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.command() == "vrf");
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Parse a command with value but without client or detector id") {
|
||||
TEST_CASE("Parse a command with value but without client or detector id",
|
||||
"[support]") {
|
||||
int argc = 3;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
char a1[] = "vrf";
|
||||
char a2[] = "3000";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
argv[1] = static_cast<char *>(a1);
|
||||
argv[2] = static_cast<char *>(a2);
|
||||
|
||||
const char* const argv[]{"caller", "vrf", "3000"};
|
||||
CmdLineParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
@ -81,26 +158,10 @@ TEST_CASE("Parse a command with value but without client or detector id") {
|
||||
REQUIRE(p.arguments().size() == 1);
|
||||
REQUIRE(p.arguments()[0] == "3000");
|
||||
}
|
||||
TEST_CASE("Parse a string with value but without client or detector id") {
|
||||
std::string s = "vrf 3000\n";
|
||||
|
||||
CmdLineParser p;
|
||||
p.Parse(s);
|
||||
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.command() == "vrf");
|
||||
REQUIRE(p.arguments().size() == 1);
|
||||
REQUIRE(p.arguments()[0] == "3000");
|
||||
}
|
||||
|
||||
TEST_CASE("Decodes position") {
|
||||
int argc = 2;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
char a1[] = "7:vrf";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
argv[1] = static_cast<char *>(a1);
|
||||
const char*const argv[]{"caller", "7:vrf"};
|
||||
|
||||
CmdLineParser p;
|
||||
p.Parse(argc, argv);
|
||||
@ -110,26 +171,10 @@ TEST_CASE("Decodes position") {
|
||||
REQUIRE(p.command() == "vrf");
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
TEST_CASE("Decodes position from string") {
|
||||
std::string s = "7:vrf\n";
|
||||
|
||||
CmdLineParser p;
|
||||
p.Parse(s);
|
||||
|
||||
REQUIRE(p.detector_id() == 7);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.command() == "vrf");
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Decodes double digit position") {
|
||||
TEST_CASE("Decodes double digit position", "[support]") {
|
||||
int argc = 2;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
char a1[] = "73:vcmp";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
argv[1] = static_cast<char *>(a1);
|
||||
|
||||
const char* const argv[]{"caller", "73:vcmp"};
|
||||
CmdLineParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
@ -139,26 +184,9 @@ TEST_CASE("Decodes double digit position") {
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Decodes double digit position from string") {
|
||||
|
||||
std::string s = "73:vcmp";
|
||||
CmdLineParser p;
|
||||
p.Parse(s);
|
||||
|
||||
REQUIRE(p.detector_id() == 73);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.command() == "vcmp");
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Decodes position and id") {
|
||||
TEST_CASE("Decodes position and id", "[support]") {
|
||||
int argc = 2;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
char a1[] = "5-8:vrf";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
argv[1] = static_cast<char *>(a1);
|
||||
|
||||
const char* const argv[]{"caller", "5-8:vrf"};
|
||||
CmdLineParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
@ -167,94 +195,34 @@ TEST_CASE("Decodes position and id") {
|
||||
REQUIRE(p.command() == "vrf");
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
TEST_CASE("Decodes position and id from string") {
|
||||
std::string s = "5-8:vrf";
|
||||
CmdLineParser p;
|
||||
p.Parse(s);
|
||||
|
||||
REQUIRE(p.detector_id() == 8);
|
||||
REQUIRE(p.multi_id() == 5);
|
||||
REQUIRE(p.command() == "vrf");
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Double digit id") {
|
||||
TEST_CASE("Double digit id", "[support]") {
|
||||
int argc = 2;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
char a1[] = "56-8:vrf";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
argv[1] = static_cast<char *>(a1);
|
||||
|
||||
const char *const argv[]{"caller", "56-8:vrf"};
|
||||
CmdLineParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
REQUIRE(p.detector_id() == 8);
|
||||
REQUIRE(p.multi_id() == 56);
|
||||
REQUIRE(p.command() == "vrf");
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Double digit id from string") {
|
||||
std::string s = "56-8:vrf";
|
||||
CmdLineParser p;
|
||||
p.Parse(s);
|
||||
|
||||
REQUIRE(p.detector_id() == 8);
|
||||
REQUIRE(p.multi_id() == 56);
|
||||
REQUIRE(p.command() == std::string("vrf"));
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Calling with wrong id throws invalid_argument") {
|
||||
|
||||
TEST_CASE("Calling with wrong id throws invalid_argument", "[support]") {
|
||||
int argc = 2;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
char a1[] = "asvldkn:vrf";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
argv[1] = static_cast<char *>(a1);
|
||||
|
||||
const char *const argv[]{"caller", "asvldkn:vrf"};
|
||||
CmdLineParser p;
|
||||
CHECK_THROWS(p.Parse(argc, argv));
|
||||
}
|
||||
TEST_CASE("Calling with string with wrong id throws invalid_argument") {
|
||||
std::string s = "asvldkn:vrf";
|
||||
CmdLineParser p;
|
||||
CHECK_THROWS(p.Parse(s));
|
||||
}
|
||||
|
||||
TEST_CASE("Calling with wrong client throws invalid_argument") {
|
||||
TEST_CASE("Calling with wrong client throws invalid_argument", "[support]") {
|
||||
int argc = 2;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
char a1[] = "lki-3:vrf";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
argv[1] = static_cast<char *>(a1);
|
||||
|
||||
const char *const argv[]{"caller", "lki-3:vrf"};
|
||||
CmdLineParser p;
|
||||
CHECK_THROWS(p.Parse(argc, argv));
|
||||
}
|
||||
TEST_CASE("Calling with string with wrong client throws invalid_argument") {
|
||||
std::string s = "lki-3:vrf";
|
||||
CmdLineParser p;
|
||||
CHECK_THROWS(p.Parse(s));
|
||||
}
|
||||
|
||||
TEST_CASE("Parses string with two arguments") {
|
||||
std::string s = "trimen 3000 4000\n";
|
||||
TEST_CASE("Build up argv", "[support]") {
|
||||
CmdLineParser p;
|
||||
p.Parse(s);
|
||||
|
||||
REQUIRE("trimen" == p.command());
|
||||
REQUIRE("3000" == p.arguments()[0]);
|
||||
REQUIRE("4000" == p.arguments()[1]);
|
||||
REQUIRE(p.arguments().size() == 2);
|
||||
}
|
||||
|
||||
TEST_CASE("Build up argv"){
|
||||
CmdLineParser p;
|
||||
// p.argv();
|
||||
REQUIRE(p.argv().empty());
|
||||
REQUIRE(p.argv().data() == nullptr);
|
||||
|
||||
@ -262,5 +230,4 @@ TEST_CASE("Build up argv"){
|
||||
p.Parse(s);
|
||||
REQUIRE(p.argv().data() != nullptr);
|
||||
REQUIRE(p.argv().size() == 3);
|
||||
|
||||
}
|
@ -11,9 +11,9 @@ using namespace sls;
|
||||
|
||||
TEST_CASE("Convert mac address using classes", "[support]") {
|
||||
|
||||
std::vector<uint64_t> vec_addr{346856806822, 346856806852, 262027939863028};
|
||||
std::vector<uint64_t> vec_addr{346856806822, 346856806852, 262027939863028,0, 281474976710655};
|
||||
std::vector<std::string> vec_ans{"00:50:c2:46:d9:a6", "00:50:c2:46:d9:c4",
|
||||
"ee:50:22:46:d9:f4"};
|
||||
"ee:50:22:46:d9:f4", "00:00:00:00:00:00", "ff:ff:ff:ff:ff:ff"};
|
||||
for (size_t i = 0; i != vec_addr.size(); ++i) {
|
||||
auto mac0 = MacAddr(vec_addr[i]);
|
||||
auto mac1 = MacAddr(vec_ans[i]);
|
||||
|
Reference in New Issue
Block a user