You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2018/07/24 14:22:50 UTC

[trafficserver] branch master updated: TextView: Unit tests for token handling on single characters, and with trim.

This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 67a6e05  TextView: Unit tests for token handling on single characters, and with trim.
67a6e05 is described below

commit 67a6e05a0fa37346de0c7e3db917a8af520b7050
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Thu Jul 19 19:32:00 2018 -0500

    TextView: Unit tests for token handling on single characters, and with trim.
---
 lib/ts/unit-tests/test_TextView.cc | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/lib/ts/unit-tests/test_TextView.cc b/lib/ts/unit-tests/test_TextView.cc
index 9b93436..a33d38d 100644
--- a/lib/ts/unit-tests/test_TextView.cc
+++ b/lib/ts/unit-tests/test_TextView.cc
@@ -194,6 +194,26 @@ TEST_CASE("TextView Affixes", "[libts][TextView]")
   fqdn.remove_suffix(std::min(fqdn.size(), elt.size() + 1));
   elt = ts::TextView{fqdn}.suffix('.');
   REQUIRE(elt.empty());
+
+  // Check some edge cases.
+  fqdn  = "."sv;
+  token = ts::TextView{fqdn}.take_suffix_at('.');
+  REQUIRE(token.size() == 0);
+  REQUIRE(token.empty());
+
+  s = "."sv;
+  REQUIRE(s.size() == 1);
+  REQUIRE(s.rtrim('.').empty());
+  token = s.take_suffix_at('.');
+  REQUIRE(token.size() == 0);
+  REQUIRE(token.empty());
+
+  s = "."sv;
+  REQUIRE(s.size() == 1);
+  REQUIRE(s.ltrim('.').empty());
+  token = s.take_prefix_at('.');
+  REQUIRE(token.size() == 0);
+  REQUIRE(token.empty());
 };
 
 TEST_CASE("TextView Formatting", "[libts][TextView]")