blob: dbc935885c632526c881a15f9f4e119539088266 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include <cassert>
#include <stdexcept>
#include <libformat/version.hxx>
#include <libformat/format.hxx>
using namespace std;
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"));
}
}
|