How to use testResolveBuildSetting_handlesUnbalancedParenthesesClose method of PBXTargetTests class

Best Mockingbird code snippet using PBXTargetTests.testResolveBuildSetting_handlesUnbalancedParenthesesClose

Run Mockingbird automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

PBXTargetTests.swift

Source: PBXTargetTests.swift Github

copy
1//
2//  PBXTargetTests.swift
3//  MockingbirdTests
4//
5//  Created by Sterling Hackley on 10/26/19.
6//
7
8import XCTest
9import XcodeProj
10@testable import MockingbirdGenerator
11
12class PBXTargetTests: XCTestCase {
13
14  // MARK: - productModuleName
15
16  func testProductModuleName_handlesNonAlphaNumericCharacters() {
17    let actual = PBXTarget(name: "a-module.name").resolveProductModuleName(environment: { [:] })
18    XCTAssertEqual(actual, "a_module_name")
19  }
20
21  func testProductModuleName_handlesFirstCharacterNumeral() {
22    let actual = PBXTarget(name: "123name").resolveProductModuleName(environment: { [:] })
23    XCTAssertEqual(actual, "_23name")
24  }
25  
26  // MARK: - Build setting resolving
27  
28  func testResolveBuildSetting_literalValue() {
29    let actual = try? PBXTarget.resolve(BuildSetting("foobar"), from: [:])
30    XCTAssertEqual(actual, "foobar")
31  }
32  
33  func testResolveBuildSetting_simpleExpression() {
34    let actual = try? PBXTarget.resolve(BuildSetting("$(FOO)"), from: ["FOO": "BAR"])
35    XCTAssertEqual(actual, "BAR")
36  }
37  
38  func testResolveBuildSetting_simpleExpressionBashStyle() {
39    let actual = try? PBXTarget.resolve(BuildSetting("${FOO}"), from: ["FOO": "BAR"])
40    XCTAssertEqual(actual, "BAR")
41  }
42  
43  func testResolveBuildSetting_simpleExpressionWithLeadingPadding() {
44    let actual = try? PBXTarget.resolve(BuildSetting("pad$(FOO)"), from: ["FOO": "BAR"])
45    XCTAssertEqual(actual, "padBAR")
46  }
47  
48  func testResolveBuildSetting_simpleExpressionWithLeadingPaddingBashStyle() {
49    let actual = try? PBXTarget.resolve(BuildSetting("pad${FOO}"), from: ["FOO": "BAR"])
50    XCTAssertEqual(actual, "padBAR")
51  }
52  
53  func testResolveBuildSetting_simpleExpressionWithTrailingPadding() {
54    let actual = try? PBXTarget.resolve(BuildSetting("$(FOO)dap"), from: ["FOO": "BAR"])
55    XCTAssertEqual(actual, "BARdap")
56  }
57  
58  func testResolveBuildSetting_simpleExpressionWithTrailingPaddingBashStyle() {
59    let actual = try? PBXTarget.resolve(BuildSetting("${FOO}dap"), from: ["FOO": "BAR"])
60    XCTAssertEqual(actual, "BARdap")
61  }
62  
63  func testResolveBuildSetting_simpleExpressionWithLeadingTrailingPadding() {
64    let actual = try? PBXTarget.resolve(BuildSetting("pad$(FOO)dap"), from: ["FOO": "BAR"])
65    XCTAssertEqual(actual, "padBARdap")
66  }
67  
68  func testResolveBuildSetting_simpleExpressionWithLeadingTrailingPaddingBashStyle() {
69    let actual = try? PBXTarget.resolve(BuildSetting("pad${FOO}dap"), from: ["FOO": "BAR"])
70    XCTAssertEqual(actual, "padBARdap")
71  }
72  
73  func testResolveBuildSetting_multipleConsecutiveExpressions() {
74    let actual = try? PBXTarget.resolve(BuildSetting("$(FOO)$(BAR)"),
75                                        from: ["FOO": "BAR", "BAR": "BAZ"])
76    XCTAssertEqual(actual, "BARBAZ")
77  }
78  
79  func testResolveBuildSetting_multipleConsecutiveExpressionsBashStyle() {
80    let actual = try? PBXTarget.resolve(BuildSetting("${FOO}${BAR}"),
81                                        from: ["FOO": "BAR", "BAR": "BAZ"])
82    XCTAssertEqual(actual, "BARBAZ")
83  }
84  
85  func testResolveBuildSetting_multipleExpressionsWithPadding() {
86    let actual = try? PBXTarget.resolve(BuildSetting("$(FOO)pad$(BAR)"),
87                                        from: ["FOO": "BAR", "BAR": "BAZ"])
88    XCTAssertEqual(actual, "BARpadBAZ")
89  }
90  
91  func testResolveBuildSetting_multipleExpressionsWithPaddingBashStyle() {
92    let actual = try? PBXTarget.resolve(BuildSetting("${FOO}pad${BAR}"),
93                                        from: ["FOO": "BAR", "BAR": "BAZ"])
94    XCTAssertEqual(actual, "BARpadBAZ")
95  }
96  
97  // MARK: Chained expressions
98  
99  func testResolveBuildSetting_simpleChainedExpression() {
100    let actual = try? PBXTarget.resolve(BuildSetting("$(FOO)"),
101                                        from: ["FOO": "$(BAR)", "BAR": "BAZ"])
102    XCTAssertEqual(actual, "BAZ")
103  }
104  
105  func testResolveBuildSetting_simpleChainedExpressionBashStyle() {
106    let actual = try? PBXTarget.resolve(BuildSetting("${FOO}"),
107                                        from: ["FOO": "${BAR}", "BAR": "BAZ"])
108    XCTAssertEqual(actual, "BAZ")
109  }
110  
111  func testResolveBuildSetting_simpleChainedExpressionMixedStyle() {
112    let actual = try? PBXTarget.resolve(BuildSetting("$(FOO)"),
113                                        from: ["FOO": "${BAR}", "BAR": "BAZ"])
114    XCTAssertEqual(actual, "BAZ")
115  }
116  
117  // MARK: Default values
118  
119  func testResolveBuildSetting_nonEmptyExpressionWithDefaultValue() {
120    let actual = try? PBXTarget.resolve(BuildSetting("$(FOO:default=a value)"),
121                                        from: ["FOO": "BAR"])
122    XCTAssertEqual(actual, "BAR")
123  }
124  
125  func testResolveBuildSetting_missingExpressionWithDefaultValueLiteral() {
126    let actual = try? PBXTarget.resolve(BuildSetting("$(FOO:default=a value)"), from: [:])
127    XCTAssertEqual(actual, "a value")
128  }
129  
130  func testResolveBuildSetting_multipleMissingExpressionWithDefaultValueLiteral() {
131    let actual = try? PBXTarget.resolve(
132      BuildSetting("$(FOO:default=a value) $(BAR:default=another value)"),
133      from: [:]
134    )
135    XCTAssertEqual(actual, "a value another value")
136  }
137  
138  func testResolveBuildSetting_emptyExpressionWithDefaultValueLiteral() {
139    let actual = try? PBXTarget.resolve(BuildSetting("$(FOO:default=a value)"),
140                                        from: ["FOO": ""])
141    XCTAssertEqual(actual, "a value")
142  }
143  
144  func testResolveBuildSetting_multipleEmptyExpressionWithDefaultValueLiteral() {
145    let actual = try? PBXTarget.resolve(
146      BuildSetting("$(FOO:default=a value) $(BAR:default=another value)"),
147      from: ["FOO": "", "BAR": ""]
148    )
149    XCTAssertEqual(actual, "a value another value")
150  }
151  
152  func testResolveBuildSetting_missingExpressionWithDefaultValueExpression() {
153    let actual = try? PBXTarget.resolve(BuildSetting("$(FOO:default=$(BAR))"),
154                                        from: ["BAR": "BAZ"])
155    XCTAssertEqual(actual, "BAZ")
156  }
157  
158  func testResolveBuildSetting_multipleMissingExpressionsWithDefaultValueExpression() {
159    let actual = try? PBXTarget.resolve(
160      BuildSetting("$(FOO:default=$(BAR)) $(HELLO:default=$(WORLD))"),
161      from: ["BAR": "BAZ", "WORLD": "!!"]
162    )
163    XCTAssertEqual(actual, "BAZ !!")
164  }
165  
166  func testResolveBuildSetting_missingExpressionWithDefaultValuePaddedExpression() {
167    let actual = try? PBXTarget.resolve(BuildSetting("$(FOO:default=pad $(BAR) dap)"),
168                                        from: ["BAR": "BAZ"])
169    XCTAssertEqual(actual, "pad BAZ dap")
170  }
171  
172  func testResolveBuildSetting_missingExpressionWithNestedDefaultValueLiteral() {
173    let actual = try? PBXTarget.resolve(BuildSetting("$(FOO:default=$(BAR:default=a value))"),
174                                        from: [:])
175    XCTAssertEqual(actual, "a value")
176  }
177  
178  func testResolveBuildSetting_missingExpressionWithNestedDefaultValueExpression() {
179    let actual = try? PBXTarget.resolve(BuildSetting("$(FOO:default=$(BAR:default=$(BAZ)))"),
180                                        from: ["BAZ": "BOO"])
181    XCTAssertEqual(actual, "BOO")
182  }
183  
184  // MARK: Circular evaluations
185  
186  func testResolveBuildSetting_handlesCircularEvaluatedExpressions() {
187    XCTAssertThrowsError(try PBXTarget.resolve(BuildSetting("$(FOO)"),
188                                               from: ["FOO": "$(BAR)",
189                                                      "BAR": "$(BAZ)",
190                                                      "BAZ": "$(FOO)"]))
191  }
192  
193  func testResolveBuildSetting_handlesCircularEvaluatedExpressionsFromDefaults() {
194    XCTAssertThrowsError(try PBXTarget.resolve(BuildSetting("$(FOO:default=$(BAR))"),
195                                               from: ["BAR": "$(BAZ)",
196                                                      "BAZ": "$(FOO)"]))
197  }
198  
199  // MARK: Unbalanced parentheses
200  
201  func testResolveBuildSetting_handlesUnbalancedParenthesesClose() {
202    let actual = try? PBXTarget.resolve(BuildSetting("$(FOO"), from: ["FOO": "BAR"])
203    XCTAssertEqual(actual, "$(FOO")
204  }
205  
206  func testResolveBuildSetting_handlesUnbalancedParenthesesCloseBashStyle() {
207    let actual = try? PBXTarget.resolve(BuildSetting("${FOO"), from: ["FOO": "BAR"])
208    XCTAssertEqual(actual, "${FOO")
209  }
210  
211  func testResolveBuildSetting_handlesUnbalancedParenthesesOpen() {
212    let actual = try? PBXTarget.resolve(BuildSetting("FOO)"), from: ["FOO": "BAR"])
213    XCTAssertEqual(actual, "FOO)")
214  }
215  
216  func testResolveBuildSetting_handlesUnbalancedParenthesesOpenBashStyle() {
217    let actual = try? PBXTarget.resolve(BuildSetting("FOO}"), from: ["FOO": "BAR"])
218    XCTAssertEqual(actual, "FOO}")
219  }
220  
221  func testResolveBuildSetting_handlesUnbalancedMultipleParenthesesClose() {
222    let actual = try? PBXTarget.resolve(BuildSetting("$((FOO)"), from: ["FOO": "BAR"])
223    XCTAssertEqual(actual, "")
224  }
225  
226  func testResolveBuildSetting_handlesUnbalancedMultipleParenthesesCloseBashStyle() {
227    let actual = try? PBXTarget.resolve(BuildSetting("${{FOO}"), from: ["FOO": "BAR"])
228    XCTAssertEqual(actual, "")
229  }
230  
231  func testResolveBuildSetting_handlesUnbalancedMultipleParenthesesOpen() {
232    let actual = try? PBXTarget.resolve(BuildSetting("$(FOO))"), from: ["FOO": "BAR"])
233    XCTAssertEqual(actual, "BAR)")
234  }
235  
236  func testResolveBuildSetting_handlesUnbalancedMultipleParenthesesOpenBashStyle() {
237    let actual = try? PBXTarget.resolve(BuildSetting("${FOO}}"), from: ["FOO": "BAR"])
238    XCTAssertEqual(actual, "BAR}")
239  }
240}
241
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used method in PBXTargetTests

Trigger testResolveBuildSetting_handlesUnbalancedParenthesesClose code on LambdaTest Cloud Grid

Execute automation tests with testResolveBuildSetting_handlesUnbalancedParenthesesClose on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)