Make fuzz test check round-trip correctness of upb encoder/decoder.

Prior to this CL, the fuzz tests only checked that the code does not crash, but it was not checking any correctness properties.  This CL adds correctness checking, verifying that we can round trip through the wire format without losing or corrupting data.

This highlighted a minor bug in the encoder where the depth limit check was off by one (too strict).  This CL makes the encoder more accepting when checking the depth limit.

PiperOrigin-RevId: 698527429
pull/19335/head
Joshua Haberman 3 weeks ago committed by Copybara-Service
parent 36111c2e6b
commit 245acbfc16
  1. 1
      upb/message/BUILD
  2. 3
      upb/message/test.cc

@ -381,6 +381,7 @@ cc_test(
"//upb:eps_copy_input_stream", "//upb:eps_copy_input_stream",
"//upb:json", "//upb:json",
"//upb:mem", "//upb:mem",
"//upb:message_compare",
"//upb:mini_table", "//upb:mini_table",
"//upb:reflection", "//upb:reflection",
"//upb:wire", "//upb:wire",

@ -7,8 +7,10 @@
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <optional>
#include <string> #include <string>
#include <string_view> #include <string_view>
#include <utility>
#include <vector> #include <vector>
#include <gmock/gmock.h> #include <gmock/gmock.h>
@ -22,6 +24,7 @@
#include "upb/mem/arena.h" #include "upb/mem/arena.h"
#include "upb/mem/arena.hpp" #include "upb/mem/arena.hpp"
#include "upb/message/array.h" #include "upb/message/array.h"
#include "upb/message/compare.h"
#include "upb/message/map.h" #include "upb/message/map.h"
#include "upb/message/message.h" #include "upb/message/message.h"
#include "upb/message/test.upb.h" #include "upb/message/test.upb.h"

Loading…
Cancel
Save