mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[yul-phaser] Common: Add readLinesFromFile()
This commit is contained in:
@@ -158,6 +158,7 @@ set(yul_phaser_sources
|
||||
# My current workaround is just to include its source files here but this introduces
|
||||
# unnecessary duplication. Create a library or find a way to reuse the list in both places.
|
||||
../tools/yulPhaser/AlgorithmRunner.cpp
|
||||
../tools/yulPhaser/Common.cpp
|
||||
../tools/yulPhaser/Chromosome.cpp
|
||||
../tools/yulPhaser/FitnessMetrics.cpp
|
||||
../tools/yulPhaser/GeneticAlgorithms.cpp
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <test/yulPhaser/TestHelpers.h>
|
||||
|
||||
#include <tools/yulPhaser/Common.h>
|
||||
|
||||
#include <libsolutil/CommonData.h>
|
||||
@@ -22,6 +24,7 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/tools/output_test_stream.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
@@ -32,6 +35,12 @@ using namespace solidity::util;
|
||||
namespace solidity::phaser::test
|
||||
{
|
||||
|
||||
class ReadLinesFromFileFixture
|
||||
{
|
||||
protected:
|
||||
TemporaryDirectory m_tempDir;
|
||||
};
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@@ -60,6 +69,17 @@ map<string, TestEnum> const StringToTestEnumMap = invertMap(TestEnumToStringMap)
|
||||
BOOST_AUTO_TEST_SUITE(Phaser)
|
||||
BOOST_AUTO_TEST_SUITE(CommonTest)
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(readLinesFromFile_should_return_all_lines_from_a_text_file_as_strings_without_newlines, ReadLinesFromFileFixture)
|
||||
{
|
||||
{
|
||||
ofstream tmpFile(m_tempDir.memberPath("test-file.txt"));
|
||||
tmpFile << endl << "Line 1" << endl << endl << endl << "Line 2" << endl << "#" << endl << endl;
|
||||
}
|
||||
|
||||
vector<string> lines = readLinesFromFile(m_tempDir.memberPath("test-file.txt"));
|
||||
BOOST_TEST((lines == vector<string>{"", "Line 1", "", "", "Line 2", "#", ""}));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(deserializeChoice_should_convert_string_to_enum)
|
||||
{
|
||||
istringstream aStream("a");
|
||||
|
||||
Reference in New Issue
Block a user