Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
AssertImpl.cpp
00001 /* 00002 * COPYRIGHT AND PERMISSION NOTICE 00003 * 00004 * Copyright (c) 2003 Embedded Unit Project 00005 * 00006 * All rights reserved. 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining 00009 * a copy of this software and associated documentation files (the 00010 * "Software"), to deal in the Software without restriction, including 00011 * without limitation the rights to use, copy, modify, merge, publish, 00012 * distribute, and/or sell copies of the Software, and to permit persons 00013 * to whom the Software is furnished to do so, provided that the above 00014 * copyright notice(s) and this permission notice appear in all copies 00015 * of the Software and that both the above copyright notice(s) and this 00016 * permission notice appear in supporting documentation. 00017 * 00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00019 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00020 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 00021 * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00022 * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY 00023 * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER 00024 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 00025 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 00026 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00027 * 00028 * Except as contained in this notice, the name of a copyright holder 00029 * shall not be used in advertising or otherwise to promote the sale, 00030 * use or other dealings in this Software without prior written 00031 * authorization of the copyright holder. 00032 * 00033 * $Id: AssertImpl.c,v 1.5 2004/02/10 16:15:25 arms22 Exp $ 00034 */ 00035 #include "config.h" 00036 #include "stdImpl.h" 00037 #include "AssertImpl.h" 00038 00039 void assertImplementationInt(int expected,int actual, long line, const char *file) 00040 { 00041 char buffer[32]; /*"exp -2147483647 was -2147483647"*/ 00042 char numbuf[12]; /*32bit int decimal maximum column is 11 (-2147483647~2147483647)*/ 00043 00044 stdimpl_strcpy(buffer, "exp "); 00045 00046 { stdimpl_itoa(expected, numbuf, 10); 00047 stdimpl_strncat(buffer, numbuf, 11); } 00048 00049 stdimpl_strcat(buffer, " was "); 00050 00051 { stdimpl_itoa(actual, numbuf, 10); 00052 stdimpl_strncat(buffer, numbuf, 11); } 00053 00054 addFailure(buffer, line, file); 00055 } 00056 00057 void assertImplementationCStr(const char *expected,const char *actual, long line, const char *file) 00058 { 00059 char buffer[ASSERT_STRING_BUFFER_MAX]; 00060 #define exp_act_limit ((ASSERT_STRING_BUFFER_MAX-11-1)/2)/* "exp'' was''" = 11 byte */ 00061 int el; 00062 int al; 00063 00064 if (expected) { 00065 el = stdimpl_strlen(expected); 00066 } else { 00067 el = 4; 00068 expected = "null"; 00069 } 00070 00071 if (actual) { 00072 al = stdimpl_strlen(actual); 00073 } else { 00074 al = 4; 00075 actual = "null"; 00076 } 00077 if (el > exp_act_limit) { 00078 if (al > exp_act_limit) { 00079 al = exp_act_limit; 00080 el = exp_act_limit; 00081 } else { 00082 int w = exp_act_limit + (exp_act_limit - al); 00083 if (el > w) { 00084 el = w; 00085 } 00086 } 00087 } else { 00088 int w = exp_act_limit + (exp_act_limit - el); 00089 if (al > w) { 00090 al = w; 00091 } 00092 } 00093 stdimpl_strcpy(buffer, "exp \""); 00094 stdimpl_strncat(buffer, expected, el); 00095 stdimpl_strcat(buffer, "\" was \""); 00096 stdimpl_strncat(buffer, actual, al); 00097 stdimpl_strcat(buffer, "\""); 00098 00099 addFailure(buffer, line, file); 00100 }
Generated on Wed Jul 13 2022 18:17:56 by
1.7.2