Skip to content

Instantly share code, notes, and snippets.

@truizlop
Created July 24, 2018 13:19
Show Gist options
  • Save truizlop/62abfe094d06abac94fc344c42d8135a to your computer and use it in GitHub Desktop.
Save truizlop/62abfe094d06abac94fc344c42d8135a to your computer and use it in GitHub Desktop.
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