github.com/apache/skywalking-eyes@v0.6.0/pkg/comments/config_test.go (about)

     1  // Licensed to the Apache Software Foundation (ASF) under one
     2  // or more contributor license agreements.  See the NOTICE file
     3  // distributed with this work for additional information
     4  // regarding copyright ownership.  The ASF licenses this file
     5  // to you under the Apache License, Version 2.0 (the
     6  // "License"); you may not use this file except in compliance
     7  // with the License.  You may obtain a copy of the License at
     8  //
     9  //     http://www.apache.org/licenses/LICENSE-2.0
    10  //
    11  // Unless required by applicable law or agreed to in writing,
    12  // software distributed under the License is distributed on an
    13  // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    14  // KIND, either express or implied.  See the License for the
    15  // specific language governing permissions and limitations
    16  // under the License.
    17  
    18  package comments
    19  
    20  import "testing"
    21  
    22  func TestConfig(t *testing.T) {
    23  	if len(languages) == 0 {
    24  		t.Fail()
    25  	}
    26  }
    27  
    28  func TestLanguages(t *testing.T) {
    29  	tests := []struct {
    30  		lang      string
    31  		extension string
    32  	}{
    33  		{lang: "Java", extension: ".java"},
    34  		{lang: "Python", extension: ".py"},
    35  		{lang: "JavaScript", extension: ".js"},
    36  	}
    37  	for _, test := range tests {
    38  		t.Run(test.lang, func(t *testing.T) {
    39  			for _, extension := range languages[test.lang].Extensions {
    40  				if extension == test.extension {
    41  					return
    42  				}
    43  			}
    44  			t.Fail()
    45  		})
    46  	}
    47  }
    48  
    49  func TestCommentStyle(t *testing.T) {
    50  	tests := []struct {
    51  		filename       string
    52  		commentStyleID string
    53  	}{
    54  		{filename: "Test.java", commentStyleID: "SlashAsterisk"},
    55  		{filename: "Test.py", commentStyleID: "PythonStyle"},
    56  	}
    57  	for _, test := range tests {
    58  		t.Run(test.filename, func(t *testing.T) {
    59  			if style := FileCommentStyle(test.filename); test.commentStyleID != style.ID {
    60  				t.Logf("Extension = %v, Comment style = %v", test.filename, style.ID)
    61  				t.Fail()
    62  			}
    63  		})
    64  	}
    65  }