Exemplo n.º 1
0
// This test contains a few checks that fail. Notice that a failed check does
// not cause the function to return.
void test_math_skills() {
  int bar = 2;
  nu_assert("bar isn't 2", bar == 2);
  nu_check("i can add", 1+1 == 2);
  nu_check("i can subtract", 5-3 == 1);          // This check fails
  nu_check("i can multiply", 7*11 == 77);
  nu_check("i can divide", 6/2 == 4);            // And this check fails
}
Exemplo n.º 2
0
// Here we have an assert that fails, causing the function to return
void test_cake() {
  int cake = 0;
  int healthy = 1;
  int weight = 200;
  nu_assert("i like food", 1);
  nu_assert("cake is healthy", cake == healthy);  // This assert fails
  nu_check("my weight is ok", weight < 180);      // This never runs
}
Exemplo n.º 3
0
void test_nu_assert() {
  nu_assert(1 == 2); // Runs, fails
  nu_check(1 == 1);  // Does not run
}
Exemplo n.º 4
0
void test_nu_check() {
  nu_check(1 == 2); // Runs, fails
  nu_check(1 == 1); // Runs
}