You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cses/introductory_test.go

29 lines
710 B
Go

package cses
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestWeirdAlgo(t *testing.T) {
assert.Equal(t, "[3 10 5 16 8 4 2 1]", WeirdAlgo(3))
}
func TestMissingNumber(t *testing.T) {
assert.Equal(t, 4, MissingNumber(5, []int{2, 3, 1, 5}))
assert.Equal(t, 7, MissingNumber(9, []int{2, 3, 1, 5, 4, 6, 9, 8}))
}
func TestRepetitions(t *testing.T) {
assert.Equal(t, 0, Repetitions(""))
assert.Equal(t, 3, Repetitions("ATTCGGGA"))
assert.Equal(t, 4, Repetitions("AGGTTCGGGGA"))
}
func TestIncreasingArray(t *testing.T) {
assert.Equal(t, 0, IncreasingArray(5, []int{}))
assert.Equal(t, 0, IncreasingArray(5, []int{3}))
assert.Equal(t, 5, IncreasingArray(5, []int{3, 2, 5, 1, 7}))
}