doc / ch.tutteli.atrium.api.infix.en_GB / notToBe

notToBe

infix fun <T : CharSequence> Expect<T>.notToBe(empty: empty): Expect<T> (source)

Expects that the subject of this expectation (a CharSequence) CharSequence.kotlin.text.isNotEmpty.

expect("XYZ") notToBe empty

fails {
    expect("") notToBe empty
}

// use `notToBe blank` to check for whitespaces
expect(" ") notToBe empty

Parameters

empty - Use the pseudo-keyword empty.

Return
an Expect for the subject of this expectation.

infix fun <T : CharSequence> Expect<T>.notToBe(blank: blank): Expect<T> (source)

Expects that the subject of this expectation (a CharSequence) CharSequence.kotlin.text.isNotBlank.

expect("XZY") notToBe blank

fails {
    expect(" ") notToBe blank
}

fails { // because an empty string is also considered to be a blank string
    expect("") notToBe blank
}

Parameters

blank - Use the pseudo-keyword blank.

Return
an Expect for the subject of this expectation.

infix fun <T> Expect<T>.notToBe(expected: T): Expect<T> (source)
Deprecated: Use notToEqual; will be removed with 1.0.0 at the latest

Expects that the subject of this expectation is not (equal to) expected.

expect(2) notToBe 3

fails {
    expect(12) notToBe 12
}

expect(listOf(2)) notToBe listOf(3)

fails {
    expect(listOf(2)) notToBe listOf(2)
}

Return
an Expect for the subject of this expectation.

infix fun <T : Path> Expect<T>.notToBe(existing: existing): Expect<T> (source)

Expects that the subject of this expectation (a Path) does not exist; meaning that there is no file system entry at the location the Path points to.

This assertion resolves symbolic links. Therefore, if a symbolic link exists at the location the subject points to, then the search will continue at that location.

val dir = tempDir.newDirectory("test_dir")

expect(Paths.get("non_existing_dir")) notToBe existing

fails {
    expect(dir) notToBe existing
}

Return
an Expect for the subject of this expectation.

Since
0.12.0

infix fun <T : Path> Expect<T>.notToBe(readable: readable): Expect<T> (source)

Expects that the subject of this expectation (a Path) is not readable; meaning that there is a file system entry at the location the Path points to and that the current thread does not have the permission to read from it.

This assertion resolves symbolic links. Therefore, if a symbolic link exists at the location the subject points to, search will continue at the location the link points at.

This assertion is not atomic with respect to concurrent file system operations on the paths the assertion works on. Its result, in particular its extended explanations, may be wrong if such concurrent file system operations take place.

assertIf(fileSystemSupportsPosixPermissions()) {
    val writeOnlyPermissions =
        PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("-w--w--w-"))
    val readWritePermissions =
        PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-rw-rw-"))

    val writeOnlyDir = tempDir.newDirectory("write_only_dir", writeOnlyPermissions)
    val writeOnlyFile = tempDir.newFile("write_only_file", writeOnlyPermissions)
    val readWriteDir = tempDir.newDirectory("read_write_dir", readWritePermissions)
    val readWriteFile = tempDir.newFile("read_write_file", readWritePermissions)

    expect(writeOnlyDir) notToBe readable
    expect(writeOnlyFile) notToBe readable

    fails {
        expect(readWriteDir) notToBe readable
    }
    fails {
        expect(readWriteFile) notToBe readable
    }
}

fails {
    expect(Paths.get("non_existing_dir")) notToBe readable
}

Return
an Expect for the subject of this expectation.

Since
0.17.0

infix fun <T : Path> Expect<T>.notToBe(writable: writable): Expect<T> (source)

Expects that the subject of this expectation (a Path) is not writable; meaning that there is a file system entry at the location the Path points to and that the current thread does not have the permission to write from it.

This assertion resolves symbolic links. Therefore, if a symbolic link exists at the location the subject points to, search will continue at the location the link points at.

This assertion is not atomic with respect to concurrent file system operations on the paths the assertion works on. Its result, in particular its extended explanations, may be wrong if such concurrent file system operations take place.

assertIf(ifPosixSupported) {
    val readyOnlyPermissions =
        PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("r--r--r--"))
    val readyWritePermissions =
        PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-r--r--"))

    val readOnlyDir = tempDir.newDirectory("read_only_dir", readyOnlyPermissions)
    val readOnlyFile = tempDir.newFile("read_only_file", readyOnlyPermissions)
    val readWriteDir = tempDir.newDirectory("read_write_dir", readyWritePermissions)
    val readWriteFile = tempDir.newFile("read_write_file", readyWritePermissions)

    expect(readOnlyDir) notToBe writable
    expect(readOnlyFile) notToBe writable

    fails {
        expect(readWriteDir) notToBe writable
    }
    fails {
        expect(readWriteFile) notToBe writable
    }
}

fails {
    expect(Paths.get("non_existing_dir")) notToBe writable
}

Return
an Expect for the subject of this expectation.

Since
0.17.0

infix fun <T : Path> Expect<T>.notToBe(executable: executable): Expect<T> (source)

Expects that the subject of this expectation (a Path) is not executable; meaning that there is a file system entry at the location the Path points to and that the current thread does not have the permission to execute it.

The semantics of “permission to execute it” may differ when checking access to a directory. For example, on UNIX systems, it means that the Java virtual machine has permission to search the directory in order to access file or subdirectories.

This assertion resolves symbolic links. Therefore, if a symbolic link exists at the location the subject points to, search will continue at the location the link points at.

assertIf(ifPosixSupported) {
    val readyOnlyPermissions =
        PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("r--r--r--"))
    val readyWriteExecutePermissions =
        PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxr--r--"))

    val readOnlyDir = tempDir.newDirectory("read_only_dir", readyOnlyPermissions)
    val readOnlyFile = tempDir.newFile("read_only_file", readyOnlyPermissions)
    val readWriteExecuteDir = tempDir.newDirectory("read_write_execute_dir", readyWriteExecutePermissions)
    val readWriteExecuteFile = tempDir.newFile("read_write_execute_file", readyWriteExecutePermissions)

    expect(readOnlyDir) notToBe executable
    expect(readOnlyFile) notToBe executable

    fails {
        expect(readWriteExecuteDir) notToBe executable
    }
    fails {
        expect(readWriteExecuteFile) notToBe executable
    }
}

fails {
    expect(Paths.get("non_existing_dir")) notToBe executable
}

Return
an Expect for the subject of this expectation.

Since
0.17.0