Skip to content

Commit 40bf586

Browse files
committed
Unit test added.
1 parent 07294e3 commit 40bf586

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

unittests_cgnsfile/case_sol_readwrite.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <iostream>
1616
#include <string>
17+
#include <sstream>
1718
#include <vector>
1819

1920
extern "C" {
@@ -147,6 +148,10 @@ void writeSolution(const char* filename, int* fid, bool iterMode)
147148
int DamOpen = i;
148149
ier = cg_iRIC_Write_Sol_BaseIterative_Integer_Mul(*fid, "DamOpen", DamOpen);
149150
VERIFY_LOG("cg_iRIC_Write_Sol_BaseIterative_Integer_Mul() for DamOpen ier == 0", ier == 0);
151+
std::ostringstream ss;
152+
ss << "Test" << i;
153+
ier = cg_iRIC_Write_Sol_BaseIterative_String_Mul(*fid, "TestStr", ss.str().c_str());
154+
VERIFY_LOG("cg_iRIC_Write_Sol_BaseIterative_String_Mul() for TestStr ier == 0", ier == 0);
150155

151156
// Particle solutions
152157

@@ -458,6 +463,19 @@ void readSolution(int fid)
458463
VERIFY_LOG("cg_iRIC_Read_Sol_BaseIterative_Integer_Mul() for DamOpen ier == 0", ier == 0);
459464
sprintf(buffer, "cg_iRIC_Read_Sol_BaseIterative_Integer_Mul() for DamOpen i == %d", DamOpen);
460465
VERIFY_LOG(buffer, i == DamOpen);
466+
467+
std::ostringstream ss;
468+
ss << "Test" << S - 1;
469+
std::string validVal = ss.str();
470+
std::vector<char> retval;
471+
int len;
472+
ier = cg_iRIC_Read_Sol_BaseIterative_StringLen_Mul(fid, S, "TestStr", &len);
473+
VERIFY_LOG("cg_iRIC_Read_Sol_BaseIterative_StringLen_Mul() for TestStr ier == 0", ier == 0);
474+
retval.assign(len + 1, '\0');
475+
ier = cg_iRIC_Read_Sol_BaseIterative_String_Mul(fid, S, "TestStr", retval.data());
476+
VERIFY_LOG("cg_iRIC_Read_Sol_BaseIterative_String_Mul() for TestStr ier == 0", ier == 0);
477+
sprintf(buffer, "cg_iRIC_Read_Sol_BaseIterative_String_Mul() for TestStr s == %s", validVal.c_str());
478+
VERIFY_LOG(buffer, validVal == retval.data());
461479
}
462480
}
463481

0 commit comments

Comments
 (0)