summaryrefslogtreecommitdiff
path: root/ACE/contrib/utility/Test/ExH/Converter/converter.cpp
blob: 396b616e6a6fd5631987ca8b44acdb125481a82b (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
44
45
46
47
48
// file      : Test/ExH/Converter/converter.cpp
// author    : Boris Kolpackov <boris@kolpackov.net>
// copyright : Copyright (c) 2002-2003 Boris Kolpackov
// license   : http://kolpackov.net/license.html

#include "Utility/ExH/Converter.hpp"
#include "Utility/ExH/StringStreamConverter.hpp"

#include <string>
#include <sstream>

using std::string;
using namespace Utility::ExH;

struct E {};

void postcondition (bool p) throw (E)
{
  if (!p) throw E ();
}

int
main ()
{
  try
  {
    // template<T>
    // converter (T const&)
    //
    {
      postcondition (converter ("hello") == string("hello"));
    }

    // template<>
    // converter (std::ostringstream const&)
    //
    {
      std::ostringstream ostr;
      ostr << "hello";
      postcondition (converter (ostr) == string("hello"));
    }
  }
  catch (...)
  {
    return -1;
  }
}
//$Id$