2019/day4/main_test.go

157 lines
3.9 KiB
Go
Raw Normal View History

package main
import "testing"
func TestCountDigitsPositiveNumber(t *testing.T) {
count := CountDigits(237841)
solution := 6
if count != solution {
t.Errorf("DigitCount was incorrect, got: {%d}, want: {%d}.", count, solution)
}
}
func TestCountDigitsNegativeNumber(t *testing.T) {
count := CountDigits(-2378541)
solution := 7
if count != solution {
t.Errorf("DigitCount was incorrect, got: {%d}, want: {%d}.", count, solution)
}
}
func TestAreDigitsNotDecreasingSuccess(t *testing.T) {
success := AreDigitsNotDecreasing(1134569)
solution := true
if success != solution {
t.Errorf("AreDigitsNotDecreasing was incorrect, got: {%t}, want: {%t}.", success, solution)
}
}
func TestAreDigitsNotDecreasingFailure(t *testing.T) {
success := AreDigitsNotDecreasing(12246378)
solution := false
if success != solution {
t.Errorf("AreDigitsNotDecreasing was incorrect, got: {%t}, want: {%t}.", success, solution)
}
}
func TestHaveDoubleInputsSuccess(t *testing.T) {
success := HaveDoubleInputs(123445)
solution := true
if success != solution {
t.Errorf("HaveDoubleInputs was incorrect, got: {%t}, want: {%t}.", success, solution)
}
}
func TestHaveDoubleInputsFailure(t *testing.T) {
success := HaveDoubleInputs(12345)
solution := false
if success != solution {
t.Errorf("HaveDoubleInputs was incorrect, got: {%t}, want: {%t}.", success, solution)
}
}
func TestHaveDoubleInputsSuccessAdditional(t *testing.T) {
success := HasOneDouble(114444)
solution := true
if success != solution {
t.Errorf("HaveDoubleInputs was incorrect, got: {%t}, want: {%t}.", success, solution)
}
}
func TestHaveDoubleInputsSuccessAdditional2(t *testing.T) {
success := HasOneDouble(111444)
solution := false
if success != solution {
t.Errorf("HaveDoubleInputs was incorrect, got: {%t}, want: {%t}.", success, solution)
}
}
func TestHaveDoubleInputsSuccessAdditional3(t *testing.T) {
success := HasOneDouble(111114)
solution := false
if success != solution {
t.Errorf("HaveDoubleInputs was incorrect, got: {%t}, want: {%t}.", success, solution)
}
}
func TestHaveDoubleInputsSuccessAdditional4(t *testing.T) {
success := HasOneDouble(111111)
solution := false
if success != solution {
t.Errorf("HaveDoubleInputs was incorrect, got: {%t}, want: {%t}.", success, solution)
}
}
func TestHaveDoubleInputsFailureAdditional(t *testing.T) {
success := HasOneDouble(1234555)
solution := false
if success != solution {
t.Errorf("HaveDoubleInputs was incorrect, got: {%t}, want: {%t}.", success, solution)
}
}
func TestCheckPasswordCriteriaExample1(t *testing.T) {
success := MeetPasswordCriteria(111111, false)
solution := true
if success != solution {
t.Errorf("PasswordCriteria was incorrect, got: {%t}, want: {%t}.", success, solution)
}
}
func TestCheckPasswordCriteriaExample2(t *testing.T) {
success := MeetPasswordCriteria(223450, false)
solution := false
if success != solution {
t.Errorf("PasswordCriteria was incorrect, got: {%t}, want: {%t}.", success, solution)
}
}
func TestCheckPasswordCriteriaExample3(t *testing.T) {
success := MeetPasswordCriteria(123789, false)
solution := false
if success != solution {
t.Errorf("PasswordCriteria was incorrect, got: {%t}, want: {%t}.", success, solution)
}
}
func TestCheckPasswordAdditionalCriteriaExample1(t *testing.T) {
success := MeetPasswordCriteria(112233, true)
solution := true
if success != solution {
t.Errorf("PasswordCriteria was incorrect, got: {%t}, want: {%t}.", success, solution)
}
}
func TestCheckPasswordAdditionalCriteriaExample2(t *testing.T) {
success := MeetPasswordCriteria(123444, true)
solution := false
if success != solution {
t.Errorf("PasswordCriteria was incorrect, got: {%t}, want: {%t}.", success, solution)
}
}
func TestCheckPasswordAdditionalCriteriaExample3(t *testing.T) {
success := MeetPasswordCriteria(111122, true)
solution := true
if success != solution {
t.Errorf("PasswordCriteria was incorrect, got: {%t}, want: {%t}.", success, solution)
}
}