aboutsummaryrefslogtreecommitdiffstats
path: root/src/google/protobuf/unittest_accessors_nano.proto
diff options
context:
space:
mode:
authorMax Cai <maxtroy@google.com>2014-01-09 18:46:04 +0000
committerMax Cai <maxtroy@google.com>2014-01-10 18:11:07 +0000
commit04e0fa44e105bc644bf07ba5154fc4a1ca4baec2 (patch)
tree44943acb07112a8c052d58aaea062d8529670dcc /src/google/protobuf/unittest_accessors_nano.proto
parentf84177299a76759be1eb925093b059aef246fc0e (diff)
downloadexternal_protobuf-04e0fa44e105bc644bf07ba5154fc4a1ca4baec2.zip
external_protobuf-04e0fa44e105bc644bf07ba5154fc4a1ca4baec2.tar.gz
external_protobuf-04e0fa44e105bc644bf07ba5154fc4a1ca4baec2.tar.bz2
Correctness: floating point equality using bits instead of ==.
Special values for float and double make it inaccurate to test the equality with ==. The main Java library uses the standard Object.equals() implementation for all fields, which for floating point fields means Float.equals() or Double.equals(). They define equality as bitwise equality, with all NaN representations normalized to the same bit sequence (and therefore equal to each other). This test checks that the nano implementation complies with Object.equals(), so NaN == NaN and +0.0 != -0.0. Change-Id: I97bb4a3687223d8a212c70cd736436b9dd80c1d7
Diffstat (limited to 'src/google/protobuf/unittest_accessors_nano.proto')
-rw-r--r--src/google/protobuf/unittest_accessors_nano.proto2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/google/protobuf/unittest_accessors_nano.proto b/src/google/protobuf/unittest_accessors_nano.proto
index 875af25..f1d4d34 100644
--- a/src/google/protobuf/unittest_accessors_nano.proto
+++ b/src/google/protobuf/unittest_accessors_nano.proto
@@ -49,6 +49,8 @@ message TestNanoAccessors {
// Singular
optional int32 optional_int32 = 1;
+ optional float optional_float = 11;
+ optional double optional_double = 12;
optional string optional_string = 14;
optional bytes optional_bytes = 15;