c++ - UnitTest++ Why are CheckEqual() overloads that take non const char* needed -


In the Checks.cpp module there are 4 overloaded versions of CheckEqual. Each surcharge takes a different constness for the expected or actual, then all four call the bus checkings () which takes four config * for each of the four expected and actual I can remove the overload and fix everything but Unit test fails when anything other than two const strings is passed when strings are declared using the ARA syntax ie.

  char txt1 [] = "hello";   

Explanation The original unit ++ code reflects this behavior, not my implementation. Apart from this, it is also the fact that tests fail when the overload is removed which makes me hard.

There are four overloads:

  Check the zero (test results and results, four constraints * expected, four consents * actual, test details consort & amp; Std :: string const & msg) for the default of msg. In {checksets'qualue (results, expected, actual, details, messages); } Zero probation aqual (test results and results, four * expected, four * actual, test-detail consort and details) {checkswitings exam (results, expected, real, details); } Zero probation aqual (test results and results, four * required, four cons * actual, test details, brackets and details) {checkswitings exam (results, expected, actual, details); } Zero Investigation Acquired (Test Results and Results, Thief Conte * Expected, Four * Real, Test Details Consort and Details) {Checkswitings Exam (Results, Expected, Real, Description); }   

CheckStringsEqual

  Zero CheckSatings Accolve (Test Results and Results, Four Cost * Expected, Four Conveys * Actual, Test Details Const & amp; , Std :: string Const & amp; msg = "") {namespace std; If (strcmp (expected, real)) {UnitTest :: MemoryOutStream stream; Stream & lt; & Lt; message; Stream & lt; & Lt; "Expected" & lt; & Lt; Expected & lt; & Lt; "But" & lt; & Lt; Actual; Results: Ontest Feller (Details, Stream. GetText ()); }}   

Finally, these are the exams, where some of them fail if you comment out all but first CheckAqual

  char txt1 [] = "Hello"; // Non-contract on purpose, any folds of duplicate data- txt2 [] = "hello"; Test (Czech aquiluswitswitings workoncontentnonconnost nonconstruction) {Charles Constant-Cant P1 = TST1; Four const * const p2 = txt2; Exam Results Results; Czech aqual (results, p1, p2, test details ("", "", "", 0)); CHECK_EQUAL (0, results. GetFailureCount ()); } Test (CheckEquelsWitWitts WorksOncontentsConstant) {char * const p1 = txt1; Char * const p2 = txt2; Exam Results Results; Czech aqual (results, p1, p2, test details ("", "", "", 0)); CHECK_EQUAL (0, results. GetFailureCount ()); } Test (CheckEquelsWitWitWitingsWorkon ContentsConoconsta Connest) {char * const p1 = txt1; Four const * const p2 = txt2; Exam Results Results; Czech aqual (results, p1, p2, test details ("", "", "", 0)); CHECK_EQUAL (0, results. GetFailureCount ()); } Test (CheckEquelsWitWitWitingsWorkoncontentCommonNonConst) {Charles Constant-Const P1 = TCT1; Char * const p2 = txt2; Exam Results Results; Czech aqual (results, p1, p2, test details ("", "", "", 0)); CHECK_EQUAL (0, results. GetFailureCount ()); }   

The first checkEqual function takes an additional parameter and There is no default value in it, I'm calling your code without that std :: string parameter, I hope the compiler has to say that he can not get a function to call .

With the same number of parameters, I'm not sure why they will overload the const . You can always create a non- const variable const, and if you are not changing it, then you should do this (change the CheckStringsEqual It is not)

Comments