Bug #157

Unregistered Test Marker for Registered Tests

Added by Thomas Corbat over 1 year ago.

Status:NewStart date:11 May 2016
Priority:LowDue date:
Assignee:-% Done:

0%

Category:-
Target version:-

Description

I get markers at test_num_literal and test_den_literal in the code below:

#include "cute.h" 
#include "ide_listener.h" 
#include "xml_listener.h" 
#include "cute_runner.h" 

#include <cstdint>
#include <ratio>
#include <type_traits>

template<typename T>
struct is_ratio {
    static bool const value = false;
};

template<std::intmax_t N, std::intmax_t D>
struct is_ratio<std::ratio<N, D>> {
    static bool const value = true;
};

template<typename T>
bool const is_ratio_v = is_ratio<T>::value;

template<typename T, typename ... REST>
bool const are_ratio_v = is_ratio_v<T> && are_ratio_v<REST...>;

template<typename T>
bool const are_ratio_v<T> = is_ratio_v<T>;

template<std::intmax_t N, std::intmax_t D = 1>
constexpr std::ratio<N, D> ratiov = std::ratio<N, D>{};

constexpr unsigned value(char c) {
    return c - '0';
}

constexpr unsigned ten_to_the(unsigned e) {
    if (e == 0) {
        return 1;
    }
    return 10 * ten_to_the(e - 1);
}

template <typename LHS, typename RHS, typename = std::enable_if_t<are_ratio_v<LHS, RHS>>>
constexpr bool operator==(LHS const &, RHS const &) {
    return std::ratio_equal<LHS, RHS>::value;
}

template <typename LHS, typename RHS>
constexpr bool operator!=(LHS const &, RHS const &) {
    return std::ratio_not_equal<LHS, RHS>::value;
}

template <typename LHS, typename RHS>
constexpr bool operator<(LHS const &, RHS const &) {
    return std::ratio_less<LHS, RHS>::value;
}

template <typename LHS, typename RHS>
constexpr bool operator<=(LHS const &, RHS const &) {
    return std::ratio_less_equal<LHS, RHS>::value;
}

template <typename LHS, typename RHS>
constexpr bool operator>(LHS const &, RHS const &) {
    return std::ratio_greater<LHS, RHS>::value;
}

template <typename LHS, typename RHS>
constexpr bool operator>=(LHS const &, RHS const &) {
    return std::ratio_greater_equal<LHS, RHS>::value;
}

template <typename LHS, typename RHS>
constexpr auto operator+(LHS const &, RHS const &) {
    return std::ratio_add<LHS, RHS>{};
}

template<typename LHS, typename RHS>
constexpr auto operator*(LHS const &, RHS const &) {
    return std::ratio_multiply<LHS, RHS>{};
}

template<char...DIGITS>
constexpr unsigned long long dec_value;

template<char D>
constexpr unsigned long long dec_value<D> {value(D)};

template<char D, char...REST>
constexpr unsigned long long dec_value<D, REST...> {value(D) * ten_to_the(sizeof...(REST)) + dec_value<REST...>};

template<char...DIGITS>
constexpr auto operator"" _num() {
    return ratiov<dec_value<DIGITS...>>;
}

template<char...DIGITS>
constexpr auto operator"" _den() {
    return ratiov<1, dec_value<DIGITS...>>;
}

void test_den_lieral() {
    std::ratio<1, 123> e{};
    ASSERT_EQUAL(e, 123_den);
}

void test_num_literal() {
    std::ratio<123, 1> e{};
    ASSERT_EQUAL(e, 123_num);
}

void test_add_ratio() {
    std::ratio<4,5> l{};
    std::ratio<7,10> r{};
    std::ratio<3,2> e{};
    ASSERT_EQUAL(e, l + r);
}

void test_equality_of_same_cancelled_value() {
    std::ratio<4,6> l{};
    std::ratio<2,3> r{};
    ASSERT_EQUAL(l, r);
}

void test_equality_of_same_value_different_object() {
    std::ratio<2,3> l{}, r{};
    ASSERT_EQUAL(l, r);
}

void test_equality_of_same_object() {
    std::ratio<2,3> r{};
    ASSERT_EQUAL(r, r);
}

void test_determine_functionality_of_ratio_num() {
    ASSERT_EQUAL(2, (std::ratio<2, 3>::num));
}

void test_determine_functionality_of_ratio_den() {
    ASSERT_EQUAL(3, (std::ratio<2, 3>::den));
}

void test_determine_functionality_of_ratio_num_cancelled() {
    ASSERT_EQUAL(2, (std::ratio<4, 6>::num));
}

void test_determine_functionality_of_ratio_den_cancelled() {
    ASSERT_EQUAL(3, (std::ratio<4, 6>::den));
}

void runAllTests(int argc, char const *argv[]){
    cute::suite s;
    //TODO add your test here
    s.push_back(CUTE(test_determine_functionality_of_ratio_num));
    s.push_back(CUTE(test_determine_functionality_of_ratio_den));
    s.push_back(CUTE(test_determine_functionality_of_ratio_num_cancelled));
    s.push_back(CUTE(test_determine_functionality_of_ratio_den_cancelled));
    s.push_back(CUTE(test_equality_of_same_cancelled_value));
    s.push_back(CUTE(test_equality_of_same_value_different_object));
    s.push_back(CUTE(test_equality_of_same_object));
    s.push_back(CUTE(test_add_ratio));
    s.push_back(CUTE(test_num_literal));
    s.push_back(CUTE(test_den_lieral));
    cute::xml_file_opener xmlfile(argc,argv);
    cute::xml_listener<cute::ide_listener<> >  lis(xmlfile.out);
    cute::makeRunner(lis,argc,argv)(s, "AllTests");
}

int main(int argc, char const *argv[]){
    runAllTests(argc,argv);
    return 0;
}

Also available in: Atom PDF