Commit 071b5b24 authored by Mikaël Salson's avatar Mikaël Salson

Tests: test KmerAffect

parent 6ac0cfa3
#include "tests.h"
#include <core/kmeraffect.h>
void testAffect() {
affect_t Vminus = {'V'}, Vplus = {'V'};
Vplus.c |= 1 << 7;
affect_t Jplus = {'J'};
Jplus.c |= 1 << 7;
TAP_TEST(affect_strand(Vminus) == -1, TEST_AFFECT_STRAND, "");
TAP_TEST(affect_strand(Vplus) == 1, TEST_AFFECT_STRAND, "");
TAP_TEST(affect_char(Vminus) == 'V', TEST_AFFECT_CHAR, "");
TAP_TEST(affect_char(Vplus) == 'V', TEST_AFFECT_CHAR, "");
TAP_TEST(affect_char(Jplus) == 'J', TEST_AFFECT_CHAR, "");
TAP_TEST(! (Vminus == Vplus), TEST_AFFECT_COMPARISON, "");
TAP_TEST(Vminus != Vplus, TEST_AFFECT_COMPARISON, "");
TAP_TEST(! (Vminus < Vplus), TEST_AFFECT_COMPARISON, "");
TAP_TEST(Vminus > Vplus, TEST_AFFECT_COMPARISON, "");
TAP_TEST(! (Vminus <= Vplus), TEST_AFFECT_COMPARISON, "");
TAP_TEST(Vminus >= Vplus, TEST_AFFECT_COMPARISON, "");
TAP_TEST(! (Vminus == Jplus), TEST_AFFECT_COMPARISON, "");
TAP_TEST(Vminus != Jplus, TEST_AFFECT_COMPARISON, "");
TAP_TEST(! (Vminus <= Jplus), TEST_AFFECT_COMPARISON, "");
TAP_TEST(Vminus >= Jplus, TEST_AFFECT_COMPARISON, "");
TAP_TEST(! (Vminus < Jplus), TEST_AFFECT_COMPARISON, "");
TAP_TEST(Vminus > Jplus, TEST_AFFECT_COMPARISON, "");
TAP_TEST(Vminus == Vminus, TEST_AFFECT_COMPARISON, "");
TAP_TEST(! (Vminus != Vminus), TEST_AFFECT_COMPARISON, "");
TAP_TEST(! (Vminus < Vminus), TEST_AFFECT_COMPARISON, "");
TAP_TEST(! (Vminus > Vminus), TEST_AFFECT_COMPARISON, "");
TAP_TEST(Vminus <= Vminus, TEST_AFFECT_COMPARISON, "");
TAP_TEST(Vminus >= Vminus, TEST_AFFECT_COMPARISON, "");
TAP_TEST(toString(Vminus) == "-V", TEST_AFFECT_TO_STRING, toString(Vminus));
TAP_TEST(toString(Vplus) == "+V", TEST_AFFECT_TO_STRING, toString(Vplus));
TAP_TEST(toString(Jplus) == "+J", TEST_AFFECT_TO_STRING, toString(Jplus));
TAP_TEST(toString(AFFECT_UNKNOWN.affect) == " _", TEST_AFFECT_TO_STRING, "");
TAP_TEST(toString(AFFECT_AMBIGUOUS.affect) == " ?", TEST_AFFECT_TO_STRING, "");
ostringstream oss;
oss << Vminus;
TAP_TEST(toString(Vminus) == oss.str(), TEST_AFFECT_OUT, "");
ostringstream oss2;
oss2 << Vplus;
TAP_TEST(toString(Vplus) == oss2.str(), TEST_AFFECT_OUT, "");
ostringstream oss3;
oss3 << Jplus;
TAP_TEST(toString(Jplus) == oss3.str(), TEST_AFFECT_OUT, "");
}
void testKmerAffectClass() {
affect_t Vminus = {'V'}, Vplus = {'V'};
Vplus.c |= 1 << 7;
affect_t Jplus = {'J'};
Jplus.c |= 1 << 7;
KmerAffect KAVp("V", 1);
KmerAffect KAVm("V", -1);
KmerAffect KAJp("J", 1);
TAP_TEST(KAVp.affect == Vplus, TEST_KMERAFFECT_CONSTRUCTOR, "");
TAP_TEST(KAVm.affect == Vminus, TEST_KMERAFFECT_CONSTRUCTOR, "");
TAP_TEST(KAJp.affect == Jplus, TEST_KMERAFFECT_CONSTRUCTOR, "");
KmerAffect test = KAVp;
TAP_TEST(test.affect == KAVp.affect, TEST_KMERAFFECT_AFFECTATION, "");
test += KAVp;
TAP_TEST(test.affect == KAVp.affect, TEST_KMERAFFECT_ADD, "");
test += KAVm;
TAP_TEST(test == AFFECT_AMBIGUOUS, TEST_KMERAFFECT_ADD, "");
KmerAffect unknown;
TAP_TEST(unknown == AFFECT_UNKNOWN, TEST_KMERAFFECT_CONSTRUCTOR, "");
TAP_TEST(unknown.isUnknown(), TEST_KMERAFFECT_UNKNOWN, "");
TAP_TEST(unknown.getStrand() == 0, TEST_KMERAFFECT_STRAND, "");
TAP_TEST(unknown.getLabel() == AFFECT_UNKNOWN_SYMBOL, TEST_KMERAFFECT_LABEL, "");
unknown += KAVm;
TAP_TEST(unknown.affect == KAVm, TEST_KMERAFFECT_ADD, "");
unknown += KAJp;
TAP_TEST(unknown == AFFECT_AMBIGUOUS, TEST_KMERAFFECT_ADD, "");
TAP_TEST(unknown.isAmbiguous(), TEST_KMERAFFECT_AMBIGUOUS, "");
TAP_TEST(unknown.getLabel() == AFFECT_AMBIGUOUS_SYMBOL, TEST_KMERAFFECT_LABEL, "");
TAP_TEST(unknown.getStrand() == 0, TEST_KMERAFFECT_STRAND, "");
TAP_TEST(KAVp.getStrand() == 1, TEST_KMERAFFECT_STRAND, "");
TAP_TEST(KAVm.getStrand() == -1, TEST_KMERAFFECT_STRAND, "");
TAP_TEST(KAJp.getStrand() == 1, TEST_KMERAFFECT_STRAND, "");
TAP_TEST(KAVp.getLabel() == "V", TEST_KMERAFFECT_LABEL, "");
TAP_TEST(KAVm.getLabel() == "V", TEST_KMERAFFECT_LABEL, "");
TAP_TEST(KAJp.getLabel() == "J", TEST_KMERAFFECT_LABEL, "");
ostringstream ossKA, ossA;
ossKA << KAVp;
ossA << Vplus;
TAP_TEST(ossA.str() == ossKA.str(), TEST_KMERAFFECT_OUT, "");
ossKA << KAVm;
ossA << Vminus;
TAP_TEST(ossA.str() == ossKA.str(), TEST_KMERAFFECT_OUT, "");
ossKA << KAJp;
ossA << Jplus;
TAP_TEST(ossA.str() == ossKA.str(), TEST_KMERAFFECT_OUT, "");
}
void testKmerAffectComparison() {
KmerAffect Vminus("V", -1);
KmerAffect Vplus("V", 1);
KmerAffect Jplus("J", 1);
TAP_TEST(! (Vminus == Vplus), TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(Vminus != Vplus, TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(! (Vminus < Vplus), TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(Vminus > Vplus, TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(! (Vminus <= Vplus), TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(Vminus >= Vplus, TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(! (Vminus == Jplus), TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(Vminus != Jplus, TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(! (Vminus <= Jplus), TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(Vminus >= Jplus, TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(! (Vminus < Jplus), TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(Vminus > Jplus, TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(Vminus == Vminus, TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(! (Vminus != Vminus), TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(! (Vminus < Vminus), TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(! (Vminus > Vminus), TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(Vminus <= Vminus, TEST_KMERAFFECT_COMPARISON, "");
TAP_TEST(Vminus >= Vminus, TEST_KMERAFFECT_COMPARISON, "");
}
void testKmerAffect() {
testAffect();
testKmerAffectClass();
testKmerAffectComparison();
}
......@@ -2,6 +2,7 @@
#include "tests.h"
#include "testTools.cpp"
#include "testKmerAffect.cpp"
#include "testStorage.cpp"
#include "testAffectAnalyser.cpp"
#include "testBugs.cpp"
......@@ -18,6 +19,7 @@ int main(void) {
testTools();
testStorage();
testKmerAffect();
testAffectAnalyser();
testBugs();
testCluster();
......
......@@ -33,6 +33,22 @@ enum {
TEST_KMERSTORE_GET_S,
TEST_KMERSTORE_GET_SEED,
/* KmerAffect */
TEST_AFFECT_STRAND,
TEST_AFFECT_CHAR,
TEST_AFFECT_COMPARISON,
TEST_AFFECT_TO_STRING,
TEST_AFFECT_OUT,
TEST_KMERAFFECT_CONSTRUCTOR,
TEST_KMERAFFECT_AFFECTATION,
TEST_KMERAFFECT_ADD,
TEST_KMERAFFECT_UNKNOWN,
TEST_KMERAFFECT_AMBIGUOUS,
TEST_KMERAFFECT_STRAND,
TEST_KMERAFFECT_LABEL,
TEST_KMERAFFECT_COMPARISON,
TEST_KMERAFFECT_OUT,
/* Affect analyzer */
TEST_AA_COUNT,
TEST_AA_GET_AFFECT,
......@@ -135,6 +151,22 @@ inline void declare_tests() {
RECORD_TAP_TEST(TEST_KMERSTORE_GET_S, "Testing getK() in KmerStore");
RECORD_TAP_TEST(TEST_KMERSTORE_GET_SEED, "Testing getK() in KmerStore");
RECORD_TAP_TEST(TEST_AFFECT_STRAND, "affect_strand()");
RECORD_TAP_TEST(TEST_AFFECT_CHAR, "affect_char()");
RECORD_TAP_TEST(TEST_AFFECT_COMPARISON, "Comparison operators for affect_t");
RECORD_TAP_TEST(TEST_AFFECT_TO_STRING, "toString() for affect_t");
RECORD_TAP_TEST(TEST_AFFECT_OUT, "operator<< for affect_t");
RECORD_TAP_TEST(TEST_KMERAFFECT_CONSTRUCTOR, "KmerAffect constructor");
RECORD_TAP_TEST(TEST_KMERAFFECT_AFFECTATION, "KmerAffect operator=");
RECORD_TAP_TEST(TEST_KMERAFFECT_ADD, "KmerAffect operator +=");
RECORD_TAP_TEST(TEST_KMERAFFECT_UNKNOWN, "KmerAffect::isUnknown()");
RECORD_TAP_TEST(TEST_KMERAFFECT_AMBIGUOUS, "KmerAffect::isAmbiguous()");
RECORD_TAP_TEST(TEST_KMERAFFECT_STRAND, "KmerAffect::getStrand()");
RECORD_TAP_TEST(TEST_KMERAFFECT_LABEL, "KmerAffect::getLabel()");
RECORD_TAP_TEST(TEST_KMERAFFECT_COMPARISON, "KmerAffect comparison operators");
RECORD_TAP_TEST(TEST_KMERAFFECT_OUT, "KmerAffect operator<<");
RECORD_TAP_TEST(TEST_AA_COUNT, "AffectAnalyser.count()");
RECORD_TAP_TEST(TEST_AA_GET_AFFECT, "AffectAnalyser.getAffectation()");
RECORD_TAP_TEST(TEST_AA_GET_DISTINCT_AFFECT, "AffectAnalyser.getDistinctAffectations()");
......
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