This commit is contained in:
Máximo Cuadros
2016-07-13 22:21:18 +02:00
parent 180da1c6df
commit bead3a606f
9 changed files with 123 additions and 76 deletions

31
content_test.go Normal file
View File

@ -0,0 +1,31 @@
package slinguist
import (
"io/ioutil"
"os"
"path"
"path/filepath"
. "gopkg.in/check.v1"
)
func (s *TSuite) TestGetLanguageByContent(c *C) {
s.testGetLanguageByContent(c, "C")
}
func (s *TSuite) testGetLanguageByContent(c *C, expected string) {
files, err := filepath.Glob(path.Join(".linguist/samples", expected, "*"))
c.Assert(err, IsNil)
for _, file := range files {
s, _ := os.Stat(file)
if s.IsDir() {
continue
}
content, _ := ioutil.ReadFile(file)
obtained, _ := GetLanguageByContent(path.Base(file), content)
c.Assert(obtained, Equals, expected, Commentf(file))
}
}