~mbogomilov/maus/devel3

« back to all changes in this revision

Viewing changes to tests/cpp_unit/Maths/VectorTest.cc

  • Committer: Durga Rajaram
  • Date: 2014-01-14 07:07:02 UTC
  • mfrom: (659.1.80 relcand)
  • Revision ID: durga@fnal.gov-20140114070702-2l1fuj1w6rraw7xe
Tags: MAUS-v0.7.6
MAUS-v0.7.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
#include "Maths/Complex.hh"
29
29
#include "Maths/Vector.hh"
30
 
#include "Interface/Squeal.hh"
 
30
#include "Utils/Exception.hh"
31
31
 
32
32
using MAUS::Vector;
33
33
using MAUS::operator ==;
118
118
  try {
119
119
    d_mv0.subvector(0, 1);
120
120
    testpass = false;
121
 
  } catch (Squeal squeal) {}
 
121
  } catch (MAUS::Exception exc) {}
122
122
  EXPECT_TRUE(testpass);
123
123
 
124
124
  size_t sub1 = 2, sub2 = 3;
132
132
  try {
133
133
    c_mv0.subvector(0, 1);
134
134
    testpass = false;
135
 
  } catch (Squeal squeal) {}
 
135
  } catch (MAUS::Exception exc) {}
136
136
  EXPECT_TRUE(testpass);
137
137
 
138
138
  Vector<MAUS::complex> c_mv_sub = c_mv4.subvector(sub1, sub2);
147
147
  try {
148
148
    d_mv0[0];
149
149
    testpass = false;
150
 
  } catch (Squeal squeal) {}
 
150
  } catch (MAUS::Exception exc) {}
151
151
  EXPECT_TRUE(testpass);
152
152
  testpass = true;
153
153
  try {
154
154
    const double test_vector = d_mv0[0];
155
155
    std::cout << test_vector;  // eliminate unused variable warning
156
156
    testpass = false;
157
 
  } catch (Squeal squeal) {}
 
157
  } catch (MAUS::Exception exc) {}
158
158
  EXPECT_TRUE(testpass);
159
159
  testpass = true;
160
160
  try {
161
161
    d_mv0(1);
162
162
    testpass = false;
163
 
  } catch (Squeal squeal) {}
 
163
  } catch (MAUS::Exception exc) {}
164
164
  EXPECT_TRUE(testpass);
165
165
  testpass = true;
166
166
  try {
167
167
    const double test_vector = d_mv0(1);
168
168
    std::cout << test_vector;  // eliminate unused variable warning
169
169
    testpass = false;
170
 
  } catch (Squeal squeal) {}
 
170
  } catch (MAUS::Exception exc) {}
171
171
  EXPECT_TRUE(testpass);
172
172
 
173
173
  for (size_t i = 0; i < d_mv2.size(); ++i) ASSERT_TRUE(d_mv2(i+1) == 4.);
186
186
  try {
187
187
    c_mv0[0];
188
188
    testpass = false;
189
 
  } catch (Squeal squeal) {}
 
189
  } catch (MAUS::Exception exc) {}
190
190
  EXPECT_TRUE(testpass);
191
191
  testpass = true;
192
192
  try {
194
194
    // eliminate unused variable warning
195
195
    std::cout << real(test_vector) << imag(test_vector);
196
196
    testpass = false;
197
 
  } catch (Squeal squeal) {}
 
197
  } catch (MAUS::Exception exc) {}
198
198
  EXPECT_TRUE(testpass);
199
199
  testpass = true;
200
200
  try {
201
201
    c_mv0(1);
202
202
    testpass = false;
203
 
  } catch (Squeal squeal) {}
 
203
  } catch (MAUS::Exception exc) {}
204
204
  EXPECT_TRUE(testpass);
205
205
  testpass = true;
206
206
  try {
208
208
    // eliminate unused variable warning
209
209
    std::cout << real(test_vector) << imag(test_vector);
210
210
    testpass = false;
211
 
  } catch (Squeal squeal) {}
 
211
  } catch (MAUS::Exception exc) {}
212
212
  EXPECT_TRUE(testpass);
213
213
 
214
214
  for (size_t i = 0; i < c_mv3.size(); ++i) ASSERT_TRUE(c_mv3(i+1) == ca[i]);
