You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bn...@apache.org on 2024/01/30 16:26:04 UTC
(trafficserver-libswoc) 13/18: Fix release mode testing issues.
This is an automated email from the ASF dual-hosted git repository.
bneradt pushed a commit to branch dev-1-0-14
in repository https://gitbox.apache.org/repos/asf/trafficserver-libswoc.git
commit fdab1196b3662018ea6c19aee0a324af21db86a3
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Mon Mar 2 10:15:06 2020 -0600
Fix release mode testing issues.
---
swoc++/include/swoc/MemSpan.h | 2 +-
swoc++/include/swoc/TextView.h | 23 +++++++++++++++++++++--
swoc++/swoc++-headers.part | 2 +-
unit_tests/CMakeLists.txt | 2 +-
unit_tests/ex_ipspace_properties.cc | 3 ++-
unit_tests/test_ip.cc | 26 ++++++++++++++------------
6 files changed, 40 insertions(+), 18 deletions(-)
diff --git a/swoc++/include/swoc/MemSpan.h b/swoc++/include/swoc/MemSpan.h
index 81862c5..f341311 100644
--- a/swoc++/include/swoc/MemSpan.h
+++ b/swoc++/include/swoc/MemSpan.h
@@ -749,7 +749,7 @@ MemSpan<T>::remove_suffix(size_t count) {
template <typename T>
constexpr MemSpan<T>
MemSpan<T>::subspan(size_t offset, size_t count) const {
- return offset <= _count ? self_type{this->data() + offset, std::min(count, _count - offset)} : self_type{};
+ return offset < _count ? self_type{this->data() + offset, std::min(count, _count - offset)} : self_type{};
}
template <typename T>
diff --git a/swoc++/include/swoc/TextView.h b/swoc++/include/swoc/TextView.h
index 49d0909..db20a21 100644
--- a/swoc++/include/swoc/TextView.h
+++ b/swoc++/include/swoc/TextView.h
@@ -174,11 +174,25 @@ public:
/// Assign from a @c std::string.
self_type &operator=(const std::string &s);
+ /** Assign a view of the @a c_str
+ *
+ * @param c_str Pointer to C string.
+ * @return @a this
+ *
+ * @note @c c_str must be a null terminated string. The null byte is not included in the view.
+ */
+ self_type& assign(char const* c_str);;
+
/// Explicitly set the start @a ptr and size @a n of the view.
self_type &assign(char const *ptr, size_t n);
- /// Explicitly set the view to the half open range [ @a first , @a last )
- self_type &assign(char const *first, char const *lsat);
+ /** Assign the half open view [ @a b , @a e ) to @a this
+ *
+ * @param b First character in the view.
+ * @param e One character after the last character in the view.
+ * @return @a this
+ */
+ self_type &assign(char const *b, char const *e);
/// Explicitly set the view from a @c std::string
self_type &assign(std::string const &s);
@@ -900,6 +914,11 @@ TextView::operator=(const std::string &s) {
return *this;
}
+inline TextView&
+TextView::assign(char const *c_str) {
+ return this->assign(c_str, strlen(c_str));
+}
+
inline TextView &
TextView::assign(const std::string &s) {
*this = super_type(s);
diff --git a/swoc++/swoc++-headers.part b/swoc++/swoc++-headers.part
index b0cd428..4c61a89 100644
--- a/swoc++/swoc++-headers.part
+++ b/swoc++/swoc++-headers.part
@@ -2,5 +2,5 @@ Import("*")
PartName("headers")
# export the include directory
-inc_files = Pattern(src_dir="include/swoc", includes=["*.h"])
+inc_files = Pattern(src_dir="include", includes=["swoc/*.h"])
env.InstallInclude(inc_files)
diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt
index fd17d9f..39de7a7 100644
--- a/unit_tests/CMakeLists.txt
+++ b/unit_tests/CMakeLists.txt
@@ -28,4 +28,4 @@ add_executable(test_libswoc
target_link_libraries(test_libswoc PUBLIC swoc++)
set_target_properties(test_libswoc PROPERTIES CLANG_FORMAT_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
-add_definitions(-DVERBOSE_EXAMPLE_OUTPUT=1)
+#add_definitions(-DVERBOSE_EXAMPLE_OUTPUT=1)
diff --git a/unit_tests/ex_ipspace_properties.cc b/unit_tests/ex_ipspace_properties.cc
index e0f0e8e..3420e6a 100644
--- a/unit_tests/ex_ipspace_properties.cc
+++ b/unit_tests/ex_ipspace_properties.cc
@@ -348,7 +348,8 @@ TextView Table::localize(TextView const&src) {
TextView Table::token(TextView & line) {
TextView::size_type idx = 0;
// Characters of interest.
- TextView sep_list { {'"', SEP} , 2 };
+ static char constexpr separators[2] = { '"', SEP };
+ static TextView sep_list { separators, 2 };
bool in_quote_p = false;
while (idx < line.size()) {
// Next character of interest.
diff --git a/unit_tests/test_ip.cc b/unit_tests/test_ip.cc
index 286d590..51f40d6 100644
--- a/unit_tests/test_ip.cc
+++ b/unit_tests/test_ip.cc
@@ -13,6 +13,7 @@
#include <swoc/TextView.h>
#include <swoc/swoc_ip.h>
#include <swoc/bwf_ip.h>
+#include <swoc/bwf_std.h>
#include <swoc/swoc_file.h>
using namespace std::literals;
@@ -643,17 +644,17 @@ TEST_CASE("IPSpace docJJ", "[libswoc][ipspace][docJJ]") {
return bits;
};
- std::array<std::tuple<TextView, std::initializer_list<unsigned>>, 9> ranges = {
+ std::array<std::tuple<TextView, PAYLOAD>, 9> ranges = {
{
- {"100.0.0.0-100.0.0.255", {0}}
- , {"100.0.1.0-100.0.1.255", {1}}
- , {"100.0.2.0-100.0.2.255", {2}}
- , {"100.0.3.0-100.0.3.255", {3}}
- , {"100.0.4.0-100.0.4.255", {4}}
- , {"100.0.5.0-100.0.5.255", {5}}
- , {"100.0.6.0-100.0.6.255", {6}}
- , {"100.0.0.0-100.0.0.255", {31}}
- , {"100.0.1.0-100.0.1.255", {30}}
+ {"100.0.0.0-100.0.0.255", make_bits({0})}
+ , {"100.0.1.0-100.0.1.255", make_bits({1})}
+ , {"100.0.2.0-100.0.2.255", make_bits({2})}
+ , {"100.0.3.0-100.0.3.255", make_bits({3})}
+ , {"100.0.4.0-100.0.4.255", make_bits({4})}
+ , {"100.0.5.0-100.0.5.255", make_bits({5})}
+ , {"100.0.6.0-100.0.6.255", make_bits({6})}
+ , {"100.0.0.0-100.0.0.255", make_bits({31})}
+ , {"100.0.1.0-100.0.1.255", make_bits({30})}
}};
std::array<std::initializer_list<unsigned>, 7> results = {{
@@ -668,8 +669,9 @@ TEST_CASE("IPSpace docJJ", "[libswoc][ipspace][docJJ]") {
Space space;
- for (auto &&[text, bit_list] : ranges) {
- space.blend(IPRange{text}, make_bits(bit_list), blender);
+ for (auto && [text, bit_list] : ranges) {
+ std::cout << W().print("{} = {}\n", text, bit_list);
+ space.blend(IPRange{text}, bit_list, blender);
}
// Check iteration - verify forward and reverse iteration yield the correct number of ranges