diff --git a/bool.go b/bool.go new file mode 100644 index 0000000..7736329 --- /dev/null +++ b/bool.go @@ -0,0 +1,8 @@ +package astikit + +func BoolToUInt32(b bool) uint32 { + if b { + return 1 + } + return 0 +} diff --git a/bool_test.go b/bool_test.go new file mode 100644 index 0000000..11aaf52 --- /dev/null +++ b/bool_test.go @@ -0,0 +1,12 @@ +package astikit + +import "testing" + +func TestBoolToUInt32(t *testing.T) { + if e, g := uint32(0), BoolToUInt32(false); e != g { + t.Errorf("expected %d, got %d", e, g) + } + if e, g := uint32(1), BoolToUInt32(true); e != g { + t.Errorf("expected %d, got %d", e, g) + } +}