OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 // Test that we get regular (non websafe) base64 encoding on byte fields by | 292 // Test that we get regular (non websafe) base64 encoding on byte fields by |
293 // default. | 293 // default. |
294 EXPECT_EQ("{\"bytes\":\"A+/A\"}", | 294 EXPECT_EQ("{\"bytes\":\"A+/A\"}", |
295 output_.substr(0, out_stream_->ByteCount())); | 295 output_.substr(0, out_stream_->ByteCount())); |
296 } | 296 } |
297 | 297 |
298 TEST_F(JsonObjectWriterTest, TestWebsafeByteEncoding) { | 298 TEST_F(JsonObjectWriterTest, TestWebsafeByteEncoding) { |
299 ow_ = new JsonObjectWriter("", out_stream_); | 299 ow_ = new JsonObjectWriter("", out_stream_); |
300 ow_->set_use_websafe_base64_for_bytes(true); | 300 ow_->set_use_websafe_base64_for_bytes(true); |
301 ow_->StartObject("") | 301 ow_->StartObject("") |
302 ->RenderBytes("bytes", "\x03\xef\xc0\x10") | 302 ->RenderBytes("bytes", "\x03\xef\xc0") |
303 ->EndObject(); | 303 ->EndObject(); |
304 | 304 |
305 // Test that we get websafe base64 encoding when explicitly asked. | 305 // Test that we get websafe base64 encoding when explicitly asked. |
306 EXPECT_EQ("{\"bytes\":\"A-_AEA==\"}", | 306 EXPECT_EQ("{\"bytes\":\"A-_A\"}", |
307 output_.substr(0, out_stream_->ByteCount())); | 307 output_.substr(0, out_stream_->ByteCount())); |
308 } | 308 } |
309 | 309 |
310 } // namespace converter | 310 } // namespace converter |
311 } // namespace util | 311 } // namespace util |
312 } // namespace protobuf | 312 } // namespace protobuf |
313 } // namespace google | 313 } // namespace google |
OLD | NEW |