;; This file is part of address-info for CHICKEN ;; Copyright (c) 2017 by Thomas Chust. All rights reserved. ;; ;; Permission is hereby granted, free of charge, to any person ;; obtaining a copy of this software and associated documentation ;; files (the Software), to deal in the Software without restriction, ;; including without limitation the rights to use, copy, modify, ;; merge, publish, distribute, sublicense, and/or sell copies of the ;; Software, and to permit persons to whom the Software is furnished ;; to do so, subject to the following conditions: ;; ;; The above copyright notice and this permission notice shall be ;; included in all copies or substantial portions of the Software. ;; ;; THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, ;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS ;; BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ;; ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ;; SOFTWARE. (import address-info test) (test-group "client mode" (test-assert "bad hostname" (not (address-infos "!foo/bar.invalid"))) (test-assert "symbolic localhost" (list? (address-infos "localhost"))) (test-assert "numeric ipv4 localhost" (member (make-address-info 'ipv4 'tcp "127.0.0.1" #f) (address-infos "127.0.0.1" type: 'stream numeric?: #t))) (test-assert "numeric ipv6 localhost" (member (make-address-info 'ipv6 'tcp "::1" #f) (address-infos "::1" type: 'stream numeric?: #t))) (test "port lookup" 80 (address-info-port (car (address-infos "example.com" port: "http"))))) (test-group "server mode" (test-assert "bad port" (not (address-infos #f port: "!foo/bar"))) (test "port lookup" 80 (address-info-port (car (address-infos #f port: "http")))) (test "ipv4 wildcard lookup" "0.0.0.0" (address-info-host (car (address-infos #f port: "http" family: 'ipv4)))) (test "ipv6 wildcard lookup" "::" (address-info-host (car (address-infos #f port: "http" family: 'ipv6))))) (test-exit)