config_test.go 872 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package splithttp_test
  2. import (
  3. "testing"
  4. . "github.com/xtls/xray-core/transport/internet/splithttp"
  5. )
  6. func Test_GetNormalizedPath(t *testing.T) {
  7. c := Config{
  8. Path: "/?world",
  9. }
  10. path := c.GetNormalizedPath("hello", true)
  11. if path != "/hello?world" {
  12. t.Error("Unexpected: ", path)
  13. }
  14. }
  15. func Test_GetNormalizedPath2(t *testing.T) {
  16. c := Config{
  17. Path: "?world",
  18. }
  19. path := c.GetNormalizedPath("hello", true)
  20. if path != "/hello?world" {
  21. t.Error("Unexpected: ", path)
  22. }
  23. }
  24. func Test_GetNormalizedPath3(t *testing.T) {
  25. c := Config{
  26. Path: "hello?world",
  27. }
  28. path := c.GetNormalizedPath("", true)
  29. if path != "/hello/?world" {
  30. t.Error("Unexpected: ", path)
  31. }
  32. }
  33. func Test_GetNormalizedPath4(t *testing.T) {
  34. c := Config{
  35. Path: "hello?world",
  36. }
  37. path := c.GetNormalizedPath("", false)
  38. if path != "/hello/" {
  39. t.Error("Unexpected: ", path)
  40. }
  41. }