### StartsWith Assertion Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/index.html Checks if a string starts with a specified prefix. (Details not fully provided in input). ```APIDOC ## startsWith ### Description Asserts that a string starts with a specified prefix. ### Method Extension function on `Assert` (assumed) ### Endpoint N/A (Kotlin function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```kotlin assertThat("hello world").startsWith("hello") ``` ### Response #### Success Response (200) Passes if the string starts with the prefix. #### Response Example N/A (Boolean result of assertion) ``` -------------------------------- ### Assert List startsWith Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/starts-with.html Asserts that a List starts with a sequence of specified elements in the exact order. This is useful for verifying the initial state or contents of a list. It handles cases with empty lists and empty expected elements. ```kotlin fun Assert>.startsWith(vararg elements: Any?) ``` -------------------------------- ### Equality Assertions (isEqualTo, isNotEqualTo) in Kotlin Source: https://context7.com/assertk-org/assertk/llms.txt Illustrates how to use `isEqualTo` and `isNotEqualTo` for checking value equality in assertk. It covers basic equality, case-insensitive string comparison, and provides an example of a failure message. ```kotlin import assertk.assertThat import assertk.assertions.* // Basic equality assertThat("hello").isEqualTo("hello") // passes assertThat(42).isEqualTo(42) // passes // Case-insensitive string comparison assertThat("HELLO").isEqualTo("hello", ignoreCase = true) // passes // Not equal assertThat("hello").isNotEqualTo("world") // passes // Failure message example: assertThat("actual").isEqualTo("expected") // -> expected:<"[expected]"> but was:<"[actual]"> ``` -------------------------------- ### Example Failure Message Format in Kotlin Source: https://github.com/assertk-org/assertk/blob/main/Contributing.md This snippet shows the recommended format for assertion failure messages in Kotlin. It uses the `show()` function to display the expected and actual values, ensuring clarity in error reporting. ```kotlin expected:${show(foo)} but was:${show(bar)} ``` -------------------------------- ### Setup AssertK for Kotlin Multiplatform Projects Source: https://github.com/assertk-org/assertk/blob/main/README.md This code demonstrates how to include assertk in a Kotlin multiplatform project. It adds the library as a common test dependency, making it available across all target platforms (JVM, JS, Native). ```kotlin plugins { kotlin("multiplatform") } kotlin { sourceSets { val commonTest by getting { dependencies { implementation("com.willowtreeapps.assertk:assertk:0.28.1") } } } } ``` -------------------------------- ### Assert CharSequence Starts With (Kotlin) Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/index.html Asserts that a CharSequence starts with another CharSequence, with an option to ignore case. This is a utility function provided by Assertk. ```kotlin fun Assert.startsWith(other: CharSequence, ignoreCase: Boolean = false) ``` -------------------------------- ### Setup assertk-coroutines Dependency Source: https://github.com/assertk-org/assertk/blob/main/assertk-coroutines/README.md This snippet shows how to add the assertk-coroutines testing dependency to your project using Gradle. It includes configuring the mavenCentral repository and declaring the testImplementation dependency for the library. ```groovy repositories { mavenCentral() } dependencies { testImplementation("com.willowtreeapps.assertk:assertk-coroutines:0.28.0") } ``` -------------------------------- ### Setup AssertK with Maven Central for JVM Projects Source: https://github.com/assertk-org/assertk/blob/main/README.md This snippet shows how to add the assertk library as a test dependency in a JVM project using Maven Central. Ensure you have the `repositories` block configured to include `mavenCentral()`. ```kotlin repositories { mavenCentral() } dependencies { testImplementation("com.willowtreeapps.assertk:assertk:0.28.1") } ``` -------------------------------- ### Setup assertk Dependency in Gradle Kotlin DSL Source: https://context7.com/assertk-org/assertk/llms.txt Add the assertk library to your project's test dependencies using the Gradle Kotlin DSL. This snippet shows configurations for both standard JVM projects and Kotlin Multiplatform projects. ```kotlin // build.gradle.kts repositories { mavenCentral() } dependencies { testImplementation("com.willowtreeapps.assertk:assertk:0.28.1") } // For multiplatform projects: kotlin { sourceSets { val commonTest by getting { dependencies { implementation("com.willowtreeapps.assertk:assertk:0.28.1") } } } } ``` -------------------------------- ### Assert List Starts With Elements (Kotlin) Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/index.html Asserts that a list begins with a specified sequence of elements in the same order. This function is part of the Assertk library for Kotlin. ```kotlin fun Assert>.startsWith(vararg elements: Any?) ``` -------------------------------- ### Testing Flow Emissions with Turbine Source: https://github.com/assertk-org/assertk/blob/main/assertk-coroutines/README.md Illustrates using the Turbine library in conjunction with assertk-coroutines for more complex flow assertions. This example shows how to test individual item emissions and completion of a flow using `test`, `expectItem`, and `expectComplete`. ```kotlin flowOf("one", "two").test { assertThat(expectItem()).isEqualTo("one") assertThat(expectItem()).isEqualTo("two") expectComplete() } ``` -------------------------------- ### Custom Assertion Example using Assert.given Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-assert/given.html Demonstrates how to create a custom assertion 'isTen' using the 'given' function. It checks if the actual integer value is 10 and provides a custom error message if it's not. ```kotlin fun Assert.isTen() = given { actual -> if (actual == 10) return expected("to be 10 but was:${show(actual)}") } ``` -------------------------------- ### Asserting Flow Contents Source: https://github.com/assertk-org/assertk/blob/main/assertk-coroutines/README.md Demonstrates how to assert the contents of a Kotlin Flow using assertk-coroutines. The example uses `runBlocking` to execute the coroutine and `assertThat(flow).contains(...)` to verify the flow emits the expected elements. ```kotlin runBlocking { val flow = flowOf("one", "two") assertThat(flow).contains("one", "two") } ``` -------------------------------- ### Assert if value is between start and end (inclusive) - Kotlin Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/index.html Asserts that the value is within the specified range, including the start and end values. This function requires the type to be Comparable. It takes two arguments: 'start' and 'end', both of the same comparable type as the asserted value. ```kotlin fun , B : A> Assert.isBetween(start: A, end: A) ``` -------------------------------- ### PlatformName Constructor Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-platform-name/-platform-name.html Constructs a new PlatformName object with the specified name. ```APIDOC ## PlatformName() ### Description Constructs a new PlatformName object with the specified name. ### Method CONSTRUCTOR ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```kotlin val platformName = PlatformName("MyPlatform") ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### ThreadLocalRef get() Function in AssertK Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-thread-local-ref/get.html Retrieves the value from the ThreadLocalRef. This function is available across multiple targets including common, JavaScript, native, and WebAssembly JavaScript. It returns the generic type T. ```kotlin expect fun [get](get.html)(): [T](index.html) ``` ```kotlin actual fun [get](get.html)(): [T](index.html) ``` ```kotlin actual fun [get](get.html)(): [T](index.html) ``` ```kotlin actual fun [get](get.html)(): [T](index.html) ``` -------------------------------- ### ThreadLocalRef Value Property Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/index.html Gets or sets the value of the thread-local reference for the current thread. ```APIDOC ## ThreadLocalRef Value Property ### Description Gets or sets the value of the thread-local reference for the current thread. ### Property var <[T](value.html)> [ThreadLocalRef](-thread-local-ref/index.html)<[T](value.html)>.[value](value.html): [T](value.html) ``` -------------------------------- ### ThreadLocalRef Functions Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-thread-local-ref/index.html Functions available for the ThreadLocalRef class, including get, remove, and set. ```APIDOC ## ThreadLocalRef Functions ### Description Functions available for the ThreadLocalRef class, including get, remove, and set. ### Method GET/POST/DELETE ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **value** (T) - Required for the `set` function. ### Request Example ```json { "value": "new_value" } ``` ### Response #### Success Response (200) - **get()**: Returns the value of type T. - **remove()**: Removes the current thread's value. - **set(value: T)**: Sets the value for the current thread. #### Response Example ```json { "get_result": "retrieved_value" } ``` ``` -------------------------------- ### Initialize Dark Mode Preference (JavaScript) Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/assert-that.html Initializes dark mode preference based on local storage or OS preference. It checks for 'dokka-dark-mode' in localStorage and applies the 'theme-dark' class to the html element if dark mode is enabled. If no preference is found in localStorage, it checks the OS preference. ```javascript var pathToRoot = "../../"; document.documentElement.classList.replace("no-js","js"); const storage = localStorage.getItem("dokka-dark-mode"); if (storage == null) { const osDarkSchemePreferred = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; if (osDarkSchemePreferred === true) { document.getElementsByTagName("html")[0].classList.add("theme-dark"); } } else { const savedDarkMode = JSON.parse(storage); if(savedDarkMode === true) { document.getElementsByTagName("html")[0].classList.add("theme-dark"); } } ``` -------------------------------- ### File Extension Assertion Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/index.html Assert that a file path exists and get an assertion on its extension. ```APIDOC ## File Extension Assertion ### Description Assert that the path exists and returns an assertion on the file's extension. ### Method GET (or similar, depending on context) ### Endpoint `/assertk/file/extension` (Hypothetical endpoint for demonstration) ### Parameters #### Path Parameters - **filePath** (string) - Required - The path to the file. #### Query Parameters None #### Request Body None ### Request Example None (This is a function call, not a typical HTTP request) ### Response #### Success Response (200) - **extension** (string) - The file extension. #### Response Example ```json { "extension": "txt" } ``` ``` -------------------------------- ### Initialize Dark Mode (JavaScript) Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-table2/for-all.html This JavaScript code initializes dark mode based on user preferences or local storage settings. It checks the operating system's preferred color scheme and saved user preferences to apply the 'theme-dark' class to the HTML element. ```javascript var pathToRoot = "../../../\n"; document.documentElement.classList.replace("no-js","js"); const storage = localStorage.getItem("dokka-dark-mode") if (storage == null) { const osDarkSchemePreferred = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches if (osDarkSchemePreferred === true) { document.getElementsByTagName("html")[0].classList.add("theme-dark") } } else { const savedDarkMode = JSON.parse(storage) if(savedDarkMode === true) { document.getElementsByTagName("html")[0].classList.add("theme-dark") } } ``` -------------------------------- ### File Path Assertions Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/index.html Provides assertions for file paths, including getting the parent directory or the full path. ```APIDOC ## parent ### Description Returns an assert on the file's parent directory. ### Method Extension function on `Assert` ### Endpoint N/A (Kotlin function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```kotlin val file = File("/path/to/some/file.txt") assertThat(file).parent().isEqualTo("/path/to/some") ``` ### Response #### Success Response (200) An `Assert` object representing the parent directory path. #### Response Example N/A (Assert object returned ``` ```APIDOC ## path ### Description Returns an assert on the file's path. ### Method Extension function on `Assert` ### Endpoint N/A (Kotlin function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```kotlin val file = File("/path/to/some/file.txt") assertThat(file).path().isEqualTo("/path/to/some/file.txt") ``` ### Response #### Success Response (200) An `Assert` object representing the file path. #### Response Example N/A (Assert object returned ``` -------------------------------- ### Assert isStrictlyBetween Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/index.html Asserts that a value falls strictly between a specified start and end value (non-inclusive). Requires the type to be Comparable. ```APIDOC ## GET /assertk/isStrictlyBetween ### Description Asserts the value is between the expected start and end values, non-inclusive. ### Method GET ### Endpoint /assertk/isStrictlyBetween ### Parameters #### Query Parameters - **value** (B) - Required - The value to check. - **start** (A) - Required - The lower bound (exclusive). - **end** (A) - Required - The upper bound (exclusive). ### Request Example ```json { "value": 5, "start": 1, "end": 10 } ``` ### Response #### Success Response (200) - **message** (string) - Assertion successful. #### Response Example ```json { "message": "Assertion successful." } ``` ``` -------------------------------- ### Assert Strictly Between (Kotlin) Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/index.html Asserts that a value is strictly between two other values (start and end, non-inclusive). The type must be comparable. ```kotlin assertThat(value).isStrictlyBetween(start, end) ``` -------------------------------- ### isBetween Assertion Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/is-between.html Asserts that a value is inclusively between a specified start and end value. This function is part of the assertk library for Kotlin. ```kotlin fun , B : Comparable> Assert.isBetween(start: A, end: A) ``` -------------------------------- ### Basic Value Assertion with assertThat in Kotlin Source: https://context7.com/assertk-org/assertk/llms.txt Demonstrates the basic usage of the `assertThat()` function in assertk to wrap a value and perform assertions. It shows direct value assertions and assertions with optional names for clearer error reporting, including the use of property references. ```kotlin import assertk.assertThat import assertk.assertions.* data class Person(val name: String, val age: Int) // Basic value assertion assertThat(42).isEqualTo(42) // With optional name for clearer error messages val person = Person("Bob", 16) assertThat(person.age, "person age").isGreaterThan(18) // Error: expected [person age] to be greater than:<18> but was:<16> // Using property reference (auto-extracts name) assertThat(person::name).isEqualTo("Bob") // Error would show: expected [name]:<"Alice"> but was:<"Bob"> ``` -------------------------------- ### Assert.all() Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/index.html Runs all assertions within the provided lambda. If any assertion fails, all failures are reported. ```APIDOC ## Assert.all() ### Description All assertions in the given lambda are run. ### Method `fun Assert.all(message: String, body: Assert.() -> Unit)` ### Endpoint N/A (This is a function within a class) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```kotlin // Example usage within a test assertThat(myObject).all("Checking all properties") { prop1.isEqualTo(expectedValue1) prop2.isNotNull() } ``` ### Response #### Success Response (200) N/A (This function does not return a value, but executes assertions) #### Response Example N/A ``` -------------------------------- ### Get Kotlin Class assertion (Kotlin) Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-assert/index.html Returns an assertion object for the Kotlin KClass of the value. This allows assertions on the compile-time Kotlin type information. ```kotlin fun Assert.kClass(): Assert> ``` -------------------------------- ### Assert if value is strictly between two bounds (Kotlin) Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-assert/index.html Asserts that the value is strictly greater than 'start' and strictly less than 'end'. This function requires the type 'A' to be comparable. ```kotlin fun , B> Assert.isStrictlyBetween(start: A, end: A) ``` -------------------------------- ### isStrictlyBetween Assertion (Kotlin) Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/is-strictly-between.html The isStrictlyBetween function in Kotlin asserts that a value is strictly between a given start and end value. It requires the type A to be comparable. This function is part of the assertk library for fluent assertions. ```kotlin fun , B : Comparable> Assert.isStrictlyBetween(start: A, end: A) ``` -------------------------------- ### PlatformName Constructor - Kotlin Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-platform-name/-platform-name.html Defines the constructor for the PlatformName class. It takes a single String argument representing the name of the platform. This is a core part of identifying and managing platform-specific configurations within the assertk framework. ```kotlin fun PlatformName(name: String) ``` -------------------------------- ### TableBuilder Classes Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/index.html Builds a table with the given rows. ```APIDOC ## TableBuilder Classes ### Description Builds a table with the given rows. ### Types - sealed class [TableBuilder](-table-builder/index.html) - class [Table1Builder](-table1-builder/index.html) : [TableBuilder](-table-builder/index.html) - class [Table2Builder](-table2-builder/index.html) : [TableBuilder](-table-builder/index.html) - class [Table3Builder](-table3-builder/index.html) : [TableBuilder](-table-builder/index.html) - class [Table4Builder](-table4-builder/index.html) : [TableBuilder](-table-builder/index.html) ``` -------------------------------- ### Get Parent Directory Assert for File in Kotlin (JVM) Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/index.html Returns an assertion on the parent directory of a given File. This is specifically for JVM environments and allows for assertions on the file's hierarchical location. ```kotlin fun Assert.parent(): Assert ``` -------------------------------- ### Get File Path Assert for File in Kotlin (JVM) Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/index.html Returns an assertion on the full path of a given File. This function is available on the JVM and enables assertions related to the complete file location string. ```kotlin fun Assert.path(): Assert ``` -------------------------------- ### Basic AssertK Usage for String and Integer Properties Source: https://github.com/assertk-org/assertk/blob/main/README.md Illustrates fundamental assertk usage by testing a `Person` object's `name` and `age` properties. It shows how to assert equality for strings and check if an integer is greater than a specific value. The `assertThat` function wraps the value under test, and assertion methods are chained to it. ```kotlin import assertk.assertThat import assertk.assertions.* class PersonTest { val person = Person(name = "Bob", age = 18) @Test fun testName() { assertThat(person.name).isEqualTo("Alice") // -> expected:<["Alice"]> but was:<["Bob"]> } @Test fun testAge() { assertThat(person.age, "age").isGreaterThan(20) // -> expected [age] to be greater than:<20> but was:<18> } @Test fun testNameProperty() { assertThat(person::name).isEqualTo("Alice") // -> expected [name]:<["Alice"]> but was:<["Bob"]> } } ``` -------------------------------- ### Initialize Dark Mode Preference - JavaScript Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-table/index.html This JavaScript code snippet initializes the dark mode preference for the webpage. It checks local storage for saved preferences or uses the operating system's preferred color scheme if no preference is found. It then applies the 'theme-dark' class to the HTML element accordingly. ```javascript var pathToRoot = "../../../"; document.documentElement.classList.replace("no-js","js"); const storage = localStorage.getItem("dokka-dark-mode") if (storage == null) { const osDarkSchemePreferred = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches if (osDarkSchemePreferred === true) { document.getElementsByTagName("html")[0].classList.add("theme-dark") } } else { const savedDarkMode = JSON.parse(storage) if(savedDarkMode === true) { document.getElementsByTagName("html")[0].classList.add("theme-dark") } } ``` -------------------------------- ### Assert CharSequence startsWith Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/starts-with.html Asserts that a CharSequence begins with a specified prefix. An optional 'ignoreCase' parameter can be set to true to perform a case-insensitive comparison. This function is useful for validating string prefixes. ```kotlin fun Assert.startsWith(other: CharSequence, ignoreCase: Boolean = false) ``` -------------------------------- ### assertAll Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/assert-all.html Runs all assertions within a given lambda and aggregates any failures encountered. ```APIDOC ## assertAll ### Description Runs all assertions in the given lambda and reports any failures. ### Method Inline function (Kotlin) ### Endpoint N/A (Kotlin function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```kotlin assertAll { assertEquals(1, 2) assertTrue(false) } ``` ### Response #### Success Response N/A (This function executes assertions and throws exceptions on failure). #### Response Example N/A ``` -------------------------------- ### Create Table with Three Columns - Kotlin Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/table-of.html This Kotlin function signature defines how to create a table with three columns. It takes three String arguments for the column names and returns a Table3Builder object. ```kotlin fun tableOf(name1: String, name2: String, name3: String): Table3Builder ``` -------------------------------- ### Assert Value Does Not Have Kotlin Class (Generic) Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/does-not-have-class.html Asserts that the subject does not have the specified Kotlin class. This is an exact match. For example, assertThat("test").doesNotHaveClass() will fail, while assertThat("test").doesNotHaveClass() will succeed. ```kotlin inline fun Assert.doesNotHaveClass() ``` -------------------------------- ### Create Table with Two Columns - Kotlin Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/table-of.html This Kotlin function signature defines how to create a table with two columns. It accepts two String arguments for the column names and returns a Table2Builder object. ```kotlin fun tableOf(name1: String, name2: String): Table2Builder ``` -------------------------------- ### Table3Builder Class Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-table3-builder/index.html Provides functionality to build tables with three columns. ```APIDOC ## Table3Builder Class ### Description Builds a table with the given rows. This class extends `TableBuilder` and is designed for tables with three columns. ### Members #### Functions ##### `row` Adds a row to the table with the given values. - **Method**: `fun` - **Signature**: ` row(val1: C1, val2: C2, val3: C3): Table3` - **Parameters**: - `val1` (C1) - The first value for the row. - `val2` (C2) - The second value for the row. - `val3` (C3) - The third value for the row. - **Returns**: A `Table3` object representing the row added. ### Example ```kotlin // Assuming 'tableBuilder' is an instance of Table3Builder val table = tableBuilder.row("value1", 123, true) ``` ``` -------------------------------- ### Assert Value Does Not Have Java Class Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/does-not-have-class.html Asserts that the subject does not have the specified Java Class. This is an exact match. For example, assertThat("test").doesNotHaveClass(String::class.java) will fail, while assertThat("test").doesNotHaveClass(Any::class.java) will succeed. ```kotlin fun Assert.doesNotHaveClass(jclass: Class) ``` -------------------------------- ### Table1.forAll Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-table1/for-all.html The forAll function allows you to execute a given lambda for each row within a table. This is useful for performing operations or assertions on every element of the table. ```APIDOC ## fun forAll ### Description Runs the given lambda for each row in the table. ### Method N/A (This is a function, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response N/A #### Response Example N/A ``` -------------------------------- ### File Assertions: hasText Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/has-text.html Asserts that a file contains exactly the specified text, with an option to define the character set. ```APIDOC ## fun File.hasText(expected: String, charset: Charset = Charsets.UTF_8) ### Description Asserts the file contains exactly the expected text (and nothing else). ### Method Extension Function (on File) ### Endpoint N/A (This is a function within a library, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```kotlin // Assuming 'file' is a File object file.assert { hasText("expected content") } file.assert { hasText("content with different charset", Charsets.ISO_8859_1) } ``` ### Response #### Success Response N/A (This is an assertion, it throws an exception on failure) #### Response Example N/A ``` -------------------------------- ### Assert Value Does Not Have Kotlin Class (KClass) Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/does-not-have-class.html Asserts that the subject does not have the specified Kotlin KClass. This is an exact match. For example, assertThat("test").doesNotHaveClass(String::class) will fail, while assertThat("test").doesNotHaveClass(Any::class) will succeed. ```kotlin fun Assert.doesNotHaveClass(kclass: KClass) ``` -------------------------------- ### Dark Mode Toggle Script Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/at-most.html This JavaScript code handles the dark mode toggle functionality for the documentation page. It checks local storage for user preferences and system settings to apply the dark theme. ```javascript var pathToRoot = "../../"; document.documentElement.classList.replace("no-js","js"); const storage = localStorage.getItem("dokka-dark-mode") if (storage == null) { const osDarkSchemePreferred = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches if (osDarkSchemePreferred === true) { document.getElementsByTagName("html")[0].classList.add("theme-dark") } } else { const savedDarkMode = JSON.parse(storage) if(savedDarkMode === true) { document.getElementsByTagName("html")[0].classList.add("theme-dark") } } ``` -------------------------------- ### Create Table with Four Columns - Kotlin Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/table-of.html This Kotlin function signature defines how to create a table with four columns. It accepts four String arguments for the column names and returns a Table4Builder object. ```kotlin fun tableOf(name1: String, name2: String, name3: String, name4: String): Table4Builder ``` -------------------------------- ### Show Function Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions.support/show.html The 'show' function is used to display a value within a failure message, optionally wrapped in specified characters. ```APIDOC ## fun show(value: Any?, wrap: String = "<>"): String ### Description Shows the primary value in a failure message. ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Request Example ```kotlin // Example usage (not a direct API call, but conceptual) val message = show("some value", "()") // Returns "(some value)" ``` ### Response #### Success Response (200) * **String** - The formatted string representation of the value. #### Response Example ```json { "example": "(some value)" } ``` ``` -------------------------------- ### Assert Map Value by Key - Kotlin Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/key.html This Kotlin extension function for Assert on Maps allows asserting the value associated with a specific key. It returns an Assert object for the value, enabling chained assertions. The example demonstrates asserting that the value for 'key' in a map is 'value'. ```kotlin assertThat(mapOf("key" to "value")).key("key").isEqualTo("value") ``` -------------------------------- ### Assert Object Does Not Have Class (Kotlin) Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/index.html Asserts that an object does not have a specific Kotlin class. This check performs an exact class match. For example, `assertThat("test").doesNotHaveClass()` will fail, while `assertThat("test").doesNotHaveClass()` will succeed. This is an inline function for `Any` type. ```kotlin inline fun Assert.doesNotHaveClass() ``` -------------------------------- ### Kotlin: Assert Path is Same File As Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/is-same-file-as.html Asserts that a Path object points to the same file as the expected Path object. This is a JVM-specific extension function for the Assert class. ```kotlin fun Assert.isSameFileAs(expected: Path) ``` -------------------------------- ### hasName Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-assert/index.html Asserts that a file has the specified name. ```APIDOC ## hasName ### Description Asserts the file has the expected name. ### Method `fun Assert.hasName(expected: String)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None (Assertion success) #### Response Example None ``` -------------------------------- ### Create Custom Assertion for Person Age (Kotlin) Source: https://github.com/assertk-org/assertk/blob/main/README.md Defines a custom assertion `hasAge` for the `Person` class by extending `Assert`. It uses `prop` to access the `age` property and `isEqualTo` for comparison. The example also shows how to use the custom assertion. ```kotlin fun Assert.hasAge(expected: Int) { prop(Person::age).isEqualTo(expected) } assertThat(person).hasAge(20) // -> expected [age]:<2[0]> but was:<2[2]> (Person(age=22)) ``` -------------------------------- ### Assertk All Assertion (with message) Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/all.html The 'all' assertion allows you to run multiple assertions within a lambda. An optional message can be provided to be displayed before any failures. ```APIDOC ## Assertk All Assertion (with message) ### Description This function allows you to run multiple assertions within a given lambda. An optional message can be provided to be displayed before all failures. ### Method N/A (This is a library function, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```kotlin assertThat("test", name = "test").all("Checking test string") { startsWith("t") endsWith("t") } ``` ### Response #### Success Response (N/A) This is a library function, not an API endpoint, so success/failure is determined by the assertion results. #### Response Example N/A ``` -------------------------------- ### Path and File Assertions Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-assert/index.html Methods to assert properties of file paths, such as readability, being a regular file, or pointing to the same file. ```APIDOC ## POST /assertk/path ### Description Assertions for file system paths. ### Method POST ### Endpoint /assertk/path ### Parameters #### Request Body - **assertionType** (string) - Required - The type of path assertion ('isReadable', 'isRegularFile', 'isSameFileAs'). - **actual** (string) - Required - The actual path string. - **expected** (string) - Optional - The expected path string (required for 'isSameFileAs'). - **options** (array) - Optional - Link options for 'isRegularFile' (e.g., ["NOFOLLOW_LINKS"]). ### Request Example ```json { "assertionType": "isReadable", "actual": "/path/to/file.txt" } ``` ### Response #### Success Response (200) - **message** (string) - A success message indicating the assertion passed. #### Response Example ```json { "message": "Assertion passed: path is readable." } ``` ``` -------------------------------- ### Perform String/CharSequence Assertions in Kotlin Source: https://context7.com/assertk-org/assertk/llms.txt AssertK offers a comprehensive set of assertions for strings and char sequences, including checks for emptiness, length, containment of substrings (case-sensitive and insensitive), prefixes, suffixes, and regular expression matching. It also supports assertions on the number of lines within a string. ```kotlin import assertk.assertThat import assertk.assertions.* val text = "Hello, World!" // Basic checks assertThat(text).isEmpty() // fails assertThat(text).isNotEmpty() // passes assertThat(text).hasLength(13) // passes // Contains assertThat(text).contains("World") // passes assertThat(text).contains("world", ignoreCase = true) // passes assertThat(text).contains("Hello", "World") // multiple: all must exist // Does not contain assertThat(text).doesNotContain("foo") // passes // Starts/ends with assertThat(text).startsWith("Hello") // passes assertThat(text).endsWith("!") // passes assertThat(text).startsWith("hello", ignoreCase = true) // passes // Regex matching assertThat(text).matches(Regex("Hello.*!")) // full match assertThat(text).containsMatch(Regex("\\w+")) // partial match assertThat(text).doesNotContainMatch(Regex("\\d+")) // no digits // Line count assertThat("line1\nline2\nline3").hasLineCount(3) ``` -------------------------------- ### Nullability Assertions (isNull, isNotNull) in Kotlin Source: https://context7.com/assertk-org/assertk/llms.txt Demonstrates assertk's handling of nullable types using `isNull()` and `isNotNull()`. The `isNotNull()` assertion allows chaining further assertions on the non-null value, ensuring type safety. ```kotlin import assertk.assertThat import assertk.assertions.* val nullString: String? = null val nonNullString: String? = "hello" // Assert null assertThat(nullString).isNull() // passes // Assert not null and chain further assertions assertThat(nonNullString).isNotNull().hasLength(5) // passes // Compile error example: // assertThat(nullString).hasLength(5) // Compile error! hasLength() requires non-null // Correct approach with nullable: assertThat(nullString).isNotNull().hasLength(5) // -> expected to not be null ``` -------------------------------- ### Performing Multiple Assertions on a Single Value with AssertK Source: https://github.com/assertk-org/assertk/blob/main/README.md Shows how to apply multiple assertions to a single value using a lambda with `assertThat`. All assertions within the lambda are executed, and failures are reported collectively. This is useful for comprehensive testing of a single data point. ```kotlin val string = "Test" assertThat(string).all { startsWith("L") hasLength(3) } // -> The following 2 assertions failed: // - expected to start with:<"L"> but was:<"Test"> // - expected to have length:<3> but was:<"Test"> (4) ``` -------------------------------- ### PlatformName Properties Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-platform-name/name.html Provides details on the 'name' property of the PlatformName class, including its common and actual values. ```APIDOC ## PlatformName Properties ### Description Details about the 'name' property for the PlatformName. ### Method N/A (Property access) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "N/A" } ``` ### Response #### Success Response (200) - **name** (String) - The name of the platform. #### Response Example ```json { "example": "commonnative" } ``` ``` -------------------------------- ### tableOf() Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/index.html Builds a table structure with specified column names for organizing test data. ```APIDOC ## tableOf() ### Description Builds a table with the given column names. ### Method `fun tableOf(name1: String): Table1Builder` `fun tableOf(name1: String, name2: String): Table2Builder` `fun tableOf(name1: String, name2: String, name3: String): Table3Builder` `fun tableOf(name1: String, name2: String, name3: String, name4: String): Table4Builder` ### Endpoint N/A (This is a top-level function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```kotlin // Example usage for creating a table val dataTable = tableOf("ID", "Name", "Email") // Further operations to add rows to the table would follow ``` ### Response #### Success Response (200) `Table1Builder`, `Table2Builder`, `Table3Builder`, or `Table4Builder` - Builder objects for constructing tables. #### Response Example N/A ``` -------------------------------- ### Array, Collection, and Map Size Assertions Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-assert/index.html Assertions for checking the specific size of arrays, collections, and maps. ```APIDOC ## POST /assertk/array/hasSize ### Description Asserts the array has the expected size. ### Method POST ### Endpoint /assertk/array/hasSize ### Parameters #### Request Body - **actual** (Array<*>) - Required - The actual Array to assert. - **size** (Int) - Required - The expected size. ### Response #### Success Response (200) - **message** (String) - Assertion successful. #### Response Example ```json { "message": "Assertion successful" } ``` ## POST /assertk/collection/hasSize ### Description Asserts the collection has the expected size. ### Method POST ### Endpoint /assertk/collection/hasSize ### Parameters #### Request Body - **actual** (Collection<*>) - Required - The actual Collection to assert. - **size** (Int) - Required - The expected size. ### Response #### Success Response (200) - **message** (String) - Assertion successful. #### Response Example ```json { "message": "Assertion successful" } ``` ## POST /assertk/map/hasSize ### Description Asserts the map has the expected size. ### Method POST ### Endpoint /assertk/map/hasSize ### Parameters #### Request Body - **actual** (Map<*, *>) - Required - The actual Map to assert. - **size** (Int) - Required - The expected size. ### Response #### Success Response (200) - **message** (String) - Assertion successful. #### Response Example ```json { "message": "Assertion successful" } ``` ``` -------------------------------- ### File Assertions Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-assert/index.html Assertions for file properties like parent path and path. ```APIDOC ## POST /assertk/file/hasParent ### Description Asserts the file has the expected parent path. ### Method POST ### Endpoint /assertk/file/hasParent ### Parameters #### Request Body - **actual** (File) - Required - The actual File to assert. - **expected** (String) - Required - The expected parent path. ### Response #### Success Response (200) - **message** (String) - Assertion successful. #### Response Example ```json { "message": "Assertion successful" } ``` ## POST /assertk/file/hasPath ### Description Asserts the file has the expected path. ### Method POST ### Endpoint /assertk/file/hasPath ### Parameters #### Request Body - **actual** (File) - Required - The actual File to assert. - **expected** (String) - Required - The expected path. ### Response #### Success Response (200) - **message** (String) - Assertion successful. #### Response Example ```json { "message": "Assertion successful" } ``` ``` -------------------------------- ### Table1 Class Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-table1/index.html Documentation for the Table1 class and its methods. ```APIDOC ## Table1 Class ### Description A table with rows of 1 value. ### See Also - [tableOf](../table-of.html) ### Members #### Functions ##### `forAll` - **Description**: Runs the given lambda for each row in the table. - **Method**: fun - **Parameters**: - `f` (([C1]) -> Unit) - Required - The lambda function to execute for each row. ##### `row` - **Description**: Adds a row to the table with the given values. - **Method**: fun - **Parameters**: - `val1` ([C1]) - Required - The value to add as a row. - **Returns**: [Table1](index.html)<[C1](index.html)> ``` -------------------------------- ### String and Object Assertions Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-assert/index.html Assertions for string representations and object equality. ```APIDOC ## POST /assertk/hasToString ### Description Asserts the value has the expected string representation from its `toString()` method. ### Method POST ### Endpoint /assertk/hasToString ### Parameters #### Request Body - **string** (String) - Required - The expected string representation. ### Request Example ```json { "string": "expected string" } ``` ### Response #### Success Response (200) (No specific success response body defined, implies assertion success) ``` ```APIDOC ## POST /assertk/isDataClassEqualTo ### Description Like `isEqualTo` but reports exactly which properties differ. Only supports data classes. Note: you should _not_ use this if your data class has a custom `Any.equals` since it can be misleading. ### Method POST ### Endpoint /assertk/isDataClassEqualTo ### Parameters #### Request Body - **expected** (T) - Required - The expected data class instance. ### Request Example ```json { "expected": { "property1": "value1", "property2": 123 } } ``` ### Response #### Success Response (200) (No specific success response body defined, implies assertion success) ``` -------------------------------- ### Assert Same File (Java/Kotlin) Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/index.html Asserts that two java.nio.file.Path objects point to the same file system entry. This checks for identity, not just content equality. ```kotlin assertThat(path1).isSameFileAs(path2) ``` -------------------------------- ### Create Table with One Column - Kotlin Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/table-of.html This Kotlin function signature defines how to create a table with a single column. It takes one String argument representing the column name and returns a Table1Builder object. ```kotlin fun tableOf(name1: String): Table1Builder ``` -------------------------------- ### Assert.toStringFun() Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/to-string-fun.html This extension function, when called on an Assert object, returns a new Assert object that specifically asserts on the result of the toString() method of the original value. ```APIDOC ## Assert.toStringFun() ### Description Returns an assert on the toString method of the value. This allows for specific assertions on the string representation of any object. ### Method Extension Function ### Endpoint N/A (This is a library function, not a web endpoint) ### Parameters None ### Request Example ```kotlin // Assuming 'actualValue' is of type Any? assertThat(actualValue).toStringFun().isEqualTo("expected string representation") ``` ### Response #### Success Response (N/A) This function returns an `Assert` object, not a direct response. #### Response Example ```kotlin // The return type is Assert, which is used for chaining assertions. val stringAssert: Assert = assertThat(someObject).toStringFun() ``` ``` -------------------------------- ### Assert Path Symbolic Link (Java/Kotlin) Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/index.html Asserts that a java.nio.file.Path points to a symbolic link. This is a file system attribute check. ```kotlin assertThat(path).isSymbolicLink() ``` -------------------------------- ### AssertkDsl Annotation Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/-assertk-dsl/index.html Documentation for the @AssertkDsl annotation, which marks the assertion DSL in the AssertK library. ```APIDOC ## @AssertkDsl Annotation ### Description Marks the assertion DSL. ### Annotation `@AssertkDsl` ### Usage This annotation is used to mark elements within the assertion DSL. ### Example ```kotlin @AssertkDsl annotation class AssertkDsl ``` ``` -------------------------------- ### Create Simple Chained Assertion for Middle Name (Kotlin) Source: https://github.com/assertk-org/assertk/blob/main/README.md Shows a more concise way to create a chained assertion for `middleName` by leveraging existing assertions like `prop` and `isNotNull`. This is generally preferred over custom logic unless a more meaningful error message is required. ```kotlin fun Assert.hasMiddleName(): Assert = prop(Person::middleName).isNotNull() ``` -------------------------------- ### Build Table with Column Names Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk/index.html The `tableOf` functions are used to construct table builders with a specified number of column names. These are likely used for organizing and presenting data in a tabular format within tests or reports. ```kotlin fun tableOf(name1: String): Table1Builder ``` ```kotlin fun tableOf(name1: String, name2: String): Table2Builder ``` ```kotlin fun tableOf(name1: String, name2: String, name3: String): Table3Builder ``` ```kotlin fun tableOf(name1: String, name2: String, name3: String, name4: String): Table4Builder ``` -------------------------------- ### Assert Sequence with 'any' Source: https://github.com/assertk-org/assertk/blob/main/docs/assertk/assertk.assertions/any.html Asserts on each item in the sequence, passing if any of the items pass. The given lambda will be run for each item. ```APIDOC ## fun > Assert.any(f: (Assert) -> Unit) ### Description Asserts on each item in the sequence, passing if any of the items pass. The given lambda will be run for each item. ### Method Extension Function ### Endpoint N/A (In-memory assertion) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```kotlin assert(sequenceOf(-1, -2, 1)).any { it.isPositive() } ``` ### Response #### Success Response (Assertion Pass) N/A (Assertion result is implicit) #### Response Example N/A ```