Tests/OrgCoreTests/ASCIISearchTests.swift

cba778d55e19c2c7a8dce862eb5d5f46d3d8c792
orgstar/Tests/OrgCoreTests/ASCIISearchTests.swift history · blame · raw

15 lines · 675 bytes

 1import Foundation
 2import Testing
 3@testable import OrgCore
 4
 5struct ASCIISearchTests {
 6    @Test func matchesCaseInsensitiveRangeOf() {
 7        let texts = ["", "#+SETUPFILE: x", "a\n#+SetupFile:y", "#+setupfil", "é #+setupfile:", "##+setupfile:", "[CITE:@a]", "x[cit"]
 8        for text in texts {
 9            for needle in ["#+setupfile:", "[cite", "#+INCLUDE:"] {
10                #expect(text.containsIgnoringASCIICase(needle) == (text.range(of: needle, options: .caseInsensitive) != nil), "\(text) \(needle)")
11                #expect(text[...].containsIgnoringASCIICase(needle) == (text.range(of: needle, options: .caseInsensitive) != nil))
12            }
13        }
14    }
15}