Add C tests

main
Leonid Maslakov 5 months ago
parent fcd58569f5
commit 716e995afb
  1. 4
      highlight.go
  2. 50
      highlight_c_test.go
  3. 0
      highlight_robotstxt.go
  4. 0
      highlight_robotstxt_test.go

@ -45,6 +45,7 @@ const (
//
// | Function name | Language name |
// |---------------|-----------------|
// | C | c |
// | Dockerfile | dockerfile |
// | Golang | go, golang |
// | Python | python, python3 |
@ -53,6 +54,9 @@ func ByName(code string, language string) (string, error) {
language = strings.ToLower(language)
switch strings.ToLower(language) {
case "c":
return C(code), nil
case "dockerfile":
return Dockerfile(code), nil

@ -0,0 +1,50 @@
// Copyright (C) 2022 Leonid Maslakov.
// This file is part of Highlight.
// Highlight is free software: you can redistribute it
// and/or modify it under the terms of the
// GNU Affero Public License as published by the
// Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
// Highlight is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Affero Public License for more details.
// You should have received a copy of the GNU Affero Public License along with Highlight.
// If not, see <https://www.gnu.org/licenses/>.
package highlight
import (
"testing"
)
func TestC(t *testing.T) {
testData := []testDataType{
{
Input: `
#include <stdio.h>
int main() {
printf("Hello, world!");
return 0;
}
`,
ExpectResult: `
#include &ltstdio.h&gt
<span class='` + StyleKeyword + `'>int</span> main() {
printf(<span class='` + StyleBrackets + `'>"Hello, world!"</span>);
<span class='` + StyleKeyword + `'>return</span> 0;
}
`,
},
}
runTest(C, testData, t)
}
Loading…
Cancel
Save