google-protobuf 3.11.0 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of google-protobuf might be problematic. Click here for more details.

File without changes
@@ -32,11 +32,11 @@ module BasicTest
32
32
  include CommonTests
33
33
 
34
34
  def test_has_field
35
- m = TestMessage.new
36
- assert !m.has_optional_msg?
37
- m.optional_msg = TestMessage2.new
38
- assert m.has_optional_msg?
39
- assert TestMessage.descriptor.lookup('optional_msg').has?(m)
35
+ m = TestSingularFields.new
36
+ assert !m.has_singular_msg?
37
+ m.singular_msg = TestMessage2.new
38
+ assert m.has_singular_msg?
39
+ assert TestSingularFields.descriptor.lookup('singular_msg').has?(m)
40
40
 
41
41
  m = OneofMessage.new
42
42
  assert !m.has_my_oneof?
@@ -45,32 +45,31 @@ module BasicTest
45
45
  assert_raise NoMethodError do
46
46
  m.has_a?
47
47
  end
48
- assert_raise ArgumentError do
49
- OneofMessage.descriptor.lookup('a').has?(m)
50
- end
48
+ assert_true OneofMessage.descriptor.lookup('a').has?(m)
51
49
 
52
- m = TestMessage.new
50
+ m = TestSingularFields.new
53
51
  assert_raise NoMethodError do
54
- m.has_optional_int32?
52
+ m.has_singular_int32?
55
53
  end
56
54
  assert_raise ArgumentError do
57
- TestMessage.descriptor.lookup('optional_int32').has?(m)
55
+ TestSingularFields.descriptor.lookup('singular_int32').has?(m)
58
56
  end
59
57
 
60
58
  assert_raise NoMethodError do
61
- m.has_optional_string?
59
+ m.has_singular_string?
62
60
  end
63
61
  assert_raise ArgumentError do
64
- TestMessage.descriptor.lookup('optional_string').has?(m)
62
+ TestSingularFields.descriptor.lookup('singular_string').has?(m)
65
63
  end
66
64
 
67
65
  assert_raise NoMethodError do
68
- m.has_optional_bool?
66
+ m.has_singular_bool?
69
67
  end
70
68
  assert_raise ArgumentError do
71
- TestMessage.descriptor.lookup('optional_bool').has?(m)
69
+ TestSingularFields.descriptor.lookup('singular_bool').has?(m)
72
70
  end
73
71
 
72
+ m = TestMessage.new
74
73
  assert_raise NoMethodError do
75
74
  m.has_repeated_msg?
76
75
  end
@@ -79,40 +78,59 @@ module BasicTest
79
78
  end
80
79
  end
81
80
 
81
+ def test_no_presence
82
+ m = TestSingularFields.new
83
+
84
+ # Explicitly setting to zero does not cause anything to be serialized.
85
+ m.singular_int32 = 0
86
+ assert_equal "", TestSingularFields.encode(m)
87
+
88
+ # Explicitly setting to a non-zero value *does* cause serialization.
89
+ m.singular_int32 = 1
90
+ assert_not_equal "", TestSingularFields.encode(m)
91
+
92
+ m.singular_int32 = 0
93
+ assert_equal "", TestSingularFields.encode(m)
94
+ end
95
+
82
96
  def test_set_clear_defaults
83
- m = TestMessage.new
97
+ m = TestSingularFields.new
98
+
99
+ m.singular_int32 = -42
100
+ assert_equal -42, m.singular_int32
101
+ m.clear_singular_int32
102
+ assert_equal 0, m.singular_int32
103
+
104
+ m.singular_int32 = 50
105
+ assert_equal 50, m.singular_int32
106
+ TestSingularFields.descriptor.lookup('singular_int32').clear(m)
107
+ assert_equal 0, m.singular_int32
108
+
109
+ m.singular_string = "foo bar"
110
+ assert_equal "foo bar", m.singular_string
111
+ m.clear_singular_string
112
+ assert_equal "", m.singular_string
113
+
114
+ m.singular_string = "foo"
115
+ assert_equal "foo", m.singular_string
116
+ TestSingularFields.descriptor.lookup('singular_string').clear(m)
117
+ assert_equal "", m.singular_string
118
+
119
+ m.singular_msg = TestMessage2.new(:foo => 42)
120
+ assert_equal TestMessage2.new(:foo => 42), m.singular_msg
121
+ assert m.has_singular_msg?
122
+ m.clear_singular_msg
123
+ assert_equal nil, m.singular_msg
124
+ assert !m.has_singular_msg?
125
+
126
+ m.singular_msg = TestMessage2.new(:foo => 42)
127
+ assert_equal TestMessage2.new(:foo => 42), m.singular_msg
128
+ TestSingularFields.descriptor.lookup('singular_msg').clear(m)
129
+ assert_equal nil, m.singular_msg
130
+ end
84
131
 
