diff options
author | Adrian Kummerlaender | 2015-01-17 14:15:56 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2015-01-17 14:15:56 +0100 |
commit | d975c2365730644a7eb15b88e02ec0e92b1fe7b1 (patch) | |
tree | 3840799b1d6ce0d310d7915baec0530fb8affb44 | |
parent | f922e0b5dfc0a03378b231ad2705dbef29310d56 (diff) | |
download | TypeAsValue-d975c2365730644a7eb15b88e02ec0e92b1fe7b1.tar TypeAsValue-d975c2365730644a7eb15b88e02ec0e92b1fe7b1.tar.gz TypeAsValue-d975c2365730644a7eb15b88e02ec0e92b1fe7b1.tar.bz2 TypeAsValue-d975c2365730644a7eb15b88e02ec0e92b1fe7b1.tar.lz TypeAsValue-d975c2365730644a7eb15b88e02ec0e92b1fe7b1.tar.xz TypeAsValue-d975c2365730644a7eb15b88e02ec0e92b1fe7b1.tar.zst TypeAsValue-d975c2365730644a7eb15b88e02ec0e92b1fe7b1.zip |
Added Scheme representation to test cases as a kind of documentation
-rw-r--r-- | test.cc | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -8,38 +8,50 @@ class TypeAsValueTest : public ::testing::Test { }; -TEST_F(TypeAsValueTest, Value) { - ASSERT_TRUE(( std::is_same<int, tav::Int<1>::value_type>::value )); -} - TEST_F(TypeAsValueTest, BasicMath) { + // (+ 1 2) EXPECT_EQ(3, ( tav::Add<tav::Int<1>, tav::Int<2>>::value )); + // (- 10 6) EXPECT_EQ(4, ( tav::Substract<tav::Int<10>, tav::Int<6>>::value )); + // (* 2 21) EXPECT_EQ(42, ( tav::Multiply<tav::Int<2>, tav::Int<21>>::value )); + // (/ 10 2) EXPECT_EQ(5, ( tav::Divide<tav::Int<10>, tav::Int<2>>::value )); } TEST_F(TypeAsValueTest, Conditional) { + // (if #t 1 2) EXPECT_EQ(1, ( tav::If<true, tav::Int<1>, tav::Int<2>>::value )); + // (if #f 1 2) EXPECT_EQ(2, ( tav::If<false, tav::Int<1>, tav::Int<2>>::value )); } TEST_F(TypeAsValueTest, Cons) { + // (car (cons 1 void)) EXPECT_EQ(1, ( tav::Car<tav::Cons<tav::Int<1>, void>>::value )); + // (car (cons 1 2)) EXPECT_EQ(1, ( tav::Car<tav::Cons<tav::Int<1>, tav::Int<2>>>::value )); + // (cdr (cons 1 2)) EXPECT_EQ(2, ( tav::Cdr<tav::Cons<tav::Int<1>, tav::Int<2>>>::value )); + // (car (cdr (cons 1 (cons 2 3)))) EXPECT_EQ(2, ( tav::Car<tav::Cdr<tav::Cons<tav::Int<1>, tav::Cons<tav::Int<2>, tav::Int<3>>>>>::value )); } TEST_F(TypeAsValueTest, List) { + // (head (list 1)) EXPECT_EQ(1, ( tav::Head<tav::List<tav::Int<1>>::type>::value )); + // (head (list 1 2)) EXPECT_EQ(1, ( tav::Head<tav::List<tav::Int<1>, tav::Int<2>>::type>::value )); + // (head (tail (list 1 2))) EXPECT_EQ(2, ( tav::Head<tav::Tail<tav::List<tav::Int<1>, tav::Int<2>>::type>>::value )); + // (head (tail (list 1 2 3))) EXPECT_EQ(2, ( tav::Head<tav::Tail<tav::List<tav::Int<1>, tav::Int<2>, tav::Int<3>>::type>>::value )); } TEST_F(TypeAsValueTest, ListConcatenate) { + // (head (concatenate (list 1) (list 2))) EXPECT_EQ(1, ( tav::Head<tav::Concatenate<tav::List<tav::Int<1>>::type, tav::List<tav::Int<2>>::type>::type>::value )); + // (head (tail (concatenate (list 1) (list 2)))) EXPECT_EQ(2, ( tav::Head<tav::Tail<tav::Concatenate<tav::List<tav::Int<1>>::type, tav::List<tav::Int<2>>::type>::type>>::value )); } |