Test Unit

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Test Unit as PDF for free.

More details

  • Words: 227
  • Pages: 1
test.h:#define TEST_FAIL(message) \ do { \ printf("[file:%s][line:%d] %s\n", __FILE__, __LINE__, message); \ } while (0)#define TEST_ASSERT_TRUE(message, test) \ do { \ if (!(test)) { \ printf("[file:%s][line:%d] %s is not equals.\n", __FILE__, __LINE__, message); \ return; \ } \ } while (0)#define TEST_ASSERT_INT(message, expected, actual) \ do { \ if ((expected) != (actual)) { \ printf("[file:%s][line:%d] %s is expected %d, but actual %d.\n", \ __FILE__, __LINE__, message, expected, actual); \ return; \ } \ } while (0)#define TEST_ASSERT_LONG(message, expected, actual) \ do { \ if ((expected) != (actual)) { \ printf("[file:%s][line:%d] %s is expected %ld, but actual %ld.\n", \ __FILE__, __LINE__, message, expected, actual); \ return; \ } \ } while (0)#define TEST_ASSERT_FLOAT(message, expected, actual) \ do { \ if ((expected) != (actual)) { \ printf("[file:%s][line:%d] %s is expected %f, but actual %f.\n", \ __FILE__, __LINE__, message, expected, actual); \ return; \ } \ } while (0)#define TEST_ASSERT_DOUBLE(message, expected, actual) \ do { \ if ((expected) != (actual)) { \ printf("[file:%s][line:%d] %s is expected %f, but actual %f.\n", \ __FILE__, __LINE__, message, expected, actual); \ return; \ } \ } while (0)#define TEST_ASSERT_STRING(message, expected, actual) \ do { \ if ((expected) != (actual)) { \ printf("[file:%s][line:%d] %s is expected %s, but actual %s.\n", \ __FILE__, __LINE__, message, expected, actual); \ return; \ } \ } while (0)test.c:void test(){ TEST_ASSERT_STRING("value", "foo", "bar");}int main(int argc, char *argv[]){ test(); return 0;}

Related Documents

Unit Test
November 2019 23
Test Unit
May 2020 10
Unit-test
May 2020 12
Unit 7 Test Review
November 2019 17
Science Unit Test
November 2019 8
Test Unit 2
May 2020 2