import XCTest
import StringDecoder
import List

final class IndentTests: XCTestCase {
    func testIndent() {
        let string = """
        this
            that
            other
        """
        
        struct Some: Equatable {
            let this: String
            let that: String
            let other: String
        }
        
        let decoder = StringDecoder(Some.init) {
            match("this").map(String.init).discard(newline)
            indent.discardThen(match("that")).map(String.init).discard(newline)
            indent.discardThen(match("other")).map(String.init)
        }
        
        switch decoder(string) {
        case .success((let element, _)):
            XCTAssertEqual(element, Some(this: "this", that: "that", other: "other"))
        case .failure(let error):
            XCTFail(error.localizedDescription)
        }
        
        
    }
}
