gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/tools/go_generics/rules_tests/template_test.go (about)

     1  // Copyright 2018 The gVisor Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package template_test
    16  
    17  import (
    18  	"math"
    19  	"testing"
    20  )
    21  
    22  func TestMax(t *testing.T) {
    23  	var a int
    24  	a = max(10, 20)
    25  	if a != 20 {
    26  		t.Errorf("Bad result of max, got %v, want %v", a, 20)
    27  	}
    28  }
    29  
    30  func TestIntConst(t *testing.T) {
    31  	var a int
    32  	a = add(10)
    33  	if a != 30 {
    34  		t.Errorf("Bad result of add, got %v, want %v", a, 30)
    35  	}
    36  }
    37  
    38  func TestStrConst(t *testing.T) {
    39  	v := getName()
    40  	if v != "test" {
    41  		t.Errorf("Bad name, got %v, want %v", v, "test")
    42  	}
    43  }
    44  
    45  func TestImport(t *testing.T) {
    46  	v := getMax()
    47  	if v != math.MaxUint64 {
    48  		t.Errorf("Bad max value, got %v, want %v", v, uint64(math.MaxUint64))
    49  	}
    50  }