Skip to content

Commit

Permalink
Fixed tests and cleaned up code
Browse files Browse the repository at this point in the history
  • Loading branch information
petermcneil committed Apr 29, 2019
1 parent 5f2dbeb commit c36b117
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 5 additions & 1 deletion lib/src/subtitle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ subtitle::subtitle(const filesystem::path &sp, RW rw) {
if (sp.empty()) {
this->file_path = sp;
} else {
if(!filesystem::exists(sp.parent_path())) {
log::debug("Directory ({}) doesn't exist - creating it", sp.parent_path());
filesystem::create_directory(sp.parent_path());
}
this->file_path = weakly_canonical(sp);
this->filename = new string(this->file_path.filename().generic_string());
this->subtitle_file = new fstream(this->file_path.c_str(),
fstream::ate | fstream::out | fstream::trunc);

}

}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/src/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ frame_header *video::read_steg_header(AVFrame *fr) {
if (regex_match(found_header, frame_header::header_regex)) {
break;
} else if (count == 2) {
log::info("Found frame_header '{}' should be |L|", found_header);
log::debug("Found frame_header '{}' should be |L|", found_header);
assert(found_header == "|L|");
}

Expand Down Expand Up @@ -968,7 +968,7 @@ bool video::has_steg_file() {
break;
}
if (ret >= 0) {
log::info("Finding a frame_header from frame: {}, {}", this->read_x, this->read_y);
log::debug("Finding a frame_header from frame: {}, {}", this->read_x, this->read_y);
frame_header *h = this->read_steg_header(picture);
if (h != nullptr) {
log::debug("Setting frame_header: {}", h->to_string());
Expand Down
6 changes: 4 additions & 2 deletions lib/test/src/TestSubtitleFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ TEST_CASE("Subtitle file can write lines out") {
string write_file("output/gen_subs.srt");
subtitle *write_sub = new subtitle(write_file, RW::WRITE);

write_sub->write_line(input);
write_sub->write_line(input2);
int ret = write_sub->write_line(input);
REQUIRE(ret == 0);
ret = write_sub->write_line(input2);
REQUIRE(ret == 0);

std::ifstream output(write_file);

Expand Down
4 changes: 2 additions & 2 deletions lib/test/src/TestVideoFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void compare_files(const std::string &f, const std::string& s) {
log::error("O: {}", second_line);
}

assert(first_line == second_line);
REQUIRE(first_line == second_line);
}

first->clear();
Expand All @@ -43,7 +43,7 @@ void input_equals_output(string i_video, const string& o_video, string i_subtitl
video *o_v = new video(o_video, o_sub);

i_v->write_subtitle_file();
assert(o_v->has_steg_file());
REQUIRE(o_v->has_steg_file());
o_v->read_subtitle_file();

compare_files(i_subtitle, o_subtitle);
Expand Down

0 comments on commit c36b117

Please sign in to comment.