group_ids_test.go 548 B

1234567891011121314151617181920212223242526
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. package osuser
  4. import (
  5. "slices"
  6. "testing"
  7. )
  8. func TestParseGroupIds(t *testing.T) {
  9. tests := []struct {
  10. in string
  11. expected []string
  12. }{
  13. {"5000\x005001\n", []string{"5000", "5001"}},
  14. {"5000\n", []string{"5000"}},
  15. {"\n", []string{""}},
  16. }
  17. for _, test := range tests {
  18. actual := parseGroupIds([]byte(test.in))
  19. if !slices.Equal(actual, test.expected) {
  20. t.Errorf("parseGroupIds(%q) = %q, wanted %s", test.in, actual, test.expected)
  21. }
  22. }
  23. }