Add capacity parameter to the extern C evaluate string function for EvalValues
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2019-07-21 11:49:45 +02:00
parent eb3afce5c5
commit bb6c7edcf2
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 3 additions and 3 deletions

View File

@ -28,9 +28,9 @@ namespace Porygon::Evaluation {
return result.size();
}
int EvaluateEvalValueString(EvalValue *v, char16_t dst[]){
int EvaluateEvalValueString(EvalValue *v, char16_t* dst, size_t capacity){
auto result = v->EvaluateString();
for (int i = 0; i < result.size(); i++){
for (int i = 0; i < capacity; i++){
dst[i] = result[i];
}
return 0;
@ -67,7 +67,7 @@ TEST_CASE( "Evaluate String", "[integration]" ) {
auto lastValue = script->GetLastValue();
size_t size = GetEvalValueStringLength(lastValue);
auto dst = new char16_t[size + 1]{'\0'};
EvaluateEvalValueString(lastValue, dst);
EvaluateEvalValueString(lastValue, dst, size);
auto s = u16string(dst);
REQUIRE(s == u"foo bar");
delete[] dst;