#include <openvpn/log/logbase.hpp>
#include <openvpn/io/io.hpp>
#include <openvpn/common/exception.hpp>
#include <openvpn/common/hexstr.hpp>
#include <openvpn/common/format.hpp>
#include <openvpn/random/mtrandapi.hpp>
#include <iostream>
#include <gtest/gtest.h>
#include <fstream>
#include <mutex>
Go to the source code of this file.
◆ JY_ASSERT_EQ
      
        
          | #define JY_ASSERT_EQ | ( |  | v1, | 
        
          |  |  |  | v2 | 
        
          |  | ) |  |  | 
      
 
Value:    do                                                                                           \
    {                                                                                            \
        if ((v1) != (v2))                                                                        \
            OPENVPN_THROW_EXCEPTION("JY_ASSERT_EQ: failure at " << __FILE__ << ':' << __LINE__); \
    } while (0)
Definition at line 447 of file test_helper.hpp.
 
 
◆ JY_ASSERT_FALSE
      
        
          | #define JY_ASSERT_FALSE | ( |  | value | ) |  | 
      
 
Value:    do                                                                                              \
    {                                                                                               \
        if (value)                                                                                  \
            OPENVPN_THROW_EXCEPTION("JY_ASSERT_FALSE: failure at " << __FILE__ << ':' << __LINE__); \
    } while (0)
Definition at line 440 of file test_helper.hpp.
 
 
◆ JY_ASSERT_GE
      
        
          | #define JY_ASSERT_GE | ( |  | v1, | 
        
          |  |  |  | v2 | 
        
          |  | ) |  |  | 
      
 
Value:    do                                                                                           \
    {                                                                                            \
        if ((v1) < (v2))                                                                         \
            OPENVPN_THROW_EXCEPTION("JY_ASSERT_GE: failure at " << __FILE__ << ':' << __LINE__); \
    } while (0)
Definition at line 468 of file test_helper.hpp.
 
 
◆ JY_ASSERT_LE
      
        
          | #define JY_ASSERT_LE | ( |  | v1, | 
        
          |  |  |  | v2 | 
        
          |  | ) |  |  | 
      
 
Value:    do                                                                                           \
    {                                                                                            \
        if ((v1) > (v2))                                                                         \
            OPENVPN_THROW_EXCEPTION("JY_ASSERT_LE: failure at " << __FILE__ << ':' << __LINE__); \
    } while (0)
Definition at line 461 of file test_helper.hpp.
 
 
◆ JY_ASSERT_NE
      
        
          | #define JY_ASSERT_NE | ( |  | v1, | 
        
          |  |  |  | v2 | 
        
          |  | ) |  |  | 
      
 
Value:    do                                                                                           \
    {                                                                                            \
        if ((v1) == (v2))                                                                        \
            OPENVPN_THROW_EXCEPTION("JY_ASSERT_NE: failure at " << __FILE__ << ':' << __LINE__); \
    } while (0)
Definition at line 454 of file test_helper.hpp.
 
 
◆ JY_ASSERT_TRUE
      
        
          | #define JY_ASSERT_TRUE | ( |  | value | ) |  | 
      
 
Value:    do                                                                                             \
    {                                                                                              \
        if (!(value))                                                                              \
            OPENVPN_THROW_EXCEPTION("JY_ASSERT_TRUE: failure at " << __FILE__ << ':' << __LINE__); \
    } while (0)
Definition at line 433 of file test_helper.hpp.
 
 
◆ JY_EXPECT_THROW
◆ OVPN_EXPECT_THROW
      
        
          | #define OVPN_EXPECT_THROW | ( |  | statement, | 
        
          |  |  |  | expected_exception, | 
        
          |  |  |  | expected_text | 
        
          |  | ) |  |  | 
      
 
Value:    try                                                                                                                             \
    {                                                                                                                               \
        statement;                                                                                                                  \
        OPENVPN_THROW_EXCEPTION("OVPN_EXPECT_THROW: no exception was thrown " << __FILE__ << ':' << __LINE__);                      \
    }                                                                                                                               \
    catch (const expected_exception &e)                                                                                             \
    {                                                                                                                               \
        if (std::string(e.what()).find(expected_text) == std::string::npos)                                                         \
            OPENVPN_THROW_EXCEPTION("OVPN_EXPECT_THROW: did not find expected text in exception at " << __FILE__ << ':' << __LINE__ \
                                                                                                     << ". Got: " << e.what());     \
    }
Definition at line 415 of file test_helper.hpp.
 
 
◆ THROW_FMT
      
        
          | #define THROW_FMT | ( |  | ... | ) | throw Exception(printfmt(__VA_ARGS__)) | 
      
 
 
◆ getExpectedOutput()
  
  | 
        
          | std::string getExpectedOutput | ( | const std::string & | filename | ) |  |  | inline | 
 
Reads the file with the expected output and returns it as a string. This function delibrately does not include the ASSERT_EQ call since otherwise gtest will report a the assert failure in this file rather than in the right place 
- Parameters
- 
  
  
- Returns
Definition at line 168 of file test_helper.hpp.
 
 
◆ getJoinedString()
template<class T > 
  
  | 
        
          | std::string getJoinedString | ( | const std::vector< T > & | r, |  
          |  |  | const std::string & | delim = "|" |  
          |  | ) |  |  |  | inline | 
 
Returns a string joined with the delimiter 
- Parameters
- 
  
    | r | the array to join |  | delim | the delimiter to use |  
 
- Returns
- A string joined by delim from the vector r 
Definition at line 207 of file test_helper.hpp.
 
 
◆ getSortedJoinedString()
template<class T > 
  
  | 
        
          | std::string getSortedJoinedString | ( | std::vector< T > & | r, |  
          |  |  | const std::string & | delim = "|" |  
          |  | ) |  |  |  | inline | 
 
Returns a sorted string join with the delimiter This function modifes the input 
- Parameters
- 
  
    | r | the array to join |  | delim | the delimiter to use |  
 
- Returns
- A string joined by delim from the sorted vector r 
Definition at line 222 of file test_helper.hpp.
 
 
◆ getSortedString()
  
  | 
        
          | std::string getSortedString | ( | const std::string & | output | ) |  |  | inline | 
 
Splits a string into lines and returns them in a sorted output string 
Definition at line 250 of file test_helper.hpp.
 
 
◆ getTempDirPath()
  
  | 
        
          | std::string getTempDirPath | ( | const std::string & | fn | ) |  |  | inline | 
 
 
◆ override_logOutput()
  
  | 
        
          | void override_logOutput | ( | bool | doLogOutput, |  
          |  |  | void(*)() | test_func |  
          |  | ) |  |  |  | inline | 
 
Overrides stdout during the run of a function. Primarly for silencing log function that throw an exception when something is wrong 
- Parameters
- 
  
    | doLogOutput | Use stdout while running |  | test_func | function to run |  
 
Definition at line 152 of file test_helper.hpp.
 
 
◆ testLog