1
/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Andrew Hutchings
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.
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.
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
23
#define BOOST_TEST_DYN_LINK
24
#include <boost/test/unit_test.hpp>
26
#include "drizzled/global_buffer.h"
28
BOOST_AUTO_TEST_SUITE(GlobalBufferTests)
29
BOOST_AUTO_TEST_CASE(overflow)
31
drizzled::global_buffer_constraint<uint64_t> test_buffer(1024);
33
BOOST_REQUIRE(test_buffer.add(512));
34
BOOST_REQUIRE(test_buffer.add(512));
35
BOOST_REQUIRE(not test_buffer.add(1));
38
BOOST_AUTO_TEST_CASE(subtract)
40
drizzled::global_buffer_constraint<uint64_t> test_buffer(1024);
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));
48
BOOST_AUTO_TEST_CASE(underflow)
50
drizzled::global_buffer_constraint<uint64_t> test_buffer(1024);
52
BOOST_REQUIRE(test_buffer.add(10));
53
BOOST_REQUIRE(not test_buffer.sub(11));
56
BOOST_AUTO_TEST_CASE(change_max)
58
drizzled::global_buffer_constraint<uint64_t> test_buffer(1024);
60
test_buffer.setMaxSize(512);
62
BOOST_REQUIRE(not test_buffer.add(513));
64
BOOST_AUTO_TEST_SUITE_END()