toHaveTheSameTextualContentAs
Expects that the subject of this
expectation (a Path) has the same textual content as targetPath (using UTF-8 for encoding)
Return
an Expect for the subject of this
expectation.
Since
0.17.0
Samples
val writtenTextInFile = "test_test"
val notEmptyFilePath = tempDir.newFile("test_file_1")
notEmptyFilePath.writeText(writtenTextInFile)
val expectedFilePath = tempDir.newFile("test_file_2")
expectedFilePath.writeText(writtenTextInFile)
val emptyFilePath = tempDir.newFile("test_file_3")
expect(notEmptyFilePath) toHaveTheSameTextualContentAs expectedFilePath
fails { // because nothing is written inside of `emptyFilePath`
expect(emptyFilePath) toHaveTheSameTextualContentAs expectedFilePath
}
infix fun <T : Path> Expect<T>.toHaveTheSameTextualContentAs(pathWithEncoding: PathWithEncoding): Expect<T>(source)
Expects that the subject of this
expectation (a Path) has the same textual content as PathWithEncoding.path in the given pathWithEncoding with the specified encodings.
Use the function withEncoding(Path, Charset, Charset)
to create a PathWithEncoding.
Return
an Expect for the subject of this
expectation.
Samples
val writtenTextInFile = "test_test"
val notEmptyFilePath = tempDir.newFile("test_file_1")
notEmptyFilePath.writeText(writtenTextInFile)
val expectedFilePath = tempDir.newFile("test_file_2")
expectedFilePath.writeText(writtenTextInFile)
val emptyFilePath = tempDir.newFile("test_file_3")
expect(notEmptyFilePath) toHaveTheSameTextualContentAs withEncoding(
expectedFilePath,
Charsets.UTF_8,
Charsets.UTF_8
)
fails { // because nothing is written inside of `emptyFilePath`
expect(emptyFilePath) toHaveTheSameTextualContentAs withEncoding(
expectedFilePath,
Charsets.UTF_8,
Charsets.UTF_8
)
}