shill: Handle empty string in Technology::GetTechnologyVectorFromString.
This CL makes the following changes:
1. Fix Technology::GetTechnologyVectorFromString to handle a given empty
string correctly.
2. Add Technology unit tests.
3. Add comments in Technology header file.
BUG=chromium-os:27779
TEST=Build and run unit tests.
Change-Id: Ia55fa558b874fec640bb050452133f906f9da83e
Reviewed-on: https://gerrit.chromium.org/gerrit/19694
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Ready: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
diff --git a/technology.h b/technology.h
index ec3a301..781b1f5 100644
--- a/technology.h
+++ b/technology.h
@@ -12,6 +12,8 @@
class Error;
+// A class that provides functions for converting between technology names
+// and identifiers.
class Technology {
public:
enum Identifier {
@@ -25,14 +27,26 @@
kUnknown,
};
+ // Returns the technology identifier for a technology name in |name|,
+ // or Technology::kUnknown if the technology name is unknown.
static Identifier IdentifierFromName(const std::string &name);
+
+ // Returns the technology name for a technology identifier in |id|,
+ // or Technology::kUnknownName ("Unknown") if the technology identifier
+ // is unknown.
static std::string NameFromIdentifier(Identifier id);
+
+ // Returns the technology identifier for a storage group identifier in
+ // |group|, which should have the format of <technology name>_<suffix>,
+ // or Technology::kUnknown if |group| is not prefixed with a known
+ // technology name.
static Identifier IdentifierFromStorageGroup(const std::string &group);
- // Convert the comma-separated list of technology names in
- // |technologies_string| into a vector of technology identifiers output in
- // |technologies_vector|. Returns true if the |technologies_string| contains
- // a valid set of technologies with no duplicate elements, false otherwise.
+ // Converts the comma-separated list of technology names (with no whitespace
+ // around commas) in |technologies_string| into a vector of technology
+ // identifiers output in |technologies_vector|. Returns true if the
+ // |technologies_string| contains a valid set of technologies with no
+ // duplicate elements, false otherwise.
static bool GetTechnologyVectorFromString(
const std::string &technologies_string,
std::vector<Identifier> *technologies_vector,