Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
redirect.h File Reference

Redirect functions and file asserts. More...

#include "internal/common.h"
#include <stdio.h>
#include "internal/redirect.h"

Go to the source code of this file.

Macros

#define cr_assert_file_contents_eq_str(File, ExpectedContents, FormatString, ...)   internal
 
#define cr_expect_file_contents_eq_str(File, ExpectedContents, FormatString, ...)   internal
 
#define cr_assert_file_contents_neq_str(File, UnexpectedContents, FormatString, ...)   internal
 
#define cr_expect_file_contents_neq_str(File, UnexpectedContents, FormatString, ...)   internal
 
#define cr_assert_file_contents_eq(File, RefFile, FormatString, ...)   internal
 
#define cr_expect_file_contents_eq(File, RefFile, FormatString, ...)   internal
 
#define cr_assert_file_contents_neq(File, RefFile, FormatString, ...)   internal
 
#define cr_expect_file_contents_neq(File, RefFile, FormatString, ...)   internal
 
#define cr_assert_stdout_eq_str(ExpectedContents, FormatString, ...)   internal
 
#define cr_expect_stdout_eq_str(ExpectedContents, FormatString, ...)   internal
 
#define cr_assert_stdout_neq_str(UnexpectedContents, FormatString, ...)   internal
 
#define cr_expect_stdout_neq_str(UnexpectedContents, FormatString, ...)   internal
 
#define cr_assert_stderr_eq_str(ExpectedContents, FormatString, ...)   internal
 
#define cr_expect_stderr_eq_str(ExpectedContents, FormatString, ...)   internal
 
#define cr_assert_stderr_neq_str(UnexpectedContents, FormatString, ...)   internal
 
#define cr_expect_stderr_neq_str(UnexpectedContents, FormatString, ...)   internal
 
#define cr_assert_stdout_eq(RefFile, FormatString, ...)   internal
 
#define cr_expect_stdout_eq(RefFile, FormatString, ...)   internal
 
#define cr_assert_stdout_neq(RefFile, FormatString, ...)   internal
 
#define cr_expect_stdout_neq(RefFile, FormatString, ...)   internal
 
#define cr_assert_stderr_eq(RefFile, FormatString, ...)   internal
 
#define cr_expect_stderr_eq(RefFile, FormatString, ...)   internal
 
#define cr_assert_stderr_neq(RefFile, FormatString, ...)   internal
 
#define cr_expect_stderr_neq(RefFile, FormatString, ...)   internal
 

Functions

CR_BEGIN_C_API CR_API void cr_redirect_stdout (void)
 
CR_API void cr_redirect_stderr (void)
 
CR_API void cr_redirect_stdin (void)
 
CR_API CR_STDN FILE * cr_get_redirected_stdout (void)
 
CR_API CR_STDN FILE * cr_get_redirected_stderr (void)
 
CR_API CR_STDN FILE * cr_get_redirected_stdin (void)
 
CR_API int cr_file_match_str (CR_STDN FILE *f, const char *str)
 
CR_API int cr_file_match_file (CR_STDN FILE *f, CR_STDN FILE *ref)
 
CR_API CR_STDN FILE * cr_mock_file_size (size_t max_size)
 

Detailed Description

Redirect functions and file asserts.

Definition in file redirect.h.

Function Documentation

◆ cr_file_match_file()

CR_API int cr_file_match_file ( CR_STDN FILE * f,
CR_STDN FILE * ref )

Compare the contents of a file with the contents of another file.

Parameters
[in]fThe first file to compare the contents to.
[in]refThe second file to compare the contents to.
Returns
1 if the contents of the files are equal, 0 otherwise.

◆ cr_file_match_str()

CR_API int cr_file_match_str ( CR_STDN FILE * f,
const char * str )

Compare the contents of a file with a string.

Parameters
[in]fThe file to compare the contents to.
[in]strThe string to compare the contents to.
Returns
1 if the contents of the file is equal to the string, 0 otherwise.

◆ cr_get_redirected_stderr()

CR_API CR_STDN FILE * cr_get_redirected_stderr ( void )

Get a file handle representing the read-end of the redirected stderr.

Returns
the file handle.

◆ cr_get_redirected_stdin()

CR_API CR_STDN FILE * cr_get_redirected_stdin ( void )

Get a file handle representing the write-end of the redirected stdin.

Returns
the file handle.

◆ cr_get_redirected_stdout()

CR_API CR_STDN FILE * cr_get_redirected_stdout ( void )

Get a file handle representing the read-end of the redirected stdout.

Returns
the file handle.

◆ cr_mock_file_size()

CR_API CR_STDN FILE * cr_mock_file_size ( size_t max_size)

Create a file mock.

Parameters
[in]max_sizeThe maximum size in bytes of the file mock.
Returns
the file handle representing the mock.

◆ cr_redirect_stderr()

CR_API void cr_redirect_stderr ( void )

Redirect stderr for testing.

◆ cr_redirect_stdin()

CR_API void cr_redirect_stdin ( void )

Redirect stdin for testing. This is implicitely called before each test.

◆ cr_redirect_stdout()

CR_BEGIN_C_API CR_API void cr_redirect_stdout ( void )

Redirect stdout for testing.