~ubuntu-branches/ubuntu/edgy/swig1.3/edgy

« back to all changes in this revision

Viewing changes to Examples/test-suite/csharp/li_std_vector_runme.cs

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:16:04 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205011604-ygx904it6413k3go
Tags: 1.3.27-1ubuntu1
Resynchronise with Debian again, for the new subversion packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
  private static readonly int collectionSize = 20;
9
9
  private static readonly int midCollection = collectionSize/2;
10
10
 
 
11
  public static DoubleVector myDoubleVector;
 
12
  public static RealVector myRealVector;
 
13
 
11
14
  public static void Main() {
12
15
    // Setup collection
13
16
    DoubleVector vect = new DoubleVector();
107
110
          throw new Exception("CopyTo (7) test failed (only a shallow copy was made), i:" + i);
108
111
      }
109
112
    }
 
113
    {
 
114
      try {
 
115
        vect.CopyTo(null);
 
116
        throw new Exception("CopyTo (8) test failed");
 
117
      } catch (ArgumentNullException) {
 
118
      }
 
119
    }
110
120
 
111
121
    // Contains() test
112
122
    if (!vect.Contains(0*10.1))
139
149
            throw new Exception("ICollection constructor not a deep copy, index:" + i);
140
150
        }
141
151
      }
 
152
      try {
 
153
        new DoubleVector(null);
 
154
        throw new Exception("ICollection constructor null test failed");
 
155
      } catch (ArgumentNullException) {
 
156
      }
142
157
 
143
158
      // IndexOf() test
144
159
      for (int i=0; i<collectionSize; i++) {
163
178
    {
164
179
      // Repeat() test
165
180
      try {
166
 
        DoubleVector d = DoubleVector.Repeat(77.7, -1);
 
181
        myDoubleVector = DoubleVector.Repeat(77.7, -1);
167
182
        throw new Exception("Repeat negative count test failed");
168
183
      } catch (ArgumentOutOfRangeException) {
169
184
      }
201
216
        if (vect.IndexOf(i*10.1) != i+dvect.Count)
202
217
          throw new Exception("InsertRange (3) test " + i + " failed");
203
218
      }
 
219
      try {
 
220
        vect.InsertRange(0, null);
 
221
        throw new Exception("InsertRange (4) test failed");
 
222
      } catch (ArgumentNullException) {
 
223
      }
204
224
 
205
225
      // RemoveRange() test
 
226
      vect.RemoveRange(0, 0);
206
227
      vect.RemoveRange(midCollection, dvect.Count);
207
228
      if (vect.Count != collectionSize)
208
229
        throw new Exception("RemoveRange test size failed");
216
237
      } catch (ArgumentOutOfRangeException) {
217
238
      }
218
239
      try {
 
240
        vect.RemoveRange(0, -1);
 
241
        throw new Exception("RemoveRange count out of range (2) test failed");
 
242
      } catch (ArgumentOutOfRangeException) {
 
243
      }
 
244
      try {
219
245
        vect.RemoveRange(collectionSize+1, 0);
220
 
        throw new Exception("RemoveRange index out of range (2) test failed");
221
 
      } catch (ArgumentOutOfRangeException) {
 
246
        throw new Exception("RemoveRange index and count out of range (1) test failed");
 
247
      } catch (ArgumentException) {
 
248
      }
 
249
      try {
 
250
        vect.RemoveRange(0, collectionSize+1);
 
251
        throw new Exception("RemoveRange index and count out of range (2) test failed");
 
252
      } catch (ArgumentException) {
222
253
      }
223
254
 
224
255
      // AddRange() test
233
264
        if (vect[i+collectionSize] != dvect[i])
234
265
          throw new Exception("AddRange (2) test " + i + " failed");
235
266
      }
 
267
      try {
 
268
        vect.AddRange(null);
 
269
        throw new Exception("AddRange (3) test failed");
 
270
      } catch (ArgumentNullException) {
 
271
      }
236
272
      vect.RemoveRange(collectionSize, dvect.Count);
237
273
 
238
274
      // GetRange() test
239
275
      int rangeSize = 5;
240
 
      DoubleVector returnedVec = vect.GetRange(midCollection, rangeSize);
 
276
      DoubleVector returnedVec = vect.GetRange(0, 0);
 
277
      returnedVec = vect.GetRange(midCollection, rangeSize);
241
278
      if (returnedVec.Count != rangeSize)
242
279
        throw new Exception("GetRange test size failed");
