Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Side by Side Diff: third_party/protobuf/ruby/tests/stress.rb

Issue 1842653006: Update //third_party/protobuf to version 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/ruby
2
3 require 'google/protobuf'
4 require 'test/unit'
5
6 module StressTest
7 pool = Google::Protobuf::DescriptorPool.new
8 pool.build do
9 add_message "TestMessage" do
10 optional :a, :int32, 1
11 repeated :b, :message, 2, "M"
12 end
13 add_message "M" do
14 optional :foo, :string, 1
15 end
16 end
17
18 TestMessage = pool.lookup("TestMessage").msgclass
19 M = pool.lookup("M").msgclass
20
21 class StressTest < Test::Unit::TestCase
22 def get_msg
23 TestMessage.new(:a => 1000,
24 :b => [M.new(:foo => "hello"),
25 M.new(:foo => "world")])
26 end
27 def test_stress
28 m = get_msg
29 data = TestMessage.encode(m)
30 100_000.times do
31 mnew = TestMessage.decode(data)
32 mnew = mnew.dup
33 assert_equal mnew.inspect, m.inspect
34 assert TestMessage.encode(mnew) == data
35 end
36 end
37 end
38 end
OLDNEW
« no previous file with comments | « third_party/protobuf/ruby/tests/repeated_field_test.rb ('k') | third_party/protobuf/ruby/travis-test.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698