1 while not 'end of file' 2 read string 3 vowels = 0 4 consonants = 0 5 character_position = 1 6 while character_position <= length(string) 7 if string[i] = 'a' or 'e' or 'i' or 'o' or 'u' then 8 vowels = vowels + 1 9 else 10 consonants = consonants + 1 11 endif 12 character_position = character_position + 1 13 endwhile 14 endwhile 15 display vowels, consonants
ลำดับกรณีทดสอบ |
Input |
Executed Statement |
Expect OutCome? |
คำอธิบาย |
1 |
123 |
1,2,3,4,5,6,7,9,10,11,12,13,14,15 | 0,3 |
ถ้าเราทดสอบ input โดยใส่ string คำว่า "123" จะเห็นได้ว่า ทุกๆ while loop ที่เข้าไปเช็คในเงื่อนไขที่บรรทัดที่ 7 ไม่มีตัวอักษรใด ที่อยู่ในข้อความ ทำให้เงื่อนไขงั้นเป็นจริงได้เลย ซึ่งไม่ทำให้เราเข้าถึงทุกๆ statement ของ function นั้นได้ |
2 |
Pok |
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 | 1,2 |
จากนั้น case ที่ 2 ใส่ คำว่า "pok" ตัว 'o' เท่านั้นที่จะทำให้เงื่อนไขที่บรรทัดที่ 7 เป็นจริง |