243
280
      for (int i=0; i<rangeSize; i++) {
250
287
      } catch (ArgumentOutOfRangeException) {
251
288
      }
252
289
      try {
 
290
        vect.GetRange(0, -1);
 
291
        throw new Exception("GetRange count out of range (2) test failed");
 
292
      } catch (ArgumentOutOfRangeException) {
 
293
      }
 
294
      try {
253
295
        vect.GetRange(collectionSize+1, 0);
254
 
        throw new Exception("GetRange index out of range (2) test failed");
255
 
      } catch (ArgumentOutOfRangeException) {
 
296
        throw new Exception("GetRange index and count out of range (1) test failed");
 
297
      } catch (ArgumentException) {
 
298
      }
 
299
      try {
 
300
        vect.GetRange(0, collectionSize+1);
 
301
        throw new Exception("GetRange index and count out of range (2) test failed");
 
302
      } catch (ArgumentException) {
256
303
      }
257
304
      {
258
305
        StructVector inputvector = new StructVector();
353
400
    {
354
401
      // Capacity test
355
402
      try {
356
 
        DoubleVector dvv = new DoubleVector(-1);
 
403
        myDoubleVector = new DoubleVector(-1);
357
404
        throw new Exception("constructor setting capacity (1) test failed");
358
405
      } catch (ArgumentOutOfRangeException) {
359
406
      }
380
427
        throw new Exception("SetRange count check test failed");
381
428
      for (int i=0; i<collectionSize; i++) {
382
429
        if (vect[i] != dv[i])
383
 
          throw new Exception("SetRange test failed, index:" + i);
 
430
          throw new Exception("SetRange test (1) failed, index:" + i);
 
431
      }
 
432
      try {
 
433
        dv.SetRange(-1, vect);
 
434
        throw new Exception("SetRange test (2) failed");
 
435
      } catch (ArgumentOutOfRangeException) {
 
436
      }
 
437
      try {
 
438
        dv.SetRange(1, vect);
 
439
        throw new Exception("SetRange test (3) failed");
 
440
      } catch (ArgumentOutOfRangeException) {
 
441
      }
 
442
      try {
 
443
        vect.SetRange(0, null);
 
444
        throw new Exception("SetRange (4) test failed");
 
445
      } catch (ArgumentNullException) {
384
446
      }
385
447
 
386
448
      // Reverse() test
397
459
      dv.Reverse(0, 0); // should do nothing!
398
460
      for (int i=0; i<collectionSize; i++) {
399
461
        if (vect[i] != dv[i])
400
 
          throw new Exception("Reverse test (2) failed, index:" + i);
 
462
          throw new Exception("Reverse test (3) failed, index:" + i);
401
463
      }
402
464
      try {
403
465
        dv.Reverse(-1, 0);
404
 
        throw new Exception("Reverse test (3) failed");
 
466
        throw new Exception("Reverse test (4) failed");
 
467
      } catch (ArgumentOutOfRangeException) {
 
468
      }
 
469
      try {
 
470
        dv.Reverse(0, -1);
 
471
        throw new Exception("Reverse test (5) failed");
405
472
      } catch (ArgumentOutOfRangeException) {
406
473
      }
407
474
      try {
408
475
        dv.Reverse(collectionSize+1, 0);
409
 
        throw new Exception("Reverse test (4) failed");
410
 
      } catch (ArgumentOutOfRangeException) {
 
476
        throw new Exception("Reverse test (6) failed");
 
477
      } catch (ArgumentException) {
 
478
      }
 
479
      try {
 
480
        dv.Reverse(0, collectionSize+1);
 
481
        throw new Exception("Reverse test (7) failed");
 
482
      } catch (ArgumentException) {
411
483
      }
412
484
    }
413
485
 
434
506
      }
435
507
 
436
508
      double x = li_std_vector.average(iv);
437
 
      double y = li_std_vector.average( new IntVector( new int[] {1, 2, 3, 4} ) );
438
 
      RealVector a = li_std_vector.half( new RealVector( new float[] {10F, 10.5F, 11F, 11.5F} ) );
 
509
      x += li_std_vector.average( new IntVector( new int[] {1, 2, 3, 4} ) );
 
510
      myRealVector = li_std_vector.half( new RealVector( new float[] {10F, 10.5F, 11F, 11.5F} ) );
439
511
 
440
512
      DoubleVector dvec = new DoubleVector();
441
513
      for (int i=0; i<10; i++) {