85
- m.optional_int32 = -42
86
- assert_equal -42, m.optional_int32
87
- m.clear_optional_int32
88
- assert_equal 0, m.optional_int32
89
-
90
- m.optional_int32 = 50
91
- assert_equal 50, m.optional_int32
92
- TestMessage.descriptor.lookup('optional_int32').clear(m)
93
- assert_equal 0, m.optional_int32
94
-
95
- m.optional_string = "foo bar"
96
- assert_equal "foo bar", m.optional_string
97
- m.clear_optional_string
98
- assert_equal "", m.optional_string
99
-
100
- m.optional_string = "foo"
101
- assert_equal "foo", m.optional_string
102
- TestMessage.descriptor.lookup('optional_string').clear(m)
103
- assert_equal "", m.optional_string
104
-
105
- m.optional_msg = TestMessage2.new(:foo => 42)
106
- assert_equal TestMessage2.new(:foo => 42), m.optional_msg
107
- assert m.has_optional_msg?
108
- m.clear_optional_msg
109
- assert_equal nil, m.optional_msg
110
- assert !m.has_optional_msg?
111
-
112
- m.optional_msg = TestMessage2.new(:foo => 42)
113
- assert_equal TestMessage2.new(:foo => 42), m.optional_msg
114
- TestMessage.descriptor.lookup('optional_msg').clear(m)
115
- assert_equal nil, m.optional_msg
132
+ def test_clear_repeated_fields
133
+ m = TestMessage.new
116
134
 
117
135
  m.repeated_int32.push(1)
118
136
  assert_equal [1], m.repeated_int32
@@ -128,6 +146,7 @@ module BasicTest
128
146
  m.a = "foo"
129
147
  assert_equal "foo", m.a
130
148
  assert m.has_my_oneof?
149
+ assert_equal :a, m.my_oneof
131
150
  m.clear_a
132
151
  assert !m.has_my_oneof?
133
152
 
@@ -143,7 +162,6 @@ module BasicTest
143
162
  assert !m.has_my_oneof?
144
163
  end
145
164
 
146
-
147
165
  def test_initialization_map_errors
148
166
  e = assert_raise ArgumentError do
149
167
  TestMessage.new(:hello => "world")
@@ -276,6 +294,86 @@ module BasicTest
276
294
  assert_equal m5, m
277
295
  end
278
296
 
