#!/usr/bin/tclsh
# versionInfo.test --
#
# Tests versioninfo queries exposed by TclCurl.
#
# Copyright (c) 2024-2026 Massimo Manghi
#
# SPDX-License-Identifier: TCL
#
# See the file "license.terms" at the top level of this distribution
# for information on usage and redistribution of this file, and for the
# complete disclaimer of warranties and limitation of liability.
#
# Portions of this file were drafted or revised with AI assistance
# under the direction and review of Massimo Manghi

package require tcltest
namespace import ::tcltest::*
source [file join [file dirname [file normalize [info script]]] support.tcl]
::tclcurl::test::load_package
package require TclCurl

test versioninfo-1.01 {: Test that -version returns something} -body {
	return [curl::versioninfo -version]
} -match regexp -result {^\d+\.\d+\.\d+(-DEV)?$}

test versioninfo-1.02 {: Test that -versionnum returns something} -body {
	return [curl::versioninfo -versionnum]
} -match regexp -result {^[0-9A-F]+$}

test versioninfo-1.03 {: Test that -features returns something} -body {
	return [curl::versioninfo -features]
} -match regexp -result {^([A-Z0-9]+ ?)+$}

test versioninfo-1.04 {: Test that -sslversion returns something} -body {
	# unix sslversion string looks like {^(OpenSSL|GnuTLS|LibreSSL)/\d+\.\d+\.\d+\w*$}
	# macosx sslversion string looks like {^SecureTransport \(OpenSSL/\d+\.\d+\.\d+\w*\)$}
        # On Windows, Schannel does not provide any version numbers
	return [curl::versioninfo -sslversion]
} -match regexp -result {((OpenSSL|GnuTLS|LibreSSL)/\d+\.\d+\.\d+\w*)|Schannel}

test versioninfo-1.05 {: Test that -sslversionnum returns something} -body {
	return [curl::versioninfo -sslversionnum]
} -match regexp -result {^\d+$}

test versioninfo-1.06 {: Test that -libzversion returns something} -body {
	return [curl::versioninfo -libzversion]
} -match regexp -result {^\d+\.\d+(\.\d+)?$}

test versioninfo-1.07 {: Test that -protocols returns something} -body {
	return [curl::versioninfo -protocols]
} -match regexp -result {^([a-z0-9]+ ?)+$}

cleanupTests
