How to use without class

Best Mockingbird code snippet using without

FakeTheme.swift

Source:FakeTheme.swift Github

copy

Full Screen

1import UIKit2@testable import Connect3class FakeTheme: Theme {4 func tabBarTintColor() -> UIColor {5 fatalError("FakeTheme used without being overridden in spec!")6 }7 func navigationBarBackgroundColor() -> UIColor {8 fatalError("FakeTheme used without being overridden in spec!")9 }10 func newsFeedBackgroundColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }11 func newsFeedTitleFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }12 func newsFeedTitleColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }13 func newsFeedExcerptFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }14 func newsFeedExcerptColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }15 func newsFeedDateFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }16 func newsFeedVideoOverlayBackgroundColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }17 func highlightDisclosureColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }18 func defaultDisclosureColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }19 func defaultTableSectionHeaderFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }20 func defaultTableSectionHeaderTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }21 func defaultTableSectionHeaderBackgroundColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }22 func defaultTableSeparatorColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }23 func navigationBarTintColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }24 func navigationBarFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }25 func navigationBarTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }26 func navigationBarButtonTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }27 func tabBarActiveTextColor() -> UIColor {28 fatalError("FakeTheme used without being overridden in spec!")29 }30 func tabBarInactiveTextColor() -> UIColor {31 fatalError("FakeTheme used without being overridden in spec!")32 }33 func tabBarFont() -> UIFont {34 fatalError("FakeTheme used without being overridden in spec!")35 }36 func feedHeaderBackgroundColor() -> UIColor {37 fatalError("FakeTheme used without being overridden in spec!")38 }39 func feedHeaderTextColor() -> UIColor {40 fatalError("FakeTheme used without being overridden in spec!")41 }42 func feedHeaderFont() -> UIFont {43 fatalError("FakeTheme used without being overridden in spec!")44 }45 func newsArticleDateFont() -> UIFont {46 fatalError("FakeTheme used without being overridden in spec!")47 }48 func newsArticleDateColor() -> UIColor {49 fatalError("FakeTheme used without being overridden in spec!")50 }51 func newsArticleTitleFont() -> UIFont {52 fatalError("FakeTheme used without being overridden in spec!")53 }54 func newsArticleTitleColor() -> UIColor {55 fatalError("FakeTheme used without being overridden in spec!")56 }57 func newsArticleBodyFont() -> UIFont {58 fatalError("FakeTheme used without being overridden in spec!")59 }60 func newsArticleBodyColor() -> UIColor {61 fatalError("FakeTheme used without being overridden in spec!")62 }63 func defaultBackgroundColor() -> UIColor {64 fatalError("FakeTheme used without being overridden in spec!")65 }66 func settingsTitleFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }67 func settingsTitleColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }68 func settingsSwitchColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }69 func eventsListNameFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }70 func eventsListNameColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }71 func eventsListDateFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }72 func eventsListDateColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }73 func eventsSearchBarBackgroundColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }74 func eventsAddressTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }75 func eventsAddressPlaceholderTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }76 func eventsAddressBackgroundColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }77 func eventsAddressBorderColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }78 func eventsSearchBarFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }79 func eventsAddressCornerRadius() -> CGFloat { fatalError("FakeTheme used without being overridden in spec!") }80 func eventsAddressBorderWidth() -> CGFloat { fatalError("FakeTheme used without being overridden in spec!") }81 func eventsAddressTextOffset() -> CATransform3D { fatalError("FakeTheme used without being overridden in spec!") }82 func eventsGoButtonCornerRadius() -> CGFloat { fatalError("FakeTheme used without being overridden in spec!") }83 func eventsInformationTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }84 func eventsNoResultsFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }85 func eventsCreateEventCTAFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }86 func defaultSpinnerColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }87 func eventNameFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }88 func eventNameColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }89 func eventStartDateFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }90 func eventStartDateColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }91 func eventAttendeesFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }92 func eventAttendeesColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }93 func eventAddressFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }94 func eventAddressColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }95 func eventDescriptionHeadingFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }96 func eventDescriptionHeadingColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }97 func eventDescriptionFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }98 func eventDescriptionColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }99 func eventDirectionsButtonBackgroundColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }100 func eventDirectionsButtonTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }101 func eventDirectionsButtonFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }102 func fullWidthRSVPButtonTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }103 func fullWidthRSVPButtonFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }104 func fullWidthButtonBackgroundColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }105 func eventBackgroundColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }106 func eventsInstructionsFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }107 func eventsSubInstructionsFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }108 func aboutButtonBackgroundColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }109 func aboutButtonTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }110 func aboutButtonFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }111 func aboutBodyTextFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }112 func defaultButtonBackgroundColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }113 func defaultButtonTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }114 func defaultButtonFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }115 func welcomeHeaderFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }116 func welcomeMessageFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }117 func settingsAnalyticsFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }118 func welcomeBackgroundColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }119 func welcomeTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }120 func welcomeButtonBackgroundColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }121 func welcomeButtonTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }122 func videoDateFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }123 func videoDateColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }124 func videoTitleFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }125 func videoTitleColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }126 func videoDescriptionFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }127 func videoDescriptionColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }128 func actionsBackgroundColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }129 func actionsTitleFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }130 func actionsTitleTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }131 func actionsShortDescriptionFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }132 func actionsShortDescriptionTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }133 func contentBackgroundColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }134 func defaultTableCellBackgroundColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }135 func navigationBarButtonFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }136 func defaultButtonDisabledTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }137 func markdownH1Font() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }138 func markdownH2Font() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }139 func markdownH3Font() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }140 func markdownH4Font() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }141 func markdownH5Font() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }142 func markdownH6Font() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }143 func markdownBodyFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }144 func markdownBodyTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }145 func markdownBodyLinkTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }146 func defaultButtonBorderColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }147 func defaultBodyTextLineHeight() -> CGFloat { fatalError("FakeTheme used without being overridden in spec!") }148 func newsFeedDateColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }149 func newsFeedCellBorderColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }150 func eventsFilterLabelFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }151 func eventsFilterLabelTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }152 func eventsFilterButtonTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }153 func eventSearchBarSearchBarTopPadding() -> CGFloat { fatalError("FakeTheme used without being overridden in spec!") }154 func eventSearchBarVerticalShift() -> CGFloat { fatalError("FakeTheme used without being overridden in spec!") }155 func eventSearchBarHorizontalPadding() -> CGFloat { fatalError("FakeTheme used without being overridden in spec!") }156 func eventSearchBarSearchBarHeight() -> CGFloat { fatalError("FakeTheme used without being overridden in spec!") }157 func eventSearchBarFilterLabelBottomPadding() -> CGFloat { fatalError("FakeTheme used without being overridden in spec!") }158 func eventsErrorTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }159 func eventsErrorHeadingFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }160 func eventsErrorDetailFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }161 func actionsErrorMessageFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }162 func actionsErrorMessageTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }163 func defaultCurrentPageIndicatorTintColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }164 func defaultPageIndicatorTintColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }165 func actionsInfoButtonTintColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }166 func newsFeedInfoButtonTintColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }167 func actionsShareButtonFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }168 func actionsShareButtonTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }169 func registrationHeaderFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }170 func registrationHeaderTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }171 func registrationHeaderBackgroundColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }172 func registrationStateFont() -> UIFont { fatalError("FakeTheme used without being overridden in spec!") }173 func registrationStateTextColor() -> UIColor { fatalError("FakeTheme used without being overridden in spec!") }174}...

