Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TomlTable.write() throws NoSuchElementException if children is empty #226

Closed
thomasgalvin opened this issue Jun 2, 2023 · 1 comment · Fixed by #227
Closed

TomlTable.write() throws NoSuchElementException if children is empty #226

thomasgalvin opened this issue Jun 2, 2023 · 1 comment · Fixed by #227

Comments

@thomasgalvin
Copy link
Contributor

@Test
    fun emptyArrayInTableTest(){
        @Serializable
        data class EmbeddedData(val data: String = "embedded data")

        @Serializable
        data class EmptyListData(val content: List<EmbeddedData> = listOf() )
        
        assertEncodedEquals(
            value = EmptyListData(),
            expectedToml = ""
        )
    }

Throws:

List is empty.
java.util.NoSuchElementException: List is empty.
	at kotlin.collections.CollectionsKt___CollectionsKt.first(_Collections.kt:214)
	at com.akuleshov7.ktoml.tree.nodes.TomlTable.write(TomlTable.kt:83)
thomasgalvin pushed a commit to thomasgalvin/ktoml that referenced this issue Jun 2, 2023
@thomasgalvin thomasgalvin changed the title TomlTable.write() throws NoSuchElementException is children is empty TomlTable.write() throws NoSuchElementException if children is empty Jun 2, 2023
thomasgalvin pushed a commit to thomasgalvin/ktoml that referenced this issue Jun 2, 2023
@orchestr7
Copy link
Owner

Will be in the nearest minor release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants