Skip to content

Commit

Permalink
[UPDATE] (1.6.1)
Browse files Browse the repository at this point in the history
[FIX] Optimised file loading
  • Loading branch information
martin-olivier committed Mar 19, 2021
1 parent 9d64d87 commit bb5b955
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 29 deletions.
Binary file removed .github/example1.png
Binary file not shown.
Binary file removed .github/example2.png
Binary file not shown.
Binary file removed .github/example3.png
Binary file not shown.
Binary file added .github/example_details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/example_diff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IO-Tester
<a href="https://github.com/tocola/IO-TESTER"><img src="https://img.shields.io/badge/IO_Tester-v1.6-blue.svg"></a>
<a href="https://github.com/tocola/IO-TESTER/releases/tag/v1.6.1"><img src="https://img.shields.io/badge/IO_Tester-v1.6.1-blue.svg"></a>

## What is IO-Tester ?

Expand Down Expand Up @@ -50,11 +50,12 @@ bad
[END]
```

### Details
![](.github/example1.png)
![](.github/example2.png)
### VSCode Diff
![](.github/example3.png)
Then execute `IO_Tester` with the file containing the tests as argument.

You can add `--details` as final argument to display the real and the expected output in the shell when a test fails.
![](.github/example_details.png)
You can add `--diff` as final argument to display the diff between the real and the expected output in VS Code when a test fails.
![](.github/example_diff.png)

## Manual

Expand Down
2 changes: 1 addition & 1 deletion src/Diff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void IOTester::VSCodeDiff(const Test &t, const Utils::CMD &c)
void IOTester::checkVSCodeBin()
{
#ifdef __APPLE__
if (access((std::string("/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code").c_str()), X_OK) != -1) {
if (access("/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code", X_OK) != -1) {
m_VSCodeBin = OK;
return;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ void IOTester::Changelog()
"(1.6)",
"> [ADD] stderr is now catch like stdout",
"> [FIX] Parsing Errors",
"(1.6.1)",
"> [FIX] Optimised file loading",
NULL
};
std::cout << "[CHANGELOG] :" << std::endl;
Expand Down
30 changes: 10 additions & 20 deletions src/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,21 @@ Utils::CMD Utils::get_cmd_output(const std::string &command)
return ret;
}

std::string Utils::get_file_content(const std::string &in)
std::string Utils::get_file_content(const std::string &path)
{
DIR *dir = opendir(in.c_str());
std::string file_content;
std::ifstream file_stream(path);
DIR *dir = opendir(path.c_str());
if (dir)
my_exit(84, "Cannot open directory [" + in + "], exiting...");
std::ifstream file;
file.open(in, std::ifstream::in);
my_exit(84, "Cannot open directory [" + path + "], exiting...");

if (file.is_open()) {
std::string data;
char c = file.get();

while (file.good()) {
data += c;
c = file.get();
}
file.close();
return data;
}
file.close();
my_exit(84, "Cannot open file [" + in + "], exiting...");
return "";
if (!file_stream.is_open())
my_exit(84, "Cannot open file [" + path + "], exiting...");
std::getline(file_stream, file_content, '\0');
return file_content;
}

std::vector<std::string> Utils::string_to_vector(std::string str, char separator)
std::vector<std::string> Utils::string_to_vector(const std::string &str, char separator)
{
std::vector<std::string> array;
std::string temp;
Expand Down
4 changes: 2 additions & 2 deletions src/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Utils
bool error;
};
CMD get_cmd_output(const std::string &command);
std::string get_file_content(const std::string &in);
std::vector<std::string> string_to_vector(std::string str, char separator);
std::string get_file_content(const std::string &path);
std::vector<std::string> string_to_vector(const std::string &str, char separator);
void my_exit(int exit_status, const std::string &error_msg);
};

0 comments on commit bb5b955

Please sign in to comment.