-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Included unit tests Signed-off-by: naveensrinivasan <[email protected]>
- Loading branch information
1 parent
6d828b7
commit 5fa216f
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2023 OpenSSF Scorecard Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package checker | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/ossf/scorecard/v4/finding" | ||
) | ||
|
||
func TestFile_Location(t *testing.T) { | ||
file := File{ | ||
Type: finding.FileTypeSource, | ||
Path: "bar.go", | ||
Offset: 10, | ||
EndOffset: 20, | ||
Snippet: "some code", | ||
} | ||
|
||
loc := file.Location() | ||
|
||
if loc.Type != finding.FileTypeSource { | ||
t.Errorf("Expected loc.Type to be 'foo', got %v", loc.Type) | ||
} | ||
if loc.Path != "bar.go" { | ||
t.Errorf("Expected loc.Path to be 'bar.go', got %v", loc.Path) | ||
} | ||
if *loc.LineStart != 10 { | ||
t.Errorf("Expected *loc.LineStart to be 10, got %v", *loc.LineStart) | ||
} | ||
if *loc.LineEnd != 20 { | ||
t.Errorf("Expected *loc.LineEnd to be 20, got %v", *loc.LineEnd) | ||
} | ||
if *loc.Snippet != "some code" { | ||
t.Errorf("Expected *loc.Snippet to be 'some code', got %v", *loc.Snippet) | ||
} | ||
} |