github.com/v2fly/tools@v0.100.0/internal/lsp/source/completion/deep_completion_test.go (about)

     1  // Copyright 2020 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package completion
     6  
     7  import (
     8  	"testing"
     9  )
    10  
    11  func TestDeepCompletionIsHighScore(t *testing.T) {
    12  	// Test that deepCompletionState.isHighScore properly tracks the top
    13  	// N=MaxDeepCompletions scores.
    14  
    15  	var s deepCompletionState
    16  
    17  	if !s.isHighScore(1) {
    18  		// No other scores yet, anything is a winner.
    19  		t.Error("1 should be high score")
    20  	}
    21  
    22  	// Fill up with higher scores.
    23  	for i := 0; i < MaxDeepCompletions; i++ {
    24  		if !s.isHighScore(10) {
    25  			t.Error("10 should be high score")
    26  		}
    27  	}
    28  
    29  	// High scores should be filled with 10s so 2 is not a high score.
    30  	if s.isHighScore(2) {
    31  		t.Error("2 shouldn't be high score")
    32  	}
    33  }