krz/daybyday

iOS learning games for young children: days, months, seasons, numbers, letters, animals and more. education ios kids swift https://krz.sh/apps/daybyday/

DayByDayTests/SpokenTextTests.swift

main
daybyday/DayByDayTests/SpokenTextTests.swift history · blame · raw

40 lines · 1896 bytes

6 symbols in this file
 1import Testing
 2@testable import DayByDay
 3
 4struct SpokenTextTests {
 5    @Test func splitsSentences() {
 6        #expect(SpokenText.sentences("That's Thursday! Try again.") == ["That's Thursday!", "Try again."])
 7        #expect(SpokenText.sentences("On October 3, it was sunny.") == ["On October 3, it was sunny."])
 8        #expect(SpokenText.sentences("b. b is for ball.") == ["b.", "b is for ball."])
 9        #expect(SpokenText.sentences("Monday") == ["Monday"])
10        #expect(SpokenText.sentences("Great job! An apple is a fruit. Is the banana a fruit or a vegetable?")
11                == ["Great job!", "An apple is a fruit.", "Is the banana a fruit or a vegetable?"])
12    }
13
14    @Test func trimsAndDropsEmpty() {
15        #expect(SpokenText.sentences("  Super!  ") == ["Super!"])
16        #expect(SpokenText.sentences("Great job! ") == ["Great job!"])
17        #expect(SpokenText.sentences("") == [])
18    }
19
20    @Test func greetingNamesOnlyListedNames() {
21        #expect(Lines.greeting(for: "Maya") == "Hi there!")
22        #expect(Lines.greeting(for: nil) == "Hi there!")
23        #expect(Lines.greeting(for: "Sammy B") == "Hi there!")
24        #expect(Lines.greeting(for: " gianna ") == "Hi, Gianna!")
25        #expect(Lines.greeting(for: "THADEUS") == "Hi, Thadeus!")
26        #expect(Lines.greeting(for: "Ollie") == "Hi, Ollie!")
27    }
28}
29
30struct CalendarDayLineTests {
31    @Test func datesSayTheirEnding() {
32        #expect(Lines.calendarDay(.october, 9, weather: nil) == "October 9th.")
33        #expect(Lines.calendarDay(.october, 3, weather: .sunny) == "On October 3rd, it was sunny.")
34        let endings = [1: "1st", 2: "2nd", 3: "3rd", 4: "4th", 11: "11th", 12: "12th", 13: "13th",
35                       21: "21st", 22: "22nd", 23: "23rd", 24: "24th", 30: "30th", 31: "31st"]
36        for (day, text) in endings {
37            #expect(Lines.ordinal(day) == text, "\(day)")
38        }
39    }
40}