SHTK_UNITTEST_ASSERT_FILE(3)

πŸ“¦ version 1.7, in nixos 26.05, nixpkgs unstable

πŸ’– SHTK_UNITTEST_ASSERT_FILE(3) β€” Library Functions Manual

okay bestie, this is a page from the Library Functions Manual and it's all about checking files against golden data. slay.


🌸 NAME

shtk_unittest_assert_file β€” Validates the contents of a file against golden data

πŸ’– LIBRARY

shtk_import unittest

✨ SYNOPSIS

shtk_unittest_assert_file golden_spec actual_file

πŸ’… DESCRIPTION

okay so shtk_unittest_assert_file verifies that actual_file, which must exist (no cap), matches some predefined contents specified by golden_spec.

The valid values for golden_spec are of the form:

  • empty β€” actual_file must be empty.
  • not-empty β€” actual_file must not be empty.
  • ignore β€” The contents of actual_file are irrelevant.
  • file:<path> β€” The contents of actual_file must match the contents of the file path.
  • inline:<text> β€” The contents of actual_file must match the inline contents provided in text. Note that text can include escape sequences.
  • match:<regexp> β€” The contents of actual_file must match the given regular expression in regexp.
  • not-match:<regexp> β€” The contents of actual_file must not match the given regular expression in regexp.
  • save:<path> β€” actual_file is saved to path for further inspection by the test case. This is not useful in the context of shtk_unittest_assert_file but comes in handy when used in conjunction of shtk_unittest_assert_command(3).
  • stdin β€” The contents of actual_file must match the golden contents provided via the standard input.

πŸ”₯ EXAMPLES

The following examples all pass:

touch my_file
assert_file empty my_file

echo "foo" >my_file
assert_file inline:"foo\n" my_file

echo "bar" >>my_file
cp my_file golden
assert_file file:golden my_file
assert_file stdin my_file <golden

assert_file match:"fo" my_file
assert_file not-match:"abcde" my_file

πŸ‘‘ SEE ALSO

shtk(3), shtk_unittest(3)

πŸ¦‹ HISTORY

shtk_unittest_assert_file first appeared in shtk 1.6.


this page is from Debian, dated November 9, 2014, and it's for SHTK_UNITTEST_ASSERT_FILE(3) β€” bye bestie πŸ’…βœ¨

πŸ“¦ where this page comes from