<commit_before>package de.eightbitboy.ecorealms.simulation

import spock.lang.Specification
import spock.lang.Subject

class InventorySpec extends Specification {

    @Subject
    private Inventory inventory = new Inventory()

    def "a new inventory is empty"() {
        when:
        Set<Resource> resources = inventory.getResources()

        then:
        resources.isEmpty()
        resources.every { !resources.contains(it) }
    }

    def "add a resource"() {
        when:
        inventory.add(Resource.Fish, 5)

        then:
        !inventory.getResources().isEmpty()
        inventory.getResources().size() == 1
        inventory.getResources().contains(Resource.Fish)
        inventory.get(Resource.Fish) == 5
    }

    def "cannot add a negative amount"() {

    }

    def "get a resource"() {
        setup:
        inventory.add(Resource.Fish, 3)

        when:
        int amount = inventory.get(Resource.Fish)

        then:
        amount == 3
        inventory.get(Resource.Fish) == 3
    }

    def "remove a resource"() {
        setup:
        inventory.add(Resource.Fish, 67)

        when:
        int amount = inventory.remove(Resource.Fish, 13)

        then:
        amount == 13
        inventory.get(Resource.Fish) == 54
    }

    def "cannot remove a negative amount"() {<commit_msg>Implement test<commit_after>package de.eightbitboy.ecorealms.simulation

import spock.lang.Specification
import spock.lang.Subject

class InventorySpec extends Specification {

    @Subject
    private Inventory inventory = new Inventory()

    def "a new inventory is empty"() {
        when:
        Set<Resource> resources = inventory.getResources()

        then:
        resources.isEmpty()
        resources.every { !resources.contains(it) }
    }

    def "add a resource"() {
        when:
        inventory.add(Resource.Fish, 5)

        then:
        !inventory.getResources().isEmpty()
        inventory.getResources().size() == 1
        inventory.getResources().contains(Resource.Fish)
        inventory.get(Resource.Fish) == 5
    }

    def "cannot add a negative amount"() {
        when:
        inventory.add(Resource.Fish, -45)

        then:
        thrown(RuntimeException)
    }

    def "get a resource"() {
        setup:
        inventory.add(Resource.Fish, 3)

        when:
        int amount = inventory.get(Resource.Fish)

        then:
        amount == 3
        inventory.get(Resource.Fish) == 3
    }

    def "remove a resource"() {
        setup:
        inventory.add(Resource.Fish, 67)

        when:
        int amount = inventory.remove(Resource.Fish, 13)

        then:
        amount == 13
        inventory.get(Resource.Fish) == 54
    }

    def "cannot remove a negative amount"() {
{'fraction_non_alphanumeric': 0.1098981077147016, 'fraction_numerical': 0.010917030567685589, 'mean_word_length': 2.1027088036117383, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '21022', 'n_tokens_mistral': 838, 'n_tokens_neox': 768, 'n_words': 188}