summaryrefslogtreecommitdiff
path: root/libformat/tests/basics/driver.cxx
blob: cb3a130be12df82f220f15391c08827b080337e1 (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
42
43
#include <stdexcept>

#include <libformat/version.hxx>
#include <libformat/format.hxx>

#undef NDEBUG
#include <cassert>

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"));
  }
}