source: anotherchoice/tags/jsp-1.4.4-full-UTF8/cfg/base/coverage_defs.h@ 363

Last change on this file since 363 was 363, checked in by ykominami, 5 years ago

add tags/jsp-1.4.4-full-UTF8

  • Property svn:executable set to *
File size: 8.2 KB
RevLine 
[363]1/*
2 * TOPPERS/JSP Kernel
3 * Toyohashi Open Platform for Embedded Real-Time Systems/
4 * Just Standard Profile Kernel
5 *
6 * Copyright (C) 2003 by Embedded and Real-Time Systems Laboratory
7 * Toyohashi Univ. of Technology, JAPAN
8 *
9 * 上記著作権者
10は,以下の (1)〜(4) の条件か,Free Software Foundation
11 * によってå…
12¬è¡¨ã•ã‚Œã¦ã„ã‚‹ GNU General Public License の Version 2 に記
13 * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
14 * を改変したものを含む.以下同じ)を使用・複製・改変・再é…
15å¸ƒï¼ˆä»¥ä¸‹ï¼Œ
16 * 利用と呼ぶ)することを無償で許諾する.
17 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
18 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
19 * スコード中に含まれていること.
20 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
21 * 用できる形で再é…
22å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œå†é…
23å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨
24 * 者
25マニュアルなど)に,上記の著作権表示,この利用条件および下記
26 * の無保証規定を掲載すること.
27 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
28 * 用できない形で再é…
29å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œæ¬¡ã®ã„ずれかの条件を満たすこ
30 * と.
31 * (a) 再é…
32å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨è€…
33マニュアルなど)に,上記の著
34 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
35 * (b) 再é…
36å¸ƒã®å½¢æ…
37‹ã‚’,別に定める方法によって,TOPPERSプロジェクトに
38 * 報告すること.
39 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
40 * 害からも,上記著作権者
41およびTOPPERSプロジェクトをå…
42è²¬ã™ã‚‹ã“と.
43 *
44 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者
45お
46 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
47 * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
48 * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
49 *
50 * @(#) $Id: coverage_defs.h,v 1.4 2003/12/15 07:32:13 takayuki Exp $
51 */
52
53/*
54 #ifdef関係
55 coverage_defsは、undefsで解除したあとに読み込む場合があるので、
56 パートをいくつかに分割している.
57 - COVERAGE : カバレッジ機能を使用するかどうか
58 - COVERAGE_H : coverage.cppに関連する部分で、多重定義されては困るもの
59 - COVERAGE_DEFS : カバレッジに関連する部分で、coverage_undefs.hでundefでき、もう一度coverage_defs.hを読んでも大丈夫なもの
60*/
61
62
63#ifdef COVERAGE
64
65#include "base/singleton.h"
66
67 /* ヘッダ */
68#include <string>
69#include <map>
70#include <set>
71#include <iostream>
72
73
74#ifndef COVERAGE_H
75#define COVERAGE_H
76/*
77 * 簡単なカバレッジチェック
78 */
79
80class Coverage {
81public:
82 /* 場所を保持するクラス */
83 class Location {
84 protected:
85 const char * filename;
86 unsigned int lineno;
87 const char * additional;
88
89 public:
90 Location(const char * _filename, unsigned int _lineno, const char * _additional = "") : filename(_filename), lineno(_lineno), additional(_additional) {}
91 Location(const Location & src) : filename(src.filename), lineno(src.lineno), additional(src.additional) {}
92
93 inline Location & operator = (const Location & right)
94 {
95 filename = right.filename;
96 lineno = right.lineno;
97 additional = right.additional;
98
99 return *this;
100 }
101
102 inline bool operator == (const Location & right) const
103 { return lineno == right.lineno && std::string(filename).compare(right.filename) == 0 && std::string(additional).compare(right.additional) == 0; }
104
105 inline bool operator < (const Location & right) const
106 {
107 if(lineno < right.lineno)
108 return true;
109 if(std::string(filename).compare(right.filename) < 0)
110 return true;
111
112 return false;
113 }
114
115 inline std::string getFilename(void) const
116 { return std::string(filename); }
117
118 inline unsigned int getLineno(void) const
119 { return lineno; }
120
121 inline std::string getAdditional(void) const
122 { return std::string(additional); }
123
124 //フォーマット済みファイル位置情
125報の取得 filename:lineno(additional)
126 std::string getDetails(void) const;
127 };
128
129 //分岐カバレッジ判定のベースクラス
130 class BranchBase {
131 protected:
132 BranchBase(const Location & location) throw(); //要素の登録
133 static BranchBase * find(const Location & location) throw(); //locationに一致する要素の取得
134
135 public:
136 virtual ~BranchBase(void) throw() {} //デストラクタ
137 virtual bool checkValidity(void) const throw(...) = 0; //正当性判定
138 virtual std::string getDetails(void) const throw(...) = 0; //データ表示
139 };
140
141 //if-statementに引っかかるクラス
142 class If : public BranchBase {
143 protected:
144 bool true_case;
145 bool false_case;
146
147 If(const Location & location) throw(); //branch経由で無いと生成させない
148
149 public:
150 virtual bool checkValidity(void) const throw(); //正当性の判定
151 virtual std::string getDetails(void) const throw(); //データ表示
152
153 static bool branch(const Location & location, bool expression) throw();
154 };
155
156 //while-statementに引っかかるクラス
157 class While : public BranchBase {
158 protected:
159 bool valid;
160
161 While(const Location & location) throw();
162 public:
163 virtual bool checkValidity(void) const throw(); //正当性の判定
164 virtual std::string getDetails(void) const throw(); //データ表示
165
166 static bool branch(const Location & location, bool expression) throw();
167 };
168
169 //switch-statementに引っかかるクラス
170 class Switch : public BranchBase {
171 protected:
172 std::set<int> checkpoint;
173
174 Switch(const Location & location) throw();
175 static void _branch(const Location & location, int expression) throw();
176
177 public:
178 virtual bool checkValidity(void) const throw(); //正当性の判定
179 virtual std::string getDetails(void) const throw(); //データ表示
180
181 template<class T>
182 static T branch(const Location & location, T expression) throw()
183 {
184 _branch(location, (int)expression);
185 return expression;
186 }
187 };
188
189
190protected:
191 class BranchMap : public std::map<Location, BranchBase *> {
192 public:
193 SINGLETON_CONSTRUCTOR(BranchMap) {}
194 ~BranchMap(void) throw();
195
196 };
197 class NewBranchList : public std::list<BranchBase *>
198 { public: SINGLETON_CONSTRUCTOR(NewBranchList) {} };
199
200 //項
201目の表示
202 static std::string getBranchName(BranchBase * node);
203
204public:
205 //å…
206¨ã¦é€šéŽã—たかどうかのチェック
207 static bool checkValidity(void);
208
209 //å…
210¨ã¦ã®é …
211目を表示
212 static void printCoverage(std::ostream & out);
213
214};
215
216#endif /* COVERAGE_H */
217
218
219#ifndef COVERAGE_DEFS
220#define COVERAGE_DEFS
221
222#define if(x) i##f(Coverage::If::branch(Coverage::Location(__FILE__, __LINE__, "if"), (x) ? true : false))
223#define while(x) w##hile(Coverage::While::branch(Coverage::Location(__FILE__, __LINE__, "while"), (x) ? true : false))
224#define switch(x) s##witch(Coverage::Switch::branch(Coverage::Location(__FILE__, __LINE__, "switch"), (x)))
225
226#endif /* COVERAGE_DEFS */
227
228#else
229
230#include <iostream>
231
232#ifndef COVERAGE_H
233#define COVERAGE_H
234class Coverage {
235public:
236 static bool checkValidity(void) { return true; }
237 static void printCoverage(std::ostream &) {}
238};
239#endif /* COVERAGE_H */
240
241#endif
242
Note: See TracBrowser for help on using the repository browser.