TEST_F(CalculationTest, WithConstant) { BufBuilder builder; ByteContainer constant("0x12ab"); builder.push_back_field(testHeader1, 0); // f16 builder.push_back_field(testHeader1, 1); // f48 builder.push_back_constant(constant, 16); builder.push_back_field(testHeader1, 3); // f32_2 Calculation calc(builder, "xxh64"); unsigned char pkt_buf[2 * header_size]; for(size_t i = 0; i < sizeof(pkt_buf); i++) { pkt_buf[i] = dis(gen); } Packet pkt = get_pkt((const char *) pkt_buf, sizeof(pkt_buf)); parser.parse(&pkt); /* A bit primitive, I have to build the buffer myself */ unsigned char expected_buf[14]; std::copy(&pkt_buf[0], &pkt_buf[2], &expected_buf[0]); std::copy(&pkt_buf[2], &pkt_buf[8], &expected_buf[2]); std::copy(constant.begin(), constant.end(), &expected_buf[8]); std::copy(&pkt_buf[12], &pkt_buf[16], &expected_buf[10]); auto expected = hash::xxh64((const char *) expected_buf, sizeof(expected_buf)); auto actual = calc.output(pkt); ASSERT_EQ(expected, actual); }