~ubuntu-branches/ubuntu/wily/libtorrent/wily-proposed

« back to all changes in this revision

Viewing changes to test/rak/allocators_test.cc

  • Committer: Bazaar Package Importer
  • Author(s): Rogério Brito
  • Date: 2011-03-20 01:06:18 UTC
  • mfrom: (1.1.13 upstream) (4.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110320010618-g3wyylccqzqko73c
Tags: 0.12.7-5
* Use Steinar's "real" patch for IPv6. Addresses #490277, #618275,
  and Closes: #617791.
* Adapt libtorrent-0.12.6-ipv6-07.patch. It FTBFS otherwise.
* Add proper attibution to the IPv6 patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "config.h"
 
2
 
 
3
#import "allocators_test.h"
 
4
 
 
5
CPPUNIT_TEST_SUITE_REGISTRATION(AllocatorsTest);
 
6
 
 
7
template <typename T>
 
8
bool is_aligned(const T& t) {
 
9
  return t.empty() || (reinterpret_cast<int>(&t[0]) & (LT_SMP_CACHE_BYTES - 1)) == 0x0;
 
10
}
 
11
 
 
12
void
 
13
AllocatorsTest::testAlignment() {
 
14
  aligned_vector_type v1;
 
15
  aligned_vector_type v2(1, 'a');
 
16
  aligned_vector_type v3(16, 'a');
 
17
  aligned_vector_type v4(LT_SMP_CACHE_BYTES, 'b');
 
18
  aligned_vector_type v5(1, 'a');
 
19
  
 
20
  CPPUNIT_ASSERT(is_aligned(v1));
 
21
  CPPUNIT_ASSERT(is_aligned(v2));
 
22
  CPPUNIT_ASSERT(is_aligned(v3));
 
23
  CPPUNIT_ASSERT(is_aligned(v4));
 
24
  CPPUNIT_ASSERT(is_aligned(v5));
 
25
}