         let lineString = LineString(string)
         _ = lineString.lineNumber(at: string.length)
         
-        lineString.string = lineString.string.replacingCharacters(in: NSRange(1..<3), with: "") as NSString  // "og"
-        lineString.invalidateLineRanges(in: NSRange(1..<1), changeInLength: -2)
+        lineString.replaceCharacters(in: NSRange(1..<3), with: "")  // "og"
         XCTAssertEqual(lineString.string, "d \n\n\n cat \n ")
         XCTAssertEqual(lineString.lineNumber(at: 1), 1)
         XCTAssertEqual(lineString.lineRange(at: 1), NSRange(0..<3))  // "d \n"

            let range = NSRange(location: location, length: length)
            let replacement = String("ab\nc".prefix(Int.random(in: 0...4)).shuffled())
            
            lineString.string = lineString.string.replacingCharacters(in: range, with: replacement) as NSString
            lineString.invalidateLineRanges(in: NSRange(location: range.location, length: replacement.length),
                                            changeInLength: replacement.length - range.length)
            
            for index in (0..<lineString.string.length).shuffled() {
                XCTAssertEqual(lineString.lineNumber(at: index), lineString.string.lineNumber(at: index),

        self.string = string as NSString
    }
    
    
    func replaceCharacters(in range: NSRange, with replacement: String) {
        
        self.string = self.string.replacingCharacters(in: range, with: replacement) as NSString
        self.invalidateLineRanges(in: NSRange(location: range.location, length: replacement.length),
                                  changeInLength: replacement.length - range.length)
    }
    
}
