package highlight import "testing" func TestGetSyntaxByFilename(t *testing.T) { var s *Syntax = nil t.Run("returns nil on empty filename", func(t *testing.T) { got := GetSyntaxByFilename("") want := s if got != want { t.Errorf("got %q want 'nil'", got.FileType) } }) t.Run("returns nil on undefined file type", func(t *testing.T) { got := GetSyntaxByFilename("foo.bar") want := s if got != want { t.Errorf("got %q want 'nil'", got.FileType) } }) t.Run("returns c on .c file", func(t *testing.T) { got := GetSyntaxByFilename("kilo.c") want := "c" if got.FileType != want { t.Errorf("got %q want %q", got.FileType, want) } }) }