Full Screen

Full Screen

PojInputConverter.swift

Source:PojInputConverter.swift Github

copy

Full Screen

1import Foundation2class PojInputConverter {3 4 fileprivate static let pojWordExtractPattern = "(?:(ph|p|m|b|th|t|l|kh|k|ng|n|g|h|chh|ch|s|j)?([aiueo+]+(?:nn)?|ng|m)(?:(ng|m|n|re|r)|(p|t|h|k))?([12345789])?|(ph|p|m|b|th|t|l|kh|k|ng|n|g|h|chh|ch|s|j)-?-?)"5 6 static func convertPojNumberRawInputToPojWords(input: String?) -> String {7 if input == nil {8 return ""9 }10 let trimInput = input!.trimmingCharacters(in: .whitespaces)11 if trimInput.isEmpty {12 return ""13 }14 15 var pojWords = ""16 17 let results = trimInput.matches(regex: self.pojWordExtractPattern)18// for result in results {19// print("convertPojNumberRawInputToPojWords: result=\(result)")20// }21 22 if results.count == 0 {23 return ""24 } else {25 for i in 0..<results.count {26 let foundTaigiWord = results[i]27// print("convertPojNumberRawInputToPojWords: foundTaigiWord=\(foundTaigiWord)")28 let pojNumber = convertPojRawInputToPojNumber(foundTaigiWord: foundTaigiWord);29// print("convertPojNumberRawInputToPojWords: pojNumber=\(pojNumber)")30 let poj = convertPojNumberToPoj(pojNumber: pojNumber)31// print("convertPojNumberRawInputToPojWords: poj=\(poj)")32 33 pojWords.append(poj)34 35 if i < results.count - 1 {36 pojWords.append("-")37 }38 }39 }40 41 return pojWords42 }43 44 fileprivate static func convertPojRawInputToPojNumber(foundTaigiWord: String) -> String {45 var pojNumber = foundTaigiWord.replacingOccurrences(of: "Oo", with: "OO")46 47 if pojNumber.range(of: "nn")?.lowerBound.encodedOffset ?? 0 > 0 {48 pojNumber = pojNumber.replacingOccurrences(of: "nn", with: "ⁿ")49 } else if pojNumber.range(of: "NN")?.lowerBound.encodedOffset ?? 0 > 0 {50 pojNumber = pojNumber.replacingOccurrences(of: "NN", with: "ⁿ")51 }52 53 return pojNumber;54 }55 56 fileprivate static func convertPojNumberToPoj(pojNumber: String) -> String {57 let fixedPojNumber = ConverterUtils.fixLomajiNumberFormat(lomajiNumber: pojNumber);58// print("fixedPojNumber: \(fixedPojNumber)")59 60 if fixedPojNumber.count <= 1 {61 return fixedPojNumber62 }63 64 var number = ""65 66 let lastCharString = fixedPojNumber.lastCharString()67// print("convertPojNumberToPoj(), lastCharString: \(lastCharString)")68 69 if !lastCharString.isNumber {70 return ConverterUtils.fixBosianntiauOo(noNumberLomaji: fixedPojNumber)71 } else {72 number = lastCharString73 74 let pojWithoutNumber = fixedPojNumber.subString(startIndex: 0, endIndex: fixedPojNumber.count - 1)75 76 let toneVowelRange = calculateRangeOfPojToneVowel(pojWithoutNumber: pojWithoutNumber)77 78 let poj = generatePojInput(pojWithoutNumber: pojWithoutNumber, number: number, toneVowelRange: toneVowelRange);79 80// print("pojWithoutNumber=\(pojWithoutNumber), number=\(number), toneVowelRange=\(String(describing: toneVowelRange?.startIndex))..<\(String(describing: toneVowelRange?.endIndex)), poj=\(poj)")81 82 return poj83 }84 }85 86 fileprivate static func calculateRangeOfPojToneVowel(pojWithoutNumber: String) -> EasyRange? {87 let pojWithoutNumberLowercased = pojWithoutNumber.lowercased()88 let count = pojWithoutNumberLowercased.count89 90// print("calculateTonePosition: pojWithoutNumberLowercased = \(pojWithoutNumberLowercased), count = \(count)")91 92 let lastRangeOfVowel: EasyRange? = pojWithoutNumberLowercased.lastRangeForRegex(regex: "a|i|u|e|oo|o")93// print("lastRangeOfVowel: \(String(describing: lastRangeOfVowel))")94 if lastRangeOfVowel == nil {95// let testWithoutNN = pojWithoutNumberLowercased.replacingOccurrences(of: "nn", with: "__")96 let lastRangeOfHalfVowel = pojWithoutNumberLowercased.lastRangeForRegex(regex: "m|ng|n")97 return lastRangeOfHalfVowel98 } else {99 if count == 1 || lastRangeOfVowel!.startIndex == 0 {100 return lastRangeOfVowel101 } else {102 let previousCharString = pojWithoutNumberLowercased.subString(startIndex: lastRangeOfVowel!.startIndex-1, endIndex: lastRangeOfVowel!.startIndex)103 if previousCharString.contains(regex: "a|i|u|e|o") {104 // vowel count >= 2105 let lastCharString = self.findLastJibo(pojBoSianntiau: pojWithoutNumberLowercased)106 let last2ndCharString = self.findLast2ndJibo(pojBoSianntiau: pojWithoutNumberLowercased)107 if lastCharString.contains(regex: "p|t|k|h") {108 // Hok Boim Jipsiann109 if last2ndCharString.contains(regex: "i|u") {110 if pojWithoutNumberLowercased.contains(regex: "iuh") {111 return self.findLast2ndJiboEasyRange(pojBoSianntiau: pojWithoutNumberLowercased)112 } else {113 return self.findLast3rdJiboEasyRange(pojBoSianntiau: pojWithoutNumberLowercased)114 }115 } else {116 return self.findLast2ndJiboEasyRange(pojBoSianntiau: pojWithoutNumberLowercased)117 }118 } else {119 // Hok Boim120 if last2ndCharString == "i" {121 return self.findLastJiboEasyRange(pojBoSianntiau: pojWithoutNumberLowercased)122 } else {123 return self.findLast2ndJiboEasyRange(pojBoSianntiau: pojWithoutNumberLowercased)124 }125 }126 } else {127 // vowel count == 1128 return lastRangeOfVowel129 }130 }131 }132 }133 134 fileprivate static func findLastJibo(pojBoSianntiau: String) -> String {135 let easyRange = findLastJiboEasyRange(pojBoSianntiau: pojBoSianntiau)136 return pojBoSianntiau[easyRange.startIndex ..< easyRange.endIndex]137 }138 139 fileprivate static func findLast2ndJibo(pojBoSianntiau: String) -> String {140 let easyRange = findLast2ndJiboEasyRange(pojBoSianntiau: pojBoSianntiau)141 return pojBoSianntiau[easyRange.startIndex ..< easyRange.endIndex]142 }143 144 fileprivate static func findLastJiboEasyRange(pojBoSianntiau: String) -> EasyRange {145 return self.findJiboPositionFromLastCharExludingPhinnim(pojBoSianntiau: pojBoSianntiau, findWhichCharFromRight: 1)146 }147 148 fileprivate static func findLast2ndJiboEasyRange(pojBoSianntiau: String) -> EasyRange {149 return self.findJiboPositionFromLastCharExludingPhinnim(pojBoSianntiau: pojBoSianntiau, findWhichCharFromRight: 2)150 }151 152 fileprivate static func findLast3rdJiboEasyRange(pojBoSianntiau: String) -> EasyRange {153 return self.findJiboPositionFromLastCharExludingPhinnim(pojBoSianntiau: pojBoSianntiau, findWhichCharFromRight: 3)154 }155 156 fileprivate static func findJiboPositionFromLastCharExludingPhinnim(pojBoSianntiau: String, findWhichCharFromRight: Int) -> EasyRange {157 var pos: Int = pojBoSianntiau.count - 1158 var foundJiboCount = 0159 160 var hasFoundPojOo = false161 while (pos >= 0) {162 let currentCharString = pojBoSianntiau[pos ..< pos + 1]163 var isFoundPojOo = false164 var isFoundPojNg = false165 166 if (currentCharString == "ⁿ") {167 // skip168 } else if (currentCharString == "o" && pos - 1 >= 0) {169 let previousCharString = pojBoSianntiau[pos - 1 ..< pos]170 if (previousCharString == "o") {171 // found "oo"172 isFoundPojOo = true173 hasFoundPojOo = true174 } else {175 // found "o"176 }177 foundJiboCount = foundJiboCount + 1178 } else if (currentCharString == "g" && pos - 1 >= 0) {179 let previousCharString = pojBoSianntiau[pos - 1 ..< pos]180 if (previousCharString == "n") {181 // found "ng"182 isFoundPojNg = true183 } else {184 // found "g"185 }186 foundJiboCount = foundJiboCount + 1187 } else {188 foundJiboCount = foundJiboCount + 1189 }190 191 if (foundJiboCount == findWhichCharFromRight) {192 break193 }194 195 if (isFoundPojOo || isFoundPojNg) {196 pos = pos - 2197 } else {198 pos = pos - 1199 }200 201 if (pos < 0) {202 break203 }204 }205 206 if hasFoundPojOo {207 return EasyRange(startIndex: pos, endIndex: pos + 2)208 } else {209 return EasyRange(startIndex: pos, endIndex: pos + 1)210 }211 }212 213 fileprivate static func generatePojInput(pojWithoutNumber: String, number: String, toneVowelRange: EasyRange?) -> String {214 if toneVowelRange == nil {215 return pojWithoutNumber216 }217 218 var pojInputStringBuilder = ""219 220 if toneVowelRange!.startIndex != 0 {221 pojInputStringBuilder.append(contentsOf: pojWithoutNumber[0 ..< toneVowelRange!.startIndex])222 }223 224 let currentToneVowelString = pojWithoutNumber.subString(startIndex: toneVowelRange!.startIndex, endIndex: toneVowelRange!.endIndex)225 let currentToneVowelStringWithNumber = currentToneVowelString + number226 227 let poj = Poj.pojNumberToPojUnicodeDictionary[currentToneVowelStringWithNumber]228 if poj != nil {229 pojInputStringBuilder.append(poj!);230 }231 232 if toneVowelRange!.endIndex != pojWithoutNumber.count {233 pojInputStringBuilder.append(contentsOf: pojWithoutNumber[toneVowelRange!.endIndex ..< pojWithoutNumber.count])234 }235 236 return pojInputStringBuilder237 }238 239}...

Full Screen

Full Screen

Functions.swift

Source:Functions.swift Github

copy

Full Screen

1//2// Created by KenmuHuang on 2020/8/19.3// Copyright (c) 2020 KenmuHuang. All rights reserved.4//5import Foundation6///7/// 函数:https://swiftgg.gitbook.io/swift/swift-jiao-cheng/06_functions8class Functions: MainProtocol {9 func main() -> Void {10 print("\n===\(NSStringFromClass(type(of: self)))===")11 print(greet("Anna", alreadyGreeted: true))12 print(greet("Brian", alreadyGreeted: false))13 let contentCount = printAndCount(content: "Hello, world")14 if contentCount > 0 {15 printWithoutCounting(content: "Hello again, world")16 printWithoutCounting()17 }18 let arrValue = [8, -6, 2, 109, 3, 71] // []19 if let bounds = minAndMax(array: arrValue) {20 print("Min is \(bounds.min) and max is \(bounds.max) in \(arrValue)")21 }22 var average = arithmeticMean(1, 2, 3, 4, 5)23 printWithoutCounting(content: "average is \(average)")24 average = arithmeticMean(3, 8.25, 18.75)25 printWithoutCounting(content: "average is \(average)")26 var someInt = 327 var anotherInt = 10728 printWithoutCounting(content: "SomeInt is now \(someInt), and anotherInt is now \(anotherInt).")29 swapTwoInts(&someInt, &anotherInt)30 printWithoutCounting(content: "SomeInt is now \(someInt), and anotherInt is now \(anotherInt) after executing swap operation.")31 // 使用函数类型32 var mathFunction: (Int, Int) -> Int = addTwoInts33 printWithoutCounting(content: "addTwoInts(5, 6) = \(mathFunction(5, 6))")34 mathFunction = multiplyTwoInts35 printWithoutCounting(content: "multiplyTwoInts(5, 6) = \(mathFunction(5, 6))")36 let anotherMathFunction = addTwoInts37 printWithoutCounting(content: "addTwoInts(50, 6) = \(anotherMathFunction(50, 6))")38 // 函数类型作为参数类型39 printMathResult(anotherMathFunction, 50, 6)40 // 函数类型作为返回类型41 var currentValue = 342 let moveNearerToZero = chooseStepFunction(backward: currentValue > 0)43 printWithoutCounting(content: "Value move nearer to zero, origin value is \(currentValue), now value is \(moveNearerToZero(currentValue))")44 currentValue = 545 let moveNearerToTen = chooseStepFunction(backward: currentValue > 10)46 printWithoutCounting(content: "Value move nearer to ten, origin value is \(currentValue), now value is \(moveNearerToTen(currentValue))")47 }48 ///49 /// 问候某人50 /// - Parameters:51 /// - person: 某人52 /// - alreadyGreeted: 是否已经问候过53 /// - Returns: 问候语54 func greet(_ person: String, alreadyGreeted: Bool) -> String {55 if alreadyGreeted {56 return greetAgain(person: person, from: "Cupertino")57 } else {58 return greet(person: person, hometown: "Cupertino")59 }60 }61 private func greetAgain(person: String, from hometown: String) -> String {62// return "Hello again, \(person)!"63 // 隐式返回的函数64 "Hello again, \(person)! Glad you could visit from \(hometown)."65 }66 private func greet(person: String, hometown: String) -> String {67// let greeting = "Hello, " + person + "!"68 let greeting = "Hello, \(person)! Glad you could visit from \(hometown)."69 return greeting70 }71 ///72 /// 有计数的打印73 /// - Parameter content: 打印内容74 /// - Returns: 内容字符个数75 func printAndCount(content: String) -> Int {76 print(content)77 return content.count78 }79 ///80 /// 没有计数的打印81 /// - Parameter content: 打印内容82 func printWithoutCounting(content: String = "Hello, IT.") {83 let _ = printAndCount(content: content)84 }85 ///86 /// 查询数字数组中的最小值和最大值87 /// - Parameter array: 数字数组88 /// - Returns: 数字数组中的最小值和最大值89 func minAndMax(array: [Int]) -> (min: Int, max: Int)? {90 if array.isEmpty {91 return nil92 }93 var currentMin = array[0]94 var currentMax = array[0]95 for value in array[1..<array.count] {96 if value < currentMin {97 currentMin = value98 } else if value > currentMax {99 currentMax = value100 }101 }102 return (currentMin, currentMax)103 }104 ///105 /// 计算一组任意长度数字的算术平均数106 /// - Parameter numbers: 一组任意长度数字107 /// - Returns: 算术平均数108 func arithmeticMean(_ numbers: Double...) -> Double {109 // 一个函数最多只能拥有一个可变参数110 var total = 0.0111 for number in numbers {112 total += number113 }114 return total / Double(numbers.count)115 }116 func swapTwoInts(_ a: inout Int, _ b: inout Int) {117 // 输入输出参数不能有默认值,而且可变参数不能用 inout 标记118 let temporaryA = a119 a = b120 b = temporaryA121 }122 // MARK: - 函数类型作为参数类型123 func addTwoInts(_ a: Int, _ b: Int) -> Int {124 return a + b125 }126 func multiplyTwoInts(_ a: Int, _ b: Int) -> Int {127 return a * b128 }129 func printMathResult(_ mathFunction: (Int, Int) -> Int, _ a: Int, _ b: Int) {130 print("Result: \(mathFunction(a, b))")131 }132 // MARK: - 函数类型作为返回类型133 func chooseStepFunction(backward: Bool) -> (Int) -> Int {134 // 嵌套函数135 func stepForward(_ input: Int) -> Int {136 return input + 1137 }138 func stepBackward(_ input: Int) -> Int {139 return input - 1140 }141 return backward ? stepBackward : stepForward142 }143}...

Full Screen

Full Screen

without

Using AI Code Generation

copy

Full Screen

1import Foundation2class Mockingbird {3 init(name: String, age: Int, color: String) {4 }5}6let mockingbird = Mockingbird(name: "Mockingbird", age: 10, color: "black")7print("The name of Mockingbird is \(mockingbird.name) and its age is \(mockingbird.age) and its color is \(mockingbird.color)")8import Foundation9class Mockingbird {10 init(name: String, age: Int, color: String) {11 }12 func nameOfBird() {13 print("The name of Mockingbird is \(name)")14 }15 func ageOfBird() {16 print("The age of Mockingbird is \(age)")17 }18 func colorOfBird() {19 print("The color of Mockingbird is \(color)")20 }21}22let mockingbird = Mockingbird(name: "Mockingbird", age: 10, color: "black")23mockingbird.nameOfBird()24mockingbird.ageOfBird()25mockingbird.colorOfBird()26import Foundation27class Mockingbird {28 init(name: String, age: Int, color: String) {29 }30 func nameOfBird() {31 print("The name of Mockingbird is \(name)")32 }33 func ageOfBird() {34 print("The age of Mockingbird is \(age)")35 }36 func colorOfBird() {37 print("The color of Mockingbird is \(color)")38 }39}40let mockingbird = Mockingbird(name: "Mockingbird", age: 10, color: "black")41mockingbird.nameOfBird()

Full Screen

Full Screen

without

Using AI Code Generation

copy

Full Screen

1let task = URLSession.shared.dataTask(with: url) { (data, response, error) in2 print("data: \(String(describing: data))")3 print("response: \(String(describing: response))")4 print("error: \(String(describing: error))")5}6task.resume()7let task = URLSession.shared.dataTask(with: url) { (data, response, error) in8 print("data: \(String(describing: data))")9 print("response: \(String(describing: response))")10 print("error: \(String(describing: error))")11}12task.resume()13let task = URLSession.shared.dataTask(with: url) { (data, response, error) in14 print("data: \(String(describing: data))")15 print("response: \(String(describing: response))")16 print("error: \(String(describing: error))")17}18task.resume()19let task = URLSession.shared.dataTask(with: url) { (data, response, error) in20 print("data: \(String(describing: data))")21 print("response: \(String(describing: response))")22 print("error: \(String(describing: error))")23}24task.resume()25let task = URLSession.shared.dataTask(with: url) { (data, response, error) in26 print("data: \(String(describing: data))")27 print("response: \(String(describing: response))")28 print("error: \(String(describing: error))")29}30task.resume()31let task = URLSession.shared.dataTask(with: url) { (data, response, error)

Full Screen

Full Screen

without

Using AI Code Generation

copy

Full Screen

1import Foundation2import XCTest3import Mockingbird4import MockingbirdXCTest5import MockingbirdFoundation6import MockingbirdUIKit7import MockingbirdCoreLocation8import MockingbirdCoreGraphics9import MockingbirdMapKit10import MockingbirdQuartzCore11class MockingbirdTests: XCTestCase {12 func testExample() throws {13 let mock = mock(NSURLSession.self)14 given(mock.dataTask(with: any(URLRequest.self), completionHandler: any((Data?, URLResponse?, Error?) -> Void))) ~> { _, completion in15 completion(nil, nil, nil)16 }17 let request = URLRequest(url: url)18 let expectation = XCTestExpectation(description: "dataTask completion handler invoked")19 let task = session.dataTask(with: request) { data, response, error in20 expectation.fulfill()21 }22 task.resume()23 wait(for: [expectation], timeout: 1.0)24 }25}

Full Screen

Full Screen

without

Using AI Code Generation

copy

Full Screen

1import Foundation2class Mockingbird {3}4let mockingbird = Mockingbird()5print(mockingbird.text)6let mockingbird2 = Mockingbird()7print(mockingbird2.text)

Full Screen

Full Screen

without

Using AI Code Generation

copy

Full Screen

1import Foundation2class Mockingbird {3 init(name: String) {4 }5 func sing() {6 print("\(name) is singing")7 }8}9let mockingbird = Mockingbird(name: "Mockingbird")10mockingbird.sing()11import Foundation12class Mockingbird {13 init(name: String) {14 }15 func sing() {16 print("\(name) is singing")17 }18}19let mockingbird = Mockingbird(name: "Mockingbird")20mockingbird.sing()21import Foundation22class Mockingbird {23 init(name: String) {24 }25 func sing() {26 print("\(name) is singing")27 }28}29let mockingbird = Mockingbird(name: "Mockingbird")30mockingbird.sing()31import Foundation32class Mockingbird {33 init(name: String) {34 }35 func sing() {36 print("\(name) is singing")37 }38}39let mockingbird = Mockingbird(name: "Mockingbird")40mockingbird.sing()41import Foundation42class Mockingbird {43 init(name: String) {44 }45 func sing() {46 print("\(name) is singing")47 }48}49let mockingbird = Mockingbird(name: "Mockingbird")50mockingbird.sing()51import Foundation52class Mockingbird {53 init(name: String) {54 }55 func sing() {56 print("\(name) is singing")57 }58}59let mockingbird = Mockingbird(name: "Mockingbird")60mockingbird.sing()

Full Screen

Full Screen

without

Using AI Code Generation

copy

Full Screen

1import Mockingbird2class Bird {3 init(bird: Mockingbird) {4 }5 func fly() {6 bird.fly()7 }8}9let mockingbird = Mockingbird()10let bird = Bird(bird: mockingbird)11bird.fly()

Full Screen

Full Screen

without

Using AI Code Generation

copy

Full Screen

1import Mockingbird2import XCTest3class MockingbirdTests: XCTestCase {4 func testExample() {5 let mock = mock(MyClass.self)6 given(mock.myFunction()) ~> 427 XCTAssertEqual(MyClass().myFunction(), 42)8 }9}10import Mockingbird11import XCTest12class MyClassTests: XCTestCase {13 func testExample() {14 let mock = mock(MyClass.self)15 given(mock.myFunction()) ~> 4216 XCTAssertEqual(MyClass().myFunction(), 42)17 }18}19import Mockingbird20import XCTest21class MyClassTests: XCTestCase {22 func testExample() {23 let mock = mock(MyClass.self)24 given(mock.myFunction()) ~> 4225 XCTAssertEqual(MyClass().myFunction(), 42)26 }27}28import Mockingbird29import XCTest30class MyClassTests: XCTestCase {31 func testExample() {32 let mock = mock(MyClass.self)33 given(mock.myFunction()) ~> 4234 XCTAssertEqual(MyClass().myFunction(), 42)35 }36}37import Mockingbird38import XCTest39class MyClassTests: XCTestCase {40 func testExample() {41 let mock = mock(MyClass.self)42 given(mock.myFunction()) ~> 4243 XCTAssertEqual(MyClass().myFunction(), 42)44 }45}46import Mockingbird47import XCTest48class MyClassTests: XCTestCase {49 func testExample() {50 let mock = mock(MyClass.self)51 given(mock.myFunction()) ~> 4252 XCTAssertEqual(MyClass().myFunction(), 42)53 }54}55import Mockingbird56import XCTest57class MyClassTests: XCTestCase {58 func testExample() {59 let mock = mock(MyClass.self)60 given(mock.myFunction()) ~> 4261 XCTAssertEqual(MyClass().myFunction(), 42)62 }63}

Full Screen

Full Screen

without

Using AI Code Generation

copy

Full Screen

1import Foundation2import Mockingbird3import MockingbirdFramework4import XCTest5class MockingbirdTest: XCTestCase {6 func test() {7 let mock = mock(Protocol.self)8 when(mock).method().thenReturn("1")9 let result = mock.method()10 XCTAssertEqual(result, "1")11 }12}13import Foundation14import Mockingbird15import MockingbirdFramework16import XCTest17class MockingbirdTest: XCTestCase {18 func test() {19 let mock = mock(Protocol.self)20 when(mock).method().thenReturn("1")21 let result = mock.method()22 XCTAssertEqual(result, "1")23 }24}25import Foundation26import Mockingbird27import MockingbirdFramework28import XCTest29class MockingbirdTest: XCTestCase {30 func test() {31 let mock = mock(Protocol.self)32 when(mock).method().thenReturn("1")33 let result = mock.method()34 XCTAssertEqual(result, "1")35 }36}37import Foundation38import Mockingbird39import MockingbirdFramework40import XCTest41class MockingbirdTest: XCTestCase {42 func test() {43 let mock = mock(Protocol.self)44 when(mock).method().thenReturn("1")45 let result = mock.method()46 XCTAssertEqual(result, "1")47 }48}49import Foundation50import Mockingbird51import MockingbirdFramework52import XCTest53class MockingbirdTest: XCTestCase {54 func test() {55 let mock = mock(Protocol.self)56 when(mock).method().thenReturn("1")57 let result = mock.method()58 XCTAssertEqual(result, "1")59 }60}61import Foundation62import Mockingbird63import MockingbirdFramework64import XCTest65class MockingbirdTest: XCTestCase {66 func test() {67 let mock = mock(Protocol.self)68 when(mock).method().thenReturn("1")69 let result = mock.method()70 XCTAssertEqual(result, "1")71 }72}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Mockingbird automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful