| 
									
										
										
										
											2010-10-14 12:54:38 +08:00
										 |  |  | /* ----------------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * GTSAM Copyright 2010, Georgia Tech Research Corporation,  | 
					
						
							|  |  |  |  * Atlanta, Georgia 30332-0415 | 
					
						
							|  |  |  |  * All Rights Reserved | 
					
						
							|  |  |  |  * Authors: Frank Dellaert, et al. (see THANKS for the full author list) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * See LICENSE for the license information | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * -------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "Failure.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  | #include <string.h> 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Failure::Failure (const SimpleString&	theTestName,  | 
					
						
							|  |  |  | 				  const SimpleString&	theFileName,  | 
					
						
							|  |  |  | 		          long	 				theLineNumber, | 
					
						
							|  |  |  | 		          const SimpleString&	theCondition)  | 
					
						
							|  |  |  | : message (theCondition),  | 
					
						
							|  |  |  |   testName (theTestName),  | 
					
						
							|  |  |  |   fileName (theFileName),  | 
					
						
							|  |  |  |   lineNumber (theLineNumber) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-17 03:30:38 +08:00
										 |  |  | Failure::Failure (const SimpleString&	theTestName, | 
					
						
							|  |  |  | 				  const SimpleString&	theFileName, | 
					
						
							|  |  |  | 		          const SimpleString&	theCondition) | 
					
						
							|  |  |  | : message (theCondition), | 
					
						
							|  |  |  |   testName (theTestName), | 
					
						
							|  |  |  |   fileName (theFileName), | 
					
						
							|  |  |  |   lineNumber (-1) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | Failure::Failure (const SimpleString&	theTestName,  | 
					
						
							|  |  |  | 			 	  const SimpleString&	theFileName,  | 
					
						
							|  |  |  | 				  long					theLineNumber, | 
					
						
							|  |  |  | 				  const SimpleString&	expected, | 
					
						
							|  |  |  | 				  const SimpleString&	actual)  | 
					
						
							|  |  |  | : testName (theTestName),  | 
					
						
							|  |  |  |   fileName (theFileName),  | 
					
						
							|  |  |  |   lineNumber (theLineNumber) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-01-07 02:59:14 +08:00
										 |  |  | 	const char *part1 = "expected "; | 
					
						
							|  |  |  | 	const char *part3 = " but was: "; | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	char *stage = new char [strlen (part1)  | 
					
						
							|  |  |  | 					+ expected.size ()  | 
					
						
							|  |  |  | 					+ strlen (part3) | 
					
						
							|  |  |  | 					+ actual.size () | 
					
						
							|  |  |  | 					+ 1]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	sprintf(stage, "%s%s%s%s",  | 
					
						
							|  |  |  | 		part1,  | 
					
						
							|  |  |  | 		expected.asCharString(),  | 
					
						
							|  |  |  | 		part3,  | 
					
						
							|  |  |  | 		actual.asCharString()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	message = SimpleString(stage); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	delete stage; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 |