~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to unittests/global_buffer_test.cc

  • Committer: Andrew Hutchings
  • Date: 2011-01-23 21:32:31 UTC
  • mto: (2108.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2109.
  • Revision ID: andrew@linuxjedi.co.uk-20110123213231-dp2r4enepa9k4g36
Convert all unit tests to boost::test
Add pandora support for boost::test
Remove pandora support for gtest

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
21
#include "config.h"
 
22
 
 
23
#define BOOST_TEST_DYN_LINK
 
24
#include <boost/test/unit_test.hpp>
 
25
 
 
26
#include "drizzled/global_buffer.h"
 
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()