diff --git a/hae.cc b/hae.cc index 02c1802..26edf94 100644 --- a/hae.cc +++ b/hae.cc @@ -75,13 +75,6 @@ std::string read_all() std::stringstream ss; std::string s; - // ignore leading newlines - while (std::getline(std::cin, s) && s.empty()) { - if (!s.empty()) { - ss << s << '\n'; - } - } - while (std::getline(std::cin, s)) { ss << s << '\n'; } @@ -392,9 +385,6 @@ int main(int argc, char *argv[]) std::stringstream ss(input); std::string line; while (std::getline(ss, line)) { - if (line == "") { - break; - } auto d = std::shared_ptr(new rapidjson::Document()); d->Parse(line.c_str()); if (d->IsNull()) { diff --git a/test/data/empty_start.txt b/test/data/empty_start.txt new file mode 100644 index 0000000..a244e4b --- /dev/null +++ b/test/data/empty_start.txt @@ -0,0 +1,3 @@ + + Foo | bar baz +1. diff --git a/test/run_tests.sh b/test/run_tests.sh index 02e2239..4bdefea 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -12,13 +12,16 @@ function error_hook() { trap error_hook ERR $HAE_PATH/hae "a detailed description of food" < data/meta.txt -n 3 -hl > res_t1.txt -diff t1.txt res_t1.txt +cmp t1.txt res_t1.txt cat data/meta.json | jq -c .[] | $HAE_PATH/hae "the time" -n 1 > res_t2.txt -diff t2.txt res_t2.txt +cmp t2.txt res_t2.txt cat data/newline_at_start.txt | $HAE_PATH/hae "foo" > res_t3.txt -diff t3.txt res_t3.txt +cmp t3.txt res_t3.txt cat data/single_line.txt | $HAE_PATH/hae "foo" > res_t4.txt -diff t4.txt res_t4.txt +cmp t4.txt res_t4.txt + +cat data/empty_start.txt | $HAE_PATH/hae "foo" > res_t5.txt +cmp t5.txt res_t5.txt \ No newline at end of file diff --git a/test/t3.txt b/test/t3.txt index a29bd34..1fc7aff 100644 --- a/test/t3.txt +++ b/test/t3.txt @@ -1,3 +1,4 @@ -This is a test + +This is a test  diff --git a/test/t4.txt b/test/t4.txt index e69de29..5a4e112 100644 --- a/test/t4.txt +++ b/test/t4.txt @@ -0,0 +1,3 @@ +This is a test + + diff --git a/test/t5.txt b/test/t5.txt new file mode 100644 index 0000000..6fb3115 --- /dev/null +++ b/test/t5.txt @@ -0,0 +1,5 @@ + + Foo | bar baz +1.  + +