flatbuffers/tests
Alex Ames bb9b9dad5f
Fixed the BytesConsumed function, which was pointing slightly ahead. (#7657)
The BytesConsumed function uses the `cursor_` to determine how many
bytes have been consumed by the parser, in case the user of the Parser
object wants to step over the parsed flatbuffer that is embedded in some
larger string. However, the `cursor_` is always one token ahead, so that
it can determine how to consume it. It points at the token that is about
to be consumed, which is ahead of the last byte consumed.

For example, if you had a string containing these two json objects and
parsed them...

    "{\"key\":\"value\"},{\"key\":\"value\"}"

...then the `cursor_` would be pointing at the comma between the two
tables. If you were to hold a pointer to the beginning of the string and
add `BytesConsumed()` to it like so:

    const char* json = // ...
    parser.ParseJson(json);
    json += parser.BytesConsumed();

then the pointer would skip over the comma, which is not the expected
behavior. It should only consume the table itself.

The solution is simple: Just hold onto a previous cursor location and
use that for the `BytesConsumed()` call. The previous cursor location
just needs to be set to the cursor_ location each time the cursor_ is
about to be updated. This will result in `BytesConsumed()` returning
the correct number of bytes without the off-by-one-token error.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-22 20:11:14 +00:00
..
DictionaryLookup FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
FlatBuffers.Benchmarks [C#] Prepares for official Nuget release (#7496) 2022-09-01 10:17:34 -07:00
FlatBuffers.Test [C#] Prepares for official Nuget release (#7496) 2022-09-01 10:17:34 -07:00
KeywordTest FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
MyGame [Go] Fix GenNativeUnionUnPack for imported union type. (#7579) 2022-11-13 11:52:02 -08:00
annotated_binary structured comments (#7192) 2022-03-29 10:01:32 -07:00
arrays_test Rust soundness fixes (#7518) 2022-09-29 09:58:49 -04:00
cpp17 Add support for using array of scalar as key field in Cpp (#7623) 2022-11-18 11:04:46 -08:00
docker Moves all of the swift test code into tests/swift (#7509) 2022-09-09 22:35:42 -07:00
evolution_test FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
flatc Add support for metadata attributes for enum values (#7567) (#7568) 2022-10-06 20:18:00 -04:00
fuzzer Audit and fixups for GCC and Clang (#7212) 2022-08-16 10:48:41 -07:00
include_test Rework how Rust generated files are laid out (#6731) 2021-07-22 19:02:28 -04:00
include_test1 Rust soundness fixes (#7518) 2022-09-29 09:58:49 -04:00
include_test2 Rust soundness fixes (#7518) 2022-09-29 09:58:49 -04:00
key_field Add support for using array of scalar as key field in Cpp (#7623) 2022-11-18 11:04:46 -08:00
keyword_test Rust soundness fixes (#7518) 2022-09-29 09:58:49 -04:00
minified_enums Fixes #7345 to add the option to minify enums (#7566) 2022-11-11 04:47:28 +00:00
monster_test Fix handling of +/-inf defaults in TS/rust/go/dart codegen (#7588) 2022-11-08 10:59:46 -08:00
monster_test_serialize Fix handling of +/-inf defaults in TS/rust/go/dart codegen (#7588) 2022-11-08 10:59:46 -08:00
monster_test_suffix Add support for using array of scalar as key field in Cpp (#7623) 2022-11-18 11:04:46 -08:00
more_defaults Rust soundness fixes (#7518) 2022-09-29 09:58:49 -04:00
my-game Wrap types in namespace for --ts-flat-files and --gen-all (#7451) 2022-08-16 12:52:26 -07:00
name_clash_test [idl_parser] Check structs and enums do not clash in a namespace (#6562) 2021-05-14 13:56:52 -07:00
namespace_test FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
nested_namespace_test FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
nim [Nim] Bfbs Nim Generator (#7534) 2022-10-21 14:30:04 -04:00
optional-scalars Wrap types in namespace for --ts-flat-files and --gen-all (#7451) 2022-08-16 12:52:26 -07:00
optional_scalars FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
private_annotation_test Rust soundness fixes (#7518) 2022-09-29 09:58:49 -04:00
prototest Add support for parsing proto map fields (#7613) 2022-11-08 10:51:24 -08:00
rust_no_std_compilation_test Rust fix compilation for no_std targets #2 (#7553) 2022-10-19 09:14:41 -04:00
rust_serialize_test Rust soundness fixes (#7518) 2022-09-29 09:58:49 -04:00
rust_usage_test Fix handling of +/-inf defaults in TS/rust/go/dart codegen (#7588) 2022-11-08 10:59:46 -08:00
swift [swift] fix broken swift test build (#7633) (#7634) 2022-11-11 18:36:47 +01:00
ts Fix handling of +/-inf defaults in TS/rust/go/dart codegen (#7588) 2022-11-08 10:59:46 -08:00
type_field_collsion FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
union_vector FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
Abc.nim FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
BUILD.bazel Add support for using array of scalar as key field in Cpp (#7623) 2022-11-18 11:04:46 -08:00
DartTest.sh Fix import problem in dart generated files. (fixes #7609). (#7621) 2022-11-13 19:21:57 +00:00
GoTest.sh Turn off go modules temporary until we get a proper fix (#7251) 2022-04-16 15:29:18 -07:00
KotlinTest.kt [Kotlin] Fix key lookup returning null clashing with default value (#7237) 2022-04-11 17:17:19 -07:00
KotlinTest.sh [Kotlin] Fix Access to union of vector element (#5994) 2020-06-22 17:08:35 -07:00
LuaTest.bat Lua Generator using IR. (#6940) 2021-12-02 21:29:19 -08:00
LuaTest.sh Lua Generator using IR. (#6940) 2021-12-02 21:29:19 -08:00
MoreDefaults.nim FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
MutatingBool.fbs Fixed default value of bool in struct for Swift (#7072) 2022-02-02 23:39:19 +03:00
Property.nim FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
PythonTest.sh [Python] Fixed the issue with nested unions relying on InitFromBuf. (#7576) 2022-10-26 14:56:52 -07:00
RustTest.bat Rust fix compilation for no_std targets #2 (#7553) 2022-10-19 09:14:41 -04:00
RustTest.sh Rust fix compilation for no_std targets #2 (#7553) 2022-10-19 09:14:41 -04:00
TableA.lua FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
TableA.nim FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
TableAT.java [Java] ObjectAPI implementation (#6521) (#6582) 2021-06-03 14:17:40 -07:00
TestAll.sh Moved TypeScriptTests to python script (#7411) 2022-08-07 11:42:02 -07:00
TestMutatingBool.nim FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
alignment_test.cpp [C++] Rare bad buffer content alignment if sizeof(T) != alignof(T) (#7520) 2022-09-21 11:05:05 -07:00
alignment_test.fbs [C++] Rare bad buffer content alignment if sizeof(T) != alignof(T) (#7520) 2022-09-21 11:05:05 -07:00
alignment_test.h [C++] Rare bad buffer content alignment if sizeof(T) != alignof(T) (#7520) 2022-09-21 11:05:05 -07:00
alignment_test_generated.h FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
arrays_test.bfbs Put documentation to bfbs if it is not empty (#7649) 2022-11-17 15:55:42 -08:00
arrays_test.fbs Fix incorrect padding in arrays of structs (Issue #5484) (#5491) 2019-08-23 10:46:47 -07:00
arrays_test.golden Fix incorrect padding in arrays of structs (Issue #5484) (#5491) 2019-08-23 10:46:47 -07:00
arrays_test.schema.json JSON schema - tailing double quotes for maximum (#6452) 2021-02-10 11:45:34 -08:00
arrays_test_generated.h FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
dictionary_lookup.fbs [Java] Fix key lookup returning null clashing with default value (#7236) 2022-04-11 17:16:41 -07:00
evolution_test.cpp Fix conform (#7532) 2022-09-14 21:45:40 -07:00
evolution_test.h Refactor test.cpp (#7487) 2022-08-28 16:54:58 -07:00
flexbuffers_test.cpp Add missing #include <algorithm> for std::min/std::max uses, and #include <limits> for std::numeric_limits<> (#7624) 2022-11-08 09:36:35 -08:00
flexbuffers_test.h Refactor test.cpp (#7487) 2022-08-28 16:54:58 -07:00
fuzz_test.cpp Add missing #include <algorithm> for std::min/std::max uses, and #include <limits> for std::numeric_limits<> (#7624) 2022-11-08 09:36:35 -08:00
fuzz_test.h Refactor test.cpp (#7487) 2022-08-28 16:54:58 -07:00
go_test.go Fix handling of +/-inf defaults in TS/rust/go/dart codegen (#7588) 2022-11-08 10:59:46 -08:00
gold_flexbuffer_example.bin Rust Flexbuffers (#5669) 2020-05-07 14:11:26 -07:00
include_build_test.cc Add deps attribute to flatbuffer_cc_library (#7107) 2022-02-21 22:33:47 -06:00
include_test1_generated.dart Fix import problem in dart generated files. (fixes #7609). (#7621) 2022-11-13 19:21:57 +00:00
include_test2_my_game.other_name_space_generated.dart Fix import problem in dart generated files. (fixes #7609). (#7621) 2022-11-13 19:21:57 +00:00
included_test.fbs Add deps attribute to flatbuffer_cc_library (#7107) 2022-02-21 22:33:47 -06:00
includer_test.fbs Add deps attribute to flatbuffer_cc_library (#7107) 2022-02-21 22:33:47 -06:00
is_quiet_nan.h Refactor test.cpp (#7487) 2022-08-28 16:54:58 -07:00
javatest.bin Fixed warnings generated by recent JSON sorting feature. 2019-10-17 15:16:40 -07:00
json_test.cpp Refactor test.cpp (#7487) 2022-08-28 16:54:58 -07:00
json_test.h Refactor test.cpp (#7487) 2022-08-28 16:54:58 -07:00
key_field_test.cpp Add support for using array of scalar as key field in Cpp (#7623) 2022-11-18 11:04:46 -08:00
key_field_test.h Add support for using array of scalar as key field in Cpp (#7623) 2022-11-18 11:04:46 -08:00
keyword_test.fbs Namerdart (#7187) 2022-03-28 18:07:09 -04:00
lobstertest.lobster [Lobster] file_identifier support 2022-03-08 15:39:12 -08:00
luatest.lua [Lua] manipulate byte array as string (#6624) 2021-05-07 22:57:13 -07:00
monster_extra.fbs [Dart] Fix deprecated field support, inf/nan (#5724) 2020-01-23 14:53:58 -08:00
monster_extra_generated.h FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
monster_extra_my_game_generated.dart Namerdart (#7187) 2022-03-28 18:07:09 -04:00
monster_test.afb Put documentation to bfbs if it is not empty (#7649) 2022-11-17 15:55:42 -08:00
monster_test.bfbs Put documentation to bfbs if it is not empty (#7649) 2022-11-17 15:55:42 -08:00
monster_test.cpp Add missing #include <algorithm> for std::min/std::max uses, and #include <limits> for std::numeric_limits<> (#7624) 2022-11-08 09:36:35 -08:00
monster_test.fbs Fix handling of +/-inf defaults in TS/rust/go/dart codegen (#7588) 2022-11-08 10:59:46 -08:00
monster_test.grpc.fb.cc [C++/grpc] added hiding of unused variables in the generated code (#6677) 2021-06-06 17:40:56 +07:00
monster_test.grpc.fb.h cpp_generator: comment out unused parameter to avoid warnings (#7381) 2022-07-26 15:05:01 -07:00
monster_test.h UnPackTo disable merge by default (#7527) 2022-09-13 22:00:01 -07:00
monster_test.schema.json Fix handling of +/-inf defaults in TS/rust/go/dart codegen (#7588) 2022-11-08 10:59:46 -08:00
monster_test_bfbs_generated.h Put documentation to bfbs if it is not empty (#7649) 2022-11-17 15:55:42 -08:00
monster_test_generated.grpc.fb.cc missing generated files (#6966) 2021-12-03 11:23:58 -08:00
monster_test_generated.grpc.fb.h missing generated files (#6966) 2021-12-03 11:23:58 -08:00
monster_test_generated.h Add support for using array of scalar as key field in Cpp (#7623) 2022-11-18 11:04:46 -08:00
monster_test_generated.lobster Fix handling of +/-inf defaults in TS/rust/go/dart codegen (#7588) 2022-11-08 10:59:46 -08:00
monster_test_generated.py Fix handling of +/-inf defaults in TS/rust/go/dart codegen (#7588) 2022-11-08 10:59:46 -08:00
monster_test_generated.ts Wrap types in namespace for --ts-flat-files and --gen-all (#7451) 2022-08-16 12:52:26 -07:00
monster_test_my_game.example2_generated.dart Fix import problem in dart generated files. (fixes #7609). (#7621) 2022-11-13 19:21:57 +00:00
monster_test_my_game.example_generated.dart Fix import problem in dart generated files. (fixes #7609). (#7621) 2022-11-13 19:21:57 +00:00
monster_test_my_game_generated.dart Fix import problem in dart generated files. (fixes #7609). (#7621) 2022-11-13 19:21:57 +00:00
monsterdata_extra.json
monsterdata_go_wire.mon.sp [go] tests/GoTest.sh: Fix flags.Parse location to work on new go SDKs. (#6388) 2021-01-07 11:54:00 -08:00
monsterdata_python_wire.mon
monsterdata_test.afb fixed padding in struct for annotated binary (#7199) 2022-03-30 16:43:22 -07:00
monsterdata_test.golden
monsterdata_test.json fixed comparator for native_inline (#7076) 2022-02-02 23:44:43 -08:00
monsterdata_test.mon fixed comparator for native_inline (#7076) 2022-02-02 23:44:43 -08:00
more_defaults.fbs Default-empty vectors of enums (#6505) 2021-04-06 07:23:45 -04:00
nan_inf_test.fbs [swift] fix broken swift test build (#7633) (#7634) 2022-11-11 18:36:47 +01:00
native_inline_table_test.fbs [C++] support native_inline attribute for vector of tables (#7479) 2022-08-29 12:48:10 -07:00
native_inline_table_test_generated.h FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
native_type_test.fbs [C++] #6501 - Problem when mapping a native type multiple times (#6514) 2021-03-18 11:01:50 -07:00
native_type_test_generated.h FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
native_type_test_impl.cpp [C++] #6501 - Problem when mapping a native type multiple times (#6514) 2021-03-18 11:01:50 -07:00
native_type_test_impl.h clang-all (#6941) 2021-11-19 17:01:48 -08:00
nested_union_test.fbs [Python] Fixed the issue with nested unions relying on InitFromBuf. (#7576) 2022-10-26 14:56:52 -07:00
optional_scalars.fbs Kotlin test optional enum (#6201) 2020-10-22 13:36:02 -07:00
optional_scalars.json Reenable optional json (#7352) 2022-06-16 09:26:44 -07:00
optional_scalars_defaults.json Reenable optional json (#7352) 2022-06-16 09:26:44 -07:00
optional_scalars_generated.h FlatBuffers Version 22.10.26 (#7607) 2022-10-26 16:02:38 -07:00
optional_scalars_generated.lobster Add explicit return types to lobster generated code (#7312) 2022-05-23 10:50:01 -07:00
optional_scalars_generated.ts Wrap types in namespace for --ts-flat-files and --gen-all (#7451) 2022-08-16 12:52:26 -07:00
optional_scalars_test.cpp Refactor test.cpp (#7487) 2022-08-28 16:54:58 -07:00
optional_scalars_test.h Refactor test.cpp (#7487) 2022-08-28 16:54:58 -07:00
parser_test.cpp Add missing #include <algorithm> for std::min/std::max uses, and #include <limits> for std::numeric_limits<> (#7624) 2022-11-08 09:36:35 -08:00
parser_test.h Refactor test.cpp (#7487) 2022-08-28 16:54:58 -07:00
phpTest.php
phpUnionVectorTest.php
phpUnionVectorTest.sh
private_annotation_test.fbs Started implementation for private flags in rust (#7269) 2022-06-05 23:04:05 +02:00
proto_test.cpp Add support for parsing proto map fields (#7613) 2022-11-08 10:51:24 -08:00
proto_test.h Refactor test.cpp (#7487) 2022-08-28 16:54:58 -07:00
py_flexbuffers_test.py Implement flexbuffers in python (#5880) 2020-05-07 14:26:33 -07:00
py_test.py Add CreateSharedString to python builder (#7608) 2022-10-29 00:28:35 +00:00
reflection_test.cpp Fix handling of +/-inf defaults in TS/rust/go/dart codegen (#7588) 2022-11-08 10:59:46 -08:00
reflection_test.h Refactor test.cpp (#7487) 2022-08-28 16:54:58 -07:00
test.cpp Fixed the BytesConsumed function, which was pointing slightly ahead. (#7657) 2022-11-22 20:11:14 +00:00
test_assert.cpp remove travis config (#7522) 2022-09-10 12:36:51 -07:00
test_assert.h avoid zero-as-null-pointer warning (#7423) 2022-08-08 21:32:13 -07:00
test_builder.cpp Audit and fixups for GCC and Clang (#7212) 2022-08-16 10:48:41 -07:00
test_builder.h test: fix undefined order of functio parameters. (#6946) 2021-11-22 12:14:31 -08:00
type_field_collsion.fbs [C#] Fix collision of field name and type name (#7149) 2022-03-30 12:51:58 -07:00
unicode_test.json Fixed JSON parser not sorting vectors of tables/structs with key. 2019-10-10 15:25:39 -07:00
unicode_test.mon [TS] Add Build TS to CI jobs (#6524) 2021-04-12 10:41:59 -07:00
util_test.cpp [Python] Python fixed size array (#7529) 2022-09-22 11:08:09 -07:00
util_test.h Refactor test.cpp (#7487) 2022-08-28 16:54:58 -07:00
vector_has_test.fbs [swift] add had<ArrayName> property for arrays to check presence in a message (#7280) 2022-05-11 15:35:53 +02:00