destination_test.go 699 B

12345678910111213141516171819202122232425
  1. package net
  2. import (
  3. "testing"
  4. "github.com/v2ray/v2ray-core/testing/unit"
  5. )
  6. func TestTCPDestination(t *testing.T) {
  7. assert := unit.Assert(t)
  8. dest := NewTCPDestination(IPAddress([]byte{1, 2, 3, 4}, 80))
  9. assert.Bool(dest.IsTCP()).IsTrue()
  10. assert.Bool(dest.IsUDP()).IsFalse()
  11. assert.String(dest.String()).Equals("tcp:1.2.3.4:80")
  12. }
  13. func TestUDPDestination(t *testing.T) {
  14. assert := unit.Assert(t)
  15. dest := NewUDPDestination(IPAddress([]byte{0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88}, 53))
  16. assert.Bool(dest.IsTCP()).IsFalse()
  17. assert.Bool(dest.IsUDP()).IsTrue()
  18. assert.String(dest.String()).Equals("udp:[2001:4860:4860::8888]:53")
  19. }