jeudi 6 août 2020

what's the correct way to organize tests for this TDD-way code?

e.g. a leetcode question has these tests or examples:

Input: pattern = "abba", str = "dog cat cat dog"
Output: true
Example 2:

Input:pattern = "abba", str = "dog cat cat fish"
Output: false
Example 3:

Input: pattern = "aaaa", str = "dog cat cat dog"
Output: false
Example 4:

Input: pattern = "abba", str = "dog dog dog dog"
Output: false

I wrote function f and now need to test it using examples above:

pattern = "abba"
s = "dog dog dog dog"

pattern = "abba"
s = "dog cat cat dog"

pattern = "abba"
s = "dog cat cat fish"

pattern = "aaaa"
s = "dog cat cat dog"

pattern = "abba"
s = "dog dog dog dog"

I could simply write assert statements:

assert( f(pattern,s)) == False 

But what's the other 'correct way to write tests using Test-driven development methodology?

Aucun commentaire:

Enregistrer un commentaire