From 583686e8d3fad184868d69572dde55744c28ff41 Mon Sep 17 00:00:00 2001 From: David Hart Date: Sat, 7 Jan 2017 19:20:26 +0100 Subject: [PATCH 1/6] trying to fix and test bugs introduced with the yogakit improvements --- YogaKit/Tests/YogaKitTests.m | 15 +++++++-- YogaKit/YGLayout.m | 63 ++++++++++++++++++------------------ 2 files changed, 44 insertions(+), 34 deletions(-) diff --git a/YogaKit/Tests/YogaKitTests.m b/YogaKit/Tests/YogaKitTests.m index 79f7043c..f77cd0c1 100644 --- a/YogaKit/Tests/YogaKitTests.m +++ b/YogaKit/Tests/YogaKitTests.m @@ -8,8 +8,8 @@ */ #import - #import +#import @interface YogaKitTests : XCTestCase @end @@ -50,7 +50,7 @@ #endif -- (void)testUsesYoga +- (void)testIsEnabled { UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; XCTAssertFalse(view.yoga.isEnabled); @@ -384,4 +384,15 @@ [container.yoga applyLayout]; } +- (void)testPositionalPropertiesWork +{ + YGNodeRef node = YGNodeNew(); + YGNodeStyleSetPosition(node, YGEdgeLeft, 1); + + XCTAssertEqual(1, YGNodeStyleGetPosition(node, YGEdgeLeft).value); + XCTAssertEqual(YGUnitPixel, YGNodeStyleGetPosition(node, YGEdgeLeft).unit); + + YGNodeFree(node); +} + @end diff --git a/YogaKit/YGLayout.m b/YogaKit/YGLayout.m index d6a2baf0..c7f25136 100644 --- a/YogaKit/YGLayout.m +++ b/YogaKit/YGLayout.m @@ -9,7 +9,6 @@ #import "YGLayout+Private.h" #import "UIView+Yoga.h" -#import #define YG_STYLE_PROPERTY_IMPL(type, lowercased_name, capitalized_name) \ - (type)lowercased_name \ @@ -47,37 +46,36 @@ YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \ } -#define YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, edge, edge_suffix) \ -- (CGFloat)lowercased_name##edge_suffix \ -{ \ - YGValue value = YGNodeStyleGet##capitalized_name(self.node, edge); \ - if (value.unit == YGUnitPixel) { \ - return value.value; \ - } else { \ - return YGUndefined; \ - } \ -} \ - \ -- (void)set##capitalized_name##edge_suffix:(CGFloat)lowercased_name \ -{ \ - YGNodeStyleSet##capitalized_name(self.node, edge, lowercased_name); \ +#define YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(objc_lowercased_name, objc_capitalized_name, c_name, edge) \ +- (CGFloat)objc_lowercased_name \ +{ \ + YGValue value = YGNodeStyleGet##c_name(self.node, edge); \ + if (value.unit == YGUnitPixel) { \ + return value.value; \ + } else { \ + return YGUndefined; \ + } \ +} \ + \ +- (void)set##objc_capitalized_name:(CGFloat)objc_lowercased_name \ +{ \ + YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name); \ } -#define YG_STYLE_ALL_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeLeft, Left) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeTop, Top) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeRight, Right) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeBottom, Bottom) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeStart, Start) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeEnd, End) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeHorizontal, Horizontal) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeVertical, Vertical) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeAll, ) +#define YG_STYLE_ALL_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name) \ +YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name##Left, capitalized_name##Left, capitalized_name, YGEdgeLeft) \ +YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name##Top, capitalized_name##Top, capitalized_name, YGEdgeTop) \ +YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name##Right, capitalized_name##Right, capitalized_name, YGEdgeRight) \ +YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name##Bottom, capitalized_name##Bottom, capitalized_name, YGEdgeBottom) \ +YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name##Start, capitalized_name##Start, capitalized_name, YGEdgeStart) \ +YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name##End, capitalized_name##End, capitalized_name, YGEdgeEnd) \ +YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name##Horizontal, capitalized_name##Horizontal, capitalized_name, YGEdgeHorizontal) \ +YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name##Vertical, capitalized_name##Vertical, capitalized_name, YGEdgeVertical) \ +YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, capitalized_name, YGEdgeAll) @interface YGLayout () @property (nonatomic, weak, readonly) UIView *view; -@property (nonatomic, assign, readonly) YGNodeRef node; @end @@ -85,6 +83,7 @@ YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, YGEdgeAll, ) @synthesize isEnabled=_isEnabled; @synthesize isIncludedInLayout=_isIncludedInLayout; +@synthesize node=_node; + (void)initialize { @@ -161,12 +160,12 @@ YG_STYLE_PROPERTY_IMPL(CGFloat, flexGrow, FlexGrow) YG_STYLE_PROPERTY_IMPL(CGFloat, flexShrink, FlexShrink) YG_STYLE_VALUE_PROPERTY_IMPL(flexBasis, FlexBasis) -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(position, Position, YGEdgeLeft, Left) -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(position, Position, YGEdgeTop, Top) -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(position, Position, YGEdgeRight, Right) -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(position, Position, YGEdgeBottom, Bottom) -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(position, Position, YGEdgeStart, Start) -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(position, Position, YGEdgeEnd, End) +YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(left, Left, Position, YGEdgeLeft) +YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(top, Top, Position, YGEdgeTop) +YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(right, Right, Position, YGEdgeRight) +YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(bottom, Bottom, Position, YGEdgeBottom) +YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(start, Start, Position, YGEdgeStart) +YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(end, End, Position, YGEdgeEnd) YG_STYLE_ALL_EDGE_PROPERTY_UNIT_IMPL(margin, Margin) YG_STYLE_ALL_EDGE_PROPERTY_UNIT_IMPL(padding, Padding) -- 2.50.1.windows.1 From 4be987c603408e188987e9e55898d89272723422 Mon Sep 17 00:00:00 2001 From: David Hart Date: Sat, 7 Jan 2017 20:47:14 +0100 Subject: [PATCH 2/6] missing files --- YogaKit/YGLayout+Private.h | 5 +- .../YogaKitSample.xcodeproj/project.pbxproj | 119 +++++++++++++++++- 2 files changed, 119 insertions(+), 5 deletions(-) diff --git a/YogaKit/YGLayout+Private.h b/YogaKit/YGLayout+Private.h index 15232b7e..7113b4c5 100644 --- a/YogaKit/YGLayout+Private.h +++ b/YogaKit/YGLayout+Private.h @@ -8,8 +8,11 @@ */ #import "YGLayout.h" +#import -@interface YGLayout (Private) +@interface YGLayout () + +@property (nonatomic, assign, readonly) YGNodeRef node; - (instancetype)initWithView:(UIView *)view; diff --git a/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.pbxproj b/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.pbxproj index eed408a6..11afe6ff 100644 --- a/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.pbxproj +++ b/YogaKit/YogaKitSample/YogaKitSample.xcodeproj/project.pbxproj @@ -21,10 +21,20 @@ 13687D851DF87D1E00E7C260 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D841DF87D1E00E7C260 /* UIKit.framework */; }; 13687D871DF87D2400E7C260 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D861DF87D2400E7C260 /* Foundation.framework */; }; 638A94431E1EF5D000A726AD /* YGLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 638A94411E1EF5D000A726AD /* YGLayout.m */; }; - 638A94451E1EF8A900A726AD /* YGValue.h in yoga */ = {isa = PBXBuildFile; fileRef = 638A94441E1EF89C00A726AD /* YGValue.h */; }; 638A94481E1F06D100A726AD /* SwiftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 638A94471E1F06D100A726AD /* SwiftViewController.swift */; }; + 638A945A1E215CD400A726AD /* YogaKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 638A94591E215CD400A726AD /* YogaKitTests.m */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + 638A94541E215CC800A726AD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 13687D3B1DF8748300E7C260 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 13687D421DF8748300E7C260; + remoteInfo = YogaKitSample; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXCopyFilesBuildPhase section */ 13687D771DF878A000E7C260 /* yoga */ = { isa = PBXCopyFilesBuildPhase; @@ -32,7 +42,6 @@ dstPath = include/yoga; dstSubfolderSpec = 16; files = ( - 638A94451E1EF8A900A726AD /* YGValue.h in yoga */, 13687D781DF878C600E7C260 /* YGEnums.h in yoga */, 13687D791DF878C600E7C260 /* YGMacros.h in yoga */, 13687D7A1DF878C600E7C260 /* Yoga.h in yoga */, @@ -75,9 +84,11 @@ 638A94401E1EF5D000A726AD /* YGLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGLayout.h; sourceTree = ""; }; 638A94411E1EF5D000A726AD /* YGLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YGLayout.m; sourceTree = ""; }; 638A94421E1EF5D000A726AD /* YGLayout+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "YGLayout+Private.h"; sourceTree = ""; }; - 638A94441E1EF89C00A726AD /* YGValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGValue.h; sourceTree = ""; }; 638A94461E1F06D100A726AD /* YogaKitSample-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "YogaKitSample-Bridging-Header.h"; sourceTree = ""; }; 638A94471E1F06D100A726AD /* SwiftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftViewController.swift; sourceTree = ""; }; + 638A944F1E215CC800A726AD /* YogaKitSampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YogaKitSampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 638A94531E215CC800A726AD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 638A94591E215CD400A726AD /* YogaKitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = YogaKitTests.m; path = ../../Tests/YogaKitTests.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -90,6 +101,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 638A944C1E215CC800A726AD /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -99,6 +117,7 @@ 13687D5D1DF8778F00E7C260 /* yoga */, 13687D641DF8778F00E7C260 /* YogaKit */, 13687D451DF8748400E7C260 /* YogaKitSample */, + 638A94501E215CC800A726AD /* YogaKitSampleTests */, 13687D441DF8748400E7C260 /* Products */, 13687D831DF87D1E00E7C260 /* Frameworks */, ); @@ -108,6 +127,7 @@ isa = PBXGroup; children = ( 13687D431DF8748400E7C260 /* YogaKitSample.app */, + 638A944F1E215CC800A726AD /* YogaKitSampleTests.xctest */, ); name = Products; sourceTree = ""; @@ -139,7 +159,6 @@ 13687D5D1DF8778F00E7C260 /* yoga */ = { isa = PBXGroup; children = ( - 638A94441E1EF89C00A726AD /* YGValue.h */, 13687D5E1DF8778F00E7C260 /* YGEnums.h */, 13687D5F1DF8778F00E7C260 /* YGMacros.h */, 13687D601DF8778F00E7C260 /* YGNodeList.c */, @@ -173,6 +192,15 @@ name = Frameworks; sourceTree = ""; }; + 638A94501E215CC800A726AD /* YogaKitSampleTests */ = { + isa = PBXGroup; + children = ( + 638A94591E215CD400A726AD /* YogaKitTests.m */, + 638A94531E215CC800A726AD /* Info.plist */, + ); + path = YogaKitSampleTests; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -195,6 +223,24 @@ productReference = 13687D431DF8748400E7C260 /* YogaKitSample.app */; productType = "com.apple.product-type.application"; }; + 638A944E1E215CC800A726AD /* YogaKitSampleTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 638A94561E215CC800A726AD /* Build configuration list for PBXNativeTarget "YogaKitSampleTests" */; + buildPhases = ( + 638A944B1E215CC800A726AD /* Sources */, + 638A944C1E215CC800A726AD /* Frameworks */, + 638A944D1E215CC800A726AD /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 638A94551E215CC800A726AD /* PBXTargetDependency */, + ); + name = YogaKitSampleTests; + productName = YogaKitSampleTests; + productReference = 638A944F1E215CC800A726AD /* YogaKitSampleTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -209,6 +255,11 @@ LastSwiftMigration = 0820; ProvisioningStyle = Automatic; }; + 638A944E1E215CC800A726AD = { + CreatedOnToolsVersion = 8.2.1; + ProvisioningStyle = Automatic; + TestTargetID = 13687D421DF8748300E7C260; + }; }; }; buildConfigurationList = 13687D3E1DF8748300E7C260 /* Build configuration list for PBXProject "YogaKitSample" */; @@ -225,6 +276,7 @@ projectRoot = ""; targets = ( 13687D421DF8748300E7C260 /* YogaKitSample */, + 638A944E1E215CC800A726AD /* YogaKitSampleTests */, ); }; /* End PBXProject section */ @@ -238,6 +290,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 638A944D1E215CC800A726AD /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -256,8 +315,24 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 638A944B1E215CC800A726AD /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 638A945A1E215CD400A726AD /* YogaKitTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 638A94551E215CC800A726AD /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 13687D421DF8748300E7C260 /* YogaKitSample */; + targetProxy = 638A94541E215CC800A726AD /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin XCBuildConfiguration section */ 13687D581DF8748400E7C260 /* Debug */ = { isa = XCBuildConfiguration; @@ -378,6 +453,34 @@ }; name = Release; }; + 638A94571E215CC800A726AD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + INFOPLIST_FILE = YogaKitSampleTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSampleTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YogaKitSample.app/YogaKitSample"; + }; + name = Debug; + }; + 638A94581E215CC800A726AD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + INFOPLIST_FILE = YogaKitSampleTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSampleTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YogaKitSample.app/YogaKitSample"; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -399,6 +502,14 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 638A94561E215CC800A726AD /* Build configuration list for PBXNativeTarget "YogaKitSampleTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 638A94571E215CC800A726AD /* Debug */, + 638A94581E215CC800A726AD /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; /* End XCConfigurationList section */ }; rootObject = 13687D3B1DF8748300E7C260 /* Project object */; -- 2.50.1.windows.1 From 468191e160c03505bc8d485b7903c5fa1c389b2c Mon Sep 17 00:00:00 2001 From: David Hart Date: Mon, 9 Jan 2017 22:55:08 +0100 Subject: [PATCH 3/6] fixed the remaining bugs but had to modify Yoga.c --- YogaKit/Tests/YogaKitTests.m | 168 +++++++++++++++++++++++++++++++++-- tests/YGEdgeTest.cpp | 51 +++++++++++ yoga/Yoga.c | 2 - 3 files changed, 214 insertions(+), 7 deletions(-) diff --git a/YogaKit/Tests/YogaKitTests.m b/YogaKit/Tests/YogaKitTests.m index f77cd0c1..15112b9c 100644 --- a/YogaKit/Tests/YogaKitTests.m +++ b/YogaKit/Tests/YogaKitTests.m @@ -9,6 +9,7 @@ #import #import +#import #import @interface YogaKitTests : XCTestCase @@ -386,13 +387,170 @@ - (void)testPositionalPropertiesWork { - YGNodeRef node = YGNodeNew(); - YGNodeStyleSetPosition(node, YGEdgeLeft, 1); + UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; - XCTAssertEqual(1, YGNodeStyleGetPosition(node, YGEdgeLeft).value); - XCTAssertEqual(YGUnitPixel, YGNodeStyleGetPosition(node, YGEdgeLeft).unit); + view.yoga.left = 1; + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeLeft).value, 1); + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.left, 1); - YGNodeFree(node); + view.yoga.right = 2; + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeRight).value, 2); + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeRight).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.right, 2); + + view.yoga.top = 3; + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeTop).value, 3); + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.top, 3); + + view.yoga.bottom = 4; + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeBottom).value, 4); + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.bottom, 4); + + view.yoga.start = 5; + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeStart).value, 5); + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeStart).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.start, 5); + + view.yoga.end = 6; + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeEnd).value, 6); + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.end, 6); +} + +- (void)testMarginPropertiesWork +{ + UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; + + view.yoga.marginLeft = 1; + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).value, 1); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginLeft, 1); + + view.yoga.marginRight = 2; + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).value, 2); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginRight, 2); + + view.yoga.marginTop = 3; + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).value, 3); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginTop, 3); + + view.yoga.marginBottom = 4; + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).value, 4); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginBottom, 4); + + view.yoga.marginStart = 5; + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).value, 5); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginStart, 5); + + view.yoga.marginEnd = 6; + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).value, 6); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginEnd, 6); + + view.yoga.marginHorizontal = 7; + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeHorizontal).value, 7); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeHorizontal).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginHorizontal, 7); + + view.yoga.marginVertical = 8; + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeVertical).value, 8); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeVertical).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginVertical, 8); + + view.yoga.margin = 9; + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeAll).value, 9); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeAll).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.margin, 9); +} + +- (void)testPaddingPropertiesWork +{ + UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; + + view.yoga.paddingLeft = 1; + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).value, 1); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingLeft, 1); + + view.yoga.paddingRight = 2; + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).value, 2); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingRight, 2); + + view.yoga.paddingTop = 3; + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).value, 3); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingTop, 3); + + view.yoga.paddingBottom = 4; + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).value, 4); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingBottom, 4); + + view.yoga.paddingStart = 5; + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).value, 5); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingStart, 5); + + view.yoga.paddingEnd = 6; + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).value, 6); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingEnd, 6); + + view.yoga.paddingHorizontal = 7; + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeHorizontal).value, 7); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeHorizontal).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingHorizontal, 7); + + view.yoga.paddingVertical = 8; + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeVertical).value, 8); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeVertical).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingVertical, 8); + + view.yoga.padding = 9; + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeAll).value, 9); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeAll).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.padding, 9); +} + +- (void)testBorderWidthPropertiesWork +{ + UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; + + view.yoga.borderLeftWidth = 1; + XCTAssertEqual(YGNodeStyleGetBorder(view.yoga.node, YGEdgeLeft), 1); + XCTAssertEqual(view.yoga.borderLeftWidth, 1); + + view.yoga.borderRightWidth = 2; + XCTAssertEqual(YGNodeStyleGetBorder(view.yoga.node, YGEdgeRight), 2); + XCTAssertEqual(view.yoga.borderRightWidth, 2); + + view.yoga.borderTopWidth = 3; + XCTAssertEqual(YGNodeStyleGetBorder(view.yoga.node, YGEdgeTop), 3); + XCTAssertEqual(view.yoga.borderTopWidth, 3); + + view.yoga.borderBottomWidth = 4; + XCTAssertEqual(YGNodeStyleGetBorder(view.yoga.node, YGEdgeBottom), 4); + XCTAssertEqual(view.yoga.borderBottomWidth, 4); + + view.yoga.borderStartWidth = 5; + XCTAssertEqual(YGNodeStyleGetBorder(view.yoga.node, YGEdgeStart), 5); + XCTAssertEqual(view.yoga.borderStartWidth, 5); + + view.yoga.borderEndWidth = 6; + XCTAssertEqual(YGNodeStyleGetBorder(view.yoga.node, YGEdgeEnd), 6); + XCTAssertEqual(view.yoga.borderEndWidth, 6); + + view.yoga.borderWidth = 7; + XCTAssertEqual(YGNodeStyleGetBorder(view.yoga.node, YGEdgeAll), 7); + XCTAssertEqual(view.yoga.borderWidth, 7); } @end diff --git a/tests/YGEdgeTest.cpp b/tests/YGEdgeTest.cpp index 4122b11b..e1272a2a 100644 --- a/tests/YGEdgeTest.cpp +++ b/tests/YGEdgeTest.cpp @@ -161,3 +161,54 @@ TEST(YogaTest, all_overridden) { YGNodeFreeRecursive(root); } + +TEST(YogaTest, get_style_horizontal) { + const YGNodeRef node = YGNodeNew(); + + YGNodeStyleSetMargin(node, YGEdgeLeft, 10); + YGNodeStyleSetMargin(node, YGEdgeRight, 10); + YGNodeStyleSetMargin(node, YGEdgeStart, 10); + YGNodeStyleSetMargin(node, YGEdgeEnd, 10); + ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(node, YGEdgeHorizontal).value); + + YGNodeStyleSetMargin(node, YGEdgeAll, 15); + ASSERT_FLOAT_EQ(15, YGNodeStyleGetMargin(node, YGEdgeHorizontal).value); + + YGNodeStyleSetMargin(node, YGEdgeHorizontal, 20); + ASSERT_FLOAT_EQ(20, YGNodeStyleGetMargin(node, YGEdgeHorizontal).value); + + YGNodeFreeRecursive(node); +} + +TEST(YogaTest, get_style_vertical) { + const YGNodeRef node = YGNodeNew(); + + YGNodeStyleSetMargin(node, YGEdgeTop, 10); + YGNodeStyleSetMargin(node, YGEdgeBottom, 10); + ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(node, YGEdgeVertical).value); + + YGNodeStyleSetMargin(node, YGEdgeAll, 15); + ASSERT_FLOAT_EQ(15, YGNodeStyleGetMargin(node, YGEdgeVertical).value); + + YGNodeStyleSetMargin(node, YGEdgeVertical, 20); + ASSERT_FLOAT_EQ(20, YGNodeStyleGetMargin(node, YGEdgeVertical).value); + + YGNodeFreeRecursive(node); +} + +TEST(YogaTest, get_style_all) { + const YGNodeRef node = YGNodeNew(); + + YGNodeStyleSetMargin(node, YGEdgeLeft, 10); + YGNodeStyleSetMargin(node, YGEdgeRight, 10); + YGNodeStyleSetMargin(node, YGEdgeStart, 10); + YGNodeStyleSetMargin(node, YGEdgeEnd, 10); + YGNodeStyleSetMargin(node, YGEdgeTop, 10); + YGNodeStyleSetMargin(node, YGEdgeBottom, 10); + ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(node, YGEdgeAll).value); + + YGNodeStyleSetMargin(node, YGEdgeAll, 15); + ASSERT_FLOAT_EQ(15, YGNodeStyleGetMargin(node, YGEdgeAll).value); + + YGNodeFreeRecursive(node); +} \ No newline at end of file diff --git a/yoga/Yoga.c b/yoga/Yoga.c index d5e4917b..5a6aff1a 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -229,8 +229,6 @@ static YGLogger gLogger = &YGDefaultLog; static inline const YGValue *YGComputedEdgeValue(const YGValue edges[YGEdgeCount], const YGEdge edge, const YGValue *const defaultValue) { - YG_ASSERT(edge <= YGEdgeEnd, "Cannot get computed value of multi-edge shorthands"); - if (edges[edge].unit != YGUnitUndefined) { return &edges[edge]; } -- 2.50.1.windows.1 From bb19861db5ed1e51a23eda45288a61bb74381f23 Mon Sep 17 00:00:00 2001 From: David Hart Date: Fri, 13 Jan 2017 17:38:18 +0100 Subject: [PATCH 4/6] working towards applying suggestions --- YogaKit/Tests/YogaKitTests.m | 228 ++++++++++++++++++++--------------- YogaKit/YGLayout.m | 11 +- yoga/Yoga.c | 2 + 3 files changed, 142 insertions(+), 99 deletions(-) diff --git a/YogaKit/Tests/YogaKitTests.m b/YogaKit/Tests/YogaKitTests.m index 15112b9c..79b1155a 100644 --- a/YogaKit/Tests/YogaKitTests.m +++ b/YogaKit/Tests/YogaKitTests.m @@ -8,6 +8,7 @@ */ #import + #import #import #import @@ -424,133 +425,172 @@ { UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; - view.yoga.marginLeft = 1; - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).value, 1); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + view.yoga.margin = 1; XCTAssertEqual(view.yoga.marginLeft, 1); - - view.yoga.marginRight = 2; - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).value, 2); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginRight, 1); XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPixel); - XCTAssertEqual(view.yoga.marginRight, 2); - - view.yoga.marginTop = 3; - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).value, 3); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); - XCTAssertEqual(view.yoga.marginTop, 3); - - view.yoga.marginBottom = 4; - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).value, 4); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); - XCTAssertEqual(view.yoga.marginBottom, 4); - - view.yoga.marginStart = 5; - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).value, 5); + XCTAssertEqual(view.yoga.marginStart, 1); XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPixel); - XCTAssertEqual(view.yoga.marginStart, 5); - - view.yoga.marginEnd = 6; - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).value, 6); + XCTAssertEqual(view.yoga.marginEnd, 1); XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel); - XCTAssertEqual(view.yoga.marginEnd, 6); + XCTAssertEqual(view.yoga.marginTop, 1); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginBottom, 1); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); + XCTAssertTrue(isnan(view.yoga.marginHorizontal)); + XCTAssertTrue(isnan(view.yoga.marginVertical)); + XCTAssertTrue(isnan(view.yoga.margin)); - view.yoga.marginHorizontal = 7; - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeHorizontal).value, 7); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeHorizontal).unit, YGUnitPixel); - XCTAssertEqual(view.yoga.marginHorizontal, 7); + view.yoga.marginHorizontal = 2; + XCTAssertEqual(view.yoga.marginLeft, 2); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginRight, 2); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginStart, 2); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginEnd, 2); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel); + XCTAssertTrue(isnan(view.yoga.marginHorizontal)); - view.yoga.marginVertical = 8; - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeVertical).value, 8); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeVertical).unit, YGUnitPixel); - XCTAssertEqual(view.yoga.marginVertical, 8); + view.yoga.marginVertical = 3; + XCTAssertEqual(view.yoga.marginTop, 3); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginBottom, 3); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); + XCTAssertTrue(isnan(view.yoga.marginVertical)); - view.yoga.margin = 9; - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeAll).value, 9); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeAll).unit, YGUnitPixel); - XCTAssertEqual(view.yoga.margin, 9); + view.yoga.marginLeft = 4; + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).value, 4); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginLeft, 4); + + view.yoga.marginRight = 5; + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).value, 5); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginRight, 5); + + view.yoga.marginTop = 6; + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).value, 6); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginTop, 6); + + view.yoga.marginBottom = 7; + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).value, 7); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginBottom, 7); + + view.yoga.marginStart = 8; + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).value, 8); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginStart, 8); + + view.yoga.marginEnd = 9; + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).value, 9); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.marginEnd, 9); } - (void)testPaddingPropertiesWork { UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; - view.yoga.paddingLeft = 1; - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).value, 1); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + view.yoga.padding = 1; XCTAssertEqual(view.yoga.paddingLeft, 1); - - view.yoga.paddingRight = 2; - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).value, 2); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingRight, 1); XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPixel); - XCTAssertEqual(view.yoga.paddingRight, 2); - - view.yoga.paddingTop = 3; - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).value, 3); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); - XCTAssertEqual(view.yoga.paddingTop, 3); - - view.yoga.paddingBottom = 4; - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).value, 4); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); - XCTAssertEqual(view.yoga.paddingBottom, 4); - - view.yoga.paddingStart = 5; - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).value, 5); + XCTAssertEqual(view.yoga.paddingStart, 1); XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPixel); - XCTAssertEqual(view.yoga.paddingStart, 5); - - view.yoga.paddingEnd = 6; - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).value, 6); + XCTAssertEqual(view.yoga.paddingEnd, 1); XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel); - XCTAssertEqual(view.yoga.paddingEnd, 6); + XCTAssertEqual(view.yoga.paddingTop, 1); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingBottom, 1); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); + XCTAssertTrue(isnan(view.yoga.paddingHorizontal)); + XCTAssertTrue(isnan(view.yoga.paddingVertical)); + XCTAssertTrue(isnan(view.yoga.padding)); - view.yoga.paddingHorizontal = 7; - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeHorizontal).value, 7); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeHorizontal).unit, YGUnitPixel); - XCTAssertEqual(view.yoga.paddingHorizontal, 7); + view.yoga.paddingHorizontal = 2; + XCTAssertEqual(view.yoga.paddingLeft, 2); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingRight, 2); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingStart, 2); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingEnd, 2); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel); + XCTAssertTrue(isnan(view.yoga.paddingHorizontal)); - view.yoga.paddingVertical = 8; - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeVertical).value, 8); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeVertical).unit, YGUnitPixel); - XCTAssertEqual(view.yoga.paddingVertical, 8); + view.yoga.paddingVertical = 3; + XCTAssertEqual(view.yoga.paddingTop, 3); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingBottom, 3); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); + XCTAssertTrue(isnan(view.yoga.paddingVertical)); - view.yoga.padding = 9; - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeAll).value, 9); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeAll).unit, YGUnitPixel); - XCTAssertEqual(view.yoga.padding, 9); + view.yoga.paddingLeft = 4; + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).value, 4); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingLeft, 4); + + view.yoga.paddingRight = 5; + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).value, 5); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingRight, 5); + + view.yoga.paddingTop = 6; + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).value, 6); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingTop, 6); + + view.yoga.paddingBottom = 7; + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).value, 7); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingBottom, 7); + + view.yoga.paddingStart = 8; + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).value, 8); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingStart, 8); + + view.yoga.paddingEnd = 9; + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).value, 9); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel); + XCTAssertEqual(view.yoga.paddingEnd, 9); } - (void)testBorderWidthPropertiesWork { UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; - view.yoga.borderLeftWidth = 1; - XCTAssertEqual(YGNodeStyleGetBorder(view.yoga.node, YGEdgeLeft), 1); + view.yoga.borderWidth = 1; XCTAssertEqual(view.yoga.borderLeftWidth, 1); + XCTAssertEqual(view.yoga.borderRightWidth, 1); + XCTAssertEqual(view.yoga.borderStartWidth, 1); + XCTAssertEqual(view.yoga.borderEndWidth, 1); + XCTAssertEqual(view.yoga.borderTopWidth, 1); + XCTAssertEqual(view.yoga.borderBottomWidth, 1); + XCTAssertTrue(isnan(view.yoga.borderWidth)); - view.yoga.borderRightWidth = 2; - XCTAssertEqual(YGNodeStyleGetBorder(view.yoga.node, YGEdgeRight), 2); - XCTAssertEqual(view.yoga.borderRightWidth, 2); + view.yoga.borderLeftWidth = 2; + XCTAssertEqual(view.yoga.borderLeftWidth, 2); - view.yoga.borderTopWidth = 3; - XCTAssertEqual(YGNodeStyleGetBorder(view.yoga.node, YGEdgeTop), 3); - XCTAssertEqual(view.yoga.borderTopWidth, 3); + view.yoga.borderRightWidth = 3; + XCTAssertEqual(view.yoga.borderRightWidth, 3); - view.yoga.borderBottomWidth = 4; - XCTAssertEqual(YGNodeStyleGetBorder(view.yoga.node, YGEdgeBottom), 4); - XCTAssertEqual(view.yoga.borderBottomWidth, 4); + view.yoga.borderTopWidth = 4; + XCTAssertEqual(view.yoga.borderTopWidth, 4); - view.yoga.borderStartWidth = 5; - XCTAssertEqual(YGNodeStyleGetBorder(view.yoga.node, YGEdgeStart), 5); - XCTAssertEqual(view.yoga.borderStartWidth, 5); + view.yoga.borderBottomWidth = 5; + XCTAssertEqual(view.yoga.borderBottomWidth, 5); - view.yoga.borderEndWidth = 6; - XCTAssertEqual(YGNodeStyleGetBorder(view.yoga.node, YGEdgeEnd), 6); - XCTAssertEqual(view.yoga.borderEndWidth, 6); + view.yoga.borderStartWidth = 6; + XCTAssertEqual(view.yoga.borderStartWidth, 6); - view.yoga.borderWidth = 7; - XCTAssertEqual(YGNodeStyleGetBorder(view.yoga.node, YGEdgeAll), 7); - XCTAssertEqual(view.yoga.borderWidth, 7); + view.yoga.borderEndWidth = 7; + XCTAssertEqual(view.yoga.borderEndWidth, 7); } @end diff --git a/YogaKit/YGLayout.m b/YogaKit/YGLayout.m index c7f25136..221b4cde 100644 --- a/YogaKit/YGLayout.m +++ b/YogaKit/YGLayout.m @@ -49,12 +49,13 @@ #define YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(objc_lowercased_name, objc_capitalized_name, c_name, edge) \ - (CGFloat)objc_lowercased_name \ { \ - YGValue value = YGNodeStyleGet##c_name(self.node, edge); \ - if (value.unit == YGUnitPixel) { \ - return value.value; \ - } else { \ - return YGUndefined; \ + if (edge <= YGEdgeEnd) { \ + YGValue value = YGNodeStyleGet##c_name(self.node, edge); \ + if (value.unit == YGUnitPixel) { \ + return value.value; \ + } \ } \ + return YGUndefined; \ } \ \ - (void)set##objc_capitalized_name:(CGFloat)objc_lowercased_name \ diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 4b9e1142..598f273c 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -227,6 +227,8 @@ static YGLogger gLogger = &YGDefaultLog; static inline const YGValue *YGComputedEdgeValue(const YGValue edges[YGEdgeCount], const YGEdge edge, const YGValue *const defaultValue) { + YG_ASSERT(edge <= YGEdgeEnd, "Cannot get computed value of multi-edge shorthands"); + if (edges[edge].unit != YGUnitUndefined) { return &edges[edge]; } -- 2.50.1.windows.1 From 6cf6236a9b4d3433a1d6fe82fbeac2e782513a7a Mon Sep 17 00:00:00 2001 From: David Hart Date: Sat, 14 Jan 2017 01:14:33 +0100 Subject: [PATCH 5/6] rewrote macros to simplify them and satisfy the requirement of having the shorthand edge getters return YGUndefined --- YogaKit/YGLayout.m | 201 +++++++++++++++++++++++++-------------------- 1 file changed, 113 insertions(+), 88 deletions(-) diff --git a/YogaKit/YGLayout.m b/YogaKit/YGLayout.m index 221b4cde..23cee161 100644 --- a/YogaKit/YGLayout.m +++ b/YogaKit/YGLayout.m @@ -10,69 +10,94 @@ #import "YGLayout+Private.h" #import "UIView+Yoga.h" -#define YG_STYLE_PROPERTY_IMPL(type, lowercased_name, capitalized_name) \ -- (type)lowercased_name \ -{ \ - return YGNodeStyleGet##capitalized_name(self.node); \ -} \ - \ -- (void)set##capitalized_name:(type)lowercased_name \ -{ \ - YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \ +#define YG_PROPERTY(type, lowercased_name, capitalized_name) \ +- (type)lowercased_name \ +{ \ + return YGNodeStyleGet##capitalized_name(self.node); \ +} \ + \ +- (void)set##capitalized_name:(type)lowercased_name \ +{ \ + YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \ } -#define YG_STYLE_EDGE_PROPERTY_IMPL(lowercased_name, capitalized_name, property, edge) \ -- (CGFloat)lowercased_name { \ - return YGNodeStyleGet##property(self.node, edge); \ -} \ - \ -- (void)set##capitalized_name:(CGFloat)lowercased_name { \ - YGNodeStyleSet##property(self.node, edge, lowercased_name); \ +#define YG_VALUE_PROPERTY(lowercased_name, capitalized_name) \ +- (CGFloat)lowercased_name \ +{ \ + YGValue value = YGNodeStyleGet##capitalized_name(self.node); \ + if (value.unit == YGUnitPixel) { \ + return value.value; \ + } else { \ + return YGUndefined; \ + } \ +} \ + \ +- (void)set##capitalized_name:(CGFloat)lowercased_name \ +{ \ + YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \ } -#define YG_STYLE_VALUE_PROPERTY_IMPL(lowercased_name, capitalized_name) \ -- (CGFloat)lowercased_name \ -{ \ - YGValue value = YGNodeStyleGet##capitalized_name(self.node); \ - if (value.unit == YGUnitPixel) { \ - return value.value; \ - } else { \ - return YGUndefined; \ - } \ -} \ - \ -- (void)set##capitalized_name:(CGFloat)lowercased_name \ -{ \ - YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \ +#define YG_EDGE_PROPERTY_GETTER(lowercased_name, capitalized_name, property, edge) \ +- (CGFloat)lowercased_name \ +{ \ + return YGNodeStyleGet##property(self.node, edge); \ } -#define YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(objc_lowercased_name, objc_capitalized_name, c_name, edge) \ -- (CGFloat)objc_lowercased_name \ -{ \ - if (edge <= YGEdgeEnd) { \ - YGValue value = YGNodeStyleGet##c_name(self.node, edge); \ - if (value.unit == YGUnitPixel) { \ - return value.value; \ - } \ - } \ - return YGUndefined; \ -} \ - \ -- (void)set##objc_capitalized_name:(CGFloat)objc_lowercased_name \ -{ \ - YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name); \ +#define YG_SHORTHAND_EDGE_PROPERTY_GETTER(lowercased_name) \ +- (CGFloat)lowercased_name \ +{ \ + return YGUndefined; \ } -#define YG_STYLE_ALL_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name##Left, capitalized_name##Left, capitalized_name, YGEdgeLeft) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name##Top, capitalized_name##Top, capitalized_name, YGEdgeTop) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name##Right, capitalized_name##Right, capitalized_name, YGEdgeRight) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name##Bottom, capitalized_name##Bottom, capitalized_name, YGEdgeBottom) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name##Start, capitalized_name##Start, capitalized_name, YGEdgeStart) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name##End, capitalized_name##End, capitalized_name, YGEdgeEnd) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name##Horizontal, capitalized_name##Horizontal, capitalized_name, YGEdgeHorizontal) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name##Vertical, capitalized_name##Vertical, capitalized_name, YGEdgeVertical) \ -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, capitalized_name, YGEdgeAll) +#define YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge) \ +- (void)set##capitalized_name:(CGFloat)lowercased_name \ +{ \ + YGNodeStyleSet##property(self.node, edge, lowercased_name); \ +} + +#define YG_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \ +YG_EDGE_PROPERTY_GETTER(lowercased_name, capitalized_name, property, edge) \ +YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge) + +#define YG_SHORTHAND_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \ +YG_SHORTHAND_EDGE_PROPERTY_GETTER(lowercased_name) \ +YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge) + +#define YG_VALUE_EDGE_PROPERTY_GETTER(objc_lowercased_name, objc_capitalized_name, c_name, edge) \ +- (CGFloat)objc_lowercased_name \ +{ \ + YGValue value = YGNodeStyleGet##c_name(self.node, edge); \ + if (value.unit == YGUnitPixel) { \ + return value.value; \ + } else { \ + return YGUndefined; \ + } \ +} + +#define YG_VALUE_EDGE_PROPERTY_SETTER(objc_lowercased_name, objc_capitalized_name, c_name, edge) \ +- (void)set##objc_capitalized_name:(CGFloat)objc_lowercased_name \ +{ \ + YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name); \ +} + +#define YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \ +YG_VALUE_EDGE_PROPERTY_GETTER(lowercased_name, capitalized_name, property, edge) \ +YG_VALUE_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge) + +#define YG_VALUE_SHORTHAND_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \ +YG_SHORTHAND_EDGE_PROPERTY_GETTER(lowercased_name) \ +YG_VALUE_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge) + +#define YG_VALUE_EDGES_PROPERTIES(lowercased_name, capitalized_name) \ +YG_VALUE_EDGE_PROPERTY(lowercased_name##Left, capitalized_name##Left, capitalized_name, YGEdgeLeft) \ +YG_VALUE_EDGE_PROPERTY(lowercased_name##Top, capitalized_name##Top, capitalized_name, YGEdgeTop) \ +YG_VALUE_EDGE_PROPERTY(lowercased_name##Right, capitalized_name##Right, capitalized_name, YGEdgeRight) \ +YG_VALUE_EDGE_PROPERTY(lowercased_name##Bottom, capitalized_name##Bottom, capitalized_name, YGEdgeBottom) \ +YG_VALUE_EDGE_PROPERTY(lowercased_name##Start, capitalized_name##Start, capitalized_name, YGEdgeStart) \ +YG_VALUE_EDGE_PROPERTY(lowercased_name##End, capitalized_name##End, capitalized_name, YGEdgeEnd) \ +YG_VALUE_SHORTHAND_EDGE_PROPERTY(lowercased_name##Horizontal, capitalized_name##Horizontal, capitalized_name, YGEdgeHorizontal) \ +YG_VALUE_SHORTHAND_EDGE_PROPERTY(lowercased_name##Vertical, capitalized_name##Vertical, capitalized_name, YGEdgeVertical) \ +YG_VALUE_SHORTHAND_EDGE_PROPERTY(lowercased_name, capitalized_name, capitalized_name, YGEdgeAll) @interface YGLayout () @@ -148,43 +173,43 @@ YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(lowercased_name, capitalized_name, capitalized_ YGNodeStyleSetPositionType(self.node, position); } -YG_STYLE_PROPERTY_IMPL(YGDirection, direction, Direction) -YG_STYLE_PROPERTY_IMPL(YGFlexDirection, flexDirection, FlexDirection) -YG_STYLE_PROPERTY_IMPL(YGJustify, justifyContent, JustifyContent) -YG_STYLE_PROPERTY_IMPL(YGAlign, alignContent, AlignContent) -YG_STYLE_PROPERTY_IMPL(YGAlign, alignItems, AlignItems) -YG_STYLE_PROPERTY_IMPL(YGAlign, alignSelf, AlignSelf) -YG_STYLE_PROPERTY_IMPL(YGWrap, flexWrap, FlexWrap) -YG_STYLE_PROPERTY_IMPL(YGOverflow, overflow, Overflow) +YG_PROPERTY(YGDirection, direction, Direction) +YG_PROPERTY(YGFlexDirection, flexDirection, FlexDirection) +YG_PROPERTY(YGJustify, justifyContent, JustifyContent) +YG_PROPERTY(YGAlign, alignContent, AlignContent) +YG_PROPERTY(YGAlign, alignItems, AlignItems) +YG_PROPERTY(YGAlign, alignSelf, AlignSelf) +YG_PROPERTY(YGWrap, flexWrap, FlexWrap) +YG_PROPERTY(YGOverflow, overflow, Overflow) -YG_STYLE_PROPERTY_IMPL(CGFloat, flexGrow, FlexGrow) -YG_STYLE_PROPERTY_IMPL(CGFloat, flexShrink, FlexShrink) -YG_STYLE_VALUE_PROPERTY_IMPL(flexBasis, FlexBasis) +YG_PROPERTY(CGFloat, flexGrow, FlexGrow) +YG_PROPERTY(CGFloat, flexShrink, FlexShrink) +YG_VALUE_PROPERTY(flexBasis, FlexBasis) -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(left, Left, Position, YGEdgeLeft) -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(top, Top, Position, YGEdgeTop) -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(right, Right, Position, YGEdgeRight) -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(bottom, Bottom, Position, YGEdgeBottom) -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(start, Start, Position, YGEdgeStart) -YG_STYLE_EDGE_PROPERTY_UNIT_IMPL(end, End, Position, YGEdgeEnd) -YG_STYLE_ALL_EDGE_PROPERTY_UNIT_IMPL(margin, Margin) -YG_STYLE_ALL_EDGE_PROPERTY_UNIT_IMPL(padding, Padding) +YG_VALUE_EDGE_PROPERTY(left, Left, Position, YGEdgeLeft) +YG_VALUE_EDGE_PROPERTY(top, Top, Position, YGEdgeTop) +YG_VALUE_EDGE_PROPERTY(right, Right, Position, YGEdgeRight) +YG_VALUE_EDGE_PROPERTY(bottom, Bottom, Position, YGEdgeBottom) +YG_VALUE_EDGE_PROPERTY(start, Start, Position, YGEdgeStart) +YG_VALUE_EDGE_PROPERTY(end, End, Position, YGEdgeEnd) +YG_VALUE_EDGES_PROPERTIES(margin, Margin) +YG_VALUE_EDGES_PROPERTIES(padding, Padding) -YG_STYLE_EDGE_PROPERTY_IMPL(borderLeftWidth, BorderLeftWidth, Border, YGEdgeLeft) -YG_STYLE_EDGE_PROPERTY_IMPL(borderTopWidth, BorderTopWidth, Border, YGEdgeTop) -YG_STYLE_EDGE_PROPERTY_IMPL(borderRightWidth, BorderRightWidth, Border, YGEdgeRight) -YG_STYLE_EDGE_PROPERTY_IMPL(borderBottomWidth, BorderBottomWidth, Border, YGEdgeBottom) -YG_STYLE_EDGE_PROPERTY_IMPL(borderStartWidth, BorderStartWidth, Border, YGEdgeStart) -YG_STYLE_EDGE_PROPERTY_IMPL(borderEndWidth, BorderEndWidth, Border, YGEdgeEnd) -YG_STYLE_EDGE_PROPERTY_IMPL(borderWidth, BorderWidth, Border, YGEdgeAll) +YG_EDGE_PROPERTY(borderLeftWidth, BorderLeftWidth, Border, YGEdgeLeft) +YG_EDGE_PROPERTY(borderTopWidth, BorderTopWidth, Border, YGEdgeTop) +YG_EDGE_PROPERTY(borderRightWidth, BorderRightWidth, Border, YGEdgeRight) +YG_EDGE_PROPERTY(borderBottomWidth, BorderBottomWidth, Border, YGEdgeBottom) +YG_EDGE_PROPERTY(borderStartWidth, BorderStartWidth, Border, YGEdgeStart) +YG_EDGE_PROPERTY(borderEndWidth, BorderEndWidth, Border, YGEdgeEnd) +YG_SHORTHAND_EDGE_PROPERTY(borderWidth, BorderWidth, Border, YGEdgeAll) -YG_STYLE_VALUE_PROPERTY_IMPL(width, Width) -YG_STYLE_VALUE_PROPERTY_IMPL(height, Height) -YG_STYLE_VALUE_PROPERTY_IMPL(minWidth, MinWidth) -YG_STYLE_VALUE_PROPERTY_IMPL(minHeight, MinHeight) -YG_STYLE_VALUE_PROPERTY_IMPL(maxWidth, MaxWidth) -YG_STYLE_VALUE_PROPERTY_IMPL(maxHeight, MaxHeight) -YG_STYLE_PROPERTY_IMPL(CGFloat, aspectRatio, AspectRatio) +YG_VALUE_PROPERTY(width, Width) +YG_VALUE_PROPERTY(height, Height) +YG_VALUE_PROPERTY(minWidth, MinWidth) +YG_VALUE_PROPERTY(minHeight, MinHeight) +YG_VALUE_PROPERTY(maxWidth, MaxWidth) +YG_VALUE_PROPERTY(maxHeight, MaxHeight) +YG_PROPERTY(CGFloat, aspectRatio, AspectRatio) #pragma mark - Layout and Sizing -- 2.50.1.windows.1 From a219251ee92ee58e50d5365bac69f4f57185e73d Mon Sep 17 00:00:00 2001 From: David Hart Date: Mon, 16 Jan 2017 08:53:40 +0100 Subject: [PATCH 6/6] revert the tests I had added to test the removal of the ASSERT --- tests/YGEdgeTest.cpp | 51 -------------------------------------------- 1 file changed, 51 deletions(-) diff --git a/tests/YGEdgeTest.cpp b/tests/YGEdgeTest.cpp index e1272a2a..4122b11b 100644 --- a/tests/YGEdgeTest.cpp +++ b/tests/YGEdgeTest.cpp @@ -161,54 +161,3 @@ TEST(YogaTest, all_overridden) { YGNodeFreeRecursive(root); } - -TEST(YogaTest, get_style_horizontal) { - const YGNodeRef node = YGNodeNew(); - - YGNodeStyleSetMargin(node, YGEdgeLeft, 10); - YGNodeStyleSetMargin(node, YGEdgeRight, 10); - YGNodeStyleSetMargin(node, YGEdgeStart, 10); - YGNodeStyleSetMargin(node, YGEdgeEnd, 10); - ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(node, YGEdgeHorizontal).value); - - YGNodeStyleSetMargin(node, YGEdgeAll, 15); - ASSERT_FLOAT_EQ(15, YGNodeStyleGetMargin(node, YGEdgeHorizontal).value); - - YGNodeStyleSetMargin(node, YGEdgeHorizontal, 20); - ASSERT_FLOAT_EQ(20, YGNodeStyleGetMargin(node, YGEdgeHorizontal).value); - - YGNodeFreeRecursive(node); -} - -TEST(YogaTest, get_style_vertical) { - const YGNodeRef node = YGNodeNew(); - - YGNodeStyleSetMargin(node, YGEdgeTop, 10); - YGNodeStyleSetMargin(node, YGEdgeBottom, 10); - ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(node, YGEdgeVertical).value); - - YGNodeStyleSetMargin(node, YGEdgeAll, 15); - ASSERT_FLOAT_EQ(15, YGNodeStyleGetMargin(node, YGEdgeVertical).value); - - YGNodeStyleSetMargin(node, YGEdgeVertical, 20); - ASSERT_FLOAT_EQ(20, YGNodeStyleGetMargin(node, YGEdgeVertical).value); - - YGNodeFreeRecursive(node); -} - -TEST(YogaTest, get_style_all) { - const YGNodeRef node = YGNodeNew(); - - YGNodeStyleSetMargin(node, YGEdgeLeft, 10); - YGNodeStyleSetMargin(node, YGEdgeRight, 10); - YGNodeStyleSetMargin(node, YGEdgeStart, 10); - YGNodeStyleSetMargin(node, YGEdgeEnd, 10); - YGNodeStyleSetMargin(node, YGEdgeTop, 10); - YGNodeStyleSetMargin(node, YGEdgeBottom, 10); - ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(node, YGEdgeAll).value); - - YGNodeStyleSetMargin(node, YGEdgeAll, 15); - ASSERT_FLOAT_EQ(15, YGNodeStyleGetMargin(node, YGEdgeAll).value); - - YGNodeFreeRecursive(node); -} \ No newline at end of file -- 2.50.1.windows.1