decode "null" string

PVD encoding distinguishes between 'null' and '""'
(a residual java-ism).  Decode both as an empty string.
This commit is contained in:
Michael Davidsaver
2021-01-12 10:58:50 -08:00
parent a25c164066
commit 0356eee740
2 changed files with 36 additions and 3 deletions
+32 -2
View File
@@ -1,4 +1,4 @@
/**
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* pvxs is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
@@ -51,6 +51,35 @@ void testFromBytes(bool be, const char(&input)[N], Fn&& fn)
testCase(S.good() && S.empty())<<"Deserialize \""<<escape(std::string((const char*)input, N-1))<<"\" leaves "<<S.good()<<" "<<S.size();
}
void testDeserializeString()
{
testDiag("%s", __func__);
{
std::string dut("canary");
testFromBytes(true, "\x00", [&dut](Buffer& buf) {
from_wire(buf, dut);
});
testEq(dut, "");
}
{
std::string dut("canary");
testFromBytes(true, "\xff", [&dut](Buffer& buf) {
from_wire(buf, dut);
});
testEq(dut, "");
}
{
std::string dut("canary");
testFromBytes(true, "\x0bhello world", [&dut](Buffer& buf) {
from_wire(buf, dut);
});
testEq(dut, "hello world");
}
}
void testSerialize1()
{
testDiag("%s", __func__);
@@ -952,8 +981,9 @@ void testEmptyRequest()
MAIN(testxcode)
{
testPlan(116);
testPlan(122);
testSetup();
testDeserializeString();
testSerialize1();
testDeserialize1();
testSimpleDef();