~ubuntu-branches/ubuntu/wily/bombono-dvd/wily

« back to all changes in this revision

Viewing changes to src/mlib/tests/foreach/array_byref.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-11-04 11:46:25 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20101104114625-8xfdhvhpsm51i0nu
Tags: upstream-0.8.0
ImportĀ upstreamĀ versionĀ 0.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  (C) Copyright Eric Niebler 2004.
 
2
//  Use, modification and distribution are subject to the
 
3
//  Boost Software License, Version 1.0. (See accompanying file
 
4
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
5
 
 
6
/*
 
7
 Revision history:
 
8
   25 August 2005 : Initial version.
 
9
*/
 
10
 
 
11
#include <mlib/tests/_pc_.h>
 
12
//#include <boost/test/minimal.hpp>
 
13
#include <boost/foreach.hpp>
 
14
 
 
15
///////////////////////////////////////////////////////////////////////////////
 
16
// define the container types, used by utility.hpp to generate the helper functions
 
17
typedef int foreach_container_type[5];
 
18
typedef int const foreach_const_container_type[5];
 
19
typedef int foreach_value_type;
 
20
typedef int &foreach_reference_type;
 
21
typedef int const &foreach_const_reference_type;
 
22
 
 
23
#include "./utility.hpp"
 
24
 
 
25
///////////////////////////////////////////////////////////////////////////////
 
26
// define some containers
 
27
//
 
28
static int my_array[5] = { 1,2,3,4,5 };
 
29
static int const (&my_const_array)[5] = my_array;
 
30
 
 
31
///////////////////////////////////////////////////////////////////////////////
 
32
// test_main
 
33
//   
 
34
BOOST_AUTO_TEST_CASE( array_byref )
 
35
{
 
36
    // non-const containers by reference
 
37
    BOOST_CHECK(sequence_equal_byref_n(my_array, "\1\2\3\4\5"));
 
38
 
 
39
    // const containers by reference
 
40
    BOOST_CHECK(sequence_equal_byref_c(my_const_array, "\1\2\3\4\5"));
 
41
 
 
42
    // mutate the mutable collections
 
43
    mutate_foreach_byref(my_array);
 
44
 
 
45
    // compare the mutated collections to the actual results
 
46
    BOOST_CHECK(sequence_equal_byref_n(my_array, "\2\3\4\5\6"));
 
47
}