Sha256: 8a82df4bc3c88289e1f627dae23df11032fc786cf26a5892b8ab63f2f01c7ce1

Contents?: true

Size: 1.72 KB

Versions: 107

Compression:

Stored size: 1.72 KB

Contents

@Grab('org.spockframework:spock-core:1.0-groovy-2.4')
import spock.lang.*

class DoubleLinkedListSpec extends Specification {

    def 'can push and pop'() {
        DoubleLinkedList<Integer> list = new DoubleLinkedList<>()
        when:
            list.push(10)
            list.push(20)
        then:
            list.pop() == 20
        and:
            list.pop() == 10
    }

    @Ignore
    def 'can push and shift'() {
        DoubleLinkedList<String> list = new DoubleLinkedList<>()
        when:
            list.push("10")
            list.push("20")
        then:
            list.shift() == "10"
        and:
            list.shift() == "20"
    }

    @Ignore
    def 'can unshift an shift'() {
        DoubleLinkedList<Character> list = new DoubleLinkedList<>()
        when:
            list.unshift('1')
            list.unshift('2')
        then:
            list.shift() == '2'
        and:
            list.shift() == '1'
    }

    @Ignore
    def 'can unshift and pop'() {
        DoubleLinkedList<Integer> list = new DoubleLinkedList<>()
        when:
            list.unshift(10)
            list.unshift(20)
        then:
            list.pop() == 10
        and:
            list.pop() == 20
    }

    @Ignore
    def 'complete example'() {
        DoubleLinkedList<String> list = new DoubleLinkedList<>()
        when:
            list.push("ten")
            list.push("twenty")

        then:
            list.pop() == "twenty"

        when:
            list.push("thirty")

        then:
            list.shift() == "ten"

        when:
            list.unshift("forty")
            list.push("fifty")

        then:
            list.shift() == "forty"
            list.pop() == "fifty"
            list.shift() == "thirty"

    }
}

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.179 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.178 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.177 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.176 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.175 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.174 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.173 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.172 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.171 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.170 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.169 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.167 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.166 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.165 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.164 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.163 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.162 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.161 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy
trackler-2.2.1.160 tracks/groovy/exercises/double-linked-list/DoubleLinkedListSpec.groovy