Commit ffb2c00e authored by Mikaël Salson's avatar Mikaël Salson

Test: Test operator<< for Fasta and Sequence

parent ad60c833
......@@ -153,6 +153,27 @@ void testFastaAddThrows() {
}
void testSequenceOutputOperator() {
ostringstream oss;
Sequence seq = {"a b c", "a", "GATTACA", "AIIIIIH", NULL};
oss << seq;
TAP_TEST(oss.str() == "@a\nGATTACA\n+\nAIIIIIH\n", TEST_SEQUENCE_OUT, oss.str());
ostringstream oss2;
seq.quality = "";
oss2 << seq;
TAP_TEST(oss2.str() == ">a\nGATTACA\n", TEST_SEQUENCE_OUT, oss.str());
}
void testFastaOutputOperator(){
ostringstream oss;
Fasta fa("../../data/test1.fa");
oss << fa;
TAP_TEST(oss.str() == ">seq1\nACAAC\n>seq2\nCGACCCCCAA\n>seq3\nA\n>seq4\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n>\nAATN\n", TEST_FASTA_OUT, oss.str());
}
void testRevcomp() {
TAP_TEST(complement("AATCAGactgactagATCGAn") == "TTAGTCTGACTGATCTAGCTN", TEST_REVCOMP, "");
TAP_TEST(revcomp("AATCAGactgactagATCGAn") == "NTCGATCTAGTCAGTCTGATT", TEST_REVCOMP, "");
......@@ -248,6 +269,8 @@ void testTools() {
testFasta1();
testFastaAdd();
testFastaAddThrows();
testSequenceOutputOperator();
testFastaOutputOperator();
testRevcomp();
testCreateSequence();
testNucToInt();
......
......@@ -13,10 +13,12 @@ enum {
TEST_FASTA_SEQUENCE,
TEST_FASTA_ADD,
TEST_FASTA_INVALID_FILE,
TEST_FASTA_OUT,
TEST_CREATE_SEQUENCE_LABEL_FULL,
TEST_CREATE_SEQUENCE_LABEL,
TEST_CREATE_SEQUENCE_SEQUENCE,
TEST_CREATE_SEQUENCE_QUALITY,
TEST_SEQUENCE_OUT,
TEST_NUC_TO_INT,
TEST_DNA_TO_INT,
TEST_REVCOMP_INT,
......@@ -114,10 +116,12 @@ inline void declare_tests() {
RECORD_TAP_TEST(TEST_FASTA_SEQUENCE, "Fasta/Fastq sequence");
RECORD_TAP_TEST(TEST_FASTA_ADD, "Fasta add() method");
RECORD_TAP_TEST(TEST_FASTA_INVALID_FILE, "Fasta with invalid file");
RECORD_TAP_TEST(TEST_FASTA_OUT, "Test operator<< with Fasta");
RECORD_TAP_TEST(TEST_CREATE_SEQUENCE_LABEL_FULL, "create_sequence: label_full field");
RECORD_TAP_TEST(TEST_CREATE_SEQUENCE_LABEL, "create_sequence: label field");
RECORD_TAP_TEST(TEST_CREATE_SEQUENCE_SEQUENCE, "create_sequence: sequence field");
RECORD_TAP_TEST(TEST_CREATE_SEQUENCE_QUALITY, "create_sequence: quality field");
RECORD_TAP_TEST(TEST_SEQUENCE_OUT, "Test operator<< for Sequence");
RECORD_TAP_TEST(TEST_NUC_TO_INT, "nuc_to_int()");
RECORD_TAP_TEST(TEST_DNA_TO_INT, "dna_to_int()");
RECORD_TAP_TEST(TEST_REVCOMP_INT, "revcomp_int()");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment