Name

Test::File::Contents - Test routines for examining the contents of files

Synopsis

use Test::File::Contents;

file_contents_eq        $file,  $string,  $description;
file_contents_like      $file,  qr/foo/,  $description;
file_md5sum             $file,  $md5sum,  $description;
file_contents_identical $file1, $file2,   $description;

Description

Got an app that generates files? Then you need to test those files to make sure that their contents are correct. This module makes that easy. Use its test functions to make sure that the contents of files are exactly what you expect them to be.

Interface

Test Functions

file_contents_eq

file_contents_eq $file, $string, $description;

Checks that the file's contents are equal to a string. Pass in a Unix-style file name and it will be converted for the local file system. The old name for this function, file_contents_is, remains as an alias.

file_contents_ne

file_contents_ne $file, $string, $description;

Checks that the file's contents do not equal a string. Pass in a Unix-style file name and it will be converted for the local file system. The old name for this function, file_contents_isnt, remains as an alias.

file_contents_like

file_contents_like $file, qr/foo/, $description;

Checks that the contents of a file match a regular expression. The regular expression must be passed as a regular expression object created by qr//.

file_contents_unlike

file_contents_unlike $file, qr/foo/, $description;

Checks that the contents of a file do not match a regular expression. The regular expression must be passed as a regular expression object created by qr//.

file_md5sum

file_md5sum $file, $md5sum, $description;

Checks whether a file matches a given MD5 checksum. The checksum should be provided as a hex string, for example, 6df23dc03f9b54cc38a0fc1483df6e21. Pass in a Unix-style file name and it will be converted for the local file system.

file_contents_identical

file_contents_identical $file1, $file2, $description;

Tests that the contents of two files are identical. Pass in a Unix-style file name and it will be converted for the local file system.

Authors

  • Kirrily Robert <skud@cpan.org>

  • David E. Wheeler <david@kineticode.com>

Support

This module is stored in an open GitHub repository. Feel free to fork and contribute!

Please file bug reports via GitHub Issues or by sending mail to bug-Test-File-Contents@rt.cpan.org.

Copyright and License

Copyright (c) 2004-2007 Kirrily Robert. Some Rights Reserved. Copyright (c) 2007-2011 David E. Wheeler. Some Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.