diff options
author | Adrian Kummerlaender | 2015-01-19 18:43:46 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2015-01-19 18:43:46 +0100 |
commit | f7706caa40132403d6c92ee660dc37560d032af5 (patch) | |
tree | 2595e3a99235194d54a317238869e1e90fe85250 | |
parent | 46e028017b34f43d7aa8004ccef5a56fccf2826c (diff) | |
download | TypeAsValue-f7706caa40132403d6c92ee660dc37560d032af5.tar TypeAsValue-f7706caa40132403d6c92ee660dc37560d032af5.tar.gz TypeAsValue-f7706caa40132403d6c92ee660dc37560d032af5.tar.bz2 TypeAsValue-f7706caa40132403d6c92ee660dc37560d032af5.tar.lz TypeAsValue-f7706caa40132403d6c92ee660dc37560d032af5.tar.xz TypeAsValue-f7706caa40132403d6c92ee660dc37560d032af5.tar.zst TypeAsValue-f7706caa40132403d6c92ee660dc37560d032af5.zip |
Added type and value equality test case
-rw-r--r-- | src/type.h | 11 | ||||
-rw-r--r-- | test.cc | 26 |
2 files changed, 28 insertions, 9 deletions
@@ -18,19 +18,16 @@ template < typename X, typename Y > -using equal_type = typename std::integral_constant< - bool, - std::is_same<typename X::value_type, typename Y::value_type>::value +using EqualType = typename std::is_same< + typename X::value_type, + typename Y::value_type >::type; template < typename X, typename Y > -using equal_value = typename std::integral_constant< - bool, - X::value == Y::value ->::type; +using EqualValue = Boolean<X::value == Y::value>; } @@ -9,8 +9,27 @@ int main(int, char **) { } -template <typename Element> -using quadruple = tav::Multiply<tav::Int<4>, Element>; +// equality + +static_assert( + std::is_same<tav::Boolean<true>, tav::EqualType<tav::Int<1>, tav::Int<2>>>::value, + "(EqualType 1 2) != #t" +); + +static_assert( + std::is_same<tav::Boolean<false>, tav::EqualType<tav::Int<1>, tav::Size<1>>>::value, + "(EqualType (int 1) (size 2)) != #f" +); + +static_assert( + std::is_same<tav::Boolean<true>, tav::EqualValue<tav::Int<1>, tav::Size<1>>>::value, + "(equal? (int 1) (size 1)) != #t" +); + +static_assert( + std::is_same<tav::Boolean<false>, tav::EqualValue<tav::Int<1>, tav::Int<2>>>::value, + "(equal? 1 2) != #f" +); // basic math operations @@ -147,6 +166,9 @@ static_assert( // list map +template <typename Element> +using quadruple = tav::Multiply<tav::Int<4>, Element>; + static_assert( std::is_same<tav::List<tav::Int<4>, tav::Int<8>, tav::Int<12>>::type, tav::Map<quadruple, tav::List<tav::Int<1>, tav::Int<2>, tav::Int<3>>::type>::type>::value, "(map quadruple (list 1 2 3)) != (list 4 8 12)" |