blob: 7d25711c2080fe7bcb11e942c753812eb08bb654 (
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
49
50
51
52
53
54
55
56
57
|
#define BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
#define BOOST_TEST_MODULE FakeOStreamTest
#include "util/string_stream.hh"
#include <boost/test/unit_test.hpp>
#include <boost/lexical_cast.hpp>
#include <cstddef>
#include <limits>
namespace util { namespace {
template <class T> void TestEqual(const T value) {
std::string str;
StringStream(str) << value;
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(value), str);
}
template <class T> void TestCorners() {
TestEqual(std::numeric_limits<T>::max());
TestEqual(std::numeric_limits<T>::min());
TestEqual(static_cast<T>(0));
TestEqual(static_cast<T>(-1));
TestEqual(static_cast<T>(1));
}
BOOST_AUTO_TEST_CASE(Integer) {
TestCorners<char>();
TestCorners<signed char>();
TestCorners<unsigned char>();
TestCorners<short>();
TestCorners<signed short>();
TestCorners<unsigned short>();
TestCorners<int>();
TestCorners<unsigned int>();
TestCorners<signed int>();
TestCorners<long>();
TestCorners<unsigned long>();
TestCorners<signed long>();
TestCorners<long long>();
TestCorners<unsigned long long>();
TestCorners<signed long long>();
TestCorners<std::size_t>();
}
enum TinyEnum { EnumValue };
BOOST_AUTO_TEST_CASE(EnumCase) {
TestEqual(EnumValue);
}
}} // namespaces
|