package day5 import ( "testing" "gitea.paas.celticinfo.fr/oabrivard/aoc2023/utils" ) func TestFindClosestLocation(t *testing.T) { lines := []string{ "seeds: 79 14 55 13", "", "seed-to-soil map:", "50 98 2", "52 50 48", "", "soil-to-fertilizer map:", "0 15 37", "37 52 2", "39 0 15", "", "fertilizer-to-water map:", "49 53 8", "0 11 42", "42 0 7", "57 7 4", "", "water-to-light map:", "88 18 7", "18 25 70", "", "light-to-temperature map:", "45 77 23", "81 45 19", "68 64 13", "", "temperature-to-humidity map:", "0 69 1", "1 0 69", "", "humidity-to-location map:", "60 56 37", "56 93 4", "", } result := FindClosestLocation(lines) if result != int64(35) { t.Fatalf("expected 35, got %v", result) } } func TestFindClosestLocationWithInput(t *testing.T) { lines := utils.ReadLines("input.txt") result := FindClosestLocation(lines) if result != 1181555926 { t.Fatalf("expected 1181555926, got %d", result) } } func TestRangedFindClosestLocation(t *testing.T) { lines := []string{ "seeds: 79 14 55 13", "", "seed-to-soil map:", "50 98 2", "52 50 48", "", "soil-to-fertilizer map:", "0 15 37", "37 52 2", "39 0 15", "", "fertilizer-to-water map:", "49 53 8", "0 11 42", "42 0 7", "57 7 4", "", "water-to-light map:", "88 18 7", "18 25 70", "", "light-to-temperature map:", "45 77 23", "81 45 19", "68 64 13", "", "temperature-to-humidity map:", "0 69 1", "1 0 69", "", "humidity-to-location map:", "60 56 37", "56 93 4", "", } result := FindRangedClosestLocation(lines) if result != int64(46) { t.Fatalf("expected 46, got %v", result) } } func TestRangedFindClosestLocationWithInput(t *testing.T) { lines := utils.ReadLines("input.txt") result := FindRangedClosestLocation(lines) if result != 1181555926 { t.Fatalf("expected 1181555926, got %d", result) } }