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/ParentGateTests.swift

062549ad26607ce9e973ed2a9a7ef6f853885f83
daybyday/DayByDayTests/ParentGateTests.swift history · blame · raw

27 lines · 717 bytes

4 symbols in this file
 1import Testing
 2@testable import DayByDay
 3
 4struct ParentGateTests {
 5    @Test func operandsInRange() {
 6        var rng = SeededGenerator(seed: 9)
 7        for _ in 0..<1000 {
 8            let c = ParentGateChallenge.random(using: &rng)
 9            #expect((6...9).contains(c.a))
10            #expect((6...9).contains(c.b))
11        }
12    }
13
14    @Test func acceptsCorrectSum() {
15        let c = ParentGateChallenge(a: 7, b: 8)
16        #expect(c.answer == 15)
17        #expect(c.accepts("15"))
18        #expect(c.accepts(" 15 "))
19    }
20
21    @Test func rejectsWrong() {
22        let c = ParentGateChallenge(a: 7, b: 8)
23        #expect(!c.accepts("14"))
24        #expect(!c.accepts(""))
25        #expect(!c.accepts("abc"))
26    }
27}