Created
July 24, 2018 13:19
-
-
Save truizlop/62abfe094d06abac94fc344c42d8135a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func testConcatLengthIsEqualToSumOfLengths() { | |
property("Concatenation length is equal to sum of input lengths") <- forAll { (a : String, b : String) in | |
let output = concat(first: a, second: b) | |
return output.characters.count == a.characters.count + b.characters.count | |
} | |
} | |
func testConcatIsAssociative() { | |
property("Concatenation is associative") <- forAll { (a : String, b : String, c : String) in | |
let output1 = concat(first: concat(first: a, second: b), second: c) | |
let output2 = concat(first: a, second: concat(first: b, second: c)) | |
return output1 == output2 | |
} | |
} | |
func testConcatHasEmptyStringAsNeutralElement() { | |
property("Concatenation has empty String as neutral element") <- forAll { (a : String) in | |
let output = concat(first: a, second: "") | |
return output == a | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment