gilo/editor/highlight/syntax_test.go
Timothy Warren 469679cf6f
Some checks failed
timw4mail/gilo/pipeline/head There was a failure building this commit
Complete step 164 in Chapter 7 of Kilo tutorial
2023-10-04 10:37:47 -04:00

35 lines
674 B
Go

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)
}
})
}