diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-05-04 16:14:03 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-05-04 16:14:03 +0200 |
commit | b636924958794af6763c7098ea7d36f73c8b7f44 (patch) | |
tree | 3066b86a7a98e959f343e5b9777a5fb135dd8ab6 /libformat/tests/basics/driver.cxx | |
parent | 8728018f93a73b08a68ab1cea502a5f6b4a2a79e (diff) |
Improve libhello with better error handling
Diffstat (limited to 'libformat/tests/basics/driver.cxx')
-rw-r--r-- | libformat/tests/basics/driver.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libformat/tests/basics/driver.cxx b/libformat/tests/basics/driver.cxx index 03faea7..dbc9358 100644 --- a/libformat/tests/basics/driver.cxx +++ b/libformat/tests/basics/driver.cxx @@ -1,4 +1,5 @@ #include <cassert> +#include <stdexcept> #include <libformat/version.hxx> #include <libformat/format.hxx> @@ -8,7 +9,33 @@ using namespace format; int main () { + // Basics. + // assert (format_hello ("Hello", "World", volume::quiet) == "hello, World!"); assert (format_hello ("Hello", "World", volume::normal) == "Hello, World!"); assert (format_hello ("Hello", "World", volume::loud) == "HELLO, World!"); + + // Empty greeting. + // + try + { + format_hello ("", "World"); + assert (false); + } + catch (const invalid_argument& e) + { + assert (e.what () == string ("empty greeting")); + } + + // Empty name. + // + try + { + format_hello ("Hello", ""); + assert (false); + } + catch (const invalid_argument& e) + { + assert (e.what () == string ("empty name")); + } } |