Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add unit tests for construction, erosion, and dilation

git-svn-id: http://simple-iphone-image-processing.googlecode.com/svn/trunk@5 f0a95276-1093-11de-b0d4-7fec019aa467
  • Loading branch information...
commit cea417279760192d822a8cecc11f06f8d8bd4abb 1 parent ddd6c38
awostenberg authored
170 ImageProcessing.xcodeproj/project.pbxproj
@@ -14,6 +14,14 @@
14 14 2892E4100DC94CBA00A64D0F /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2892E40F0DC94CBA00A64D0F /* CoreGraphics.framework */; };
15 15 2899E5600DE3E45000AC0155 /* RootViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2899E55F0DE3E45000AC0155 /* RootViewController.xib */; };
16 16 28C286E10D94DF7D0034E888 /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28C286E00D94DF7D0034E888 /* RootViewController.m */; };
  17 + 3808B6D20F7F60C8004A0F75 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
  18 + 3808B6D40F7F6122004A0F75 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3808B6D30F7F6122004A0F75 /* SenTestingKit.framework */; };
  19 + 3808B6DE0F7F616A004A0F75 /* TestImage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3808B6DD0F7F616A004A0F75 /* TestImage.mm */; };
  20 + 3808B6E10F7F6193004A0F75 /* r50g100b200.png in Resources */ = {isa = PBXBuildFile; fileRef = 3808B6E00F7F6193004A0F75 /* r50g100b200.png */; };
  21 + 3808B6E30F7F61AE004A0F75 /* elmo.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 3808B6E20F7F61AE004A0F75 /* elmo.jpg */; };
  22 + 3808B6E80F7F62BA004A0F75 /* Image.mm in Sources */ = {isa = PBXBuildFile; fileRef = 839D2F770F6BC9E2000E4323 /* Image.mm */; };
  23 + 3808B6EA0F7F62F0004A0F75 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
  24 + 3808B6EC0F7F630D004A0F75 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2892E40F0DC94CBA00A64D0F /* CoreGraphics.framework */; };
17 25 839D2F5F0F6BC914000E4323 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 839D2F5E0F6BC914000E4323 /* MainWindow.xib */; };
18 26 839D2F620F6BC940000E4323 /* ListBundleImagesViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 839D2F610F6BC940000E4323 /* ListBundleImagesViewController.mm */; };
19 27 839D2F650F6BC984000E4323 /* ResultViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 839D2F640F6BC984000E4323 /* ResultViewController.xib */; };
@@ -23,6 +31,16 @@
23 31 839D30210F6BCE03000E4323 /* ListBundleImagesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 839D30200F6BCE03000E4323 /* ListBundleImagesViewController.xib */; };
24 32 /* End PBXBuildFile section */
25 33
  34 +/* Begin PBXContainerItemProxy section */
  35 + 3808B6D50F7F6131004A0F75 /* PBXContainerItemProxy */ = {
  36 + isa = PBXContainerItemProxy;
  37 + containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
  38 + proxyType = 1;
  39 + remoteGlobalIDString = 3808B6CC0F7F60A1004A0F75 /* Unit Tests */;
  40 + remoteInfo = "Unit Tests";
  41 + };
  42 +/* End PBXContainerItemProxy section */
  43 +
