ceao_competency.cpp 1.77 KB
Newer Older
1 2 3 4
#include <eo>
#include <iostream>
#include <string>

5 6
#include <cassert>

7 8
#include "model/magnitude.h"
#include "model/competency.h"
9
#include "model/course.h"
10 11 12 13 14 15 16 17 18

#include "model/exception/magnitudeException.h"
#include "model/exception/competencyEvolvingException.h"

int main(int argc, char* argv[])
{
    Magnitude m = Magnitude::build(0.7);
    Competency c = Competency::build(0.5, "");
    Competency c2 = Competency::build(m,"");
19 20
    Competency c3 = Competency::build(0.5);

21 22 23 24 25 26 27
    std::vector<Competency> vec;
    vec.push_back(c);
    vec.push_back(c2);
    vec.push_back(c3);
    Course cour = Course::build();
    cour.findInVector(vec, c);
    
28 29
    assert(c3.name().compare("Competency#"+std::to_string(c3.id())) == 0);
        std::cout << "Default naming ok" << std::endl;
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

    std::cout << std::to_string(c.c_magnitude().value()) << std::endl ;
    std::cout << c2.competencyValue() << std::endl;

    c.evolveTowards(0.2);
    std::cout << c << std::endl;
    c.evolveTowards(-0.2);
    std::cout << c << std::endl;
    c.evolveTowards(-0.3);
    std::cout << c << std::endl;
    c.evolveTowards(m);
    std::cout << c << std::endl;
    try
    {
        c.evolveTowards(2);
    }
    catch(CompetencyEvolvingException & e)
    {
        std::cout << e.what() << std::endl;

        e.getCompetency().setName("Oeuf!");
        std::cout << e.getCompetency() << std::endl;
        std::cout << c << std::endl;
    }
    
    c.evolveTowards(-0.5);
    std::cout << c << std::endl;

58 59 60 61 62 63 64 65 66 67
    assert( c == c);
        std::cout << "c == c OK" << std::endl ;
    std::cout << "renaming c2 as c.name()" << std::endl;
    c2.setName(c.name());
    assert( c == c2);
        std::cout << "c == c2 OK" << std::endl ;

    assert ( !(c == c3) );
        std::cout << "c != c3 OK" << std::endl;

68
    return EXIT_SUCCESS;
69
}