fixed name of file

This commit is contained in:
Oliver Drobnik
2025-03-07 12:18:05 +01:00
parent e6c67ff418
commit bb4fcc55eb
3 changed files with 3 additions and 89 deletions
@@ -1,4 +1,4 @@
// StringExtensions.swift
// String+Redacting.swift
// String extensions for the SwiftMailCore library
import Foundation
@@ -1,86 +0,0 @@
import Foundation
import Testing
import NIOIMAP
@testable import SwiftIMAP
struct StringUtilitiesTests {
// MARK: - Sanitized Filename Tests
@Test
func testSanitizedFileName() {
// Test basic valid filename
let validName = "document.txt"
#expect(validName.sanitizedFileName() == "document.txt")
// Test filename with invalid characters
let invalidChars = "file:with*invalid/characters?.txt"
#expect(invalidChars.sanitizedFileName() == "file_with_invalid_characters_.txt")
// Test filename with spaces
let spacesName = "my document.pdf"
#expect(spacesName.sanitizedFileName() == "my_document.pdf")
// Test filename with special characters
let specialChars = "résumé (2023).pdf"
#expect(specialChars.sanitizedFileName() == "résumé_(2023).pdf")
// Test empty string
let emptyString = ""
#expect(emptyString.sanitizedFileName() == "")
}
// MARK: - File Extension Tests
@Test
func testFileExtension() {
// Test common MIME types
#expect(String.fileExtension(for: "text/plain") == "txt")
#expect(String.fileExtension(for:"text/html") == "html")
#expect(String.fileExtension(for:"image/jpeg") == "jpeg")
#expect(String.fileExtension(for:"image/png") == "png")
#expect(String.fileExtension(for:"application/pdf") == "pdf")
// Test less common MIME types
#expect(String.fileExtension(for:"audio/mp3") == "mp3")
#expect(String.fileExtension(for:"video/mp4") == "mp4")
#expect(String.fileExtension(for:"application/zip") == "zip")
// Test unknown MIME types
#expect(String.fileExtension(for:"application/x-custom") == nil)
#expect(String.fileExtension(for:"unknown/type") == nil)
}
// MARK: - Sequence Set Tests
@Test
func testToSequenceSet() throws {
// Test single number
let singleNumber = "42"
_ = try singleNumber.toSequenceSet()
// We can't directly test the contents, so we'll just verify it doesn't throw
// Test simple range
let simpleRange = "1:10"
_ = try simpleRange.toSequenceSet()
// We can't directly test the contents, so we'll just verify it doesn't throw
// Test invalid input
let invalidRange = "abc"
do {
_ = try invalidRange.toSequenceSet()
throw TestFailure("Expected toSequenceSet to throw for invalid input")
} catch {
// Expected to throw
}
// Test empty string
let emptyString = ""
do {
_ = try emptyString.toSequenceSet()
throw TestFailure("Expected toSequenceSet to throw for empty string")
} catch {
// Expected to throw
}
}
}
@@ -1,4 +1,4 @@
// StringExtensionsTests.swift
// String+RedactingTests.swift
// Tests for string extensions in the SwiftMailCore library
import Testing
@@ -68,4 +68,4 @@ struct StringExtensionsTests {
let result = loginAtEnd.redactAfter("LOGIN")
#expect(result == loginAtEnd, "Should not redact when LOGIN is at the end with no credentials")
}
}
}