Protocol Buffers - Google's data interchange format (grpc依赖)
https://developers.google.com/protocol-buffers/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
723 B
36 lines
723 B
7 months ago
|
#include "upb/lex/round_trip.h"
|
||
|
|
||
|
#include <math.h>
|
||
|
|
||
|
#include <gtest/gtest.h>
|
||
|
|
||
|
namespace {
|
||
|
|
||
|
TEST(RoundTripTest, Double) {
|
||
|
char buf[32];
|
||
|
|
||
|
_upb_EncodeRoundTripDouble(0.123456789, buf, sizeof(buf));
|
||
|
EXPECT_STREQ(buf, "0.123456789");
|
||
|
|
||
|
_upb_EncodeRoundTripDouble(0.0, buf, sizeof(buf));
|
||
|
EXPECT_STREQ(buf, "0");
|
||
|
|
||
|
_upb_EncodeRoundTripDouble(nan(""), buf, sizeof(buf));
|
||
|
EXPECT_STREQ(buf, "nan");
|
||
|
}
|
||
|
|
||
|
TEST(RoundTripTest, Float) {
|
||
|
char buf[32];
|
||
|
|
||
|
_upb_EncodeRoundTripFloat(0.123456, buf, sizeof(buf));
|
||
|
EXPECT_STREQ(buf, "0.123456");
|
||
|
|
||
|
_upb_EncodeRoundTripFloat(0.0, buf, sizeof(buf));
|
||
|
EXPECT_STREQ(buf, "0");
|
||
|
|
||
|
_upb_EncodeRoundTripFloat(nan(""), buf, sizeof(buf));
|
||
|
EXPECT_STREQ(buf, "nan");
|
||
|
}
|
||
|
|
||
|
} // namespace
|