~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to unittests/constrained_value.cc

  • Committer: Monty Taylor
  • Date: 2010-10-19 21:51:42 UTC
  • mto: This revision was merged to the branch mainline in revision 1870.
  • Revision ID: mordred@inaugust.com-20101019215142-bwof1oqrswj9ms3v
Add a constrained_value class which allows us to set compile-time
constraints on a value.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include "config.h"
22
22
 
 
23
#include <string>
 
24
 
23
25
#include <gtest/gtest.h>
24
26
 
25
27
#include <drizzled/constrained_value.h>
 
28
#include <boost/lexical_cast.hpp>
26
29
 
27
30
using namespace drizzled;
28
31
 
30
33
 
31
34
TEST(constrained_value, raw_usage)
32
35
{
33
 
  constrained_value<uint64_t> val(1, 1024, 1, 10);
 
36
  constrained_check<uint64_t,1024,1,10> val(1);
34
37
 
35
38
  EXPECT_EQ(UINT64_C(1), (uint64_t)val);
36
39
 
42
45
  EXPECT_EQ(20, (uint64_t)val);
43
46
}
44
47
 
 
48
TEST(constrained_value, lexical_cast_usage)
 
49
{
 
50
  constrained_check<uint64_t,1024,1,10> val(1);
 
51
 
 
52
  std::string string_val= boost::lexical_cast<std::string>(val);
 
53
 
 
54
  EXPECT_EQ(std::string("1"), string_val);
 
55
}
 
56
 
 
57