summaryrefslogtreecommitdiff
path: root/t/00constants.t
blob: bd411f765d16668ca72364ed7990ea5d2967f862 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!perl
use strict;
use warnings;
use Test::More;
use WWW::Curl::Easy;

my $ver_num_raw = WWW::Curl::Easy::version();
my ($ver_num) = $ver_num_raw =~ m!libcurl/(\d\.\d+\.\d+)!;
my ($major, $minor, $bugfix) = split(/\./, $ver_num);

open(my $fh, '<', 't/symbols-in-versions') or die($!);

my @consts;
for my $row (<$fh>) {
	chomp($row);
	next if ($row =~ m/^#/);
	my ($name, $intro, $dep, $remov) = split(/\s+/, $row);
	push @consts, [$name, $intro, $dep, $remov];
}

# In case we can't use cpp to extract symbols, skipping the multi constant tests for now.
my $skip_multi;
my $value = WWW::Curl::Easy::constant('CURL_LAST');
$skip_multi++ if (! $!);

my @checklist;
for my $row (@consts) {
	my ($name, $intro, $depr, $outro) = @{$row};
	my $check = 0;
	if (!$outro && $intro) {
		my ($maj_in, $min_in, $bf_in) = split(/\./, $intro);
		if ($maj_in eq '-' || $major > $maj_in) {
			$check = 1;	
		} elsif ($major == $maj_in) {
			if ($minor > $min_in) { $check = 1
			} elsif ($minor == $min_in ) {
				if ($bugfix > $bf_in) {
					$check = 1;
				} elsif ($bugfix == $bf_in) {
					$check = 1;
				} else {
					next
				}
			} else {
				next;
			}
		} else {
			next;
		}
	}
	if ($check) {
		next if ($skip_multi && $name =~ m/^CURLM/);
		push @checklist, [$name, $depr];
	}
}
plan tests => scalar(@checklist);
for my $row (@checklist) {
		my $value = WWW::Curl::Easy::constant($row->[0]);
		ok(!$! && (defined($value) || $row->[1]), "$row->[0] is defined alright - $!");
}