From 334776da5a3129fe422253432d326b3ba4673955 Mon Sep 17 00:00:00 2001 From: Oschly Date: Sat, 6 Jun 2026 20:40:58 +0200 Subject: [PATCH] split the code to fix rendering issues --- Thesis/Chapters/3. Tests.typ | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/Thesis/Chapters/3. Tests.typ b/Thesis/Chapters/3. Tests.typ index b0de688..96eb913 100644 --- a/Thesis/Chapters/3. Tests.typ +++ b/Thesis/Chapters/3. Tests.typ @@ -53,7 +53,7 @@ final class InMemoryStorageProvider: StorageProvider { Na bazie powyższego kodu zbudowałem pięć przypadków testowych klasy `NotesStorageTests` (program 4.2). Pierwszy z nich weryfikuje, że przy pustym katalogu metoda `loadNotes()` zwraca pustą tablicę. Kolejne dwa testy sprawdzają poprawność tworzenia pliku oraz odczytu istniejącej notatki. Ostatni test sprawdza, czy dwukrotne wywołanie metody tworzącej notatkę o tej samej nazwie generuje dwa odrębne obiekty. -#let notes_storage_tests = [```swift +#let notes_storage_tests_part_1 = [```swift @Suite struct NotesStorageTests { private func makeStorage(root: URL = URL(filePath: "/test")) -> (NotesStorage, InMemoryStorageProvider) { @@ -99,21 +99,22 @@ struct NotesStorageTests { let paths = provider.files.keys #expect(paths.contains(where: { $0.contains("Note 1") })) } - - @Test - func createNoteTwiceCreatesTwoFiles() { - let root = URL(filePath: "/test") - let (storage, _) = makeStorage(root: root) - storage.createNote(name: "Note") - storage.createNote(name: "Note") - let notes = storage.loadNotes() - #expect(notes.count == 2) - } -} ```] +#let notes_storage_tests_part_2 = [```swift + @Test + func createNoteTwiceCreatesTwoFiles() { + let root = URL(filePath: "/test") + let (storage, _) = makeStorage(root: root) + storage.createNote(name: "Note") + storage.createNote(name: "Note") + let notes = storage.loadNotes() + #expect(notes.count == 2) + } +} +```] #figure( - notes_storage_tests, + [#notes_storage_tests_part_1, #notes_storage_tests_part_2], kind: raw, caption: [Testy jednostkowe dla NotesStorage], ) @@ -195,7 +196,7 @@ struct NoteContentCodableTests { `NoteInvitationTests` (program 4.5) obejmuje siedem przypadków testowych. Dwa pierwsze weryfikują, czy metody `accept()` oraz `decline()` przekazują odpowiednio wartości logiczne `true` i `false` do handlera. Kolejne dwa testy sprawdzają czy wielokrotne wywołanie tej samej metody nie powoduje powtórnego wywołania handlera. Piąty test gwarantuje, że po zaakceptowaniu zaproszenia próba jego odrzucenia jest ignorowana. Ostatnie dwa testy weryfikują poprawność obliczanych właściwości: `noteName` zwraca tytuł notatki, a `id` jest tożsame z identyfikatorem nadawcy (`MCPeerID`). -#let note_invitation_tests = [```swift +#let note_invitation_tests_part_1 = [```swift @Suite struct NoteInvitationTests { @Test @@ -246,7 +247,8 @@ struct NoteInvitationTests { let invitation = NoteInvitation { _ in } #expect(invitation.noteName == "Shared note") } - +```] +#let note_invitation_tests_part_2 = [```swift @Test func idIsInvitatorPeerID() { let peerID = MCPeerID(displayName: "host") @@ -260,7 +262,7 @@ struct NoteInvitationTests { ```] #figure( - note_invitation_tests, + [#note_invitation_tests_part_1, #note_invitation_tests_part_2], kind: raw, caption: [Testy jednostkowe NoteInvitation], )