aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Stephen P. Bennett <spb@exherbo.org> 2006-01-23 02:40:45 +0000
committerAvatar Stephen P. Bennett <spb@exherbo.org> 2006-01-23 02:40:45 +0000
commit6bce4b1f94124611e934117fd29bbfe0c1923beb (patch)
tree2913a97c26d3034545e42927cfbd8de6683eb40c
parent7c14cbaced4a71fb8dae281ced65c9be76d230c3 (diff)
downloadpaludis-6bce4b1f94124611e934117fd29bbfe0c1923beb.tar.gz
paludis-6bce4b1f94124611e934117fd29bbfe0c1923beb.tar.xz
Might want to handle an empty string properly, while we're at it
-rw-r--r--paludis/destringify.cc2
-rw-r--r--paludis/destringify.hh3
-rw-r--r--paludis/destringify_TEST.cc1
3 files changed, 5 insertions, 1 deletions
diff --git a/paludis/destringify.cc b/paludis/destringify.cc
index 6389461..0b497ef 100644
--- a/paludis/destringify.cc
+++ b/paludis/destringify.cc
@@ -24,6 +24,6 @@
using namespace paludis;
DestringifyError::DestringifyError(const std::string & str) throw () :
- Exception("Couldn't destringify " + str + "." )
+ Exception("Couldn't destringify '" + str + "'." )
{
}
diff --git a/paludis/destringify.hh b/paludis/destringify.hh
index e29147c..dc85685 100644
--- a/paludis/destringify.hh
+++ b/paludis/destringify.hh
@@ -98,6 +98,9 @@ namespace paludis
template <typename Type_, typename Exception_>
Type_ destringify(const std::string & s)
{
+ if (s == "")
+ throw Exception_("");
+
return destringify_internals::Destringifier<Type_, Exception_>::do_destringify(s);
}
diff --git a/paludis/destringify_TEST.cc b/paludis/destringify_TEST.cc
index c86f20a..be543a0 100644
--- a/paludis/destringify_TEST.cc
+++ b/paludis/destringify_TEST.cc
@@ -50,6 +50,7 @@ namespace test_cases
TEST_CHECK_EQUAL(destringify<int>("99"), 99);
TEST_CHECK_EQUAL(destringify<int>("-99"), -99);
TEST_CHECK_EQUAL(destringify<int>(" 12345"), 12345);
+ TEST_CHECK_THROWS(destringify<int>(""), DestringifyError);
}
} test_case_destringify_int;