297
+ def test_map_wrappers_with_default_values
298
+ run_asserts = ->(m) {
299
+ assert_equal 0.0, m.map_double[0].value
300
+ assert_equal 0.0, m.map_float[0].value
301
+ assert_equal 0, m.map_int32[0].value
302
+ assert_equal 0, m.map_int64[0].value
303
+ assert_equal 0, m.map_uint32[0].value
304
+ assert_equal 0, m.map_uint64[0].value
305
+ assert_equal false, m.map_bool[0].value
306
+ assert_equal '', m.map_string[0].value
307
+ assert_equal '', m.map_bytes[0].value
308
+ }
309
+
310
+ m = proto_module::Wrapper.new(
311
+ map_double: {0 => Google::Protobuf::DoubleValue.new(value: 0.0)},
312
+ map_float: {0 => Google::Protobuf::FloatValue.new(value: 0.0)},
313
+ map_int32: {0 => Google::Protobuf::Int32Value.new(value: 0)},
314
+ map_int64: {0 => Google::Protobuf::Int64Value.new(value: 0)},
315
+ map_uint32: {0 => Google::Protobuf::UInt32Value.new(value: 0)},
316
+ map_uint64: {0 => Google::Protobuf::UInt64Value.new(value: 0)},
317
+ map_bool: {0 => Google::Protobuf::BoolValue.new(value: false)},
318
+ map_string: {0 => Google::Protobuf::StringValue.new(value: '')},
319
+ map_bytes: {0 => Google::Protobuf::BytesValue.new(value: '')},
320
+ )
321
+
322
+ run_asserts.call(m)
323
+ serialized = proto_module::Wrapper::encode(m)
324
+ m2 = proto_module::Wrapper::decode(serialized)
325
+ run_asserts.call(m2)
326
+
327
+ # Test the case where we are serializing directly from the parsed form
328
+ # (before anything lazy is materialized).
329
+ m3 = proto_module::Wrapper::decode(serialized)
330
+ serialized2 = proto_module::Wrapper::encode(m3)
331
+ m4 = proto_module::Wrapper::decode(serialized2)
332
+ run_asserts.call(m4)
333
+
334
+ # Test that the lazy form compares equal to the expanded form.
335
+ m5 = proto_module::Wrapper::decode(serialized2)
336
+ assert_equal m5, m
337
+ end
338
+
339
+ def test_map_wrappers_with_no_value
340
+ run_asserts = ->(m) {
341
+ assert_equal 0.0, m.map_double[0].value
342
+ assert_equal 0.0, m.map_float[0].value
343
+ assert_equal 0, m.map_int32[0].value
344
+ assert_equal 0, m.map_int64[0].value
345
+ assert_equal 0, m.map_uint32[0].value
346
+ assert_equal 0, m.map_uint64[0].value
347
+ assert_equal false, m.map_bool[0].value
348
+ assert_equal '', m.map_string[0].value
349
+ assert_equal '', m.map_bytes[0].value
350
+ }
351
+
352
+ m = proto_module::Wrapper.new(
353
+ map_double: {0 => Google::Protobuf::DoubleValue.new()},
354
+ map_float: {0 => Google::Protobuf::FloatValue.new()},
355
+ map_int32: {0 => Google::Protobuf::Int32Value.new()},
356
+ map_int64: {0 => Google::Protobuf::Int64Value.new()},
357
+ map_uint32: {0 => Google::Protobuf::UInt32Value.new()},
358
+ map_uint64: {0 => Google::Protobuf::UInt64Value.new()},
359
+ map_bool: {0 => Google::Protobuf::BoolValue.new()},
360
+ map_string: {0 => Google::Protobuf::StringValue.new()},
361
+ map_bytes: {0 => Google::Protobuf::BytesValue.new()},
362
+ )
363
+ run_asserts.call(m)
364
+
365
+ serialized = proto_module::Wrapper::encode(m)
366
+ m2 = proto_module::Wrapper::decode(serialized)
367
+ run_asserts.call(m2)
368
+
369
+ # Test the case where we are serializing directly from the parsed form
370
+ # (before anything lazy is materialized).
371
+ m3 = proto_module::Wrapper::decode(serialized)
372
+ serialized2 = proto_module::Wrapper::encode(m3)
373
+ m4 = proto_module::Wrapper::decode(serialized2)
374
+ run_asserts.call(m4)
375
+ end
376
+
279
377
  def test_concurrent_decoding
280
378
  o = Outer.new
281
379
  o.items[0] = Inner.new
File without changes
File without changes
metadata CHANGED
@@ -1,43 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.0
4
+ version: 3.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Protobuf Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-25 00:00:00.000000000 Z
11
+ date: 2020-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler-dock
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.1
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: 0.6.0
22
+ version: '2.0'
20
23
  type: :development
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.1
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: 0.6.0
32
+ version: '2.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rake-compiler
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: 0.9.5
39
+ version: 1.1.0
34
40
  type: :development
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
44
  - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: 0.9.5
46
+ version: 1.1.0
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: test-unit
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -112,7 +118,7 @@ homepage: https://developers.google.com/protocol-buffers
112
118
  licenses:
113
119
  - BSD-3-Clause
114
120
  metadata:
115
- source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.11.0/ruby
121
+ source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.12.0/ruby
116
122
  post_install_message:
117
123
  rdoc_options: []
118
124
  require_paths:
@@ -128,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
134
  - !ruby/object:Gem::Version
129
135
  version: '0'
130
136
  requirements: []
131
- rubygems_version: 3.0.6
137
+ rubygems_version: 3.1.3
132
138
  signing_key:
133
139
  specification_version: 4
134
140
  summary: Protocol Buffers