mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-02 21:10:27 +02:00
80 lines
2.4 KiB
Scheme
80 lines
2.4 KiB
Scheme
;;;; socket.test --- test socket functions -*- scheme -*-
|
|
;;;;
|
|
;;;; Copyright (C) 2004 Free Software Foundation, Inc.
|
|
;;;;
|
|
;;;; This library is free software; you can redistribute it and/or
|
|
;;;; modify it under the terms of the GNU Lesser General Public
|
|
;;;; License as published by the Free Software Foundation; either
|
|
;;;; version 2.1 of the License, or (at your option) any later version.
|
|
;;;;
|
|
;;;; This library is distributed in the hope that it will be useful,
|
|
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
;;;; Lesser General Public License for more details.
|
|
;;;;
|
|
;;;; You should have received a copy of the GNU Lesser General Public
|
|
;;;; License along with this library; if not, write to the Free Software
|
|
;;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
(define-module (test-suite test-numbers)
|
|
#:use-module (test-suite lib))
|
|
|
|
;;;
|
|
;;; inet-ntop
|
|
;;;
|
|
|
|
(if (defined? 'inet-ntop)
|
|
(with-test-prefix "inet-ntop"
|
|
|
|
(with-test-prefix "ipv6"
|
|
(pass-if "0"
|
|
(string? (inet-ntop AF_INET6 0)))
|
|
|
|
(pass-if "2^128-1"
|
|
(string? (inet-ntop AF_INET6 (1- (ash 1 128)))))
|
|
|
|
(pass-if-exception "-1" exception:out-of-range
|
|
(inet-ntop AF_INET6 -1))
|
|
|
|
(pass-if-exception "2^128" exception:out-of-range
|
|
(inet-ntop AF_INET6 (ash 1 128)))
|
|
|
|
(pass-if-exception "2^1024" exception:out-of-range
|
|
(inet-ntop AF_INET6 (ash 1 1024))))))
|
|
|
|
;;;
|
|
;;; inet-pton
|
|
;;;
|
|
|
|
(if (defined? 'inet-pton)
|
|
(with-test-prefix "inet-pton"
|
|
|
|
(with-test-prefix "ipv6"
|
|
(pass-if "00:00:00:00:00:00:00:00"
|
|
(eqv? 0 (inet-pton AF_INET6 "00:00:00:00:00:00:00:00")))
|
|
|
|
(pass-if "0:0:0:0:0:0:0:1"
|
|
(eqv? 1 (inet-pton AF_INET6 "0:0:0:0:0:0:0:1")))
|
|
|
|
(pass-if "::1"
|
|
(eqv? 1 (inet-pton AF_INET6 "::1")))
|
|
|
|
(pass-if "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"
|
|
(eqv? #xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
|
(inet-pton AF_INET6
|
|
"FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF")))
|
|
|
|
(pass-if "F000:0000:0000:0000:0000:0000:0000:0000"
|
|
(eqv? #xF0000000000000000000000000000000
|
|
(inet-pton AF_INET6
|
|
"F000:0000:0000:0000:0000:0000:0000:0000")))
|
|
|
|
(pass-if "0F00:0000:0000:0000:0000:0000:0000:0000"
|
|
(eqv? #x0F000000000000000000000000000000
|
|
(inet-pton AF_INET6
|
|
"0F00:0000:0000:0000:0000:0000:0000:0000")))
|
|
|
|
(pass-if "0000:0000:0000:0000:0000:0000:0000:00F0"
|
|
(eqv? #xF0
|
|
(inet-pton AF_INET6
|
|
"0000:0000:0000:0000:0000:0000:0000:00F0"))))))
|