escaping_test_common.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // Copyright 2017 The Abseil Authors.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. // This test contains common things needed by both escaping_test.cc and
  16. // escaping_benchmark.cc.
  17. #ifndef ABSL_STRINGS_INTERNAL_ESCAPING_TEST_COMMON_H_
  18. #define ABSL_STRINGS_INTERNAL_ESCAPING_TEST_COMMON_H_
  19. #include <array>
  20. #include "absl/strings/string_view.h"
  21. namespace absl {
  22. ABSL_NAMESPACE_BEGIN
  23. namespace strings_internal {
  24. struct base64_testcase {
  25. absl::string_view plaintext;
  26. absl::string_view cyphertext;
  27. };
  28. inline const std::array<base64_testcase, 5>& base64_strings() {
  29. static const std::array<base64_testcase, 5> testcase{{
  30. // Some google quotes
  31. // Cyphertext created with "uuencode (GNU sharutils) 4.6.3"
  32. // (Note that we're testing the websafe encoding, though, so if
  33. // you add messages, be sure to run "tr -- '+/' '-_'" on the output)
  34. { "I was always good at math and science, and I never realized "
  35. "that was unusual or somehow undesirable. So one of the things "
  36. "I care a lot about is helping to remove that stigma, "
  37. "to show girls that you can be feminine, you can like the things "
  38. "that girls like, but you can also be really good at technology. "
  39. "You can be really good at building things."
  40. " - Marissa Meyer, Newsweek, 2010-12-22" "\n",
  41. "SSB3YXMgYWx3YXlzIGdvb2QgYXQgbWF0aCBhbmQgc2NpZW5jZSwgYW5kIEkg"
  42. "bmV2ZXIgcmVhbGl6ZWQgdGhhdCB3YXMgdW51c3VhbCBvciBzb21laG93IHVu"
  43. "ZGVzaXJhYmxlLiBTbyBvbmUgb2YgdGhlIHRoaW5ncyBJIGNhcmUgYSBsb3Qg"
  44. "YWJvdXQgaXMgaGVscGluZyB0byByZW1vdmUgdGhhdCBzdGlnbWEsIHRvIHNo"
  45. "b3cgZ2lybHMgdGhhdCB5b3UgY2FuIGJlIGZlbWluaW5lLCB5b3UgY2FuIGxp"
  46. "a2UgdGhlIHRoaW5ncyB0aGF0IGdpcmxzIGxpa2UsIGJ1dCB5b3UgY2FuIGFs"
  47. "c28gYmUgcmVhbGx5IGdvb2QgYXQgdGVjaG5vbG9neS4gWW91IGNhbiBiZSBy"
  48. "ZWFsbHkgZ29vZCBhdCBidWlsZGluZyB0aGluZ3MuIC0gTWFyaXNzYSBNZXll"
  49. "ciwgTmV3c3dlZWssIDIwMTAtMTItMjIK" },
  50. { "Typical first year for a new cluster: "
  51. "~0.5 overheating "
  52. "~1 PDU failure "
  53. "~1 rack-move "
  54. "~1 network rewiring "
  55. "~20 rack failures "
  56. "~5 racks go wonky "
  57. "~8 network maintenances "
  58. "~12 router reloads "
  59. "~3 router failures "
  60. "~dozens of minor 30-second blips for dns "
  61. "~1000 individual machine failures "
  62. "~thousands of hard drive failures "
  63. "slow disks, bad memory, misconfigured machines, flaky machines, etc."
  64. " - Jeff Dean, The Joys of Real Hardware" "\n",
  65. "VHlwaWNhbCBmaXJzdCB5ZWFyIGZvciBhIG5ldyBjbHVzdGVyOiB-MC41IG92"
  66. "ZXJoZWF0aW5nIH4xIFBEVSBmYWlsdXJlIH4xIHJhY2stbW92ZSB-MSBuZXR3"
  67. "b3JrIHJld2lyaW5nIH4yMCByYWNrIGZhaWx1cmVzIH41IHJhY2tzIGdvIHdv"
  68. "bmt5IH44IG5ldHdvcmsgbWFpbnRlbmFuY2VzIH4xMiByb3V0ZXIgcmVsb2Fk"
  69. "cyB-MyByb3V0ZXIgZmFpbHVyZXMgfmRvemVucyBvZiBtaW5vciAzMC1zZWNv"
  70. "bmQgYmxpcHMgZm9yIGRucyB-MTAwMCBpbmRpdmlkdWFsIG1hY2hpbmUgZmFp"
  71. "bHVyZXMgfnRob3VzYW5kcyBvZiBoYXJkIGRyaXZlIGZhaWx1cmVzIHNsb3cg"
  72. "ZGlza3MsIGJhZCBtZW1vcnksIG1pc2NvbmZpZ3VyZWQgbWFjaGluZXMsIGZs"
  73. "YWt5IG1hY2hpbmVzLCBldGMuIC0gSmVmZiBEZWFuLCBUaGUgSm95cyBvZiBS"
  74. "ZWFsIEhhcmR3YXJlCg" },
  75. { "I'm the head of the webspam team at Google. "
  76. "That means that if you type your name into Google and get porn back, "
  77. "it's my fault. Unless you're a porn star, in which case porn is a "
  78. "completely reasonable response."
  79. " - Matt Cutts, Google Plus" "\n",
  80. "SSdtIHRoZSBoZWFkIG9mIHRoZSB3ZWJzcGFtIHRlYW0gYXQgR29vZ2xlLiAg"
  81. "VGhhdCBtZWFucyB0aGF0IGlmIHlvdSB0eXBlIHlvdXIgbmFtZSBpbnRvIEdv"
  82. "b2dsZSBhbmQgZ2V0IHBvcm4gYmFjaywgaXQncyBteSBmYXVsdC4gVW5sZXNz"
  83. "IHlvdSdyZSBhIHBvcm4gc3RhciwgaW4gd2hpY2ggY2FzZSBwb3JuIGlzIGEg"
  84. "Y29tcGxldGVseSByZWFzb25hYmxlIHJlc3BvbnNlLiAtIE1hdHQgQ3V0dHMs"
  85. "IEdvb2dsZSBQbHVzCg" },
  86. { "It will still be a long time before machines approach human "
  87. "intelligence. "
  88. "But luckily, machines don't actually have to be intelligent; "
  89. "they just have to fake it. Access to a wealth of information, "
  90. "combined with a rudimentary decision-making capacity, "
  91. "can often be almost as useful. Of course, the results are better yet "
  92. "when coupled with intelligence. A reference librarian with access to "
  93. "a good search engine is a formidable tool."
  94. " - Craig Silverstein, Siemens Pictures of the Future, Spring 2004"
  95. "\n",
  96. "SXQgd2lsbCBzdGlsbCBiZSBhIGxvbmcgdGltZSBiZWZvcmUgbWFjaGluZXMg"
  97. "YXBwcm9hY2ggaHVtYW4gaW50ZWxsaWdlbmNlLiBCdXQgbHVja2lseSwgbWFj"
  98. "aGluZXMgZG9uJ3QgYWN0dWFsbHkgaGF2ZSB0byBiZSBpbnRlbGxpZ2VudDsg"
  99. "dGhleSBqdXN0IGhhdmUgdG8gZmFrZSBpdC4gQWNjZXNzIHRvIGEgd2VhbHRo"
  100. "IG9mIGluZm9ybWF0aW9uLCBjb21iaW5lZCB3aXRoIGEgcnVkaW1lbnRhcnkg"
  101. "ZGVjaXNpb24tbWFraW5nIGNhcGFjaXR5LCBjYW4gb2Z0ZW4gYmUgYWxtb3N0"
  102. "IGFzIHVzZWZ1bC4gT2YgY291cnNlLCB0aGUgcmVzdWx0cyBhcmUgYmV0dGVy"
  103. "IHlldCB3aGVuIGNvdXBsZWQgd2l0aCBpbnRlbGxpZ2VuY2UuIEEgcmVmZXJl"
  104. "bmNlIGxpYnJhcmlhbiB3aXRoIGFjY2VzcyB0byBhIGdvb2Qgc2VhcmNoIGVu"
  105. "Z2luZSBpcyBhIGZvcm1pZGFibGUgdG9vbC4gLSBDcmFpZyBTaWx2ZXJzdGVp"
  106. "biwgU2llbWVucyBQaWN0dXJlcyBvZiB0aGUgRnV0dXJlLCBTcHJpbmcgMjAw"
  107. "NAo" },
  108. // Degenerate edge case
  109. { "",
  110. "" },
  111. }};
  112. return testcase;
  113. }
  114. } // namespace strings_internal
  115. ABSL_NAMESPACE_END
  116. } // namespace absl
  117. #endif // ABSL_STRINGS_INTERNAL_ESCAPING_TEST_COMMON_H_