github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/utils/posix/posix_test.go (about)

     1  package posix
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/lmorg/murex/test/count"
     7  )
     8  
     9  // TestPosix checks isPosix logic is correct
    10  func TestPosix(t *testing.T) {
    11  	platforms := map[string]bool{
    12  		"linux":     true,
    13  		"freebsd":   true,
    14  		"openbsd":   true,
    15  		"netbsd":    true,
    16  		"dragonfly": true,
    17  		"darwin":    true,
    18  		"solaris":   true,
    19  		"windows":   false,
    20  		"plan9":     false,
    21  	}
    22  
    23  	count.Tests(t, len(platforms))
    24  
    25  	for os, val := range platforms {
    26  		if val {
    27  			if !isPosix(os) {
    28  				t.Errorf("%s not returning as posix. Expecting it to be posix", os)
    29  			}
    30  		} else {
    31  			if isPosix(os) {
    32  				t.Errorf("%s is returning as posix. Expecting it not to", os)
    33  			}
    34  		}
    35  	}
    36  }