diff options
Diffstat (limited to 'linden/indra/test/llerror_tut.cpp')
-rw-r--r-- | linden/indra/test/llerror_tut.cpp | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/linden/indra/test/llerror_tut.cpp b/linden/indra/test/llerror_tut.cpp index 46a5707..a240980 100644 --- a/linden/indra/test/llerror_tut.cpp +++ b/linden/indra/test/llerror_tut.cpp | |||
@@ -372,27 +372,21 @@ namespace | |||
372 | std::string logFromClassWithLogTypeMember(bool id) { ClassWithLogType c; return c.logFromMember(id); } | 372 | std::string logFromClassWithLogTypeMember(bool id) { ClassWithLogType c; return c.logFromMember(id); } |
373 | std::string logFromClassWithLogTypeStatic(bool id) { return ClassWithLogType::logFromStatic(id); } | 373 | std::string logFromClassWithLogTypeStatic(bool id) { return ClassWithLogType::logFromStatic(id); } |
374 | 374 | ||
375 | void ensure_has_once(const std::string& message, | 375 | void ensure_has(const std::string& message, |
376 | const std::string& actual, const std::string& expected) | 376 | const std::string& actual, const std::string& expected) |
377 | { | 377 | { |
378 | std::string::size_type n1 = actual.find(expected); | 378 | std::string::size_type n1 = actual.find(expected); |
379 | std::string::size_type n2 = std::string::npos; | 379 | if (n1 == std::string::npos) |
380 | if (n1 != std::string::npos) | ||
381 | { | ||
382 | n2 = std::string(actual, n1 + expected.size()).find(expected); | ||
383 | } | ||
384 | |||
385 | if (n1 == std::string::npos || n2 != std::string::npos) | ||
386 | { | 380 | { |
387 | std::stringstream ss; | 381 | std::stringstream ss; |
388 | ss << message << ": " << "expected to find one copy of " << expected | 382 | ss << message << ": " << "expected to find a copy of " << expected |
389 | << " in actual " << actual; | 383 | << " in actual " << actual; |
390 | throw tut::failure(ss.str().c_str()); | 384 | throw tut::failure(ss.str().c_str()); |
391 | } | 385 | } |
392 | } | 386 | } |
393 | 387 | ||
394 | typedef std::string (*LogFromFunction)(bool); | 388 | typedef std::string (*LogFromFunction)(bool); |
395 | void testLogNameOnce(TestRecorder& recorder, LogFromFunction f, | 389 | void testLogName(TestRecorder& recorder, LogFromFunction f, |
396 | const std::string& class_name = "") | 390 | const std::string& class_name = "") |
397 | { | 391 | { |
398 | recorder.clearMessages(); | 392 | recorder.clearMessages(); |
@@ -402,16 +396,16 @@ namespace | |||
402 | std::string messageWithoutName = recorder.message(0); | 396 | std::string messageWithoutName = recorder.message(0); |
403 | std::string messageWithName = recorder.message(1); | 397 | std::string messageWithName = recorder.message(1); |
404 | 398 | ||
405 | ensure_has_once(name + " logged without name", | 399 | ensure_has(name + " logged without name", |
406 | messageWithoutName, name); | 400 | messageWithoutName, name); |
407 | ensure_has_once(name + " logged with name", | 401 | ensure_has(name + " logged with name", |
408 | messageWithName, name); | 402 | messageWithName, name); |
409 | 403 | ||
410 | if (!class_name.empty()) | 404 | if (!class_name.empty()) |
411 | { | 405 | { |
412 | ensure_has_once(name + "logged without name", | 406 | ensure_has(name + "logged without name", |
413 | messageWithoutName, class_name); | 407 | messageWithoutName, class_name); |
414 | ensure_has_once(name + "logged with name", | 408 | ensure_has(name + "logged with name", |
415 | messageWithName, class_name); | 409 | messageWithName, class_name); |
416 | } | 410 | } |
417 | } | 411 | } |
@@ -423,15 +417,15 @@ namespace tut | |||
423 | // class/function information in output | 417 | // class/function information in output |
424 | void ErrorTestObject::test<6>() | 418 | void ErrorTestObject::test<6>() |
425 | { | 419 | { |
426 | testLogNameOnce(mRecorder, logFromGlobal); | 420 | testLogName(mRecorder, logFromGlobal); |
427 | testLogNameOnce(mRecorder, logFromStatic); | 421 | testLogName(mRecorder, logFromStatic); |
428 | testLogNameOnce(mRecorder, logFromAnon); | 422 | testLogName(mRecorder, logFromAnon); |
429 | testLogNameOnce(mRecorder, logFromNamespace); | 423 | testLogName(mRecorder, logFromNamespace); |
430 | //testLogNameOnce(mRecorder, logFromClassWithNoLogTypeMember, "ClassWithNoLogType"); | 424 | //testLogName(mRecorder, logFromClassWithNoLogTypeMember, "ClassWithNoLogType"); |
431 | //testLogNameOnce(mRecorder, logFromClassWithNoLogTypeStatic, "ClassWithNoLogType"); | 425 | //testLogName(mRecorder, logFromClassWithNoLogTypeStatic, "ClassWithNoLogType"); |
432 | // XXX: figure out what the exepcted response is for these | 426 | // XXX: figure out what the exepcted response is for these |
433 | testLogNameOnce(mRecorder, logFromClassWithLogTypeMember, "ClassWithLogType"); | 427 | testLogName(mRecorder, logFromClassWithLogTypeMember, "ClassWithLogType"); |
434 | testLogNameOnce(mRecorder, logFromClassWithLogTypeStatic, "ClassWithLogType"); | 428 | testLogName(mRecorder, logFromClassWithLogTypeStatic, "ClassWithLogType"); |
435 | } | 429 | } |
436 | } | 430 | } |
437 | 431 | ||