Test itk.simple.Image.
| 6 | namespace itk.simple { |
| 7 | /// <summary>Test itk.simple.Image.</summary> |
| 8 | public class CSharpImageTest { |
| 9 | public const int ExitSuccess = 0; |
| 10 | public const int ExitFailure = 1; |
| 11 | |
| 12 | public static int CheckHash(Image img, string expectedHash, ref int success) |
| 13 | { |
| 14 | HashImageFilter hasher = new HashImageFilter(); |
| 15 | string actualHash = hasher.Execute(img); |
| 16 | if (actualHash != expectedHash) |
| 17 | { |
| 18 | success = ExitFailure; |
| 19 | Console.WriteLine("Expected hash: \"{0}\" actual hash: \"{1}\".", expectedHash, actualHash ); |
| 20 | } |
| 21 | return 0; |
| 22 | } |
| 23 | |
| 24 | /// <summary>Main entry point.</summary> |
| 25 | public static int Main (string[] args) { |
| 26 | int success = ExitSuccess; |
| 27 | try { |
| 28 | Image image = new Image(100, 100, PixelId.sitkInt8); |
| 29 | Image image2 = new Image(100, 100, PixelId.sitkInt8); |
| 30 | |
| 31 | |
| 32 | image += 10; |
| 33 | image -= 1; |
| 34 | CheckHash(image, "1cda91cc1bf474a25d6365f7fa7ef1fc75b3c7c9", ref success); |
| 35 | image *= 2; |
| 36 | image /= 3; |
| 37 | CheckHash(image, "856f68940ff670209aa9d60f38fc4cca1880f647", ref success); |
| 38 | |
| 39 | |
| 40 | // image with just one 7 reset zero |
| 41 | image *= 0; |
| 42 | VectorUInt32 idx = new VectorUInt32(); |
| 43 | idx.Add(0); |
| 44 | idx.Add(0); |
| 45 | image.SetPixelAsInt8( idx, 7 ); |
| 46 | |
| 47 | // Unary operators |
| 48 | CheckHash(-image, "fe7e0c8ac8252189cf5766a352397bc62dd42e4d", ref success); |
| 49 | CheckHash(+image, "6cccaa2d5c958e79ebd5ca4a0b00bee747797c8d", ref success); |
| 50 | CheckHash(!image, "f4695dbf5bc9ea2796b2e4f360ea4b5ecbf70c37", ref success); |
| 51 | CheckHash(~image, "746470f03126f653cc23265e0b1c1fe16a952745", ref success); |
| 52 | CheckHash(image, "6cccaa2d5c958e79ebd5ca4a0b00bee747797c8d", ref success); |
| 53 | |
| 54 | |
| 55 | // Comparison operators |
| 56 | CheckHash( image < 7, "f4695dbf5bc9ea2796b2e4f360ea4b5ecbf70c37", ref success); |
| 57 | CheckHash( image > 7, "f907b7bf318b79fd6b9da589646f8b1dac77d0c8", ref success); |
| 58 | CheckHash( image <= 7, "cef864600fc947062ac359fe9a7cc049c7273b8e", ref success); |
| 59 | CheckHash( image >= 7, "52f583bfeb07a6c4c5a26b28f8ae180bf8e0079b", ref success); |
| 60 | |
| 61 | CheckHash( image < image2, "f907b7bf318b79fd6b9da589646f8b1dac77d0c8", ref success); |
| 62 | CheckHash( image > image2, "52f583bfeb07a6c4c5a26b28f8ae180bf8e0079b", ref success); |
| 63 | CheckHash( image <= image2, "f4695dbf5bc9ea2796b2e4f360ea4b5ecbf70c37", ref success); |
| 64 | CheckHash( image >= image2, "cef864600fc947062ac359fe9a7cc049c7273b8e", ref success); |
| 65 |
nothing calls this directly
no outgoing calls
no test coverage detected