From d975c2365730644a7eb15b88e02ec0e92b1fe7b1 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 17 Jan 2015 14:15:56 +0100 Subject: Added Scheme representation to test cases as a kind of documentation --- test.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/test.cc b/test.cc index 5b24c32..390804b 100644 --- a/test.cc +++ b/test.cc @@ -8,38 +8,50 @@ class TypeAsValueTest : public ::testing::Test { }; -TEST_F(TypeAsValueTest, Value) { - ASSERT_TRUE(( std::is_same::value_type>::value )); -} - TEST_F(TypeAsValueTest, BasicMath) { + // (+ 1 2) EXPECT_EQ(3, ( tav::Add, tav::Int<2>>::value )); + // (- 10 6) EXPECT_EQ(4, ( tav::Substract, tav::Int<6>>::value )); + // (* 2 21) EXPECT_EQ(42, ( tav::Multiply, tav::Int<21>>::value )); + // (/ 10 2) EXPECT_EQ(5, ( tav::Divide, tav::Int<2>>::value )); } TEST_F(TypeAsValueTest, Conditional) { + // (if #t 1 2) EXPECT_EQ(1, ( tav::If, tav::Int<2>>::value )); + // (if #f 1 2) EXPECT_EQ(2, ( tav::If, tav::Int<2>>::value )); } TEST_F(TypeAsValueTest, Cons) { + // (car (cons 1 void)) EXPECT_EQ(1, ( tav::Car, void>>::value )); + // (car (cons 1 2)) EXPECT_EQ(1, ( tav::Car, tav::Int<2>>>::value )); + // (cdr (cons 1 2)) EXPECT_EQ(2, ( tav::Cdr, tav::Int<2>>>::value )); + // (car (cdr (cons 1 (cons 2 3)))) EXPECT_EQ(2, ( tav::Car, tav::Cons, tav::Int<3>>>>>::value )); } TEST_F(TypeAsValueTest, List) { + // (head (list 1)) EXPECT_EQ(1, ( tav::Head>::type>::value )); + // (head (list 1 2)) EXPECT_EQ(1, ( tav::Head, tav::Int<2>>::type>::value )); + // (head (tail (list 1 2))) EXPECT_EQ(2, ( tav::Head, tav::Int<2>>::type>>::value )); + // (head (tail (list 1 2 3))) EXPECT_EQ(2, ( tav::Head, tav::Int<2>, tav::Int<3>>::type>>::value )); } TEST_F(TypeAsValueTest, ListConcatenate) { + // (head (concatenate (list 1) (list 2))) EXPECT_EQ(1, ( tav::Head>::type, tav::List>::type>::type>::value )); + // (head (tail (concatenate (list 1) (list 2)))) EXPECT_EQ(2, ( tav::Head>::type, tav::List>::type>::type>>::value )); } -- cgit v1.2.3