from: github.com/remko/age-plugin-se
This commit is contained in:
27
Tests/MemoryStream.swift
Normal file
27
Tests/MemoryStream.swift
Normal file
@@ -0,0 +1,27 @@
|
||||
@testable import age_plugin_se
|
||||
|
||||
class MemoryStream: Stream {
|
||||
var inputLines: [String] = []
|
||||
var outputLines: [String] = []
|
||||
|
||||
var output: String {
|
||||
return outputLines.joined(separator: "\n")
|
||||
}
|
||||
|
||||
func add(input: String) {
|
||||
inputLines.append(contentsOf: input.components(separatedBy: "\n"))
|
||||
}
|
||||
|
||||
func readLine() -> String? {
|
||||
if inputLines.isEmpty {
|
||||
return nil
|
||||
}
|
||||
let result = inputLines[0]
|
||||
inputLines.removeFirst()
|
||||
return result
|
||||
}
|
||||
|
||||
func writeLine(_ line: String) {
|
||||
outputLines.append(contentsOf: line.components(separatedBy: "\n"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user