Skip to content

Instantly share code, notes, and snippets.

@liuliu
Created January 29, 2011 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liuliu/801482 to your computer and use it in GitHub Desktop.
Save liuliu/801482 to your computer and use it in GitHub Desktop.
test case file
#include "case.h"
TEST_CASE("fail test")
{
REQUIRE_EQ(1, 2, "should fail %d", 1024);
}
TEST_CASE("fail array test")
{
int a[3] = {1,2,3};
int b[3] = {1,3,3};
REQUIRE_ARRAY_EQ(int, a, b, 3, "a / b should be not equal");
}
TEST_CASE("tolerance test")
{
double a = 1.0 / 3.0;
REQUIRE_EQ_WITH_TOLERANCE(1, a * 2.999, 0.001, "should fail");
}
TEST_CASE("array tolerance test")
{
double a[3] = {1,2,3};
double b[3] = {1,2.001,3};
REQUIRE_ARRAY_EQ_WITH_TOLERANCE(double, a, b, 3, 0.01, "a / b should be not equal");
}
TEST_CASE("pass test")
{
REQUIRE_EQ(1, 1, "should pass");
}
TEST_CASE("pass array test")
{
int a[3] = {1,2,3};
int b[3] = {1,2,3};
REQUIRE_ARRAY_EQ(int, a, b, 3, "a / b should be equal");
}
#include "case_main.h"
[1/6] [RUN] fail test ...
REQUIRE_EQ: 1(1) != 2(2), should fail 1024
[1/6] [FAIL] fail test
[2/6] [RUN] fail array test ...
REQUIRE_ARRAY_EQ: a[1](2) != b[1](3), a / b should be not equal
[2/6] [FAIL] fail array test
[3/6] [PASS] tolerance test
[4/6] [PASS] array tolerance test
[5/6] [PASS] pass test
[6/6] [PASS] pass array test
4 of 6 test case(s) passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment