reprtest.cc 1.61 KB
Newer Older
thomas.forbriger's avatar
thomas.forbriger committed
1
2
3
4
5
/*! \file reprtest.cc
 * \brief test representation classes (implementation)
 * 
 * ----------------------------------------------------------------------------
 * 
thomas.forbriger's avatar
huuu    
thomas.forbriger committed
6
 * $Id: reprtest.cc,v 1.2 2002-12-15 20:57:19 forbrig Exp $
thomas.forbriger's avatar
thomas.forbriger committed
7
8
9
10
11
12
13
14
15
16
17
18
 * \author Thomas Forbriger
 * \date 10/05/2002
 * 
 * test representation classes (implementation)
 * 
 * Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) 
 * 
 * REVISIONS and CHANGES 
 *  - 10/05/2002   V1.0   Thomas Forbriger
 * 
 * ============================================================================
 */
thomas.forbriger's avatar
huuu    
thomas.forbriger committed
19
20
21
22
#define AFF_REPRTEST_CC_VERSION \
  "AFF_REPRTEST_CC   V1.0   "
#define AFF_REPRTEST_CC_CVSID \
  "$Id: reprtest.cc,v 1.2 2002-12-15 20:57:19 forbrig Exp $"
thomas.forbriger's avatar
thomas.forbriger committed
23

thomas.forbriger's avatar
huuu    
thomas.forbriger committed
24
25
26
#include<aff/array.h>
#include <aff/lib/sharedheap.h>
#include <aff/dump.h>
thomas.forbriger's avatar
thomas.forbriger committed
27
28
29
30

using std::cout;
using std::endl;

thomas.forbriger's avatar
huuu    
thomas.forbriger committed
31
//! testing SharedHeap
thomas.forbriger's avatar
thomas.forbriger committed
32
33
int main()
{
thomas.forbriger's avatar
huuu    
thomas.forbriger committed
34
35
  cout << AFF_REPRTEST_CC_VERSION << endl;
  cout << AFF_REPRTEST_CC_CVSID << endl;
thomas.forbriger's avatar
thomas.forbriger committed
36
37
38

  const int N=10;
  const int N2=23;
thomas.forbriger's avatar
huuu    
thomas.forbriger committed
39
40
41
42
43
  aff::SharedHeap<int> A(N);
  aff::SharedHeap<int> B(N2);
  aff::SharedHeap<const int> C(N2);
  C=B;
  aff::SharedHeap<float> D(N2);
thomas.forbriger's avatar
thomas.forbriger committed
44
45
46
47
48

  for (int i=0; i<N; i++) { A[i]=(i+1)*10; }
  for (int i=0; i<N2; i++) { B[i]=(i+4)*3; }
  for (int i=0; i<N2; i++) { D[i]=(i+2.45)*2; }

thomas.forbriger's avatar
huuu    
thomas.forbriger committed
49
50
51
52
53
54
  aff::SharedHeap<float>::Tcoc E(D);

  DUMP(A)
  DUMP(B)
  DUMP(C)
  DUMP(E)
thomas.forbriger's avatar
thomas.forbriger committed
55
56
  // modify C through B
  B[8]=632;
thomas.forbriger's avatar
huuu    
thomas.forbriger committed
57
  DUMP(C)
thomas.forbriger's avatar
thomas.forbriger committed
58
59
60
  // modify C directly - is illegal
#ifdef ILLEGAL1
  C[9]=354;
thomas.forbriger's avatar
huuu    
thomas.forbriger committed
61
  DUMP(C)
thomas.forbriger's avatar
thomas.forbriger committed
62
63
64
65
66
#endif
  // make B a reference to A
  B=A;
  // modification should be visible through B
  A[5]=453;
thomas.forbriger's avatar
huuu    
thomas.forbriger committed
67
  DUMP(B)
thomas.forbriger's avatar
thomas.forbriger committed
68
  // test another type
thomas.forbriger's avatar
huuu    
thomas.forbriger committed
69
  DUMP(D)
thomas.forbriger's avatar
thomas.forbriger committed
70
71
72
73
74

  cout << endl;
}

/* ----- END OF reprtest.cc ----- */