...

Source file src/github.com/cilium/ebpf/internal/cpu_test.go

Documentation: github.com/cilium/ebpf/internal

     1  package internal
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestParseCPUs(t *testing.T) {
     8  	for str, result := range map[string]int{
     9  		"0-1":   2,
    10  		"0-2\n": 3,
    11  		"0":     1,
    12  	} {
    13  		n, err := parseCPUs(str)
    14  		if err != nil {
    15  			t.Errorf("Can't parse `%s`: %v", str, err)
    16  		} else if n != result {
    17  			t.Error("Parsing", str, "returns", n, "instead of", result)
    18  		}
    19  	}
    20  
    21  	for _, str := range []string{
    22  		"0,3-4",
    23  		"0-",
    24  		"1,",
    25  		"",
    26  	} {
    27  		_, err := parseCPUs(str)
    28  		if err == nil {
    29  			t.Error("Parsed invalid format:", str)
    30  		}
    31  	}
    32  }
    33  

View as plain text