Fix FileAccess test issues, now works everywhere
This commit is contained in:
parent
bec621e410
commit
dd920dffaa
1 changed files with 18 additions and 7 deletions
|
@ -47,12 +47,13 @@ class FileAccessTest : TestBase() {
|
|||
* extensively in the tests provided by this class.
|
||||
*
|
||||
* @param path path string to transform
|
||||
* @param raw if to instead target [FileAccess.toStringRaw]
|
||||
* @return transformed path string
|
||||
* @throws NullPointerException if [FileAccess.temporaryCacheDirectory] is `null`
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
@Throws(NullPointerException::class)
|
||||
private fun transformToStringPath(path: String): String {
|
||||
private fun transformToStringPath(path: String, raw: Boolean = false): String {
|
||||
var string: String = path
|
||||
|
||||
// Replace formatting rules of this test class
|
||||
|
@ -62,10 +63,19 @@ class FileAccessTest : TestBase() {
|
|||
|
||||
// Apply operating system-specific updates
|
||||
when (Environment.operatingSystem) {
|
||||
Environment.OperatingSystem.WINDOWS -> string = "C:${string}"
|
||||
Environment.OperatingSystem.WINDOWS -> {
|
||||
if (string.startsWith(File.separator) || string.startsWith("/"))
|
||||
string = "C:${string}"
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
|
||||
// Replace all slashes with File.separator or vice versa
|
||||
string = if (raw)
|
||||
string.replace("/", File.separator)
|
||||
else
|
||||
string.replace(File.separator, "/")
|
||||
|
||||
return string
|
||||
}
|
||||
|
||||
|
@ -78,7 +88,7 @@ class FileAccessTest : TestBase() {
|
|||
textBlock = """
|
||||
"/some/test/file", "/some/test/file"
|
||||
"\very\nice\test\file.txt", "/very/nice/test/file.txt"
|
||||
"/./did/somebody\\/say\\yoga?", "/did/somebody/say/yoga?"
|
||||
"/./did/somebody\\/say\\yoga" , "/did/somebody/say/yoga"
|
||||
"test.txt", "+/test.txt""""
|
||||
)
|
||||
fun toStringTest(supplyValue: String, compareValue: String) {
|
||||
|
@ -98,12 +108,12 @@ class FileAccessTest : TestBase() {
|
|||
textBlock = """
|
||||
"/some/test/file", "%some%test%file"
|
||||
"\very\nice\test\file.txt", "%very%nice%test%file.txt"
|
||||
"/./did/somebody\////say\\\yoga?", "%did%somebody%say%yoga?"
|
||||
"/./did/somebody\////say\\\yoga", "%did%somebody%say%yoga"
|
||||
"test.txt", "+%test.txt""""
|
||||
)
|
||||
fun toStringRaw(supplyValue: String, compareValue: String) {
|
||||
assertEquals(
|
||||
transformToStringPath(compareValue),
|
||||
transformToStringPath(compareValue, raw = true),
|
||||
FileAccess
|
||||
.temporaryCacheDirectory!!
|
||||
.traverse(supplyValue)
|
||||
|
@ -118,7 +128,7 @@ class FileAccessTest : TestBase() {
|
|||
textBlock = """
|
||||
"/some/test/file", "file"
|
||||
"\very\nice\test\file.txt", "file.txt"
|
||||
"/./did/somebody\\/say\\yoga?", "yoga?"
|
||||
"/./did/somebody\\/say\\yoga", "yoga"
|
||||
"test.txt", "test.txt""""
|
||||
)
|
||||
fun getBaseName(supplyValue: String, compareValue: String) {
|
||||
|
@ -137,10 +147,11 @@ class FileAccessTest : TestBase() {
|
|||
textBlock = """
|
||||
"/some/test/file", "/some/test"
|
||||
"\very\nice\test\file.txt", "/very/nice/test"
|
||||
"/./did/somebody\\/say\\yoga?", "/did/somebody/say"
|
||||
"/./did/somebody\\/say\\yoga", "/did/somebody/say"
|
||||
"test.txt", "+"
|
||||
"configs/default.conf", "+/configs""""
|
||||
)
|
||||
// TODO error /
|
||||
fun parent(supplyValue: String, compareValue: String) {
|
||||
assertEquals(
|
||||
transformToStringPath(compareValue),
|
||||
|
|
Loading…
Reference in a new issue