password_test.go 668 B

123456789101112131415161718192021222324252627282930313233
  1. package lightsocks
  2. import (
  3. "sort"
  4. "testing"
  5. )
  6. func (password *password) Len() int {
  7. return passwordLength
  8. }
  9. func (password *password) Less(i, j int) bool {
  10. return password[i] < password[j]
  11. }
  12. func (password *password) Swap(i, j int) {
  13. password[i], password[j] = password[j], password[i]
  14. }
  15. func TestRandPassword(t *testing.T) {
  16. password := RandPassword()
  17. t.Log(password)
  18. bsPassword, err := ParsePassword(password)
  19. if err != nil {
  20. t.Error(err)
  21. }
  22. sort.Sort(bsPassword)
  23. for i := 0; i < passwordLength; i++ {
  24. if bsPassword[i] != byte(i) {
  25. t.Error("不能出现任何一个重复的byte位,必须由 0-255 组成,并且都需要包含")
  26. }
  27. }
  28. }