<commit_before>package me.moallemi.gradle.advancedbuildversion.gradleextensions

import org.gradle.api.GradleException
import org.junit.Assert.assertEquals
import org.junit.Assert.assertThrows
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@RunWith(JUnit4::class)
class VersionNameOptionsTest {

    private lateinit var versionNameOptions: VersionNameOptions

    @Before
    fun setUp() {
        versionNameOptions = VersionNameOptions()
    }

    @Test
    fun `expect exception when versionMajor is null`() {
        val exception = assertThrows(GradleException::class.java) {
            versionNameOptions.versionName
        }
        assertEquals(exception.message, "nameOptions.versionMajor could not be null or less than 0")
    }
}<commit_msg>Add more tests for VersionNameOptions<commit_after>package me.moallemi.gradle.advancedbuildversion.gradleextensions

import org.gradle.api.GradleException
import org.junit.Assert.assertEquals
import org.junit.Assert.assertThrows
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@RunWith(JUnit4::class)
class VersionNameOptionsTest {

    private lateinit var versionNameOptions: VersionNameOptions

    @Before
    fun setUp() {
        versionNameOptions = VersionNameOptions()
    }

    @Test
    fun `expect exception when versionMajor is null`() {
        val exception = assertThrows(GradleException::class.java) {
            versionNameOptions.versionName
        }
        assertEquals(exception.message, "nameOptions.versionMajor could not be null or less than 0")
    }

    @Test
    fun `version major is 1_0`() {
        versionNameOptions.versionMajor(1)

        assertEquals(versionNameOptions.versionName, "1.0")
    }

    @Test
    fun `version major is 1_3`() {
        versionNameOptions.apply {
            versionMajor(1)
            versionMinor(3)
        }

        assertEquals(versionNameOptions.versionName, "1.3")
    }

    @Test
    fun `version major is 1_0_3`() {
        versionNameOptions.apply {
            versionMajor(1)
            versionPatch(3)
        }

        assertEquals(versionNameOptions.versionName, "1.0.3")
    }

    @Test
    fun `version major is 1_0_0_3`() {
        versionNameOptions.apply {
            versionMajor(1)
            versionBuild(3)
        }

        assertEquals(versionNameOptions.versionName, "1.0.0.3")
    }

    @Test
    fun `version major is 1_2_3`() {
        versionNameOptions.apply {
            versionMajor(1)
            versionMinor(2)
            versionPatch(3)
        }

        assertEquals(versionNameOptions.versionName, "1.2.3")
    }

    @Test
    fun `version major is 1_0_3_4`() {
        versionNameOptions.apply {
            versionMajor(1)
            versionPatch(3)
            versionBuild(4)
        }

        assertEquals(versionNameOptions.versionName, "1.0.3.4")
    }

    @Test
    fun `version major is 1_2_0_3`() {
        versionNameOptions.apply {
            versionMajor(1)
            versionMinor(2)
            versionBuild(3)
        }

        assertEquals(versionNameOptions.versionName, "1.2.0.3")
    }

    @Test
    fun `check version minor is not less than 0`() {
        val exception = assertThrows(GradleException::class.java) {
            versionNameOptions.apply {
                versionMajor(1)
                versionMinor(-1)
            }
            versionNameOptions.versionName
        }
        assertEquals(exception.message, "nameOptions.versionMinor could not be less than 0")
    }

    @Test
    fun `check version patch is not less than 0`() {
        val exception = assertThrows(GradleException::class.java) {
            versionNameOptions.apply {
                versionMajor(1)
                versionPatch(-1)
            }
            versionNameOptions.versionName
        }
        assertEquals(exception.message, "nameOptions.versionPatch could not be less than 0")
    }

    @Test
    fun `check version build is not less than 0`() {
        val exception = assertThrows(GradleException::class.java) {
            versionNameOptions.apply {
                versionMajor(1)
                versionBuild(-1)
            }
            versionNameOptions.versionName
        }
        assertEquals(exception.message, "nameOptions.versionBuild could not be less than 0")
    }
}
{'fraction_non_alphanumeric': 0.08585630366018979, 'fraction_numerical': 0.01762313601446001, 'mean_word_length': 2.321080270067517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7595180', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1211, 'n_words': 259}