tools: alias 'nfdc cs' to 'nfdc cs info'
Change-Id: Ied1d34a84110ee0b6488d35d56fb1caecaf14117
Refs: #4498
diff --git a/tests/tools/nfdc/command-definition.t.cpp b/tests/tools/nfdc/command-definition.t.cpp
index 34b5969..374e36d 100644
--- a/tests/tools/nfdc/command-definition.t.cpp
+++ b/tests/tools/nfdc/command-definition.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -144,6 +144,8 @@
BOOST_AUTO_TEST_CASE(NoneType)
{
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ArgValueType::NONE), "none");
+
CommandDefinition cs("noun", "verb");
cs.addArg("a", ArgValueType::NONE, Required::YES, Positional::NO);
@@ -159,6 +161,8 @@
BOOST_AUTO_TEST_CASE(AnyType)
{
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ArgValueType::ANY), "any");
+
CommandDefinition cs("noun", "verb");
cs.addArg("a", ArgValueType::ANY, Required::NO, Positional::YES);
@@ -183,8 +187,42 @@
BOOST_CHECK_EQUAL(values.at(1), "c");
}
+BOOST_AUTO_TEST_CASE(BooleanType)
+{
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ArgValueType::BOOLEAN), "boolean");
+
+ CommandDefinition cs("noun", "verb");
+ cs.addArg("a", ArgValueType::BOOLEAN, Required::YES);
+
+ CommandArguments ca;
+
+ ca = cs.parse({"a", "on"});
+ BOOST_CHECK_EQUAL(ca.size(), 1);
+ BOOST_CHECK(ca.at("a").type() == typeid(bool));
+ BOOST_CHECK_EQUAL(ca.get<bool>("a"), true);
+
+ ca = cs.parse({"a", "off"});
+ BOOST_CHECK_EQUAL(ca.size(), 1);
+ BOOST_CHECK(ca.at("a").type() == typeid(bool));
+ BOOST_CHECK_EQUAL(ca.get<bool>("a"), false);
+
+ BOOST_CHECK_EQUAL(cs.parse({"a", "true"}).get<bool>("a"), true);
+ BOOST_CHECK_EQUAL(cs.parse({"a", "enabled"}).get<bool>("a"), true);
+ BOOST_CHECK_EQUAL(cs.parse({"a", "yes"}).get<bool>("a"), true);
+ BOOST_CHECK_EQUAL(cs.parse({"a", "1"}).get<bool>("a"), true);
+ BOOST_CHECK_EQUAL(cs.parse({"a", "false"}).get<bool>("a"), false);
+ BOOST_CHECK_EQUAL(cs.parse({"a", "disabled"}).get<bool>("a"), false);
+ BOOST_CHECK_EQUAL(cs.parse({"a", "no"}).get<bool>("a"), false);
+ BOOST_CHECK_EQUAL(cs.parse({"a", "0"}).get<bool>("a"), false);
+
+ BOOST_CHECK_THROW(cs.parse({"a", "42"}), CommandDefinition::Error);
+ BOOST_CHECK_THROW(cs.parse({"a", "not-bool"}), CommandDefinition::Error);
+}
+
BOOST_AUTO_TEST_CASE(UnsignedType)
{
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ArgValueType::UNSIGNED), "non-negative integer");
+
CommandDefinition cs("noun", "verb");
cs.addArg("a", ArgValueType::UNSIGNED, Required::YES);
@@ -206,6 +244,8 @@
BOOST_AUTO_TEST_CASE(StringType)
{
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ArgValueType::STRING), "string");
+
CommandDefinition cs("noun", "verb");
cs.addArg("a", ArgValueType::STRING, Required::YES);
@@ -219,6 +259,8 @@
BOOST_AUTO_TEST_CASE(ReportFormatType)
{
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ArgValueType::REPORT_FORMAT), "ReportFormat");
+
CommandDefinition cs("noun", "verb");
cs.addArg("a", ArgValueType::REPORT_FORMAT, Required::YES);
@@ -239,6 +281,8 @@
BOOST_AUTO_TEST_CASE(NameType)
{
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ArgValueType::NAME), "Name");
+
CommandDefinition cs("noun", "verb");
cs.addArg("a", ArgValueType::NAME, Required::YES);
@@ -252,6 +296,8 @@
BOOST_AUTO_TEST_CASE(FaceUriType)
{
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ArgValueType::FACE_URI), "FaceUri");
+
CommandDefinition cs("noun", "verb");
cs.addArg("a", ArgValueType::FACE_URI, Required::YES);
@@ -268,6 +314,8 @@
BOOST_AUTO_TEST_CASE(FaceIdOrUriType)
{
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ArgValueType::FACE_ID_OR_URI), "FaceId or FaceUri");
+
CommandDefinition cs("noun", "verb");
cs.addArg("a", ArgValueType::FACE_ID_OR_URI, Required::YES);
@@ -288,6 +336,8 @@
BOOST_AUTO_TEST_CASE(FacePersistencyType)
{
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ArgValueType::FACE_PERSISTENCY), "FacePersistency");
+
CommandDefinition cs("noun", "verb");
cs.addArg("a", ArgValueType::FACE_PERSISTENCY, Required::YES);
@@ -296,14 +346,12 @@
ca = cs.parse(std::vector<std::string>{"a", "persistent"});
BOOST_CHECK_EQUAL(ca.size(), 1);
BOOST_CHECK(ca.at("a").type() == typeid(FacePersistency));
- BOOST_CHECK_EQUAL(ca.get<FacePersistency>("a"),
- FacePersistency::FACE_PERSISTENCY_PERSISTENT);
+ BOOST_CHECK_EQUAL(ca.get<FacePersistency>("a"), FacePersistency::FACE_PERSISTENCY_PERSISTENT);
ca = cs.parse(std::vector<std::string>{"a", "permanent"});
BOOST_CHECK_EQUAL(ca.size(), 1);
BOOST_CHECK(ca.at("a").type() == typeid(FacePersistency));
- BOOST_CHECK_EQUAL(ca.get<FacePersistency>("a"),
- FacePersistency::FACE_PERSISTENCY_PERMANENT);
+ BOOST_CHECK_EQUAL(ca.get<FacePersistency>("a"), FacePersistency::FACE_PERSISTENCY_PERMANENT);
// nfdc does not accept "on-demand"
BOOST_CHECK_THROW(cs.parse(std::vector<std::string>{"a", "on-demand"}), CommandDefinition::Error);
@@ -311,6 +359,8 @@
BOOST_AUTO_TEST_CASE(RouteOriginType)
{
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ArgValueType::ROUTE_ORIGIN), "RouteOrigin");
+
CommandDefinition cs("noun", "verb");
cs.addArg("a", ArgValueType::ROUTE_ORIGIN, Required::YES);
@@ -319,14 +369,12 @@
ca = cs.parse(std::vector<std::string>{"a", "Nlsr"});
BOOST_CHECK_EQUAL(ca.size(), 1);
BOOST_CHECK(ca.at("a").type() == typeid(RouteOrigin));
- BOOST_CHECK_EQUAL(ca.get<RouteOrigin>("a"),
- RouteOrigin::ROUTE_ORIGIN_NLSR);
+ BOOST_CHECK_EQUAL(ca.get<RouteOrigin>("a"), RouteOrigin::ROUTE_ORIGIN_NLSR);
ca = cs.parse(std::vector<std::string>{"a", "27"});
BOOST_CHECK_EQUAL(ca.size(), 1);
BOOST_CHECK(ca.at("a").type() == typeid(RouteOrigin));
- BOOST_CHECK_EQUAL(ca.get<RouteOrigin>("a"),
- static_cast<RouteOrigin>(27));
+ BOOST_CHECK_EQUAL(ca.get<RouteOrigin>("a"), static_cast<RouteOrigin>(27));
BOOST_CHECK_THROW(cs.parse(std::vector<std::string>{"a", "not-RouteOrigin"}), CommandDefinition::Error);
}