26 44 /* Begin PBXFileReference section */
27 45 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
28 46 1D3623240D0F684500981E51 /* ImageProcessingAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageProcessingAppDelegate.h; sourceTree = "<group>"; };
@@ -35,6 +53,13 @@
35 53 28C286DF0D94DF7D0034E888 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = "<group>"; };
36 54 28C286E00D94DF7D0034E888 /* RootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootViewController.m; sourceTree = "<group>"; };
37 55 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
  56 + 3808B6CD0F7F60A1004A0F75 /* Unit Tests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Unit Tests.octest"; sourceTree = BUILT_PRODUCTS_DIR; };
  57 + 3808B6CE0F7F60A1004A0F75 /* Unit Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Unit Tests-Info.plist"; sourceTree = "<group>"; };
  58 + 3808B6D30F7F6122004A0F75 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Developer/Library/Frameworks/SenTestingKit.framework; sourceTree = SDKROOT; };
  59 + 3808B6DD0F7F616A004A0F75 /* TestImage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestImage.mm; sourceTree = "<group>"; };
  60 + 3808B6DF0F7F6179004A0F75 /* TestImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestImage.h; sourceTree = "<group>"; };
  61 + 3808B6E00F7F6193004A0F75 /* r50g100b200.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = r50g100b200.png; sourceTree = "<group>"; };
  62 + 3808B6E20F7F61AE004A0F75 /* elmo.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; name = elmo.jpg; path = "../Documents/simple-iphone-image-processing-read-only/elmo.jpg"; sourceTree = SOURCE_ROOT; };
38 63 839D2F5E0F6BC914000E4323 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = "<group>"; };
39 64 839D2F600F6BC940000E4323 /* ListBundleImagesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListBundleImagesViewController.h; sourceTree = "<group>"; };
40 65 839D2F610F6BC940000E4323 /* ListBundleImagesViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ListBundleImagesViewController.mm; sourceTree = "<group>"; };
@@ -59,6 +84,17 @@
59 84 );
60 85 runOnlyForDeploymentPostprocessing = 0;
61 86 };
  87 + 3808B6CA0F7F60A1004A0F75 /* Frameworks */ = {
  88 + isa = PBXFrameworksBuildPhase;
  89 + buildActionMask = 2147483647;
  90 + files = (
  91 + 3808B6D20F7F60C8004A0F75 /* Foundation.framework in Frameworks */,
  92 + 3808B6D40F7F6122004A0F75 /* SenTestingKit.framework in Frameworks */,
  93 + 3808B6EA0F7F62F0004A0F75 /* UIKit.framework in Frameworks */,
  94 + 3808B6EC0F7F630D004A0F75 /* CoreGraphics.framework in Frameworks */,
  95 + );
  96 + runOnlyForDeploymentPostprocessing = 0;
  97 + };
