1Test::HexDifferences(3)User Contributed Perl DocumentatioTnest::HexDifferences(3)
2
3
4
6 Test::HexDifferences - Test binary as hexadecimal string
7
9 1.001
10
12 use Test::HexDifferences;
13
14 eq_or_dump_diff(
15 $got,
16 $expected,
17 );
18
19 eq_or_dump_diff(
20 $got,
21 $expected,
22 $test_name,
23 );
24
25 eq_or_dump_diff(
26 $got,
27 $expected,
28 {
29 address => $start_address,
30 format => "%a : %4C : %d\n",
31 }
32 $test_name,
33 );
34
35 If $got or $expected is "undef" or a reference, the hexadecimal
36 formatter is off. Then "eq_or_dump_diff" is a text compare.
37
38 dumped_eq_dump_or_diff(
39 $got_value,
40 $expected_dump,
41 );
42
43 dumped_eq_dump_or_diff(
44 $got_value,
45 $expected_dump,
46 $test_name,
47 );
48
49 dumped_eq_dump_or_diff(
50 $got_value,
51 $expected_dump,
52 {
53 address => $start_address,
54 format => "%a : %4C : %d\n",
55 }
56 $test_name,
57 );
58
59 See Test::HexDifferences::HexDump for the format description.
60
62 Inside of this Distribution is a directory named example. Run this *.t
63 files.
64
66 The are some special cases for testing binary data.
67
68 • The ascii format is not good for e.g. a length byte 0x41 displayed
69 as A.
70
71 • Multibyte values are better shown as 1 value.
72
73 • Structured binary e.g. 2 byte length followed by bytes better are
74 shown as it is.
75
76 • Compare 2 binary or 1 binary and a dump.
77
79 subroutine eq_or_dump_diff
80 eq_or_dump_diff(
81 $got_value,
82 $expected_value,
83 { # optional hash reference
84 address => $display_start_address, # optional
85 format => $format_string, # optional
86 }
87 $test_name, # optional
88 );
89
90 subroutine dumped_eq_dump_or_diff
91 dumped_eq_dump_or_diff(
92 $got_value,
93 $expected_dump,
94 { # optional hash reference
95 address => $display_start_address, # optional
96 format => $format_string, # optional
97 }
98 $test_name, # optional
99 );
100
102 nothing
103
105 nothing
106
108 Sub::Exporter
109
110 Test::Builder::Module
111
112 Test::HexDifferences::HexDump
113
114 Text::Diff
115
117 none
118
120 none
121
123 Test::HexDifferences::HexDump
124
126 Steffen Winkler
127
129 Copyright (c) 2012 - 2015, Steffen Winkler "<steffenw at cpan.org>".
130 All rights reserved.
131
132 This module is free software; you can redistribute it and/or modify it
133 under the same terms as Perl itself.
134
135
136
137perl v5.32.1 2021-01-27 Test::HexDifferences(3)