Commit f4f58cfa authored by Mikaël Salson's avatar Mikaël Salson Committed by Mathieu Giraud
Browse files

unit-tests: Test trimSequence()

parent 2099c49f
......@@ -349,6 +349,100 @@ void testNChooseK() {
TAP_TEST(nChoosek(8, 4) == 70, TEST_N_CHOOSE_K, "");
}
void testTrimSequence() {
string seq = "NNNNNAATAGTAGACTANNNNN";
size_t start = 0;
size_t length = seq.size();
trimSequence(seq, start, length);
string trimmed = seq.substr(start, length);
PRINT_VAR(start);
PRINT_VAR(length);
TAP_TEST(trimmed == "", TEST_TRIM_SEQUENCE,
"trimmed sequence was " << trimmed);
seq = "ANANANATAGAGTAGATGATANANANANA";
start = 0;
length = seq.size();
trimSequence(seq, start, length);
trimmed = seq.substr(start, length);
TAP_TEST(trimmed == "ATAGAGTAGATGATA", TEST_TRIM_SEQUENCE,
"obtained " << trimmed);
seq = "ANAANATAGAGTAGATGATANAANA";
start = 0;
length = seq.size();
trimSequence(seq, start, length);
trimmed = seq.substr(start, length);
TAP_TEST(trimmed == "ATAGAGTAGATGATA", TEST_TRIM_SEQUENCE,
"got " << trimmed);
seq = "ATAGAGTAGATGATANAANA";
start = 0;
length = seq.size();
trimSequence(seq, start, length);
trimmed = seq.substr(start, length);
TAP_TEST(trimmed == "ATAGAGTAGATGATA", TEST_TRIM_SEQUENCE,
"got " << trimmed);
seq = "ANAANATAGAGTAGATGATA";
start = 0;
length = seq.size();
trimSequence(seq, start, length);
trimmed = seq.substr(start, length);
TAP_TEST(trimmed == "ATAGAGTAGATGATA", TEST_TRIM_SEQUENCE,
"got " << trimmed);
seq = "NATAGAGTAGATGATA";
start = 0;
length = seq.size();
trimSequence(seq, start, length);
trimmed = seq.substr(start, length);
TAP_TEST(trimmed == "ATAGAGTAGATGATA", TEST_TRIM_SEQUENCE,
"got " << trimmed);
seq = "CCNCCNATAGAGTAGATGATANCCNCC";
start = 0;
length = seq.size();
trimSequence(seq, start, length);
trimmed = seq.substr(start, length);
TAP_TEST(trimmed == "ATAGAGTAGATGATA", TEST_TRIM_SEQUENCE,
"got " << trimmed);
seq = "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNATAGAGTAGATGATA";
start = 28;
length = 16;
trimSequence(seq, start, length);
trimmed = seq.substr(start, length);
TAP_TEST(trimmed == "ATAGAGTAGATGATA", TEST_TRIM_SEQUENCE,
"got " << trimmed);
seq = "ATAGAGTAGATGATANNNNNNNNNNNNNNNNNNNNNNNNNNNNN";
start = 0;
length = 16;
trimSequence(seq, start, length);
trimmed = seq.substr(start, length);
TAP_TEST(trimmed == "ATAGAGTAGATGATA", TEST_TRIM_SEQUENCE,
"got " << trimmed);
seq = "ATAGAGTAGATGATA";
start = 0;
length = seq.size();
trimSequence(seq, start, length);
trimmed = seq.substr(start, length);
TAP_TEST(trimmed == "ATAGAGTAGATGATA", TEST_TRIM_SEQUENCE,
"got " << trimmed);
}
void testTools() {
testOnlineFasta1();
testOnlineFastaMaxNth();
......@@ -368,4 +462,5 @@ void testTools() {
testExtendedNucleotides();
testExtractBasename();
testNChooseK();
testTrimSequence();
}
......@@ -29,6 +29,7 @@ enum {
TEST_EXTENDED_NUCL,
TEST_EXTRACT_BASENAME,
TEST_N_CHOOSE_K,
TEST_TRIM_SEQUENCE,
/* Storage tests */
TEST_ARRAY_KMERSTORE,
......@@ -186,6 +187,7 @@ inline void declare_tests() {
RECORD_TAP_TEST(TEST_REVCOMP_INT, "revcomp_int()");
RECORD_TAP_TEST(TEST_EXTRACT_BASENAME, "extractBasename()");
RECORD_TAP_TEST(TEST_N_CHOOSE_K, "test nChooseK()");
RECORD_TAP_TEST(TEST_TRIM_SEQUENCE, "test trimSequence()");
RECORD_TAP_TEST(TEST_ARRAY_KMERSTORE, "Testing ArrayKmerStore");
RECORD_TAP_TEST(TEST_KMERSTORE_INSERT_ONE_SEQ, "Testing IKmerStore::insert() on one sequence");
......
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