62 98 /* End PBXFrameworksBuildPhase section */
63 99
64 100 /* Begin PBXGroup section */
@@ -83,6 +119,7 @@
83 119 isa = PBXGroup;
84 120 children = (
85 121 1D6058910D05DD3D006BFB54 /* ImageProcessing.app */,
  122 + 3808B6CD0F7F60A1004A0F75 /* Unit Tests.octest */,
86 123 );
87 124 name = Products;
88 125 sourceTree = "<group>";
@@ -90,11 +127,13 @@
90 127 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
91 128 isa = PBXGroup;
92 129 children = (
  130 + 3808B6DA0F7F614E004A0F75 /* Test Cases */,
93 131 080E96DDFE201D6D7F000001 /* Classes */,
94 132 29B97315FDCFA39411CA2CEA /* Other Sources */,
95 133 29B97317FDCFA39411CA2CEA /* Resources */,
96 134 29B97323FDCFA39411CA2CEA /* Frameworks */,
97 135 19C28FACFE9D520D11CA2CBB /* Products */,
  136 + 3808B6CE0F7F60A1004A0F75 /* Unit Tests-Info.plist */,
98 137 );
99 138 name = CustomTemplate;
100 139 sourceTree = "<group>";
@@ -111,6 +150,8 @@
111 150 29B97317FDCFA39411CA2CEA /* Resources */ = {
112 151 isa = PBXGroup;
113 152 children = (
  153 + 3808B6E20F7F61AE004A0F75 /* elmo.jpg */,
  154 + 3808B6E00F7F6193004A0F75 /* r50g100b200.png */,
114 155 839D2FD30F6BCC13000E4323 /* me.jpg */,
115 156 839D2F640F6BC984000E4323 /* ResultViewController.xib */,
116 157 839D2F5E0F6BC914000E4323 /* MainWindow.xib */,
@@ -124,6 +165,7 @@
124 165 29B97323FDCFA39411CA2CEA /* Frameworks */ = {
125 166 isa = PBXGroup;
126 167 children = (
  168 + 3808B6D30F7F6122004A0F75 /* SenTestingKit.framework */,
127 169 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */,
128 170 1D30AB110D05D00D00671497 /* Foundation.framework */,
129 171 2892E40F0DC94CBA00A64D0F /* CoreGraphics.framework */,
@@ -131,6 +173,15 @@
131 173 name = Frameworks;
132 174 sourceTree = "<group>";
133 175 };
  176 + 3808B6DA0F7F614E004A0F75 /* Test Cases */ = {
  177 + isa = PBXGroup;
  178 + children = (
  179 + 3808B6DF0F7F6179004A0F75 /* TestImage.h */,
  180 + 3808B6DD0F7F616A004A0F75 /* TestImage.mm */,
  181 + );
  182 + name = "Test Cases";
  183 + sourceTree = "<group>";
  184 + };
134 185 /* End PBXGroup section */
135 186
136 187 /* Begin PBXNativeTarget section */
@@ -145,12 +196,31 @@
145 196 buildRules = (
146 197 );
147 198 dependencies = (
  199 + 3808B6D60F7F6131004A0F75 /* PBXTargetDependency */,
148 200 );
149 201 name = ImageProcessing;
150 202 productName = ImageProcessing;
151 203 productReference = 1D6058910D05DD3D006BFB54 /* ImageProcessing.app */;
152 204 productType = "com.apple.product-type.application";
153 205 };
  206 + 3808B6CC0F7F60A1004A0F75 /* Unit Tests */ = {
  207 + isa = PBXNativeTarget;
  208 + buildConfigurationList = 3808B6D10F7F60A2004A0F75 /* Build configuration list for PBXNativeTarget "Unit Tests" */;
  209 + buildPhases = (
  210 + 3808B6C80F7F60A1004A0F75 /* Resources */,
  211 + 3808B6C90F7F60A1004A0F75 /* Sources */,
  212 + 3808B6CA0F7F60A1004A0F75 /* Frameworks */,
  213 + 3808B6CB0F7F60A1004A0F75 /* ShellScript */,
  214 + );
  215 + buildRules = (
  216 + );
  217 + dependencies = (
  218 + );
  219 + name = "Unit Tests";
  220 + productName = "Unit Tests";
  221 + productReference = 3808B6CD0F7F60A1004A0F75 /* Unit Tests.octest */;
  222 + productType = "com.apple.product-type.bundle";
  223 + };
154 224 /* End PBXNativeTarget section */
155 225
156 226 /* Begin PBXProject section */
@@ -171,6 +241,7 @@
171 241 projectRoot = "";
172 242 targets = (
173 243 1D6058900D05DD3D006BFB54 /* ImageProcessing */,
  244 + 3808B6CC0F7F60A1004A0F75 /* Unit Tests */,
174 245 );
175 246 };
176 247 /* End PBXProject section */
@@ -185,11 +256,36 @@
185 256 839D2F650F6BC984000E4323 /* ResultViewController.xib in Resources */,
186 257 839D2FD40F6BCC13000E4323 /* me.jpg in Resources */,
187 258 839D30210F6BCE03000E4323 /* ListBundleImagesViewController.xib in Resources */,
  259 + 3808B6E30F7F61AE004A0F75 /* elmo.jpg in Resources */,
  260 + );
  261 + runOnlyForDeploymentPostprocessing = 0;
  262 + };
  263 + 3808B6C80F7F60A1004A0F75 /* Resources */ = {
  264 + isa = PBXResourcesBuildPhase;
  265 + buildActionMask = 2147483647;
  266 + files = (
  267 + 3808B6E10F7F6193004A0F75 /* r50g100b200.png in Resources */,
188 268 );
189 269 runOnlyForDeploymentPostprocessing = 0;
190 270 };
191 271 /* End PBXResourcesBuildPhase section */
192 272
  273 +/* Begin PBXShellScriptBuildPhase section */
  274 + 3808B6CB0F7F60A1004A0F75 /* ShellScript */ = {
  275 + isa = PBXShellScriptBuildPhase;
  276 + buildActionMask = 2147483647;
  277 + files = (
  278 + );
  279 + inputPaths = (
  280 + );
  281 + outputPaths = (
  282 + );
  283 + runOnlyForDeploymentPostprocessing = 0;
  284 + shellPath = /bin/sh;
  285 + shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n";
  286 + };
  287 +/* End PBXShellScriptBuildPhase section */
  288 +
193 289 /* Begin PBXSourcesBuildPhase section */
194 290 1D60588E0D05DD3D006BFB54 /* Sources */ = {
195 291 isa = PBXSourcesBuildPhase;
@@ -204,8 +300,25 @@
204 300 );
205 301 runOnlyForDeploymentPostprocessing = 0;
206 302 };
  303 + 3808B6C90F7F60A1004A0F75 /* Sources */ = {
  304 + isa = PBXSourcesBuildPhase;
  305 + buildActionMask = 2147483647;
  306 + files = (
  307 + 3808B6DE0F7F616A004A0F75 /* TestImage.mm in Sources */,
  308 + 3808B6E80F7F62BA004A0F75 /* Image.mm in Sources */,
  309 + );
  310 + runOnlyForDeploymentPostprocessing = 0;
  311 + };
207 312 /* End PBXSourcesBuildPhase section */
208 313
  314 +/* Begin PBXTargetDependency section */
  315 + 3808B6D60F7F6131004A0F75 /* PBXTargetDependency */ = {
  316 + isa = PBXTargetDependency;
  317 + target = 3808B6CC0F7F60A1004A0F75 /* Unit Tests */;
  318 + targetProxy = 3808B6D50F7F6131004A0F75 /* PBXContainerItemProxy */;
  319 + };
  320 +/* End PBXTargetDependency section */
  321 +
209 322 /* Begin XCBuildConfiguration section */
210 323 1D6058940D05DD3E006BFB54 /* Debug */ = {
211 324 isa = XCBuildConfiguration;
@@ -233,6 +346,54 @@
233 346 };
234 347 name = Release;
235 348 };
  349 + 3808B6CF0F7F60A2004A0F75 /* Debug */ = {
  350 + isa = XCBuildConfiguration;
  351 + buildSettings = {
  352 + ALWAYS_SEARCH_USER_PATHS = NO;
  353 + COPY_PHASE_STRIP = NO;
  354 + FRAMEWORK_SEARCH_PATHS = (
  355 + "$(DEVELOPER_LIBRARY_DIR)/Frameworks",
  356 + "\"$(SDKROOT)$(DEVELOPER_FRAMEWORKS_DIR)\"",
  357 + );
  358 + INFOPLIST_FILE = "Unit Tests-Info.plist";
  359 + INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles";
  360 + OTHER_LDFLAGS = "";
  361 + PREBINDING = NO;
  362 + PRODUCT_NAME = "Unit Tests";
  363 + WRAPPER_EXTENSION = octest;
  364 + };
  365 + name = Debug;
  366 + };
  367 + 3808B6D00F7F60A2004A0F75 /* Release */ = {
  368 + isa = XCBuildConfiguration;
  369 + buildSettings = {
  370 + ALWAYS_SEARCH_USER_PATHS = NO;
  371 + COPY_PHASE_STRIP = YES;
  372 + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
  373 + FRAMEWORK_SEARCH_PATHS = (
  374 + "$(DEVELOPER_LIBRARY_DIR)/Frameworks",
  375 + "\"$(SDKROOT)$(DEVELOPER_FRAMEWORKS_DIR)\"",
  376 + );
  377 + GCC_ENABLE_FIX_AND_CONTINUE = NO;
  378 + GCC_ENABLE_OBJC_EXCEPTIONS = YES;
  379 + GCC_MODEL_TUNING = G5;
  380 + GCC_PRECOMPILE_PREFIX_HEADER = YES;
  381 + GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h";
  382 + INFOPLIST_FILE = "Unit Tests-Info.plist";
  383 + INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles";
  384 + OTHER_LDFLAGS = (
  385 + "-framework",
  386 + Cocoa,
  387 + "-framework",
  388 + SenTestingKit,
  389 + );
  390 + PREBINDING = NO;
  391 + PRODUCT_NAME = "Unit Tests";
  392 + WRAPPER_EXTENSION = octest;
  393 + ZERO_LINK = NO;
  394 + };
  395 + name = Release;
  396 + };
