File: check_check_exit.c

package info (click to toggle)
check 0.9.8-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 2,724 kB
  • sloc: sh: 10,379; ansic: 5,276; makefile: 358
file content (51 lines) | stat: -rw-r--r-- 893 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "check.h"
#include "check_check.h"

START_TEST(test_early_exit_normal)
{
	exit(0);
	fail("Should've exitted...");
}
END_TEST

START_TEST(test_early_exit_with_allowed_error)
{
	exit(-1);
	fail("Should've exitted...");
}
END_TEST

START_TEST(loop_early_exit_normal)
{
	exit(0);
	fail("Should've exitted...");
}
END_TEST

START_TEST(loop_early_exit_allowed_exit)
{
	exit(-2);
	fail("Should've exitted...");
}
END_TEST

Suite *make_exit_suite(void)
{
  Suite *s;
  TCase *tc;

  s = suite_create("Exit");
  tc = tcase_create("Core");

  suite_add_tcase (s, tc);
  tcase_add_test(tc,test_early_exit_normal);
  tcase_add_exit_test(tc,test_early_exit_with_allowed_error,-1);
  tcase_add_loop_test(tc,loop_early_exit_normal,0,5);
  tcase_add_loop_exit_test(tc,loop_early_exit_allowed_exit,-2,0,5);
  return s;
}