File: htmltest.c

package info (click to toggle)
tk-html3 3.0~fossil20110109-6
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 6,644 kB
  • ctags: 5,882
  • sloc: ansic: 48,994; tcl: 26,030; sh: 1,190; yacc: 161; makefile: 24
file content (113 lines) | stat: -rw-r--r-- 2,743 bytes parent folder | download | duplicates (6)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
static char const rcsid[] =
        "@(#) $Id: htmltest.c,v 1.15 2005/03/23 01:36:54 danielk1977 Exp $";

/*
** This file contains the TestPoint routines used for profiling
** and coverage analysis of the code.
**
** This source code is released into the public domain by the author,
** D. Richard Hipp, on 2002 December 17.  Instead of a license, here
** is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
*/

/*
** A macro named "TestPoint" is defined which increments a counter
** whenever it is encountered.  This is very efficient, and should
** not impact performance of the system.  For delivery, the macro
** can be nulled out by recompiling without the COVERAGE_TEST macro 
** defined.
**
** See also the "renumber.c" program which can be used
** to assign unique numbers to all of the TestPoint(0) macros.
*/
#include "tcl.h"
#include "html.h"

#if INTERFACE

#endif /* INTERFACE */

/*
** The following global array keeps track of the number of visits to
** each testpoint.  The size of the array must be set manually to the
** be at least one greater than the largest TestPoint number.
*/
#if defined(COVERAGE_TEST)
int HtmlTPArray[2000];
#endif

/* Needed by the EslTestPointDump routine
*/
#include <stdio.h>

/*
** Recursion depth
*/
#if defined(DEBUG)
int HtmlDepth = 0;
#endif
#if INTERFACE
#if defined(DEBUG)
#define HtmlPush HtmlDepth+=2
#define HtmlPop  HtmlDepth-=2
#else
#define HtmlPush
#define HtmlPop
#endif
#endif

/* This function is called to print the values of all elements of the
** TP_Array to the given file.  Values are printed in decimal, one per line.
*/
void
HtmlTestPointDump(filename)
    char *filename;
{
#if defined(COVERAGE_TEST)
    FILE *fp;

    fp = fopen(filename, "a");
    if (fp) {
        int i;
        for (i = 0; i < sizeof(HtmlTPArray) / sizeof(HtmlTPArray[0]); i++) {
            if (HtmlTPArray[i] > 0) {
                fprintf(fp, "%d %d\n", i, HtmlTPArray[i]);
            }
        }
    }
    fclose(fp);
#endif
}

/* This function reports an error to stderr when code that is marked
** UNTESTED gets executed.
*/
void
HtmlTPUntested(zFile, line)
    const char *zFile;
    int line;
{
#ifndef USE_TCL_STUBS
    fprintf(stderr, "Untested HTML Widget code executed in file %s line %d\n",
            zFile, line);
#endif
}

/* This function reports an error to stderr when safety code that should
** never execute is called.
*/
void
HtmlTPCantHappen(zFile, line)
    const char *zFile;
    int line;
{
#ifndef USE_TCL_STUBS
    fprintf(stderr,
            "Unplanned behavior in the HTML Widget in file %s line %d\n", zFile,
            line);
#endif
}