File: 12_parser.t

package info (click to toggle)
libspf2 1.2.10-9
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 2,708 kB
  • sloc: sh: 11,504; ansic: 11,396; makefile: 169; perl: 18
file content (35 lines) | stat: -rw-r--r-- 813 bytes parent folder | download | duplicates (9)
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
use strict;
use warnings;
use blib;
use Test::More tests => 13;

use_ok('Mail::SPF_XS');

my $srv = new Mail::SPF_XS::Server({ debug => 0 });

my %records = (
	# This is illegal, and will re-stringify to a%%b%%c%%
	# 'a%%b%%c%'		=> 'a%b%c%',

	'a%%b%%c%%'		=> 'a%b%c%',
	'%%'			=> '%',
	'foo'	=> 'foo',
);

for (keys %records) {
	my $exp = $srv->expand($_);
	is($exp, $records{$_}, "Expanded $_ as a macro");

	my $rec = $srv->compile("v=spf1 macro=$_");

	my $str = $rec->string;
	ok(1, "Compiled v=spf1 macro=$_ as a record");
	is($str, "v=spf1 macro=$_", "Stringified the record");

	my $value = $rec->modifier('macro');
	is($value, $records{$_}, "Expanded $_ as a modifier");

#	$rec = $srv->compile("v=spf1 macro=$_ -all");
#	$value = $rec->modifier('macro');
#	is($value, $records{$_}, "Parsed $_ -all");
}