~drizzle-trunk/drizzle/development

2097.2.4 by Andrew Hutchings
Convert all unit tests to boost::test
1
/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2010 Andrew Hutchings
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU General Public License
17
 *  along with this program; if not, write to the Free Software
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 */
20
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
21
#include <config.h>
2097.2.4 by Andrew Hutchings
Convert all unit tests to boost::test
22
23
#define BOOST_TEST_DYN_LINK
24
#include <boost/test/unit_test.hpp>
25
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
26
#include <drizzled/global_buffer.h>
2097.2.4 by Andrew Hutchings
Convert all unit tests to boost::test
27
28
BOOST_AUTO_TEST_SUITE(GlobalBufferTests)
29
BOOST_AUTO_TEST_CASE(overflow)
30
{
31
  drizzled::global_buffer_constraint<uint64_t> test_buffer(1024);
32
33
  BOOST_REQUIRE(test_buffer.add(512));
34
  BOOST_REQUIRE(test_buffer.add(512));
35
  BOOST_REQUIRE(not test_buffer.add(1));
36
}
37
38
BOOST_AUTO_TEST_CASE(subtract)
39
{
40
  drizzled::global_buffer_constraint<uint64_t> test_buffer(1024);
41
42
  BOOST_REQUIRE(test_buffer.add(1024));
43
  BOOST_REQUIRE(test_buffer.sub(512));
44
  BOOST_REQUIRE(test_buffer.add(512));
45
  BOOST_REQUIRE(not test_buffer.add(1));
46
}
47
48
BOOST_AUTO_TEST_CASE(underflow)
49
{
50
  drizzled::global_buffer_constraint<uint64_t> test_buffer(1024);
51
52
  BOOST_REQUIRE(test_buffer.add(10));
53
  BOOST_REQUIRE(not test_buffer.sub(11));
54
}
55
56
BOOST_AUTO_TEST_CASE(change_max)
57
{
58
  drizzled::global_buffer_constraint<uint64_t> test_buffer(1024);
59
60
  test_buffer.setMaxSize(512);
61
62
  BOOST_REQUIRE(not test_buffer.add(513));
63
}
64
BOOST_AUTO_TEST_SUITE_END()