BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
binutils.test.cpp File Reference

Implements class CLASS? More...

Include dependency graph for binutils.test.cpp:

Go to the source code of this file.

Classes

class  BinUtilsTest
 Testing BinUtils. More...
 

Functions

 TEST_F (BinUtilsTest, testBinaryFiles)
 Testing Binary Files. More...
 
 TEST_F (BinUtilsTest, testTextFiles)
 Testing text files. More...
 

Detailed Description

Implements class CLASS?

Homepage:\n http://www.bornagainproject.org
License:\n GNU General Public License v3 or higher (see COPYING)
Authors
Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)

Definition in file binutils.test.cpp.

Function Documentation

◆ TEST_F() [1/2]

TEST_F ( BinUtilsTest  ,
testBinaryFiles   
)

Testing Binary Files.

Definition at line 32 of file binutils.test.cpp.

33 {
34  std::string root_path = TestConfig::TestData();
35 
36  std::string binary_file1 = root_path + std::string("/") + "pdf_file";
37  std::string binary_file2 = root_path + std::string("/") + "png_file.png";
38  std::string binary_file3 = root_path + std::string("/") + "word_file";
39  std::string binary_file4 = root_path + std::string("/") + "mandelbrot.ppm";
40  std::string binary_file5 = root_path + std::string("/") + "c++_exec";
41 
42  EXPECT_TRUE(Utils::is_binary(binary_file1));
43  EXPECT_TRUE(Utils::is_binary(binary_file2));
44  EXPECT_TRUE(Utils::is_binary(binary_file3));
45  EXPECT_TRUE(Utils::is_binary(binary_file4));
46  EXPECT_TRUE(Utils::is_binary(binary_file5));
47 
48  EXPECT_FALSE(Utils::is_text(binary_file1));
49  EXPECT_FALSE(Utils::is_text(binary_file2));
50  EXPECT_FALSE(Utils::is_text(binary_file3));
51  EXPECT_FALSE(Utils::is_text(binary_file4));
52  EXPECT_FALSE(Utils::is_text(binary_file5));
53 }
bool is_text(const std::string &filename)
Returns true if file is text/ascii.
Definition: binutils.cpp:53
bool is_binary(const std::string &filename)
Returns true if file is binary.
Definition: binutils.cpp:33

References ModelView ::Utils::is_binary(), and ModelView ::Utils::is_text().

Here is the call graph for this function:

◆ TEST_F() [2/2]

TEST_F ( BinUtilsTest  ,
testTextFiles   
)

Testing text files.

Definition at line 57 of file binutils.test.cpp.

58 {
59  std::string root_path = TestConfig::TestData();
60 
61  std::string text_file1 = root_path + std::string("/") + "text_UTF-8.txt";
62  std::string text_file2 = root_path + std::string("/") + "text_UTF-8-BOM.txt";
63 
64  EXPECT_TRUE(Utils::is_text(text_file1));
65  EXPECT_TRUE(Utils::is_text(text_file2));
66 
67  EXPECT_FALSE(Utils::is_binary(text_file1));
68  EXPECT_FALSE(Utils::is_binary(text_file2));
69 }

References ModelView ::Utils::is_binary(), and ModelView ::Utils::is_text().

Here is the call graph for this function: