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