Code Cleanup
- Removed unused function and corresponding unit tests. YAGNI.
This commit is contained in:
25
src/text.cpp
25
src/text.cpp
@@ -68,6 +68,7 @@ void wrapText (
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// UTF-8
|
||||||
void splitq (
|
void splitq (
|
||||||
std::vector<std::string>& results,
|
std::vector<std::string>& results,
|
||||||
const std::string& input,
|
const std::string& input,
|
||||||
@@ -86,9 +87,7 @@ void splitq (
|
|||||||
if (in_quote)
|
if (in_quote)
|
||||||
{
|
{
|
||||||
if (input[i] == quote)
|
if (input[i] == quote)
|
||||||
{
|
|
||||||
in_quote = false;
|
in_quote = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -169,28 +168,6 @@ void split (
|
|||||||
results.push_back (input.substr (start));
|
results.push_back (input.substr (start));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void split_minimal (
|
|
||||||
std::vector<std::string>& results,
|
|
||||||
const std::string& input,
|
|
||||||
const std::string& delimiter)
|
|
||||||
{
|
|
||||||
results.clear ();
|
|
||||||
std::string::size_type length = delimiter.length ();
|
|
||||||
|
|
||||||
std::string::size_type start = 0;
|
|
||||||
std::string::size_type i;
|
|
||||||
while ((i = input.find (delimiter, start)) != std::string::npos)
|
|
||||||
{
|
|
||||||
if (i != start)
|
|
||||||
results.push_back (input.substr (start, i - start));
|
|
||||||
start = i + length;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (input.length ())
|
|
||||||
results.push_back (input.substr (start));
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void join (
|
void join (
|
||||||
std::string& result,
|
std::string& result,
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ void splitq (std::vector<std::string>&, const std::string&, const char);
|
|||||||
void split (std::vector<std::string>&, const std::string&, const char);
|
void split (std::vector<std::string>&, const std::string&, const char);
|
||||||
void split (std::vector<std::string>&, const std::string&, const std::string&);
|
void split (std::vector<std::string>&, const std::string&, const std::string&);
|
||||||
void split_minimal (std::vector<std::string>&, const std::string&, const char);
|
void split_minimal (std::vector<std::string>&, const std::string&, const char);
|
||||||
void split_minimal (std::vector<std::string>&, const std::string&, const std::string&);
|
|
||||||
void join (std::string&, const std::string&, const std::vector<std::string>&);
|
void join (std::string&, const std::string&, const std::vector<std::string>&);
|
||||||
void join (std::string&, const std::string&, const std::vector<int>&);
|
void join (std::string&, const std::string&, const std::vector<int>&);
|
||||||
std::string commify (const std::string&);
|
std::string commify (const std::string&);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ Context context;
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int main (int argc, char** argv)
|
int main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
UnitTest t (262);
|
UnitTest t (261);
|
||||||
// void wrapText (std::vector <std::string>& lines, const std::string& text, const int width, bool hyphenate)
|
// void wrapText (std::vector <std::string>& lines, const std::string& text, const int width, bool hyphenate)
|
||||||
std::string text = "This is a test of the line wrapping code.";
|
std::string text = "This is a test of the line wrapping code.";
|
||||||
std::vector <std::string> lines;
|
std::vector <std::string> lines;
|
||||||
@@ -133,9 +133,6 @@ int main (int argc, char** argv)
|
|||||||
split (items, unsplit, "--");
|
split (items, unsplit, "--");
|
||||||
t.is (items.size (), (size_t) 0, "split '' '--' -> 0 items");
|
t.is (items.size (), (size_t) 0, "split '' '--' -> 0 items");
|
||||||
|
|
||||||
split_minimal (items, unsplit, "--");
|
|
||||||
t.is (items.size (), (size_t) 0, "split '' '--' -> 0");
|
|
||||||
|
|
||||||
unsplit = "a";
|
unsplit = "a";
|
||||||
split (items, unsplit, "--");
|
split (items, unsplit, "--");
|
||||||
t.is (items.size (), (size_t) 1, "split 'a' '--' -> 1 item");
|
t.is (items.size (), (size_t) 1, "split 'a' '--' -> 1 item");
|
||||||
|
|||||||
Reference in New Issue
Block a user