279
279
  try {
280
280
    empty_d_vector = d_mv0;
281
281
    testpass = false;
282
 
  } catch (Squeal squeal) {}
 
282
  } catch (MAUS::Exception exc) {}
283
283
  EXPECT_TRUE(testpass);
284
284
 
285
285
  // bad assignment of differently sized vector
287
287
  try {
288
288
    d_mv2 = d_mv4;  // d_mv2.size() is 4 while d_mv4.size() is 3
289
289
    testpass = false;
290
 
  } catch (Squeal squeal) {}
 
290
  } catch (MAUS::Exception exc) {}
291
291
  EXPECT_TRUE(testpass);
292
292
 
293
293
  Vector<double> vector_d0 = d_mv3;
307
307
  try {
308
308
    empty_c_vector = c_mv0;
309
309
    testpass = false;
310
 
  } catch (Squeal squeal) {}
 
310
  } catch (MAUS::Exception exc) {}
311
311
  EXPECT_TRUE(testpass);
312
312
 
313
313
  // bad assignment of differently sized vector
315
315
  try {
316
316
    c_mv2 = c_mv4;  // c_mv2.size() is 4 while c_mv4.size() is 3
317
317
    testpass = false;
318
 
  } catch (Squeal squeal) {}
 
318
  } catch (MAUS::Exception exc) {}
319
319
  EXPECT_TRUE(testpass);
320
320
 
321
321
  Vector<MAUS::complex> vector_c0 = c_mv3;
339
339
  try {
340
340
    test_d_vector *= d_mv2;
341
341
    testpass = false;
342
 
  } catch (Squeal squeal) {}
 
342
  } catch (MAUS::Exception exc) {}
343
343
  EXPECT_TRUE(testpass);
344
344
  testpass = true;
345
345
  try {
346
346
    test_d_vector * d_mv0;
347
347
    testpass = false;
348
 
  } catch (Squeal squeal) {}
 
348
  } catch (MAUS::Exception exc) {}
349
349
  EXPECT_TRUE(testpass);
350
350
 
351
351
  test_d_vector *= d_mv4;  // {2., 2., 2.} * {1., 2., 3.}
376
376
  try {
377
377
    test_c_vector *= c_mv2;
378
378
    testpass = false;
379
 
  } catch (Squeal squeal) {}
 
379
  } catch (MAUS::Exception exc) {}
380
380
  EXPECT_TRUE(testpass);
381
381
  testpass = true;
382
382
  try {
383
383
    test_c_vector * c_mv0;
384
384
    testpass = false;
385
 
  } catch (Squeal squeal) {}
 
385
  } catch (MAUS::Exception exc) {}
386
386
  EXPECT_TRUE(testpass);
387
387
 
388
388
  // {(2.,1.), (2.,1.), (2.,1.)} * {(1.,-1.), (2.,0.), (3.,1.)}
424
424
  try {
425
425
    test_d_vector /= d_mv2;
426
426
    testpass = false;
427
 
  } catch (Squeal squeal) {}
 
427
  } catch (MAUS::Exception exc) {}
428
428
  EXPECT_TRUE(testpass);
429
429
  testpass = true;
430
430
  try {
431
431
    test_d_vector / d_mv0;
432
432
    testpass = false;
433
 
  } catch (Squeal squeal) {}
 
433
  } catch (MAUS::Exception exc) {}
434
434
  EXPECT_TRUE(testpass);
435
435
 
436
436
  test_d_vector /= d_mv4;  // {2., 2., 2.} / {1., 2., 3.}
457
457
  try {
458
458
    test_c_vector /= c_mv2;
459
459
    testpass = false;
460
 
  } catch (Squeal squeal) {}
 
460
  } catch (MAUS::Exception exc) {}
461
461
  EXPECT_TRUE(testpass);
462
462
  testpass = true;
463
463
  try {
464
464
    test_c_vector / c_mv0;
465
465
    testpass = false;
466
 
  } catch (Squeal squeal) {}
 
466
  } catch (MAUS::Exception exc) {}
467
467
  EXPECT_TRUE(testpass);
468
468
 
469
469
  // {(2.,1.), (2.,1.), (2.,1.)} / {(1.,-1.), (2.,0.), (3.,1.)}