Skip to content

Commit

Permalink
[TEST] Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Sep 25, 2024
1 parent 8b8bb49 commit 6a23ffb
Show file tree
Hide file tree
Showing 14 changed files with 686 additions and 848 deletions.
62 changes: 29 additions & 33 deletions test/api/count_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,31 @@

#include "ibf.h"
#include "shared.h"
#include "../app_test.hpp"

#ifndef DATA_INPUT_DIR
# define DATA_INPUT_DIR @DATA_INPUT_DIR@
#endif

using seqan3::operator""_shape;
std::filesystem::path tmp_dir = std::filesystem::temp_directory_path(); // get the temp directory

void initialization_args(estimate_ibf_arguments & args)
// To prevent issues when running multiple CLI tests in parallel, give each CLI test unique names:
struct count_test : public app_test
{
args.compressed = true;
args.k = 4;
args.shape = seqan3::ungapped{args.k};
args.w_size = seqan3::window_size{4};
args.s = seqan3::seed{0};
args.path_out = tmp_dir/"Count_Test_";
}
void initialization_args(estimate_ibf_arguments & args)
{
args.compressed = true;
args.k = 4;
args.shape = seqan3::ungapped{args.k};
args.w_size = seqan3::window_size{4};
args.s = seqan3::seed{0};
args.path_out = "Count_Test_";
}
};

TEST(count, small_example)
TEST_F(count_test, small_example)
{
estimate_ibf_arguments args{};
initialization_args(args);

count(args, {std::string(DATA_INPUT_DIR) + "mini_example.fasta"}, std::string(DATA_INPUT_DIR) + "mini_gen.fasta",
std::string(DATA_INPUT_DIR) + "mini_gen.genome", false);
count(args, {data("mini_example.fasta")}, data("mini_gen.fasta"),
data("mini_gen.genome"), false);

std::ifstream output_file(tmp_dir/"mini_example.count.out");
std::ifstream output_file("mini_example.count.out");
std::string line;
std::string expected{"gen1\t3"};
if (output_file.is_open())
Expand All @@ -42,18 +40,17 @@ TEST(count, small_example)
}
output_file.close();
}
std::filesystem::remove(tmp_dir/"Count_Test_mini_example.count.out");
}

TEST(count, small_example_paired)
TEST_F(count_test, small_example_paired)
{
estimate_ibf_arguments args{};
initialization_args(args);

count(args, {std::string(DATA_INPUT_DIR) + "mini_example.fasta", std::string(DATA_INPUT_DIR) + "mini_example.fasta"},
std::string(DATA_INPUT_DIR) + "mini_gen.fasta", std::string(DATA_INPUT_DIR) + "mini_gen.genome", true);
count(args, {data("mini_example.fasta"), data("mini_example.fasta")},
data("mini_gen.fasta"), data("mini_gen.genome"), true);

std::ifstream output_file(tmp_dir/"mini_example.count.out");
std::ifstream output_file("mini_example.count.out");
std::string line;
std::string expected{"gen1\t6"};
if (output_file.is_open())
Expand All @@ -64,18 +61,17 @@ TEST(count, small_example_paired)
}
output_file.close();
}
std::filesystem::remove(tmp_dir/"Count_Test_mini_example.count.out");
}

TEST(count, small_example_exclude)
TEST_F(count_test, small_example_exclude)
{
estimate_ibf_arguments args{};
initialization_args(args);

count(args, {std::string(DATA_INPUT_DIR) + "mini_example.fasta"}, std::string(DATA_INPUT_DIR) + "mini_gen.fasta",
std::string(DATA_INPUT_DIR) + "mini_gen2.genome", false);
count(args, {data("mini_example.fasta")}, data("mini_gen.fasta"),
data("mini_gen2.genome"), false);

std::ifstream output_file(tmp_dir/"mini_example.count.out");
std::ifstream output_file("mini_example.count.out");
std::string line;
std::string expected{"gen1\t3"};
if (output_file.is_open())
Expand All @@ -86,19 +82,19 @@ TEST(count, small_example_exclude)
}
output_file.close();
}
std::filesystem::remove(tmp_dir/"Count_Test_mini_example.count.out");

}

TEST(genome, small_example)
TEST_F(count_test, genome_small_example)
{
estimate_ibf_arguments args{};
initialization_args(args);

count_genome(args, std::string(DATA_INPUT_DIR) + "mini_gen.fasta", std::string(DATA_INPUT_DIR) + "mini_gen2.fasta");
count_genome(args, data("mini_gen.fasta"), data("mini_gen2.fasta"));

std::ifstream output_file;
uint64_t expected{192};
output_file.open(tmp_dir/"mini_gen.genome", std::ios::binary);
output_file.open("mini_gen.genome", std::ios::binary);
uint64_t minimiser;
while(output_file.read((char*)&minimiser, sizeof(minimiser)))
{
Expand Down
Loading

0 comments on commit 6a23ffb

Please sign in to comment.