github.com/ncruces/go-sqlite3@v0.15.1-0.20240520133447-53eef1510ff0/internal/util/bool_test.go (about)

     1  package util
     2  
     3  import "testing"
     4  
     5  func TestParseBool(t *testing.T) {
     6  	tests := []struct {
     7  		str string
     8  		val bool
     9  		ok  bool
    10  	}{
    11  		{"", false, false},
    12  		{"0", false, true},
    13  		{"1", true, true},
    14  		{"9", true, true},
    15  		{"T", false, false},
    16  		{"true", true, true},
    17  		{"FALSE", false, true},
    18  		{"false?", false, false},
    19  	}
    20  	for _, tt := range tests {
    21  		t.Run(tt.str, func(t *testing.T) {
    22  			gotVal, gotOK := ParseBool(tt.str)
    23  			if gotVal != tt.val || gotOK != tt.ok {
    24  				t.Errorf("ParseBool(%q) = (%v, %v) want (%v, %v)", tt.str, gotVal, gotOK, tt.val, tt.ok)
    25  			}
    26  		})
    27  	}
    28  }