[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: mpstrstream.cpp,v 1.9 2003/12/15 07:32:13 takayuki Exp $
|
---|
| 51 | */
|
---|
| 52 |
|
---|
| 53 | // $Header: /home/CVS/configurator/base/mpstrstream.cpp,v 1.9 2003/12/15 07:32:13 takayuki Exp $
|
---|
| 54 |
|
---|
| 55 | #include "base/mpstrstream.h"
|
---|
| 56 |
|
---|
| 57 | using namespace std;
|
---|
| 58 |
|
---|
| 59 | /*
|
---|
| 60 | * è¤æ°é¨ä½ãããªãã¹ããªã¼ã ã®ä¸é¨ä½ã«ç¸å½ããã¯ã©ã¹
|
---|
| 61 | */
|
---|
| 62 |
|
---|
| 63 | //ã³ã³ã¹ãã©ã¯ã¿
|
---|
| 64 | MultipartStream::Part::Part(string _name) throw() : name(_name)
|
---|
| 65 | {}
|
---|
| 66 |
|
---|
| 67 | //ã³ãã¼ã³ã³ã¹ãã©ã¯ã¿
|
---|
| 68 | MultipartStream::Part::Part(const MultipartStream::Part & src) throw() : name("")
|
---|
| 69 | {
|
---|
| 70 | if(src.isValid()) {
|
---|
| 71 | name.assign(src.name);
|
---|
| 72 | setContents(src.getContents());
|
---|
| 73 | }
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | //ã¹ããªã¼ã ã«æ¸ããå
|
---|
| 77 | 容ãåãåã
|
---|
| 78 | string MultipartStream::Part::getContents(void) const throw(Exception)
|
---|
| 79 | {
|
---|
| 80 | string result;
|
---|
| 81 |
|
---|
| 82 | if(isValid())
|
---|
| 83 | result = stream.str();
|
---|
| 84 | else
|
---|
| 85 | ExceptionMessage("Operation was performed against an invalid stream.","ç¡å¹ãªã¹ããªã¼ã ã«å¯¾ãã¦æä½ãè¡ããã¾ãã").throwException();
|
---|
| 86 |
|
---|
| 87 | return result;
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | //ã¹ããªã¼ã ã®å
|
---|
| 91 | 容ãç´æ¥è¨å®ãã
|
---|
| 92 | void MultipartStream::Part::setContents(string contents) throw(Exception)
|
---|
| 93 | {
|
---|
| 94 | if(isValid()) {
|
---|
| 95 | stream.clear();
|
---|
| 96 | stream << contents;
|
---|
| 97 | }
|
---|
| 98 | else
|
---|
| 99 | ExceptionMessage("Operation was performed against an invalid stream.","ç¡å¹ãªã¹ããªã¼ã ã«å¯¾ãã¦æä½ãè¡ããã¾ãã").throwException();
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 | /*
|
---|
| 105 | * è¤æ°é¨ä½ãããªãã¹ããªã¼ã ã®ä¸é¨ä½ã«ç¸å½ããã¯ã©ã¹
|
---|
| 106 | */
|
---|
| 107 |
|
---|
| 108 | //ã³ã³ã¹ãã©ã¯ã¿
|
---|
| 109 | MultipartStream::MultipartStream(string _filename) throw() : filename(_filename), current(0), dirty(false), output(true)
|
---|
| 110 | {
|
---|
| 111 | dirty = isValid(); //空ã§ãã£ã¦ããã¡ã¤ã«ãä½ããªãã¨ãããªãã®ã§...
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | MultipartStream::~MultipartStream(void) throw()
|
---|
| 115 | {
|
---|
| 116 | if(isValid() && dirty) {
|
---|
| 117 | //è
|
---|
| 118 | try { serialize(); }
|
---|
| 119 | catch(...) {}
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | //ãã¡ã¤ã«åã®é¢é£ä»ã
|
---|
| 124 | string MultipartStream::setFilename(string _filename) throw(Exception)
|
---|
| 125 | {
|
---|
| 126 | string result;
|
---|
| 127 |
|
---|
| 128 | if(this != 0) {
|
---|
| 129 | if(!_filename.empty()) {
|
---|
| 130 | result = filename;
|
---|
| 131 | filename = _filename;
|
---|
| 132 | dirty = isValid();
|
---|
| 133 | }
|
---|
| 134 | else
|
---|
| 135 | ExceptionMessage("Empty filename should not be allowed.","空ã®ãã¡ã¤ã«åã¯ä½¿ç¨ã§ããªã").throwException();
|
---|
| 136 | }
|
---|
| 137 | else
|
---|
| 138 | ExceptionMessage("Invalid object can not perform the request.","ç¡å¹ãªãªãã¸ã§ã¯ãã«å¯¾ããè¦æ±ã¯å®è¡ã§ããªã").throwException();
|
---|
| 139 |
|
---|
| 140 | return result;
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 | //ãã¡ã¤ã«åºå (æ¬å½ã«ãã¡ã¤ã«ã«åºåããã¨ãã ãtrue)
|
---|
| 144 | bool MultipartStream::serialize(void) throw(Exception)
|
---|
| 145 | {
|
---|
| 146 | bool result = false;
|
---|
| 147 |
|
---|
| 148 | if(isValid() && dirty && output) {
|
---|
| 149 |
|
---|
| 150 | fstream file(filename.c_str(), ios::out);
|
---|
| 151 | if(file.is_open()) {
|
---|
| 152 | list<Part>::iterator scope;
|
---|
| 153 |
|
---|
| 154 | //å
|
---|
| 155 | ¨ã¦ã®é¨ä½ã®å
|
---|
| 156 | 容ãåºå
|
---|
| 157 | scope = parts.begin();
|
---|
| 158 | while(scope != parts.end()) {
|
---|
| 159 | file << scope->getContents();
|
---|
| 160 | ++ scope;
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | file.close();
|
---|
| 164 | dirty = false;
|
---|
| 165 | result = true;
|
---|
| 166 | }
|
---|
| 167 | else {
|
---|
| 168 | ExceptionMessage("File could not open [%]","ãã¡ã¤ã«ãéããªã [%]") << filename << throwException;
|
---|
| 169 | disableOutput(); //ãã¹ãã©ã¯ã¿ãããä¸åº¦ææ¦ããã®ã§
|
---|
| 170 | }
|
---|
| 171 | }
|
---|
| 172 | else {
|
---|
| 173 | if(!isValid())
|
---|
| 174 | ExceptionMessage("Invalid object can not perform the request.","ç¡å¹ãªãªãã¸ã§ã¯ãã«å¯¾ããè¦æ±ã¯å®è¡ã§ããªã").throwException();
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | return result;
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | //é¨ä½ã®ä½æ
|
---|
| 181 | MultipartStream & MultipartStream::createPart(string name, bool precedence) throw(Exception)
|
---|
| 182 | {
|
---|
| 183 | if(this != 0) {
|
---|
| 184 | list<Part>::iterator scope;
|
---|
| 185 | list<Part>::iterator newnode;
|
---|
| 186 |
|
---|
| 187 | //åãååããªããã¨ã確èª
|
---|
| 188 | scope = parts.begin();
|
---|
| 189 | while(scope != parts.end()) {
|
---|
| 190 | if(scope->getName().compare(name) == 0) {
|
---|
| 191 | ExceptionMessage("The part \"%\" is already created.","é¨ä½å[%]ã¯ãã§ã«å©ç¨ããã¦ãã") << name << throwException;
|
---|
| 192 | break;
|
---|
| 193 | }
|
---|
| 194 | ++ scope;
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 | //åãååããªããªãè¦ç´ ã追å
|
---|
| 198 | if(scope == parts.end()) {
|
---|
| 199 |
|
---|
| 200 | //æ¿å
|
---|
| 201 | ¥ä½ç½®ã®æ¤ç´¢
|
---|
| 202 | if(current != 0) {
|
---|
| 203 | scope = parts.begin();
|
---|
| 204 | while(scope != parts.end() && &(*scope) != current)
|
---|
| 205 | ++ scope;
|
---|
| 206 |
|
---|
| 207 | //æ¿å
|
---|
| 208 | ¥ä½ç½®ã®èª¿ç¯ (ç¾å¨ä½ç½®ãå¾ãã«ããã when precedence = false; )
|
---|
| 209 | if(scope != parts.end() && !precedence)
|
---|
| 210 | ++ scope;
|
---|
| 211 | }
|
---|
| 212 | else
|
---|
| 213 | scope = parts.end();
|
---|
| 214 |
|
---|
| 215 | //è¦ç´ ã®æ¿å
|
---|
| 216 | ¥
|
---|
| 217 | newnode = parts.insert(scope, Part(name));
|
---|
| 218 | current = &(*newnode);
|
---|
| 219 | }
|
---|
| 220 | }else
|
---|
| 221 | ExceptionMessage("Invalid object can not perform the request.","ç¡å¹ãªãªãã¸ã§ã¯ãã«å¯¾ããè¦æ±ã¯å®è¡ã§ããªã").throwException();
|
---|
| 222 |
|
---|
| 223 | return *this;
|
---|
| 224 | }
|
---|
| 225 |
|
---|
| 226 | //é¨ä½ã®é¸æ
|
---|
| 227 | MultipartStream & MultipartStream::movePart(string name) throw(Exception)
|
---|
| 228 | {
|
---|
| 229 | list<Part>::iterator scope;
|
---|
| 230 |
|
---|
| 231 | if(this != 0 && !name.empty()) {
|
---|
| 232 |
|
---|
| 233 | //ååãä¸è´ãããã®ãæ¢ã
|
---|
| 234 | scope = parts.begin();
|
---|
| 235 | while(scope != parts.end()) {
|
---|
| 236 | if(scope->getName() == name) {
|
---|
| 237 | current = &(*scope);
|
---|
| 238 | break;
|
---|
| 239 | }
|
---|
| 240 | ++ scope;
|
---|
| 241 | }
|
---|
| 242 |
|
---|
| 243 | //è¦ã¤ãããªãã£ã
|
---|
| 244 | if(scope == parts.end())
|
---|
| 245 | ExceptionMessage("Unknown part [%] specified.","ç¡å¹ãªèå¥å [%]") << name << throwException;
|
---|
| 246 | }
|
---|
| 247 | else{
|
---|
| 248 | if(this == 0)
|
---|
| 249 | ExceptionMessage("Invalid object can not perform the request.","ç¡å¹ãªãªãã¸ã§ã¯ãã«å¯¾ããè¦æ±ã¯å®è¡ã§ããªã").throwException();
|
---|
| 250 | else //if(name.empty()) //æåã®ifã®æ¡ä»¶ããããã®ifã¯å¸¸ã«ç
|
---|
| 251 | ExceptionMessage("Empty identifier was passed as a name of part.","空æåã渡ããã").throwException();
|
---|
| 252 | }
|
---|
| 253 |
|
---|
| 254 | return *this;
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 |
|
---|
| 258 | /********************************** ãã¹ãã¹ã£ã¼ã **********************************/
|
---|
| 259 |
|
---|
| 260 | #ifdef TESTSUITE
|
---|
| 261 |
|
---|
| 262 | #include "coverage_undefs.h"
|
---|
| 263 |
|
---|
| 264 | #include <iomanip>
|
---|
| 265 | #include <cstdio>
|
---|
| 266 |
|
---|
| 267 | #ifdef _MSC_VER
|
---|
| 268 | # pragma warning(disable:4101) //ãã¼ã«ã«å¤æ°ã¯ä¸åº¦ã使ããã¦ãã¾ãã
|
---|
| 269 | #endif
|
---|
| 270 |
|
---|
| 271 | TESTSUITE_(main,Part, MultipartStream)
|
---|
| 272 | {
|
---|
| 273 | BEGIN_CASE("constructor/isValid","ã³ã³ã¹ãã©ã¯ã¿ / æ£å½æ§å¤å®") {
|
---|
| 274 | BEGIN_CASE("1","ååã¤ãã§ä½æãããæå¹ãªãã¼ããä½ãã") {
|
---|
| 275 | Part part("test");
|
---|
| 276 | if(!part.isValid())
|
---|
| 277 | TEST_FAIL;
|
---|
| 278 | } END_CASE;
|
---|
| 279 |
|
---|
| 280 | BEGIN_CASE("2","ååãªãã§ä½æãããç¡å¹ãªãã¼ãã«ãªã") {
|
---|
| 281 | Part part("");
|
---|
| 282 | if(part.isValid())
|
---|
| 283 | TEST_FAIL;
|
---|
| 284 | } END_CASE;
|
---|
| 285 |
|
---|
| 286 | BEGIN_CASE("3","NULLã¯ç¡å¹ãªãã¼ã") {
|
---|
| 287 | if(((Part *)0)->isValid())
|
---|
| 288 | TEST_FAIL;
|
---|
| 289 | } END_CASE;
|
---|
| 290 |
|
---|
| 291 | BEGIN_CASE("4","NULLãªãã¸ã§ã¯ãã§ã³ãã¼ã³ã³ã¹ãã©ã¯ã¿ãèµ·åãã¦ã失æããªã") {
|
---|
| 292 | Part * part = 0;
|
---|
| 293 | Part work(*part);
|
---|
| 294 | } END_CASE;
|
---|
| 295 |
|
---|
| 296 | } END_CASE;
|
---|
| 297 |
|
---|
| 298 | BEGIN_CASE("operator <<","operator <<") {
|
---|
| 299 | BEGIN_CASE("1", "åºåã§ãã") {
|
---|
| 300 | Part part("test");
|
---|
| 301 |
|
---|
| 302 | part << "test";
|
---|
| 303 |
|
---|
| 304 | if(part.stream.str().compare("test") != 0)
|
---|
| 305 | TEST_FAIL;
|
---|
| 306 | } END_CASE;
|
---|
| 307 |
|
---|
| 308 | BEGIN_CASE("2", "iomanipã使ãã") {
|
---|
| 309 | Part part("test");
|
---|
| 310 |
|
---|
| 311 | part << setw(8) << setbase(16) << setfill('0') << 0x1234567;
|
---|
| 312 |
|
---|
| 313 | if(part.stream.str().compare("01234567") != 0)
|
---|
| 314 | TEST_FAIL;
|
---|
| 315 | } END_CASE;
|
---|
| 316 |
|
---|
| 317 | BEGIN_CASE("3", "ç¡å¹ãªã¹ããªã¼ã ã«æ¸ãããä¾å¤ãèµ·ã") {
|
---|
| 318 | Part part("");
|
---|
| 319 | bool result = false;
|
---|
| 320 |
|
---|
| 321 | if(part.isValid())
|
---|
| 322 | TEST_FAIL;
|
---|
| 323 |
|
---|
| 324 | Exception::setThrowControl(true);
|
---|
| 325 | try {
|
---|
| 326 | Message::selectLanguage(Message::NEUTRAL);
|
---|
| 327 | part << setw(8) << setbase(16) << setfill('0') << 0x1234567;
|
---|
| 328 | }
|
---|
| 329 | catch(Exception & e) {
|
---|
| 330 | if(e.getDetails().compare("Operation was performed against an invalid stream.") == 0)
|
---|
| 331 | result = true;
|
---|
| 332 | }
|
---|
| 333 | if(!result)
|
---|
| 334 | TEST_FAIL;
|
---|
| 335 | } END_CASE;
|
---|
| 336 | } END_CASE;
|
---|
| 337 |
|
---|
| 338 | BEGIN_CASE("getContents","getContents") {
|
---|
| 339 | BEGIN_CASE("1", "æ¸ããå
|
---|
| 340 | 容ãåå¾ã§ãã") {
|
---|
| 341 | Part part("test");
|
---|
| 342 |
|
---|
| 343 | part << "test";
|
---|
| 344 |
|
---|
| 345 | if(part.getContents().compare("test") != 0)
|
---|
| 346 | TEST_FAIL;
|
---|
| 347 | } END_CASE;
|
---|
| 348 |
|
---|
| 349 | BEGIN_CASE("2", "æ¸ãã¦èªãã§ã¾ãæ¸ãã¦èªãã") {
|
---|
| 350 | Part part("test");
|
---|
| 351 |
|
---|
| 352 | part << "abc";
|
---|
| 353 | if(part.getContents().compare("abc") != 0)
|
---|
| 354 | TEST_FAIL;
|
---|
| 355 |
|
---|
| 356 | part << "def";
|
---|
| 357 | if(part.getContents().compare("abcdef") != 0)
|
---|
| 358 | TEST_FAIL;
|
---|
| 359 | } END_CASE;
|
---|
| 360 |
|
---|
| 361 | BEGIN_CASE("3", "ç¡å¹ãªã¹ããªã¼ã ããèªãã ãä¾å¤ãèµ·ã") {
|
---|
| 362 | Part part("");
|
---|
| 363 | bool result = false;
|
---|
| 364 |
|
---|
| 365 | if(part.isValid())
|
---|
| 366 | TEST_FAIL;
|
---|
| 367 |
|
---|
| 368 | Exception::setThrowControl(true);
|
---|
| 369 | try {
|
---|
| 370 | string work = part.getContents();
|
---|
| 371 | }
|
---|
| 372 | catch(Exception & e) {
|
---|
| 373 | if(e.getDetails().compare("Operation was performed against an invalid stream.") == 0)
|
---|
| 374 | result = true;
|
---|
| 375 | }
|
---|
| 376 | if(!result)
|
---|
| 377 | TEST_FAIL;
|
---|
| 378 | } END_CASE;
|
---|
| 379 | } END_CASE;
|
---|
| 380 |
|
---|
| 381 | BEGIN_CASE("setContents","setContents") {
|
---|
| 382 | BEGIN_CASE("1", "è¨å®ããå
|
---|
| 383 | 容ãåå¾ã§ãã") {
|
---|
| 384 | Part part("test");
|
---|
| 385 |
|
---|
| 386 | part.setContents("test");
|
---|
| 387 |
|
---|
| 388 | if(part.getContents().compare("test") != 0)
|
---|
| 389 | TEST_FAIL;
|
---|
| 390 | } END_CASE;
|
---|
| 391 |
|
---|
| 392 | BEGIN_CASE("2", "setContentsã§è¨å®ãããã¨ã«è¿½è¨ã§ãã") {
|
---|
| 393 | Part part("test");
|
---|
| 394 |
|
---|
| 395 | part.setContents("abc");
|
---|
| 396 | part << "def";
|
---|
| 397 | if(part.getContents().compare("abcdef") != 0)
|
---|
| 398 | TEST_FAIL;
|
---|
| 399 | } END_CASE;
|
---|
| 400 |
|
---|
| 401 | BEGIN_CASE("3", "ç¡å¹ãªã¹ããªã¼ã ã«è¨å®ãããä¾å¤ãèµ·ã") {
|
---|
| 402 | Part part("");
|
---|
| 403 | bool result = false;
|
---|
| 404 |
|
---|
| 405 | if(part.isValid())
|
---|
| 406 | TEST_FAIL;
|
---|
| 407 |
|
---|
| 408 | Exception::setThrowControl(true);
|
---|
| 409 | try {
|
---|
| 410 | part.setContents("test");
|
---|
| 411 | }
|
---|
| 412 | catch(Exception & e) {
|
---|
| 413 | if(e.getDetails().compare("Operation was performed against an invalid stream.") == 0)
|
---|
| 414 | result = true;
|
---|
| 415 | }
|
---|
| 416 | if(!result)
|
---|
| 417 | TEST_FAIL;
|
---|
| 418 | } END_CASE;
|
---|
| 419 | } END_CASE;
|
---|
| 420 |
|
---|
| 421 | BEGIN_CASE("getName","getName") {
|
---|
| 422 | BEGIN_CASE("1", "ãã¼ãåãæ£ããåå¾ã§ãã") {
|
---|
| 423 | Part part("name_of_stream");
|
---|
| 424 |
|
---|
| 425 | if(part.getName().compare("name_of_stream") != 0)
|
---|
| 426 | TEST_FAIL;
|
---|
| 427 | } END_CASE;
|
---|
| 428 |
|
---|
| 429 | BEGIN_CASE("2", "ä¸æ£ãªãã¼ãã®ååãåãã¨ä¾å¤ãèµ·ã") {
|
---|
| 430 | Part part("");
|
---|
| 431 | bool result = false;
|
---|
| 432 |
|
---|
| 433 | Exception::setThrowControl(true);
|
---|
| 434 | try { string work = part.getName(); }
|
---|
| 435 | catch(Exception & e) {
|
---|
| 436 | if(e.getDetails().compare("Operation was performed against an invalid stream.") == 0)
|
---|
| 437 | result = true;
|
---|
| 438 | }
|
---|
| 439 | if(!result)
|
---|
| 440 | TEST_FAIL;
|
---|
| 441 | } END_CASE;
|
---|
| 442 | } END_CASE;
|
---|
| 443 |
|
---|
| 444 | BEGIN_CASE("CopyConstructor","ã³ãã¼ã³ã³ã¹ãã©ã¯ã¿") {
|
---|
| 445 | Part source("test");
|
---|
| 446 | source << "abcdefg";
|
---|
| 447 |
|
---|
| 448 | Part dest(source);
|
---|
| 449 | BEGIN_CASE("1","ã¹ããªã¼ã ã®å
|
---|
| 450 | 容ãæ£ããã³ãã¼ã§ãã¦ãã") {
|
---|
| 451 | if(dest.getContents().compare("abcdefg") != 0)
|
---|
| 452 | TEST_FAIL;
|
---|
| 453 | } END_CASE;
|
---|
| 454 |
|
---|
| 455 | BEGIN_CASE("2","é¨ä½åãæ£ããã³ãã¼ã§ãã¦ãã") {
|
---|
| 456 | if(dest.getName() != source.getName())
|
---|
| 457 | TEST_FAIL;
|
---|
| 458 | } END_CASE;
|
---|
| 459 | } END_CASE;
|
---|
| 460 | }
|
---|
| 461 |
|
---|
| 462 | TESTSUITE(main,MultipartStream)
|
---|
| 463 | {
|
---|
| 464 | BEGIN_CASE("constructor/isValid","constructor/isValid") {
|
---|
| 465 | BEGIN_CASE("1","ãã¡ã¤ã«åãæå®ãã¦çæãããªãã¸ã§ã¯ãã¯æå¹") {
|
---|
| 466 | MultipartStream mps("test.dat");
|
---|
| 467 |
|
---|
| 468 | if(!mps.isValid())
|
---|
| 469 | TEST_FAIL;
|
---|
| 470 | } END_CASE;
|
---|
| 471 |
|
---|
| 472 | BEGIN_CASE("2","ãã¡ã¤ã«åãæããªããªãã¸ã§ã¯ãã¯ç¡å¹") {
|
---|
| 473 | MultipartStream mps;
|
---|
| 474 |
|
---|
| 475 | if(mps.isValid())
|
---|
| 476 | TEST_FAIL;
|
---|
| 477 | } END_CASE;
|
---|
| 478 |
|
---|
| 479 | BEGIN_CASE("3","空ã®ãã¡ã¤ã«åãæã¤ãªãã¸ã§ã¯ãã¯ç¡å¹") {
|
---|
| 480 | MultipartStream mps("");
|
---|
| 481 |
|
---|
| 482 | if(mps.isValid())
|
---|
| 483 | TEST_FAIL;
|
---|
| 484 | } END_CASE;
|
---|
| 485 |
|
---|
| 486 | BEGIN_CASE("4","NULLãªãã¸ã§ã¯ãã¯ç¡å¹") {
|
---|
| 487 | if(((MultipartStream *)0)->isValid())
|
---|
| 488 | TEST_FAIL;
|
---|
| 489 | } END_CASE;
|
---|
| 490 | } END_CASE;
|
---|
| 491 |
|
---|
| 492 | BEGIN_CASE("setFilename","setFilename") {
|
---|
| 493 | BEGIN_CASE("1","ãã¡ã¤ã«åãæå®ããã«çæãããã¡ã¤ã«ã«ååãã¤ãã") {
|
---|
| 494 | MultipartStream mps;
|
---|
| 495 | if(mps.isValid())
|
---|
| 496 | TEST_FAIL;
|
---|
| 497 |
|
---|
| 498 | BEGIN_CASE("1","ã¹ããªã¼ã ã¯æå¹ã«ãªã") {
|
---|
| 499 | mps.setFilename("test");
|
---|
| 500 | if(!mps.isValid())
|
---|
| 501 | TEST_FAIL;
|
---|
| 502 | } END_CASE;
|
---|
| 503 |
|
---|
| 504 | BEGIN_CASE("2","ã¹ããªã¼ã ã®ååãå¤æ´ããã¦ãã") {
|
---|
| 505 | if(mps.filename.compare("test") != 0)
|
---|
| 506 | TEST_FAIL;
|
---|
| 507 | } END_CASE;
|
---|
| 508 | } END_CASE;
|
---|
| 509 |
|
---|
| 510 | BEGIN_CASE("2","ãã¡ã¤ã«åãæå®ãã¦çæãããã¡ã¤ã«ã«ååãã¤ãã") {
|
---|
| 511 | MultipartStream mps("initialname");
|
---|
| 512 | if(!mps.isValid())
|
---|
| 513 | TEST_FAIL;
|
---|
| 514 |
|
---|
| 515 | BEGIN_CASE("1","ã¹ããªã¼ã ã¯æå¹ã«ãªã") {
|
---|
| 516 | mps.setFilename("test");
|
---|
| 517 | if(!mps.isValid())
|
---|
| 518 | TEST_FAIL;
|
---|
| 519 | } END_CASE;
|
---|
| 520 |
|
---|
| 521 | BEGIN_CASE("2","ã¹ããªã¼ã ã®ååãå¤æ´ããã¦ãã") {
|
---|
| 522 | if(mps.filename.compare("test") != 0)
|
---|
| 523 | TEST_FAIL;
|
---|
| 524 | } END_CASE;
|
---|
| 525 | } END_CASE;
|
---|
| 526 |
|
---|
| 527 | BEGIN_CASE("3","空æåã渡ãã¨ä¾å¤") {
|
---|
| 528 | MultipartStream mps;
|
---|
| 529 | bool result = false;
|
---|
| 530 |
|
---|
| 531 | Exception::setThrowControl(true);
|
---|
| 532 | try { mps.setFilename(""); }
|
---|
| 533 | catch(Exception & e)
|
---|
| 534 | { result = true; }
|
---|
| 535 | if(!result)
|
---|
| 536 | TEST_FAIL;
|
---|
| 537 | } END_CASE;
|
---|
| 538 |
|
---|
| 539 | BEGIN_CASE("4","NULLãªãã¸ã§ã¯ãã«ååãã¤ããã¨ä¾å¤") {
|
---|
| 540 | bool result = false;
|
---|
| 541 |
|
---|
| 542 | Exception::setThrowControl(true);
|
---|
| 543 | try { ((MultipartStream *)0)->setFilename("test"); }
|
---|
| 544 | catch(Exception & e)
|
---|
| 545 | { result = true; }
|
---|
| 546 | if(!result)
|
---|
| 547 | TEST_FAIL;
|
---|
| 548 | } END_CASE;
|
---|
| 549 | } END_CASE;
|
---|
| 550 |
|
---|
| 551 | BEGIN_CASE("serialize","serialize") {
|
---|
| 552 |
|
---|
| 553 | BEGIN_CASE("1", "NULLãªãã¸ã§ã¯ãã«å¯¾ããã·ãªã¢ã©ã¤ãºã¯ä¾å¤") {
|
---|
| 554 | bool result = false;
|
---|
| 555 |
|
---|
| 556 | Exception::setThrowControl(true);
|
---|
| 557 | try
|
---|
| 558 | { ((MultipartStream *)0)->serialize(); }
|
---|
| 559 | catch(Exception & e)
|
---|
| 560 | { result = true; }
|
---|
| 561 |
|
---|
| 562 | if(!result)
|
---|
| 563 | TEST_FAIL;
|
---|
| 564 | } END_CASE;
|
---|
| 565 |
|
---|
| 566 | BEGIN_CASE("2", "ç¡å¹ãªãªãã¸ã§ã¯ãã«å¯¾ããã·ãªã¢ã©ã¤ãºãä¾å¤") {
|
---|
| 567 | bool result = false;
|
---|
| 568 | MultipartStream mps;
|
---|
| 569 |
|
---|
| 570 | Exception::setThrowControl(true);
|
---|
| 571 | try
|
---|
| 572 | { mps.serialize(); }
|
---|
| 573 | catch(Exception & e)
|
---|
| 574 | { result = true; }
|
---|
| 575 |
|
---|
| 576 | if(!result)
|
---|
| 577 | TEST_FAIL;
|
---|
| 578 | } END_CASE;
|
---|
| 579 |
|
---|
| 580 | BEGIN_CASE("3", "æ£å¸¸ã«ã·ãªã¢ã©ã¤ãºã§ãã") {
|
---|
| 581 | MultipartStream mps("debug.out");
|
---|
| 582 | Part part("abc");
|
---|
| 583 |
|
---|
| 584 | part << "abcdefg";
|
---|
| 585 | mps.parts.push_back(part);
|
---|
| 586 | mps.dirty = true;
|
---|
| 587 |
|
---|
| 588 | ::remove("debug.out");
|
---|
| 589 | BEGIN_CASE("1", "ã·ãªã¢ã©ã¤ãºã¯trueãè¿ã") {
|
---|
| 590 | if(!mps.serialize())
|
---|
| 591 | TEST_FAIL;
|
---|
| 592 | } END_CASE;
|
---|
| 593 |
|
---|
| 594 | BEGIN_CASE("2", "åºåãããã¡ã¤ã«ã®å
|
---|
| 595 | 容ãæ£ãã") {
|
---|
| 596 | if(!TestSuite::compareFileContents("debug.out","abcdefg"))
|
---|
| 597 | TEST_FAIL;
|
---|
| 598 | } END_CASE;
|
---|
| 599 |
|
---|
| 600 | } END_CASE;
|
---|
| 601 |
|
---|
| 602 | BEGIN_CASE("4", "å
|
---|
| 603 | 容ããã£ã¦ãdirty=falseãªãåºåãããªã") {
|
---|
| 604 | MultipartStream mps("debug.out");
|
---|
| 605 | Part part("abc");
|
---|
| 606 |
|
---|
| 607 | part << "abcdefg";
|
---|
| 608 | mps.parts.push_back(part);
|
---|
| 609 | mps.dirty = false;
|
---|
| 610 |
|
---|
| 611 | ::remove("debug.out");
|
---|
| 612 | BEGIN_CASE("1", "ã·ãªã¢ã©ã¤ãºã¯falseãè¿ã") {
|
---|
| 613 | if(mps.serialize())
|
---|
| 614 | TEST_FAIL;
|
---|
| 615 | } END_CASE;
|
---|
| 616 |
|
---|
| 617 | BEGIN_CASE("2", "ãã¡ã¤ã«ã¯åºåããã¦ããªã") {
|
---|
| 618 | fstream file("debug.out",ios::in);
|
---|
| 619 | if(file.is_open())
|
---|
| 620 | TEST_FAIL;
|
---|
| 621 | } END_CASE;
|
---|
| 622 | } END_CASE;
|
---|
| 623 |
|
---|
| 624 | BEGIN_CASE("5", "å
|
---|
| 625 | 容ããã£ã¦ãåºåç¦æ¢ãªãåºåãããªã") {
|
---|
| 626 | MultipartStream mps("debug.out");
|
---|
| 627 | Part part("abc");
|
---|
| 628 |
|
---|
| 629 | part << "abcdefg";
|
---|
| 630 | mps.parts.push_back(part);
|
---|
| 631 | mps.dirty = true;
|
---|
| 632 |
|
---|
| 633 | mps.disableOutput();
|
---|
| 634 |
|
---|
| 635 | ::remove("debug.out");
|
---|
| 636 | BEGIN_CASE("1", "ã·ãªã¢ã©ã¤ãºã¯falseãè¿ã") {
|
---|
| 637 | if(mps.serialize())
|
---|
| 638 | TEST_FAIL;
|
---|
| 639 | } END_CASE;
|
---|
| 640 |
|
---|
| 641 | BEGIN_CASE("2", "ãã¡ã¤ã«ã¯åºåããã¦ããªã") {
|
---|
| 642 | fstream file("debug.out",ios::in);
|
---|
| 643 | if(file.is_open())
|
---|
| 644 | TEST_FAIL;
|
---|
| 645 | } END_CASE;
|
---|
| 646 | } END_CASE;
|
---|
| 647 | } END_CASE;
|
---|
| 648 |
|
---|
| 649 | BEGIN_CASE("Destructor","Destructor") {
|
---|
| 650 | BEGIN_CASE("1","ä½ã£ã¦å£ã") {
|
---|
| 651 | MultipartStream mps("debug.out");
|
---|
| 652 | Part part("abc");
|
---|
| 653 |
|
---|
| 654 | part << "abcdefg";
|
---|
| 655 | mps.parts.push_back(part);
|
---|
| 656 | mps.dirty = true;
|
---|
| 657 |
|
---|
| 658 | ::remove("debug.out");
|
---|
| 659 | } END_CASE;
|
---|
| 660 |
|
---|
| 661 | BEGIN_CASE("2","å
|
---|
| 662 | 容ããã¡ã¤ã«ã«æ ¼ç´ããã¦ãã") {
|
---|
| 663 | if(!TestSuite::compareFileContents("debug.out","abcdefg"))
|
---|
| 664 | TEST_FAIL;
|
---|
| 665 | } END_CASE;
|
---|
| 666 | } END_CASE;
|
---|
| 667 |
|
---|
| 668 | BEGIN_CASE("createPart","createPart") {
|
---|
| 669 | BEGIN_CASE("1","ãã¼ããç»é²ãã") {
|
---|
| 670 | MultipartStream mps("debug.out");
|
---|
| 671 | mps.disableOutput();
|
---|
| 672 |
|
---|
| 673 | BEGIN_CASE("1","ä¾å¤ãªãç»é²ã§ãã") {
|
---|
| 674 | Exception::setThrowControl(true);
|
---|
| 675 | mps .createPart("abc")
|
---|
| 676 | .createPart("def")
|
---|
| 677 | .createPart("ghi");
|
---|
| 678 | } END_CASE;
|
---|
| 679 |
|
---|
| 680 | BEGIN_CASE("2","ä¸èº«ãç»é²é ã§ä¸¦ãã§ãã") {
|
---|
| 681 | list<Part>::iterator scope;
|
---|
| 682 | scope = mps.parts.begin();
|
---|
| 683 | if(scope->getName().compare("abc") != 0)
|
---|
| 684 | TEST_FAIL;
|
---|
| 685 | ++ scope;
|
---|
| 686 | if(scope->getName().compare("def") != 0)
|
---|
| 687 | TEST_FAIL;
|
---|
| 688 | ++ scope;
|
---|
| 689 | if(scope->getName().compare("ghi") != 0)
|
---|
| 690 | TEST_FAIL;
|
---|
| 691 | ++ scope;
|
---|
| 692 | if(scope != mps.parts.end())
|
---|
| 693 | TEST_FAIL;
|
---|
| 694 | } END_CASE;
|
---|
| 695 |
|
---|
| 696 | } END_CASE;
|
---|
| 697 |
|
---|
| 698 | BEGIN_CASE("2","ãã¼ããéé ã§ç»é²ãã") {
|
---|
| 699 | MultipartStream mps("debug.out");
|
---|
| 700 | mps.disableOutput();
|
---|
| 701 |
|
---|
| 702 | BEGIN_CASE("1","ä¾å¤ãªãç»é²ã§ãã") {
|
---|
| 703 | Exception::setThrowControl(true);
|
---|
| 704 | mps .createPart("abc",true)
|
---|
| 705 | .createPart("def",true)
|
---|
| 706 | .createPart("ghi",true);
|
---|
| 707 | } END_CASE;
|
---|
| 708 |
|
---|
| 709 | BEGIN_CASE("2","ä¸èº«ãç»é²ããéé ã§ä¸¦ãã§ãã") {
|
---|
| 710 | list<Part>::iterator scope;
|
---|
| 711 | scope = mps.parts.begin();
|
---|
| 712 | if(scope->getName().compare("ghi") != 0)
|
---|
| 713 | TEST_FAIL;
|
---|
| 714 | ++ scope;
|
---|
| 715 | if(scope->getName().compare("def") != 0)
|
---|
| 716 | TEST_FAIL;
|
---|
| 717 | ++ scope;
|
---|
| 718 | if(scope->getName().compare("abc") != 0)
|
---|
| 719 | TEST_FAIL;
|
---|
| 720 | ++ scope;
|
---|
| 721 | if(scope != mps.parts.end())
|
---|
| 722 | TEST_FAIL;
|
---|
| 723 | } END_CASE;
|
---|
| 724 |
|
---|
| 725 | } END_CASE;
|
---|
| 726 |
|
---|
| 727 | BEGIN_CASE("3","NULLã«å¯¾ããæä½ã§ä¾å¤ãçºçãã") {
|
---|
| 728 | bool result = false;
|
---|
| 729 | Exception::setThrowControl(true);
|
---|
| 730 | try {
|
---|
| 731 | ((MultipartStream *)0)->createPart("test");
|
---|
| 732 | }
|
---|
| 733 | catch(...)
|
---|
| 734 | { result = true; }
|
---|
| 735 | if(!result)
|
---|
| 736 | TEST_FAIL;
|
---|
| 737 | } END_CASE;
|
---|
| 738 |
|
---|
| 739 | BEGIN_CASE("4","åãååã®ãã¼ããä½ãã¨ä¾å¤ãèµ·ã") {
|
---|
| 740 | BEGIN_CASE("1","åãååã®ãã¼ããä½ãã¨ä¾å¤ãèµ·ã") {
|
---|
| 741 | bool result = false;
|
---|
| 742 | MultipartStream mps("debug.out");
|
---|
| 743 | Exception::setThrowControl(true);
|
---|
| 744 |
|
---|
| 745 | try {
|
---|
| 746 | mps .createPart("abc")
|
---|
| 747 | .createPart("def")
|
---|
| 748 | .createPart("abc");
|
---|
| 749 | }
|
---|
| 750 | catch(...)
|
---|
| 751 | { result = true; }
|
---|
| 752 |
|
---|
| 753 | if(!result)
|
---|
| 754 | TEST_FAIL;
|
---|
| 755 | } END_CASE;
|
---|
| 756 |
|
---|
| 757 | BEGIN_CASE("2","ä¾å¤ãå°ãã¦ãæ£ããåã") {
|
---|
| 758 | bool result = true;
|
---|
| 759 | MultipartStream mps("debug.out");
|
---|
| 760 | Exception::setThrowControl(false);
|
---|
| 761 |
|
---|
| 762 | BEGIN_CASE("1","ä¾å¤ã¯ã¹ãã¼ãããªã") {
|
---|
| 763 | try {
|
---|
| 764 | mps .createPart("abc")
|
---|
| 765 | .createPart("def")
|
---|
| 766 | .createPart("abc");
|
---|
| 767 | }
|
---|
| 768 | catch(...)
|
---|
| 769 | { result = false; }
|
---|
| 770 |
|
---|
| 771 | if(!result)
|
---|
| 772 | TEST_FAIL;
|
---|
| 773 | } END_CASE;
|
---|
| 774 |
|
---|
| 775 | BEGIN_CASE("2","ç¾å¨ä½ç½®ã¯å¤åããªã") {
|
---|
| 776 | if(mps.current == 0 || mps.current->getName().compare("def") != 0)
|
---|
| 777 | TEST_FAIL;
|
---|
| 778 | } END_CASE;
|
---|
| 779 | } END_CASE;
|
---|
| 780 | } END_CASE;
|
---|
| 781 |
|
---|
| 782 | Exception::setThrowControl(true);
|
---|
| 783 |
|
---|
| 784 | BEGIN_CASE("5","ç»é²ããã¨ç¾å¨ä½ç½®ãå¤åãã") {
|
---|
| 785 | MultipartStream mps("debug.out");
|
---|
| 786 | mps.disableOutput();
|
---|
| 787 |
|
---|
| 788 | BEGIN_CASE("1","ç»é²ããã¨ä½ç½®ãå¤åãã (1)") {
|
---|
| 789 | mps.createPart("abc");
|
---|
| 790 | if(mps.current == 0 || mps.current->getName().compare("abc") != 0)
|
---|
| 791 | TEST_FAIL;
|
---|
| 792 | } END_CASE;
|
---|
| 793 |
|
---|
| 794 | BEGIN_CASE("2","ç»é²ããã¨ä½ç½®ãå¤åãã (2)") {
|
---|
| 795 | mps.createPart("def");
|
---|
| 796 | if(mps.current == 0 || mps.current->getName().compare("def") != 0)
|
---|
| 797 | TEST_FAIL;
|
---|
| 798 | } END_CASE;
|
---|
| 799 |
|
---|
| 800 | BEGIN_CASE("3","ç»é²ããã¨ä½ç½®ãå¤åãã (3)") {
|
---|
| 801 | mps.createPart("ghi");
|
---|
| 802 | if(mps.current == 0 || mps.current->getName().compare("ghi") != 0)
|
---|
| 803 | TEST_FAIL;
|
---|
| 804 | } END_CASE;
|
---|
| 805 | } END_CASE;
|
---|
| 806 | } END_CASE;
|
---|
| 807 |
|
---|
| 808 | BEGIN_CASE("opeator <<","operator <<") {
|
---|
| 809 |
|
---|
| 810 | BEGIN_CASE("1","operator <<ã使ãã") {
|
---|
| 811 | MultipartStream mps("debug.out");
|
---|
| 812 |
|
---|
| 813 | mps.createPart("test");
|
---|
| 814 |
|
---|
| 815 | mps << "abcdefghijklmn";
|
---|
| 816 | } END_CASE;
|
---|
| 817 |
|
---|
| 818 | BEGIN_CASE("2","åºåãããä¸èº«ãæ£ãã") {
|
---|
| 819 | if(!TestSuite::compareFileContents("debug.out","abcdefghijklmn"))
|
---|
| 820 | TEST_FAIL;
|
---|
| 821 | } END_CASE;
|
---|
| 822 |
|
---|
| 823 | BEGIN_CASE("3","NULLãªãã¸ã§ã¯ãã«åºåããã¨ä¾å¤") {
|
---|
| 824 | bool result = false;
|
---|
| 825 | Exception::setThrowControl(true);
|
---|
| 826 | try {
|
---|
| 827 | *((MultipartStream *)0) << "test";
|
---|
| 828 | }
|
---|
| 829 | catch(...)
|
---|
| 830 | { result = true; }
|
---|
| 831 | if(!result)
|
---|
| 832 | TEST_FAIL;
|
---|
| 833 | } END_CASE;
|
---|
| 834 |
|
---|
| 835 | BEGIN_CASE("4","ãã¼ããå
|
---|
| 836 | ¨ãä½ã£ã¦ããªããªãã¸ã§ã¯ãã«åºåããã¨ä¾å¤") {
|
---|
| 837 | bool result = false;
|
---|
| 838 | Exception::setThrowControl(true);
|
---|
| 839 | try {
|
---|
| 840 | MultipartStream mps("debug.out");
|
---|
| 841 | mps.disableOutput();
|
---|
| 842 | *((MultipartStream *)0) << "test";
|
---|
| 843 | }
|
---|
| 844 | catch(...)
|
---|
| 845 | { result = true; }
|
---|
| 846 | if(!result)
|
---|
| 847 | TEST_FAIL;
|
---|
| 848 | } END_CASE;
|
---|
| 849 |
|
---|
| 850 | } END_CASE;
|
---|
| 851 |
|
---|
| 852 | BEGIN_CASE("movePart/operator []","movePart/operator []") {
|
---|
| 853 | BEGIN_CASE("1","æ®éã«ç§»åãã") {
|
---|
| 854 | MultipartStream mps("debug.out");
|
---|
| 855 | mps.disableOutput();
|
---|
| 856 |
|
---|
| 857 | mps .createPart("abc")
|
---|
| 858 | .createPart("def")
|
---|
| 859 | .createPart("ghi");
|
---|
| 860 |
|
---|
| 861 | BEGIN_CASE("1","移åã§ãã") {
|
---|
| 862 | mps.movePart("def");
|
---|
| 863 |
|
---|
| 864 | if(mps.current->getName().compare("def") != 0)
|
---|
| 865 | TEST_FAIL;
|
---|
| 866 | } END_CASE;
|
---|
| 867 |
|
---|
| 868 | BEGIN_CASE("2","ç¡å¹ãªååãå
|
---|
| 869 | ¥ããã¨ä¾å¤") {
|
---|
| 870 | bool result = false;
|
---|
| 871 | Exception::setThrowControl(true);
|
---|
| 872 |
|
---|
| 873 | try {
|
---|
| 874 | mps.movePart("unknwon");
|
---|
| 875 | }
|
---|
| 876 | catch(...)
|
---|
| 877 | { result = true; }
|
---|
| 878 | if(!result)
|
---|
| 879 | TEST_FAIL;
|
---|
| 880 | } END_CASE;
|
---|
| 881 |
|
---|
| 882 | BEGIN_CASE("3","空æåãå
|
---|
| 883 | ¥ããã¨ä¾å¤") {
|
---|
| 884 | bool result = false;
|
---|
| 885 | Exception::setThrowControl(true);
|
---|
| 886 |
|
---|
| 887 | try {
|
---|
| 888 | mps.movePart("");
|
---|
| 889 | }
|
---|
| 890 | catch(...)
|
---|
| 891 | { result = true; }
|
---|
| 892 | if(!result)
|
---|
| 893 | TEST_FAIL;
|
---|
| 894 | } END_CASE;
|
---|
| 895 | } END_CASE;
|
---|
| 896 |
|
---|
| 897 | BEGIN_CASE("2", "NULLãªãã¸ã§ã¯ãç¸æã«æä½ããã¨ä¾å¤") {
|
---|
| 898 | bool result = false;
|
---|
| 899 | Exception::setThrowControl(true);
|
---|
| 900 |
|
---|
| 901 | try {
|
---|
| 902 | ((MultipartStream *)0)->movePart("");
|
---|
| 903 | }
|
---|
| 904 | catch(...)
|
---|
| 905 | { result = true; }
|
---|
| 906 | if(!result)
|
---|
| 907 | TEST_FAIL;
|
---|
| 908 | } END_CASE;
|
---|
| 909 | } END_CASE;
|
---|
| 910 | }
|
---|
| 911 |
|
---|
| 912 |
|
---|
| 913 | #endif
|
---|
| 914 |
|
---|
| 915 |
|
---|
| 916 |
|
---|
| 917 |
|
---|