blob: 42b925a6b3ff4e9d9d00a562c0508fbbf14f29ff (
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>
int main ()
{
using namespace std;
using namespace format;
// 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"));
}
}
|