236 397 C01FCF4F08A954540054247B /* Debug */ = {
237 398 isa = XCBuildConfiguration;
238 399 buildSettings = {
@@ -272,6 +433,15 @@
272 433 defaultConfigurationIsVisible = 0;
273 434 defaultConfigurationName = Release;
274 435 };
  436 + 3808B6D10F7F60A2004A0F75 /* Build configuration list for PBXNativeTarget "Unit Tests" */ = {
  437 + isa = XCConfigurationList;
  438 + buildConfigurations = (
  439 + 3808B6CF0F7F60A2004A0F75 /* Debug */,
  440 + 3808B6D00F7F60A2004A0F75 /* Release */,
  441 + );
  442 + defaultConfigurationIsVisible = 0;
  443 + defaultConfigurationName = Release;
  444 + };
275 445 C01FCF4E08A954540054247B /* Build configuration list for PBXProject "ImageProcessing" */ = {
276 446 isa = XCConfigurationList;
277 447 buildConfigurations = (
15 TestImage.h
... ... @@ -0,0 +1,15 @@
  1 +//
  2 +// TestImage.h
  3 +//
  4 +// Created by Alan Wostenberg on 3/26/09.
  5 +// Copyright 2009 Wosterware.com. All rights reserved.
  6 +//
  7 +
  8 +#import <SenTestingKit/SenTestingKit.h>
  9 +
  10 +
  11 +@interface TestImage : SenTestCase {
  12 +
  13 +}
  14 +
  15 +@end
110 TestImage.mm
... ... @@ -0,0 +1,110 @@
  1 +//
  2 +// TestImage.mm
  3 +//
  4 +// Created by Alan Wostenberg on 3/26/09.
  5 +// Copyright 2009 Wosterware.com. All rights reserved.
  6 +//
  7 +// To add OCUnit on which this depends to an Xcode project,
  8 +// see http://www.sente.ch/s/?p=535&lang=en and http://developer.apple.com/tools/unittest.html
  9 +
  10 +#import "TestImage.h"
  11 +// the image.h is a mix of Objective C and C++
  12 +#import "Image.h"
  13 +
  14 +@implementation TestImage
  15 +
  16 +// constructors
  17 +
  18 +- (void)testEmptyImageDimensions {
  19 + ImageWrapper* im = Image::createImage(10,20);
  20 +
  21 + STAssertEquals(10, im.image->getWidth(), @"");
  22 + STAssertEquals(20, im.image->getHeight(), @"");
  23 +}
  24 +
  25 +- (void)testFromBytes {
  26 + uint8_t imData[6] = {1,2,
  27 + 3,4,
  28 + 5,6};
  29 + ImageWrapper* im = Image::createImage(imData,2,3);
  30 +
  31 + STAssertEquals(2, im.image->getWidth(), @"");
  32 + STAssertEquals(3, im.image->getHeight(), @"");
  33 + STAssertTrue(im.image->atRow(0) == imData, @"");
  34 + //STAssertEquals(im.image->rowAt(0), imData, @"");
  35 + STAssertEquals(im.image->atXY(0,0), 1, @"");
  36 + STAssertEquals(im.image->atXY(1,0), 2, @"");
  37 + STAssertEquals(im.image->atXY(0,1), 3, @"");
  38 +}
  39 +
  40 +
  41 +// greyscale conversion from a tiny image
  42 +
  43 +- (void)testFromUIImage {
  44 + // The image is of uniform color who's value is encoded in the filename.
  45 + // The name r50g100b200 means red channel is 50, green is 100, blue is 200.
  46 + UIImage* uim = [UIImage imageWithContentsOfFile: @"r50g100b200.png"];
  47 +
  48 + ImageWrapper* im = Image::createImage(uim,uim.size.width,uim.size.height);
  49 + STAssertEquals(im.image->getWidth(),30,@"");
  50 + STAssertEquals(im.image->getHeight(),40,@"");
  51 +
  52 + //default uses green channel, which in the sample image, is 100
  53 + STAssertEquals(im.image->atXY(1,1), 100, @"");
  54 +
  55 + //all channels averaged to grey
  56 + im = Image::createImage(uim,uim.size.width,uim.size.height,false,Image::kRed|Image::kGreen|Image::kBlue);
  57 + STAssertEquals(im.image->atXY(1,1), (50 + 100 + 200) / 3, @"");
  58 +
  59 + //red-green averaged to grey
  60 + im = Image::createImage(uim,uim.size.width,uim.size.height,false,Image::kRed|Image::kGreen);
  61 + STAssertEquals(im.image->atXY(1,1), (50+100)/2, @"");
  62 +}
  63 +
  64 +
  65 +// inverting
  66 +- (void)testInvert {
  67 + uint8_t imData[2] = {0, 255};
  68 + ImageWrapper* im = Image::createImage(imData,2,1);
  69 + im.image->invert();
  70 + STAssertEquals(im.image->atXY(0,0), 255, @"");
  71 + STAssertEquals(im.image->atXY(1,0), 0, @"");
  72 +}
  73 +
  74 +// binary erosion
  75 +// Sample data uses ranges of numbers for test readability. Real world values are 0 or 255.
  76 +- (void)testErodeKeepsCentralPixel {
  77 + uint8_t imData[9] = { 1,2,3, 4,5,6, 7,8,9};
  78 + ImageWrapper* a = Image::createImage(imData,3,3);
  79 +
  80 + ImageWrapper* b = a.image->erode();
  81 + STAssertEquals(b.image->atXY(0,0), 1, @"");
  82 + STAssertEquals(b.image->atXY(1,1), 5, @"");
  83 + STAssertEquals(b.image->atXY(2,2), 9, @"");
  84 +}
  85 +
  86 +- (void)testErodeZerosCentralPixel {
  87 + uint8_t imData[9] = {0,2,3, 4,5,6, 7,8,9};
  88 + ImageWrapper* a = Image::createImage(imData,3,3);
  89 + ImageWrapper* b = a.image->erode();
  90 + STAssertEquals(b.image->atXY(0,0), 0, @"");
  91 + STAssertEquals(b.image->atXY(1,1), 0, @"");
  92 + STAssertEquals(b.image->atXY(2,2), 9, @"");
  93 +
  94 + STAssertEquals(a.image->atXY(1,1), 5, @"");
  95 +}
  96 +
  97 +// binary dilation
  98 +- (void)testDilate {
  99 + uint8_t imData[9] = {1,0,0, 0,0,0, 0,0,0};
  100 + ImageWrapper* a = Image::createImage(imData,3,3);
  101 +
  102 + ImageWrapper* b = a.image->dilate();
  103 + STAssertEquals(b.image->atXY(0,0), 1, @"");
  104 + STAssertEquals(b.image->atXY(1,1), 255, @"");
  105 + STAssertEquals(b.image->atXY(2,2), 0, @"");
  106 +}
  107 +
  108 +
  109 +
  110 +@end
20 Unit Tests-Info.plist
... ... @@ -0,0 +1,20 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3 +<plist version="1.0">
  4 +<dict>
  5 + <key>CFBundleDevelopmentRegion</key>
  6 + <string>English</string>
  7 + <key>CFBundleExecutable</key>
  8 + <string>${EXECUTABLE_NAME}</string>
  9 + <key>CFBundleIdentifier</key>
  10 + <string>com.yourcompany.${PRODUCT_NAME:identifier}</string>
  11 + <key>CFBundleInfoDictionaryVersion</key>
  12 + <string>6.0</string>
  13 + <key>CFBundlePackageType</key>
  14 + <string>BNDL</string>
  15 + <key>CFBundleSignature</key>
  16 + <string>????</string>
  17 + <key>CFBundleVersion</key>
  18 + <string>1.0</string>
  19 +</dict>
  20 +</plist>
BIN  r50g100b200.png

0 comments on commit cea4172

Please sign in to comment.
Something went wrong with that request. Please try again.