Skip to content

Commit 1a5239d

Browse files
committed
JSON conveter: modify unit tests to check bug fixed in 0544965
1 parent 0544965 commit 1a5239d

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

tests/unit_tests/converters/json.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -966,24 +966,23 @@ class Drec_invalid : public Drec_base {
966966
trec.add_field( 11, 2); // destinationTransportPort
967967
trec.add_field( 82, ipfix_trec::SIZE_VAR); // interfaceName
968968
trec.add_field( 82, 0); // interfaceName (second occurrence)
969+
trec.add_field(32000, ipfix_trec::SIZE_VAR); // undefined field (octetArray)
969970
trec.add_field(1001,2); // myBool
970971

971972
// Prepare an IPFIX Data Record
972973
ipfix_drec drec{};
973974
drec.append_ip(VALUE_DST_IP4);
974975
drec.append_uint(VALUE_DST_PORT, 2);
975-
drec.append_string(VALUE_IFC1); // empty string (only header)
976-
drec.append_string(VALUE_IFC2);
977-
drec.append_bool(VALUE_MY_BOOL);
976+
drec.append_string(VALUE_IFC1); // empty string (only header)
977+
drec.var_header(0); // zero size octetArray
978+
drec.append_uint(VALUE_MY_BOOL, 2); // invalid size (bool must be 1 byte)
978979

979980
register_template(trec);
980981
drec_create(256, drec);
981982
}
982983

983984
std::string VALUE_DST_IP4 = "8.8.8.8";
984985
std::string VALUE_IFC1 = "qwert"; // empty string
985-
std::string VALUE_IFC2 = "enp0s31f6";
986-
uint16_t VALUE_SRC_PORT = 65000;
987986
uint16_t VALUE_DST_PORT = 80;
988987
bool VALUE_MY_BOOL = true;
989988

@@ -1011,11 +1010,12 @@ TEST_F(Drec_invalid, invalidField)
10111010
EXPECT_TRUE(cfg["iana:protocolIdentifier"].is_null());
10121011
EXPECT_TRUE(cfg["iana:tcpControlBits"].is_null());
10131012
EXPECT_TRUE(cfg["iana:sourceMacAddress"].is_null());
1013+
EXPECT_TRUE(cfg["en0:id32000"].is_null());
10141014

10151015
free(buff);
10161016
}
10171017

1018-
// Test for adding null to multifield in case of unvalid field
1018+
// Test for adding null to multifield in case of invalid field
10191019
TEST_F(Drec_invalid, nullInMulti)
10201020
{
10211021
constexpr size_t BSIZE = 2U;

0 commit comments

Comments
 (0)