Day 21: Part 2

Signed-off-by: James Griffin <james@unsupervised.ca>
This commit is contained in:
2020-12-21 21:23:33 -04:00
parent 9b3b8011df
commit ecafea7adf
3 changed files with 139 additions and 8 deletions

View File

@@ -16,7 +16,7 @@ func Test_loading_list(t *testing.T) {
t.FailNow()
}
ingredients := len(l.possibleIngredientAllergens)
ingredients := len(l.ingredientAllergens)
if ingredients != 7 {
t.Logf("Expected 7 ingredients, found %d", ingredients)
t.FailNow()
@@ -38,3 +38,35 @@ func Test_find_allergenfree(t *testing.T) {
t.FailNow()
}
}
func Test_canonical_list(t *testing.T) {
l := list{}
err := l.load("sample.txt")
if err != nil {
t.Logf(err.Error())
t.FailNow()
}
l.isolateIngredientAllergens()
list := l.canonicalDangerList()
if list != "mxmxvkd,sqjhc,fvjkl" {
t.Logf("Expected list of mxmxvkd,sqjhc,fvjkl, got %s", list)
t.Fail()
}
}
func Test_fullcanonical_list(t *testing.T) {
l := list{}
err := l.load("input.txt")
if err != nil {
t.Logf(err.Error())
t.FailNow()
}
l.isolateIngredientAllergens()
list := l.canonicalDangerList()
if list != "vmhqr,qxfzc,khpdjv,gnrpml,xrmxxvn,rfmvh,rdfr,jxh" {
t.Logf("Expected list \"vmhqr,qxfzc,khpdjv,gnrpml,xrmxxvn,rfmvh,rdfr,jxh\", got %s", list)
t.Fail()
}
}