Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nanopb/nanopb.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2020-06-24 13:22:37 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2020-06-24 13:22:37 +0300
commit2233c68866aabd3499bda2eaeeb29f0b3943702d (patch)
tree9e20b90a0ae1486b64b3d342d1a573c8bd049d20 /tests/decode_unittests
parentb226605e1fff2ed2b05fb36f015b2be31ae1cf53 (diff)
pb_decode: performance optimizations for check_wire_type()
Diffstat (limited to 'tests/decode_unittests')
-rw-r--r--tests/decode_unittests/decode_unittests.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/tests/decode_unittests/decode_unittests.c b/tests/decode_unittests/decode_unittests.c
index f177535..80b87b5 100644
--- a/tests/decode_unittests/decode_unittests.c
+++ b/tests/decode_unittests/decode_unittests.c
@@ -237,34 +237,25 @@ int main()
{
pb_istream_t s;
- pb_field_iter_t f;
float d;
- f.type = PB_LTYPE_FIXED32;
- f.data_size = sizeof(d);
- f.pData = &d;
-
COMMENT("Test pb_dec_fixed using float (failures here may be caused by imperfect rounding)")
- TEST((s = S("\x00\x00\x00\x00"), pb_dec_fixed(&s, &f) && d == 0.0f))
- TEST((s = S("\x00\x00\xc6\x42"), pb_dec_fixed(&s, &f) && d == 99.0f))
- TEST((s = S("\x4e\x61\x3c\xcb"), pb_dec_fixed(&s, &f) && d == -12345678.0f))
+ TEST((s = S("\x00\x00\x00\x00"), pb_decode_fixed32(&s, &d) && d == 0.0f))
+ TEST((s = S("\x00\x00\xc6\x42"), pb_decode_fixed32(&s, &d) && d == 99.0f))
+ TEST((s = S("\x4e\x61\x3c\xcb"), pb_decode_fixed32(&s, &d) && d == -12345678.0f))
d = -12345678.0f;
- TEST((s = S("\x00"), !pb_dec_fixed(&s, &f) && d == -12345678.0f))
+ TEST((s = S("\x00"), !pb_decode_fixed32(&s, &d) && d == -12345678.0f))
}
+ if (sizeof(double) == 8)
{
pb_istream_t s;
- pb_field_iter_t f;
double d;
- f.type = PB_LTYPE_FIXED64;
- f.data_size = sizeof(d);
- f.pData = &d;
-
COMMENT("Test pb_dec_fixed64 using double (failures here may be caused by imperfect rounding)")
- TEST((s = S("\x00\x00\x00\x00\x00\x00\x00\x00"), pb_dec_fixed(&s, &f) && d == 0.0))
- TEST((s = S("\x00\x00\x00\x00\x00\xc0\x58\x40"), pb_dec_fixed(&s, &f) && d == 99.0))
- TEST((s = S("\x00\x00\x00\xc0\x29\x8c\x67\xc1"), pb_dec_fixed(&s, &f) && d == -12345678.0f))
+ TEST((s = S("\x00\x00\x00\x00\x00\x00\x00\x00"), pb_decode_fixed64(&s, &d) && d == 0.0))
+ TEST((s = S("\x00\x00\x00\x00\x00\xc0\x58\x40"), pb_decode_fixed64(&s, &d) && d == 99.0))
+ TEST((s = S("\x00\x00\x00\xc0\x29\x8c\x67\xc1"), pb_decode_fixed64(&s, &d) && d == -12345678.0f))
}
{