equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #include <iostream> |
|
18 |
|
19 #include "testevent.h" |
|
20 |
|
21 |
|
22 namespace |
|
23 { |
|
24 const char UNKNOWN[] = "(unknown)"; |
|
25 } |
|
26 |
|
27 |
|
28 namespace Itk |
|
29 { |
|
30 |
|
31 TestEvent::TestEvent(const char * expr, |
|
32 const char * file, |
|
33 size_t line, |
|
34 const char * msg) |
|
35 : expr_(expr), |
|
36 file_(file), |
|
37 line_(line), |
|
38 msg_(msg == NULL ? "" : msg) |
|
39 { |
|
40 ; |
|
41 } |
|
42 |
|
43 |
|
44 TestEvent::TestEvent(const char * file, |
|
45 const char * msg) |
|
46 : expr_(""), |
|
47 file_(file), |
|
48 line_(0), |
|
49 msg_(msg) |
|
50 { |
|
51 ; |
|
52 } |
|
53 |
|
54 |
|
55 TestEvent::TestEvent(const char * contextName) |
|
56 : expr_(UNKNOWN), |
|
57 file_(UNKNOWN), |
|
58 line_(0), |
|
59 msg_(contextName) |
|
60 |
|
61 { |
|
62 ; |
|
63 } |
|
64 |
|
65 |
|
66 const std::string & TestEvent::expr() const |
|
67 { |
|
68 return expr_; |
|
69 } |
|
70 |
|
71 |
|
72 const std::string & TestEvent::file() const |
|
73 { |
|
74 return file_; |
|
75 } |
|
76 |
|
77 |
|
78 size_t TestEvent::line() const |
|
79 { |
|
80 return line_; |
|
81 } |
|
82 |
|
83 |
|
84 const std::string & TestEvent::msg() const |
|
85 { |
|
86 return msg_; |
|
87 } |
|
88 |
|
89 } |
|
90 |
|
91 |
|
92 |
|
93 namespace std |
|
94 { |
|
95 std::ostream & operator<<(std::ostream & os, |
|
96 const Itk::TestEvent & e) |
|
97 { |
|
98 using namespace std; |
|
99 |
|
100 if (e.expr().length() > 0 && e.file().length() > 0) |
|
101 { |
|
102 // some sort of test failure |
|
103 os |
|
104 << "Expr " |
|
105 << e.expr() |
|
106 << " failed at " |
|
107 << e.file() |
|
108 << "/" |
|
109 << e.line() |
|
110 << ": " |
|
111 << e.msg(); |
|
112 } |
|
113 else if (e.expr().length() == 0 && e.file().length() > 0) |
|
114 { |
|
115 // io capture message |
|
116 os |
|
117 << "IO Capturing: " |
|
118 << e.file() |
|
119 << ": " |
|
120 << e.msg(); |
|
121 } |
|
122 else |
|
123 { |
|
124 // unknown failure |
|
125 os |
|
126 << "Unknown failure in context " |
|
127 << e.msg(); |
|
128 } |
|
129 |
|
130 return os; |
|
131 } |
|
132 } |